diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2006-09-25 21:32:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2006-09-25 21:32:00 +0000 |
commit | e9d768636f8f187c354597d73c121a58fbb71467 (patch) | |
tree | 89e9fcd80f2c8ec74f7719991989d613381d1551 /Carpet | |
parent | bfc90ab053c760a00d000b55c450dd2906466bc6 (diff) |
Carpet: Restructure Recompose.cc
Restructure and clean up Recompose.cc.
Regridding now consists of two steps, first calling Recompose once,
then calling Regrid on each refinement level.
darcs-hash:20060925213242-dae7b-c72f88f966e9ccbf1c43f89c207af15cff535b69.gz
Diffstat (limited to 'Carpet')
-rw-r--r-- | Carpet/Carpet/src/Recompose.cc | 83 | ||||
-rw-r--r-- | Carpet/Carpet/src/carpet.hh | 3 | ||||
-rw-r--r-- | Carpet/Carpet/src/functions.hh | 11 |
3 files changed, 64 insertions, 33 deletions
diff --git a/Carpet/Carpet/src/Recompose.cc b/Carpet/Carpet/src/Recompose.cc index 43cd7c7a5..017965938 100644 --- a/Carpet/Carpet/src/Recompose.cc +++ b/Carpet/Carpet/src/Recompose.cc @@ -131,28 +131,29 @@ namespace Carpet { - bool Regrid (const cGH* cgh, - const bool force_recompose, - const bool do_init) + bool Regrid (cGH const * const cctkGH, + bool const force_recompose) { DECLARE_CCTK_PARAMETERS; assert (is_level_mode()); - if (! CCTK_IsFunctionAliased ("Carpet_Regrid")) { + if (not CCTK_IsFunctionAliased ("Carpet_Regrid")) { static bool didtell = false; - if (maxreflevels > 1 and ! didtell) { + if (maxreflevels > 1 and not didtell) { CCTK_WARN (2, "No regridding routine has been provided. There will be no regridding. Maybe you forgot to activate a regridding thorn?"); didtell = true; } return false; } + + bool did_change = false; if (not regrid_in_level_mode) { - BEGIN_MAP_LOOP(cgh, CCTK_GF) { + BEGIN_MAP_LOOP(cctkGH, CCTK_GF) { gh::mexts bbsss = vhh.at(map)->extents(); gh::rbnds obss = vhh.at(map)->outer_boundaries(); @@ -160,12 +161,12 @@ namespace Carpet { // Check whether to recompose CCTK_INT const do_recompose - = Carpet_Regrid (cgh, &bbsss, &obss, &pss, force_recompose); + = Carpet_Regrid (cctkGH, &bbsss, &obss, &pss, force_recompose); assert (do_recompose >= 0); did_change = did_change or do_recompose; if (do_recompose) { - Recompose (cgh, map, bbsss, obss, pss, do_init); + RegridMap (cctkGH, map, bbsss, obss, pss); } } END_MAP_LOOP; @@ -175,7 +176,7 @@ namespace Carpet { vector<gh::mexts> bbssss (maps); vector<gh::rbnds> obsss (maps); vector<gh::rprocs> psss (maps); - BEGIN_MAP_LOOP(cgh, CCTK_GF) { + BEGIN_MAP_LOOP(cctkGH, CCTK_GF) { bbssss.at(map) = vhh.at(map)->extents(); obsss.at(map) = vhh.at(map)->outer_boundaries(); psss.at(map) = vhh.at(map)->processors(); @@ -183,39 +184,45 @@ namespace Carpet { // Check whether to recompose CCTK_INT const do_recompose - = Carpet_RegridMaps (cgh, &bbssss, &obsss, &psss, force_recompose); + = Carpet_RegridMaps (cctkGH, &bbssss, &obsss, &psss, force_recompose); assert (do_recompose >= 0); did_change = did_change or do_recompose; if (do_recompose) { - BEGIN_MAP_LOOP(cgh, CCTK_GF) { + BEGIN_MAP_LOOP(cctkGH, CCTK_GF) { gh::mexts const & bbsss = bbssss.at(map); gh::rbnds const & obss = obsss.at(map); gh::rprocs const & pss = psss.at(map); - Recompose (cgh, map, bbsss, obss, pss, do_init); + RegridMap (cctkGH, map, bbsss, obss, pss); } END_MAP_LOOP; } - } + } // if regrid in level mode + + + + if (did_change) { + + PostRegrid (); + + } // if did change + - PostRecompose (); return did_change; } - void Recompose (cGH const * const cctkGH, + void RegridMap (cGH const * const cctkGH, int const m, gh::mexts const & bbsss, gh::rbnds const & obss, - gh::rprocs const & pss, - bool const do_init) + gh::rprocs const & pss) { DECLARE_CCTK_PARAMETERS; - CCTK_VInfo (CCTK_THORNSTRING, - "Recomposing the grid hierarchy for map %d...", m); + Waypoint ("Regridding map %d...", m); // Write grid structure to file OutputGridStructure (cctkGH, m, bbsss, obss, pss); @@ -227,19 +234,15 @@ namespace Carpet { // TODO: check also that the current and all coarser levels did // not change - // Recompose + // Regrid vhh.at(m)->regrid (bbsss, obss, pss); - for (int rl=0; rl<vhh.at(m)->reflevels(); ++rl) { - vhh.at(m)->recompose (rl, do_init); - } - CCTK_VInfo (CCTK_THORNSTRING, - "Done recomposing the grid hierarchy for map %d.", m); + Waypoint ("Done regridding map %d.", m); } - void PostRecompose () + void PostRegrid () { // Calculate new number of levels int const oldreflevels = reflevels; @@ -271,6 +274,26 @@ namespace Carpet { + bool Recompose (cGH const * const cctkGH, + int const rl, + bool const do_init) + { + bool did_recompose = false; + + for (int m=0; m<maps; ++m) { + Waypoint ("Recomposing the grid hierarchy for map %d level %d...", m, rl); + + assert (rl>=0 and rl<vhh.at(m)->reflevels()); + did_recompose |= vhh.at(m)->recompose (rl, do_init); + + Waypoint ("Done recomposing the grid hierarchy for map %d level %d.", + m, rl); + } + return did_recompose; + } + + + void OutputGrids (const cGH* cgh, const int m, const gh& hh, const dh& dd) { CCTK_INFO ("Grid structure (grid points):"); @@ -643,6 +666,7 @@ namespace Carpet { if (! dims[d]) { ++ alldims; allsizes *= rshape[d]; +#warning "TODO" // Why 0.99 and not 1.01? if (rshape[d] >= 0.99 * mysize) { mydim = d; @@ -694,6 +718,8 @@ namespace Carpet { bvect const newdims = dims.replace(mydim, true); // choose a number of slices for this direction +#warning "TODO" + // Why floor and not ceil? int const nslices = min(nprocs, (int)floor(mysize * pow(nprocs/allsizes, (CCTK_REAL)1/alldims) @@ -809,6 +835,8 @@ namespace Carpet { return; } +#warning "TODO: Add buffer zones, plus maybe more" + const int nprocs = CCTK_nProcs(cgh); if (DEBUG) cout << "SRA nprocs " << nprocs << endl; @@ -825,6 +853,7 @@ namespace Carpet { } vector<int> mynprocs(nslices); { +#warning "TODO: split slices if necessary" if (DEBUG) cout << "SRA: distributing processors to slices" << endl; int ncomps_left = nprocs * ncomps; for (int c=0; c<nslices; ++c) { @@ -913,6 +942,8 @@ namespace Carpet { assert (ps.at(n) >= 0 and ps.at(n) < nprocs); } +#warning "TODO: Remove buffer zones again, plus anything more" + if (DEBUG) cout << "SRA exit" << endl; } diff --git a/Carpet/Carpet/src/carpet.hh b/Carpet/Carpet/src/carpet.hh index 40a5f6f55..a26b12412 100644 --- a/Carpet/Carpet/src/carpet.hh +++ b/Carpet/Carpet/src/carpet.hh @@ -33,7 +33,8 @@ namespace Carpet { int CallFunction (void* function, cFunctionData* attribute, void* data); // Other functions - bool Regrid (const cGH* cgh, const bool force_recompose, const bool do_init); + bool Regrid (cGH const * cctkGH, bool force_recompose); + void CycleTimeLevels (const cGH* cgh); void FlipTimeLevels (const cGH* cgh); void SyncGroups (const cGH* cgh, const vector<int>& groups); diff --git a/Carpet/Carpet/src/functions.hh b/Carpet/Carpet/src/functions.hh index 71788a17d..a219bb9f2 100644 --- a/Carpet/Carpet/src/functions.hh +++ b/Carpet/Carpet/src/functions.hh @@ -81,14 +81,13 @@ namespace Carpet { void GroupsStorageCheck (cGH const * const cctkGH); // Helpers for recomposing the grid hierarchy - void Recompose (cGH const * const cctkGH, - int const m, + void RegridMap (cGH const * cctkGH, + int m, gh::mexts const & bbsss, gh::rbnds const & obss, - gh::rprocs const & pss, - bool const do_init); - - void PostRecompose (); + gh::rprocs const & pss); + void PostRegrid (); + bool Recompose (cGH const * cctkGH, int rl, bool do_init); void CheckRegions (const gh::mexts & bbsss, const gh::rbnds & obss, |