184 const vector<CellID>& localPropagatedCells) {
194 if (localPropagatedCells.size() == 0) {
198 std::vector<CellID> foundCells;
216 phiprof::Timer ghostYTimer {
"prepare ghost translation Y lists"};
218 for (
const CellID c : localPropagatedCells) {
236 for (
const CellID cid: foundCells) {
244 for (
const CellID cid: foundCells) {
254 phiprof::Timer ghostXTimer {
"prepare ghost translation X lists"};
272 for (
CellID cid: foundCells) {
280 for (
const CellID cid: foundCells) {
290 phiprof::Timer ghostZTimer {
"prepare ghost translation Z lists"};
308 for (
const CellID cid: foundCells) {
316 for (
const CellID cid: foundCells) {
324 std::vector<int64_t> localCounts;
331 localCounts.push_back(localPropagatedCells.size());
332 int nc = localCounts.size();
333 std::vector<int64_t> globalCounts(nc*4);
335 MPI_Comm_size(MPI_COMM_WORLD, &world_size);
336 MPI_Reduce(localCounts.data(), globalCounts.data(), nc, MPI_INT64_T, MPI_SUM,
MASTER_RANK, MPI_COMM_WORLD);
337 MPI_Reduce(localCounts.data(), &(globalCounts.at(nc)), nc, MPI_INT64_T, MPI_MIN,
MASTER_RANK, MPI_COMM_WORLD);
338 MPI_Reduce(localCounts.data(), &(globalCounts.at(2*nc)), nc, MPI_INT64_T, MPI_MAX,
MASTER_RANK, MPI_COMM_WORLD);
339 for(
int i = 0;
i <nc;
i++) {
340 globalCounts.at(3*nc+
i) = globalCounts.at(
i) / world_size;
342 logFile <<
"(CELLS) tstep = " <<
P::tstep <<
" time = " <<
P::t <<
" \n source cells (tot / avg / min / max) (x y z) [ ";
343 for(
int dim = 0; dim <3; dim++) {
344 logFile << globalCounts.at(dim) <<
" ";
347 for(
int dim = 0; dim <3; dim++) {
348 logFile << globalCounts.at(3*nc+dim) <<
" ";
351 for(
int dim = 0; dim <3; dim++) {
352 logFile << globalCounts.at(nc+dim) <<
" ";
355 for(
int dim = 0; dim <3; dim++) {
356 logFile << globalCounts.at(2*nc+dim) <<
" ";
358 logFile <<
"] \n active cells (tot / avg / min / max) (x y z) [ ";
359 for(
int dim = 3; dim <6; dim++) {
360 logFile << globalCounts.at(dim) <<
" ";
363 for(
int dim = 3; dim <6; dim++) {
364 logFile << globalCounts.at(3*nc+dim) <<
" ";
367 for(
int dim = 3; dim <6; dim++) {
368 logFile << globalCounts.at(nc+dim) <<
" ";
371 for(
int dim = 3; dim <6; dim++) {
372 logFile << globalCounts.at(2*nc+dim) <<
" ";
374 logFile <<
"] \n local cells (tot / avg / min / max) [ ";
375 logFile << globalCounts.at(nc-1) <<
" / ";
376 logFile << globalCounts.at(4*nc-1) <<
" / ";
377 logFile << globalCounts.at(2*nc-1) <<
" / ";
378 logFile << globalCounts.at(3*nc-1);
380 std::vector<float> localCountsF;
381 localCountsF.push_back((
float)localCounts.at(0) / (
float)localCounts.at(6));
382 localCountsF.push_back((
float)localCounts.at(1) / (
float)localCounts.at(6));
383 localCountsF.push_back((
float)localCounts.at(2) / (
float)localCounts.at(6));
384 localCountsF.push_back((
float)localCounts.at(3) / (
float)localCounts.at(6));
385 localCountsF.push_back((
float)localCounts.at(4) / (
float)localCounts.at(6));
386 localCountsF.push_back((
float)localCounts.at(5) / (
float)localCounts.at(6));
387 int fc = localCountsF.size();
388 std::vector<float> globalCountsF(4*fc);
389 MPI_Reduce(localCountsF.data(), globalCountsF.data(), fc, MPI_FLOAT, MPI_SUM,
MASTER_RANK, MPI_COMM_WORLD);
390 MPI_Reduce(localCountsF.data(), &(globalCountsF.at(fc)), fc, MPI_FLOAT, MPI_MIN,
MASTER_RANK, MPI_COMM_WORLD);
391 MPI_Reduce(localCountsF.data(), &(globalCountsF.at(2*fc)), fc, MPI_FLOAT, MPI_MAX,
MASTER_RANK, MPI_COMM_WORLD);
392 for(
int i = 0;
i <fc;
i++) {
393 globalCountsF.at(3*fc+
i) = globalCountsF.at(
i) / world_size;
395 logFile <<
"] \n source ratios (avg / min / max) (x y z) [ ";
396 for(
int dim = 0; dim <3; dim++) {
397 logFile << globalCountsF.at(3*fc+dim) <<
" ";
400 for(
int dim = 0; dim <3; dim++) {
401 logFile << globalCountsF.at(fc+dim) <<
" ";
404 for(
int dim = 0; dim <3; dim++) {
405 logFile << globalCountsF.at(2*fc+dim) <<
" ";
407 logFile <<
"] \n active ratios (avg / min / max) (x y z) [ ";
408 for(
int dim = 3; dim <6; dim++) {
409 logFile << globalCountsF.at(3*fc+dim) <<
" ";
412 for(
int dim = 3; dim <6; dim++) {
413 logFile << globalCountsF.at(fc+dim) <<
" ";
416 for(
int dim = 3; dim <6; dim++) {
417 logFile << globalCountsF.at(2*fc+dim) <<
" ";
419 logFile <<
"]" << endl << flush;
450 const uint dimension,
451 std::vector<uint> path,
459 for (uint
j = 0;
j < L; ++
j) {
464 const auto* frontNbrPairs = mpiGrid.get_neighbors_of(ids[VLASOV_STENCIL_WIDTH], neighborhood);
465 const auto* backNbrPairs = mpiGrid.get_neighbors_of(ids[L-VLASOV_STENCIL_WIDTH-1], neighborhood);
468 std::set< int > distances;
469 for (
const auto& nbrPair : *frontNbrPairs) {
470 if (nbrPair.second[dimension] < 0) {
472 distances.insert(-nbrPair.second[dimension]);
475 int iSrc = VLASOV_STENCIL_WIDTH - 1;
477 for (
auto it = distances.begin(); it != distances.end(); ++it) {
483 std::vector< CellID > neighbors;
484 for (
const auto& nbrPair : *frontNbrPairs) {
485 int distanceInRefinedCells = -nbrPair.second[dimension];
486 if (distanceInRefinedCells == *it) {
487 neighbors.push_back(nbrPair.first);
491 std::sort(neighbors.begin(), neighbors.end());
492 neighbors.erase(unique(neighbors.begin(), neighbors.end()), neighbors.end());
495 size_t refLvl = mpiGrid.get_refinement_level(ids[VLASOV_STENCIL_WIDTH]);
497 if (path.size() > refLvl) {
498 pathPos = path[refLvl];
500 if (neighbors.size() == 1) {
501 if (ids[iSrc+1] == neighbors.at(0)) {
504 ids[iSrc--] = neighbors.at(0);
505 }
else if ( pathPos < neighbors.size() ) {
506 if (ids[iSrc+1] == neighbors.at(pathPos)) {
509 ids[iSrc--] = neighbors.at(pathPos);
511 ss<<
"error too few front neighbors for path! cellid "<<ids[VLASOV_STENCIL_WIDTH]<<
512 " Nsize "<<neighbors.size()<<
" L "<<L<<
" refLvl "<<refLvl<<
" iSrc "<<iSrc<<
513 " pathsize "<<path.size()<<
" path "<<path[refLvl]<<std::endl;
520 for (
const auto& nbrPair : *backNbrPairs) {
521 if (nbrPair.second[dimension] > 0) {
522 distances.insert(nbrPair.second[dimension]);
528 iSrc = L - VLASOV_STENCIL_WIDTH;
529 for (
auto it = distances.begin(); it != distances.end(); ++it) {
530 if (iSrc >= (
int)L) {
535 std::vector< CellID > neighbors;
536 for (
const auto& nbrPair : *backNbrPairs) {
537 int distanceInRefinedCells = nbrPair.second[dimension];
538 if (distanceInRefinedCells == *it) {
539 neighbors.push_back(nbrPair.first);
543 std::sort(neighbors.begin(), neighbors.end());
544 neighbors.erase(unique(neighbors.begin(), neighbors.end()), neighbors.end());
546 size_t refLvl = mpiGrid.get_refinement_level(ids[L-VLASOV_STENCIL_WIDTH-1]);
548 if (path.size() > refLvl) {
549 pathPos = path[refLvl];
551 if (neighbors.size() == 1) {
552 if (ids[iSrc-1] == neighbors.at(0)) {
555 ids[iSrc++] = neighbors.at(0);
556 }
else if ( pathPos < neighbors.size() ) {
557 if (ids[iSrc-1] == neighbors.at(pathPos)) {
560 ids[iSrc++] = neighbors.at(pathPos);
562 ss<<
"error too few back neighbors for path! cellid "<<ids[L-VLASOV_STENCIL_WIDTH-1]<<
563 " Nsize "<<neighbors.size()<<
" L "<<L<<
" refLvl "<<refLvl<<
" iSrc "<<iSrc<<
564 " pathsize "<<path.size()<<
" path "<<path[refLvl]<<std::endl;
570 CellID lastGoodCell = ids[VLASOV_STENCIL_WIDTH];
571 for(
int i = VLASOV_STENCIL_WIDTH - 1;
i >= 0 ;--
i){
574 if (mpiGrid[ids[
i]] != NULL) {
583 ids[
i] = lastGoodCell;
585 lastGoodCell = ids[
i];
590 lastGoodCell = ids[L - VLASOV_STENCIL_WIDTH - 1];
591 for(
int i = (
int)L - VLASOV_STENCIL_WIDTH;
i < (int)L; ++
i){
594 if (mpiGrid[ids[
i]] != NULL) {
603 ids[
i] = lastGoodCell;
605 lastGoodCell = ids[
i];
610 for (
int i = 0;
i < (int)L; ++
i) {
615 for (
int i = 0;
i < (int)L; ++
i) {
616 if ((
i < VLASOV_STENCIL_WIDTH-1) || (
i > (
int)L-VLASOV_STENCIL_WIDTH)) {
635 std::cerr<<
"Error in path size to cell size: " << __FILE__ <<
":" << __LINE__ << std::endl;
636 targetRatios[
i] = 0.0;
638 const int ratio = 1 << -diff;
640 targetRatios[
i] = 1.0 / (Rratio*Rratio);
643 targetRatios[
i] = 0.0;
646 std::cerr<<
"Found zero id in pencils!"<<std::endl;
647 targetRatios[
i] = 0.0;
664 const CellID id,
const int dimension = 0,
const uint path = 0) {
671 vector < CellID > myNeighbors;
676 for (
const auto& [neighbor, dir] : grid.get_face_neighbors_of(
id)) {
677 if (dir == ((
int)dimension + 1)) {
678 myNeighbors.push_back(neighbor);
683 std::sort(myNeighbors.begin(), myNeighbors.end());
685 if ( myNeighbors.size() == 0 ) {
689 int neighborIndex = 0;
690 if (myNeighbors.size() > 1) {
691 neighborIndex = path;
695 neighbor = myNeighbors[neighborIndex];
721 vector<CellID> ids,
const uint dimension,
722 vector<uint> path,
const vector<CellID> &endIds) {
724 const bool debug =
false;
727 int startingRefLvl = grid.get_refinement_level(
id);
728 bool periodic =
false;
730 if ( ids.size() == 0 ) {
731 ids.push_back(seedId);
738 std::array<double, 3> coordinates = grid.get_center(seedId);
739 int startingPathSize = path.size();
742 if ( startingRefLvl > startingPathSize ) {
744 for (
int i = path.size();
i < startingRefLvl; ++
i) {
746 CellID parentId = grid.get_parent(myId);
748 auto myCoords = grid.get_center(myId);
749 auto parentCoords = grid.get_center(parentId);
765 cerr << __FILE__ <<
":"<< __LINE__ <<
" Wrong dimension, abort"<<endl;
773 if (myCoords[ix] < parentCoords[ix] && myCoords[iy] < parentCoords[iy]) {
775 }
else if (myCoords[ix] > parentCoords[ix] && myCoords[iy] < parentCoords[iy]) {
777 }
else if (myCoords[ix] < parentCoords[ix] && myCoords[iy] > parentCoords[iy]) {
779 }
else if (myCoords[ix] > parentCoords[ix] && myCoords[iy] > parentCoords[iy]) {
784 path.insert(path.begin(), step);
793 bool neighborExists =
false;
798 for (
int tmpPath = 0; tmpPath < 4; ++tmpPath) {
801 refLvl =
max(refLvl,grid.get_refinement_level(nextNeighbor));
802 neighborExists =
true;
807 if (!neighborExists) {
816 if (
static_cast<int>(path.size()) >= refLvl ) {
819 std::cout <<
"I am cell " <<
id <<
". ";
820 std::cout <<
"I have seen refinement level " << refLvl <<
" before. Path is ";
821 for (
auto k = path.begin();
k != path.end(); ++
k)
822 std::cout << *
k <<
" ";
823 std::cout << std::endl;
828 coordinates = grid.get_center(nextNeighbor);
833 std::cout <<
"I am cell " <<
id <<
". ";
834 std::cout <<
"I have NOT seen refinement level " << refLvl <<
" before. Path is ";
835 for (
auto k = path.begin();
k != path.end(); ++
k)
836 std::cout << *
k <<
' ';
837 std::cout << std::endl;
841 for ( uint newPath : {0,1,2,3} ) {
842 vector < uint > myPath = path;
844 myPath.push_back(newPath);
847 if ( newPath == 3 ) {
851 coordinates = grid.get_center(nextNeighbor);
864 std::cout <<
" Next neighbor is " << nextNeighbor <<
"." << std::endl;
867 if ( std::any_of(endIds.begin(), endIds.end(), [nextNeighbor](uint
i){return i == nextNeighbor;}) ||
872 ids.push_back(nextNeighbor);
897 cerr << __FILE__ <<
":"<< __LINE__ <<
" Wrong dimension, abort"<<endl;
906 pencils.addPencil(ids,x,y,periodic,path);
920void getSeedIds(
const dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
921 const vector<CellID> &propagatedCells,
922 const uint dimension,
923 vector<CellID> &seedIds) {
925 const bool debug =
false;
928 MPI_Comm_rank(MPI_COMM_WORLD,&
myRank);
932 const int neighborhood =
getNeighborhood(dimension,VLASOV_STENCIL_WIDTH);
934 #pragma omp parallel for
935 for (uint
i=0;
i<propagatedCells.size();
i++) {
936 const CellID celli = propagatedCells[
i];
941 seedIds.push_back(celli);
944 auto myIndices = mpiGrid.mapping.get_indices(celli);
961 for (
const auto& [neighbor, dir] : mpiGrid.get_face_neighbors_of(celli) ) {
962 if ( dir == -((
int)dimension + 1) ) {
965 auto nbrIndices = mpiGrid.mapping.get_indices(neighbor);
970 if ( (myIndices[dimension] < nbrIndices[dimension]) ||
979 if ( addToSeedIds ) {
981 seedIds.push_back(celli);
984 myRefLevel = mpiGrid.get_refinement_level(celli);
985 if (mpiGrid.get_maximum_refinement_level() == myRefLevel) {
994 const auto* nbrPairs = mpiGrid.get_neighbors_of(celli, neighborhood);
996 std::set< int > distancesplus;
997 std::set< int > distancesminus;
998 for (
const auto& nbrPair : *nbrPairs) {
999 if (nbrPair.second[dimension] > 0) {
1000 distancesplus.insert(nbrPair.second[dimension]);
1002 if (nbrPair.second[dimension] < 0) {
1004 distancesminus.insert(-nbrPair.second[dimension]);
1007 int iSrc = VLASOV_STENCIL_WIDTH-1;
1008 for (
auto it = distancesplus.begin(); it != distancesplus.end(); ++it) {
1012 for (
const auto& nbrPair : *nbrPairs) {
1013 int distanceInRefinedCells = nbrPair.second[dimension];
1014 if (distanceInRefinedCells == *it) {
1016 if (iSrc!=0 && mpiGrid.get_refinement_level(nbrPair.first)!=myRefLevel) {
1021 if (iSrc==0 && mpiGrid.get_refinement_level(nbrPair.first)>myRefLevel) {
1022 addToSeedIds =
true;
1031 #pragma omp critical
1032 seedIds.push_back(celli);
1038 iSrc = VLASOV_STENCIL_WIDTH;
1039 for (
auto it = distancesminus.begin(); it != distancesminus.end(); ++it) {
1043 for (
const auto& nbrPair : *nbrPairs) {
1044 int distanceInRefinedCells = -nbrPair.second[dimension];
1045 if (distanceInRefinedCells == *it) {
1047 if (iSrc!=0 && mpiGrid.get_refinement_level(nbrPair.first)!=myRefLevel) {
1052 if (iSrc==0 && mpiGrid.get_refinement_level(nbrPair.first)>myRefLevel) {
1053 addToSeedIds =
true;
1062 #pragma omp critical
1063 seedIds.push_back(celli);
1068 cout <<
"Rank " <<
myRank <<
", Seed ids are: ";
1069 for (
const auto seedId : seedIds) {
1070 cout << seedId <<
" ";
1085 const uint dimension) {
1087 const bool debug =
false;
1092 MPI_Comm_rank(MPI_COMM_WORLD,&
myRank);
1095 std::vector<CellID> pencilIdsToSplit;
1097 #pragma omp parallel for
1098 for (uint pencili = 0; pencili < pencils.N; ++pencili) {
1101 if (pencils.periodic[pencili]) {
1106 auto ids = pencils.getIds(pencili);
1116 int maxPencilRefLvl = pencils.path[pencili].size();
1117 int maxNbrRefLvl = 0;
1119 const auto* frontNeighbors = mpiGrid.get_neighbors_of(ids.front(),neighborhood);
1120 const auto* backNeighbors = mpiGrid.get_neighbors_of(ids.back(),neighborhood);
1123 std::set< int > distances;
1124 for (
const auto& nbrPair : *frontNeighbors) {
1125 if (nbrPair.second[dimension] < 0) {
1127 distances.insert(-nbrPair.second[dimension]);
1133 for (
auto it = distances.begin(); it != distances.end(); ++it) {
1134 for (
const auto& nbrPair : *frontNeighbors) {
1135 if (nbrPair.first==lastcell) {
1138 int distanceInRefinedCells = -nbrPair.second[dimension];
1139 if (distanceInRefinedCells == *it) {
1140 maxNbrRefLvl =
max(maxNbrRefLvl,mpiGrid.get_refinement_level(nbrPair.first));
1141 lastcell = nbrPair.first;
1146 if (foundcells >= VLASOV_STENCIL_WIDTH) {
1153 for (
const auto& nbrPair : *backNeighbors) {
1154 if (nbrPair.second[dimension] > 0) {
1155 distances.insert(nbrPair.second[dimension]);
1160 for (
auto it = distances.begin(); it != distances.end(); ++it) {
1161 for (
const auto& nbrPair : *backNeighbors) {
1162 if (nbrPair.first==lastcell) {
1165 int distanceInRefinedCells = nbrPair.second[dimension];
1166 if (distanceInRefinedCells == *it) {
1167 maxNbrRefLvl =
max(maxNbrRefLvl,mpiGrid.get_refinement_level(nbrPair.first));
1168 lastcell = nbrPair.first;
1173 if (foundcells >= VLASOV_STENCIL_WIDTH) {
1178 if (maxNbrRefLvl > maxPencilRefLvl) {
1180 std::cout <<
"I am rank " <<
myRank <<
". ";
1181 std::cout <<
"Found refinement level " << maxNbrRefLvl <<
" in one of the ghost cells of pencil " << pencili <<
". ";
1182 std::cout <<
"Highest refinement level in this pencil is " << maxPencilRefLvl;
1183 std::cout <<
". Splitting pencil " << pencili << endl;
1187 #pragma omp critical
1189 pencilIdsToSplit.push_back(pencili);
1196 for (
const auto pencili: pencilIdsToSplit) {
1200 auto ids = pencils.getIds(pencili);
1217 pencils.split(pencili,
dx,dy);
1234 ss <<
"I am rank " <<
myRank <<
", I have " << pencils.N <<
" pencils along dimension " << dimension <<
":\n";
1235 MPI_Barrier(MPI_COMM_WORLD);
1237 ss <<
"(D=DO_NOT_COMPUTE, S=Sysboundary L2, L=Sysboundary L1, N=Non-sysboundary L2, G=Ghost cell)" << std::endl;
1238 ss <<
"t, N, mpirank, dimension, length (x, y): indices {path} DZs AreaRatios" << std::endl;
1240 MPI_Barrier(MPI_COMM_WORLD);
1241 ss <<
"----------------------------------------------------------------------" << std::endl;
1242 for (uint
i = 0;
i < pencils.N;
i++) {
1243 const uint L = pencils.lengthOfPencils[
i];
1248 ss << dimension <<
", ";
1250 ss <<
"(" << pencils.x[
i] <<
", " << pencils.y[
i] <<
"): ";
1251 for (
auto j = pencils.ids.begin() + ibeg;
j != pencils.ids.begin() + iend; ++
j) {
1253 if (*
j && mpiGrid[*
j]) {
1259 if (!mpiGrid.is_local(*
j)) ss<<
"G";
1265 for (
auto step : pencils.path[
i]) {
1270 ss <<
"source DZs: ";
1271 for (
auto j = pencils.sourceDZ.begin() + ibeg;
j != pencils.sourceDZ.begin() + iend; ++
j) {
1275 ss <<
"target Ratios: ";
1276 for (
auto j = pencils.targetRatios.begin() + ibeg;
j != pencils.targetRatios.begin() + iend; ++
j) {
1284 for (
const auto& [bin, pencilsInBin] : pencils.pencilsInBin) {
1285 const auto& cells = pencils.targetCellsInBin.at(bin);
1286 std::set<uint64_t> collisions;
1288 ss <<
"Bin " << bin <<
" pencils: ";
1289 if (pencilsInBin.empty()) {
1293 for (
auto pencil : pencilsInBin) {
1294 ss << pencil <<
" ";
1299 ss <<
"Bin " << bin <<
" cells: ";
1300 if (cells.empty()) {
1304 for (
auto id : cells) {
1306 for (
auto [bin2, cells2] : pencils.targetCellsInBin) {
1307 if (bin != bin2 && cells2.contains(
id)) {
1308 collisions.insert(bin2);
1315 if (collisions.empty()) {
1316 ss <<
"No collisions";
1318 ss <<
"COLLISIONS WITH: ";
1319 for (
auto j : collisions) {
1326 std::cout<<std::flush;
1327 MPI_Barrier(MPI_COMM_WORLD);
1328 std::cout<<ss.str();
1329 MPI_Barrier(MPI_COMM_WORLD);
1331 std::cout <<
"-----------------------------------------------------------------" << std::flush << std::endl;
1358 const uint dimension) {
1361 const bool printPencils =
false;
1362 const bool printSeeds =
false;
1364 if (printPencils || printSeeds) {
1365 MPI_Comm_rank(MPI_COMM_WORLD,&
myRank);
1366 MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
1369 switch (dimension) {
1386 std::cerr<<
"Error in dimension: __FILE__:__LINE__"<<std::endl;
1390 vector<CellID> propagatedCells;
1395 switch (dimension) {
1406 std::cerr<<
"Error in dimension: __FILE__:__LINE__"<<std::endl;
1410 for (
size_t c=0;
c<localCells.size(); ++
c) {
1412 propagatedCells.push_back(localCells[
c]);
1417 phiprof::Timer getSeedIdsTimer {
"getSeedIds"};
1418 vector<CellID> seedIds;
1419 getSeedIds(mpiGrid, propagatedCells, dimension, seedIds);
1420 getSeedIdsTimer.stop();
1422 for (
int rank=0; rank<mpi_size; ++rank) {
1423 MPI_Barrier(MPI_COMM_WORLD);
1428 ss<<
"Task "<<
myRank<<
" Dimension "<<dimension<<
" Seed Ids (D=DO_NOT_COMPUTE, S=Sysboundary L2, L=Sysboundary L1, N=Non-sysboundary L2, G=Ghost cell)"<<std::endl<<std::endl;
1429 for (uint
i = 0;
i < seedIds.size();
i++) {
1430 ss << seedIds.at(
i);
1431 if (seedIds.at(
i) && mpiGrid[seedIds.at(
i)]) {
1437 if (!mpiGrid.is_local(seedIds.at(
i))) ss<<
"G";
1441 ss<<std::endl<<std::endl;
1442 std::cerr<<ss.str();
1446 phiprof::Timer buildPencilsTimer {
"buildPencils"};
1448 #pragma omp parallel
1453 std::vector<CellID> ids;
1458 std::vector<CellID>::iterator ibeg, iend;
1460 #pragma omp for schedule(guided,8)
1461 for (uint
i=0;
i<seedIds.size();
i++) {
1462 cuint seedId = seedIds[
i];
1468 #pragma omp critical
1470 for (uint
i=0;
i<thread_pencils.
N;
i++) {
1472 ibeg = thread_pencils.
ids.begin() + thread_pencils.
idsStart[
i];
1474 std::vector<CellID> pencilIds(ibeg, iend);
1480 phiprof::Timer checkGhostCellsTimer {
"check_ghost_cells"};
1485 checkGhostCellsTimer.stop();
1487 phiprof::Timer findSourceRatiosTimer {
"Find_source_cells_ratios_dz"};
1490 #pragma omp parallel for schedule(guided)
1498 findSourceRatiosTimer.stop();
1502 phiprof::Timer binPencilsTimer {
"bin_pencils"};
1504 binPencilsTimer.stop();
1507 for (
int rank=0; rank<mpi_size; ++rank) {
1508 MPI_Barrier(MPI_COMM_WORLD);
1515 buildPencilsTimer.stop();