66 dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
67 const vector<CellID>& local_propagated_cells,
68 const vector<CellID>& remoteTargetCellsx,
69 const vector<CellID>& remoteTargetCellsy,
70 const vector<CellID>& remoteTargetCellsz,
80 MPI_Comm_rank(MPI_COMM_WORLD,&
myRank);
82 phiprof::Timer btzTimer {
"barrier-trans-pre-z", {
"Barriers",
"MPI"}};
83 MPI_Barrier(MPI_COMM_WORLD);
89 phiprof::Timer transTimer {
"transfer-stencil-data-z", {
"MPI"}};
101 phiprof::Timer computeTimer {
"compute-mapping-z"};
104 time += MPI_Wtime() - t1;
106 phiprof::Timer btTimer {
"barrier-trans-pre-update_remote-z", {
"Barriers",
"MPI"}};
107 MPI_Barrier(MPI_COMM_WORLD);
110 phiprof::Timer updateRemoteTimer {
"update_remote-z", {
"MPI"}};
113 updateRemoteTimer.stop();
117 phiprof::Timer btxTimer {
"barrier-trans-pre-x", {
"Barriers",
"MPI"}};
118 MPI_Barrier(MPI_COMM_WORLD);
124 phiprof::Timer transTimer {
"transfer-stencil-data-x", {
"MPI"}};
136 phiprof::Timer computeTimer {
"compute-mapping-x"};
139 time += MPI_Wtime() - t1;
141 phiprof::Timer btTimer {
"barrier-trans-pre-update_remote-x", {
"Barriers",
"MPI"}};
142 MPI_Barrier(MPI_COMM_WORLD);
145 phiprof::Timer updateRemoteTimer {
"update_remote-x", {
"MPI"}};
148 updateRemoteTimer.stop();
152 phiprof::Timer btyTimer {
"barrier-trans-pre-y", {
"Barriers",
"MPI"}};
153 MPI_Barrier(MPI_COMM_WORLD);
159 phiprof::Timer transTimer {
"transfer-stencil-data-y", {
"MPI"}};
171 phiprof::Timer computeTimer {
"compute-mapping-y"};
174 time += MPI_Wtime() - t1;
176 phiprof::Timer btTimer {
"barrier-trans-pre-update_remote-y", {
"Barriers",
"MPI"}};
177 MPI_Barrier(MPI_COMM_WORLD);
180 phiprof::Timer updateRemoteTimer {
"update_remote-y", {
"MPI"}};
183 updateRemoteTimer.stop();
187 phiprof::Timer btpostimer {
"barrier-trans-post-trans",{
"Barriers",
"MPI"}};
188 MPI_Barrier(MPI_COMM_WORLD);
206 dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
207 const vector<CellID>& local_propagated_cells,
216 const vector<CellID> dummy_cells;
222 phiprof::Timer prepreBarrierTimer {
"MPI barrier-pre-trans-comm"};
223 MPI_Barrier(MPI_COMM_WORLD);
224 prepreBarrierTimer.stop();
226 phiprof::Timer transferTimer {
"transfer-stencil-data-all",{
"MPI"}};
229 transferTimer.stop();
231 phiprof::Timer preBarrierTimer {
"MPI barrier-pre-trans"};
232 MPI_Barrier(MPI_COMM_WORLD);
233 preBarrierTimer.stop();
237 phiprof::Timer mappingZTimer {
"compute-mapping-z"};
239 mappingZTimer.stop();
242 phiprof::Timer mappingXTimer {
"compute-mapping-x"};
244 mappingXTimer.stop();
247 phiprof::Timer mappingYTimer {
"compute-mapping-y"};
249 mappingYTimer.stop();
251 phiprof::Timer postBarrierTimer {
"MPI barrier-post-trans"};
252 MPI_Barrier(MPI_COMM_WORLD);
253 postBarrierTimer.stop();
268 dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
272 phiprof::Timer semilagTimer {
"semilag-trans"};
277 vector<CellID> remoteTargetCellsx;
278 vector<CellID> remoteTargetCellsy;
279 vector<CellID> remoteTargetCellsz;
280 vector<CellID> local_propagated_cells;
291 phiprof::Timer computeTimer {
"compute_cell_lists"};
301 for (
size_t c=0;
c<localCells.size(); ++
c) {
303 local_propagated_cells.push_back(localCells[
c]);
309 nPencils.resize(local_propagated_cells.size()+1, 0);
316 phiprof::Timer timer {profName};
323 local_propagated_cells,
333 local_propagated_cells,
347 for (
size_t c=0;
c<localCells.size(); ++
c) {
351 for (
size_t c=0;
c<local_propagated_cells.size(); ++
c) {
411 dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
412 const std::vector<CellID>& acceleratedCells,
424 std::default_random_engine rndState;
426 uint map_order = std::uniform_int_distribution<>(0,2)(rndState);
429 #pragma omp parallel for
430 for (
size_t c=0;
c<acceleratedCells.size(); ++
c) {
431 const CellID cellID = acceleratedCells[
c];
432 const Real maxVdt = mpiGrid[cellID]->get_max_v_dt(popID);
446 if( (step + 1) * maxVdt > fabs(
dt)) {
447 thisSubcycleDt =
max(fabs(
dt) - step * maxVdt, 0.0);
449 thisSubcycleDt = maxVdt;
452 thisSubcycleDt = -thisSubcycleDt;
472 if (step < (globalMaxSubcycles - 1)) {
488 MPI_Comm_rank(MPI_COMM_WORLD,&
myRank);
500 phiprof::Timer accTimer {
"semilag-acc"};
505 int globalMaxSubcycles;
513 phiprof::Timer gatherTimer {
"Gather subcycles and propagated cells"};
514 vector<CellID> acceleratedCells;
515 #pragma omp parallel for
516 for (
size_t c=0;
c<cells.size(); ++
c) {
523 uint blockCount =
vmesh->size();
524 if (blockCount != 0){
528 acceleratedCells.push_back(cells[
c]);
544 MPI_Allreduce(&maxSubcycles, &globalMaxSubcycles, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
548 for(uint step=0; step<(uint)globalMaxSubcycles; ++step) {
552 for (
const auto& cell: acceleratedCells) {
554 temp.push_back(cell);
557 acceleratedCells.swap(temp);
572 #pragma omp parallel for
573 for (
size_t c=0;
c<cells.size(); ++
c) {
588 dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
604 #pragma omp parallel for
605 for (
size_t c=0;
c<cells.size(); ++
c) {
606 const CellID cellID = cells[
c];
623 for (
int i = 0;
i < 3;
i++) {
626 for (
int i = 0;
i < 6;
i++) {
635 phiprof::Timer timer {
"Calculate moments"};
640 #pragma omp parallel for
641 for (
size_t c=0;
c<cells.size(); ++
c) {
642 const CellID cellID = cells[
c];
void calculateCellMoments(spatial_cell::SpatialCell *cell, const bool &computeSecond, const bool &computePopulationMomentsOnly, const bool &doNotSkip)
void calculateMoments_R(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &cells, const bool &computeSecond, const bool initialCompute)
void calculateMoments_V(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &cells, const bool &computeSecond, const bool initialCompute)
vmesh::LocalID get_number_of_velocity_blocks(const uint popID) const
vmesh::VelocityMesh * get_velocity_mesh(const size_t &popID)
static bool setCommunicatedSpecies(const uint popID)
static void set_mpi_transfer_type(const uint64_t type, bool atSysBoundaries=false)
const Real & get_max_v_dt(const uint popID) const
Population & get_population(const uint popID)
std::array< Real, CellParams::N_SPATIAL_CELL_PARAMS > parameters
const std::vector< CellID > & getLocalCells()
void cpu_accelerate_cells(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &acceleratedCells, const uint popID, const uint map_order)
bool trans_map_1d_amr(const dccrg::Dccrg< spatial_cell::SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const vector< CellID > &localPropagatedCells, const vector< CellID > &remoteTargetCells, std::vector< uint > &nPencils, const uint dimension, const Realf dt, const uint popID)
void update_remote_mapping_contribution_amr(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const uint dimension, int direction, const uint popID)
bool do_translate_cell(const SpatialCell *const SC)
T convert(const T &number)
void gpu_accelerate_cells(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &acceleratedCells, const uint popID, const uint map_order)
Propagates the distribution function in velocity space of given list of real space cells using a semi...
__global__ void const Realf const uint *__restrict__ const uint *__restrict__ const vmesh::GlobalID *__restrict__ const uint const uint nPencils
bool adjustVelocityBlocks(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const vector< CellID > &cellsToAdjust, bool doPrepareToReceiveBlocks, const uint popID)
void updateRemoteVelocityBlockLists(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const uint popID, const uint neighborhood)
ObjectWrapper & getObjectWrapper()
static const uint64_t VEL_BLOCK_DATA
std::vector< species::Species > particleSpecies
static bool vlasovSolverGhostTranslate
static int amrMaxSpatialRefLevel
static bool prepareForRebalance
static bool vlasovAccelerateMaxwellianBoundaries
static ARCH_HOSTDEV VecSimple< T > min(VecSimple< T > const &l, VecSimple< T > const &r)
static ARCH_HOSTDEV VecSimple< T > max(VecSimple< T > const &l, VecSimple< T > const &r)
void calculateInterpolatedVelocityMoments(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const int cp_rhom, const int cp_vx, const int cp_vy, const int cp_vz, const int cp_rhoq, const int cp_p11, const int cp_p22, const int cp_p33, const int cp_p23, const int cp_p13, const int cp_p12)
Compute real-time 1st order accurate moments from the moments after propagation in velocity and spati...
uint getAccelerationSubcycles(const SpatialCell *spatial_cell, const Real dt, const uint popID)
void calculateAcceleration(const uint popID, const uint globalMaxSubcycles, const uint step, dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &acceleratedCells, const Real dt)
void calculateInitialVelocityMoments(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid)
Compute 0th, 1st and 2nd velocity moments (RHO,VX,VY,VZ,P_11,P_22,P_33 and *_DT2) for all cells in th...
void calculateSpatialGhostTranslation(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const vector< CellID > &local_propagated_cells, vector< uint > &nPencils, const creal dt, const uint popID, Real &time)
void calculateSpatialTranslation(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const vector< CellID > &local_propagated_cells, const vector< CellID > &remoteTargetCellsx, const vector< CellID > &remoteTargetCellsy, const vector< CellID > &remoteTargetCellsz, vector< uint > &nPencils, const Realf dt, const uint popID, Real &time)