diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2006-10-03 23:37:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2006-10-03 23:37:00 +0000 |
commit | a6d2764b99d78bf2476ba154beff9ba2549e3491 (patch) | |
tree | d766b7f9aabfa68397a19a0deedfd53e8066fe44 | |
parent | f41397cb4d253af033eabd1287cc375990a7d7ff (diff) |
Carpet: Add grouptype state variable for traversing maps and components
When looping over maps and components, remember whether to loop over
grid arrays or grid functions. Grid arrays have 1 map and nprocs
components, while grid functions can have many maps are many
components per map.
Add a corresponding grouptype argument to the mode handling functions
and macros.
Update all callers.
darcs-hash:20061003233704-dae7b-d0d0bf914405821ceddfd0339fac7a640b23c42b.gz
-rw-r--r-- | Carpet/Carpet/src/SetupGH.cc | 18 | ||||
-rw-r--r-- | Carpet/Carpet/src/modes.cc | 417 | ||||
-rw-r--r-- | Carpet/Carpet/src/modes.hh | 49 | ||||
-rw-r--r-- | Carpet/Carpet/src/variables.cc | 1 | ||||
-rw-r--r-- | Carpet/Carpet/src/variables.hh | 1 |
5 files changed, 266 insertions, 220 deletions
diff --git a/Carpet/Carpet/src/SetupGH.cc b/Carpet/Carpet/src/SetupGH.cc index 11dd57eca..14b42c6db 100644 --- a/Carpet/Carpet/src/SetupGH.cc +++ b/Carpet/Carpet/src/SetupGH.cc @@ -149,10 +149,11 @@ namespace Carpet { // Initialise current position (must be the very first thing, // before the first output) - mglevel = -1; - reflevel = -1; - map = -1; - component = -1; + mglevel = -1; + reflevel = -1; + mc_grouptype = -1; + map = -1; + component = -1; // Say hello Waypoint ("Setting up the grid hierarchy"); @@ -836,10 +837,11 @@ namespace Carpet { } // Set up things as if in local mode - mglevel = 0; - reflevel = 0; - map = 0; - component = 0; + mglevel = 0; + reflevel = 0; + mc_grouptype = CCTK_GF; + map = 0; + component = 0; // Leave everything, so that everything is set up correctly leave_local_mode (cctkGH); diff --git a/Carpet/Carpet/src/modes.cc b/Carpet/Carpet/src/modes.cc index e38a0a251..1352cca06 100644 --- a/Carpet/Carpet/src/modes.cc +++ b/Carpet/Carpet/src/modes.cc @@ -320,41 +320,51 @@ namespace Carpet { // Set singlemap mode - void enter_singlemap_mode (cGH * const cctkGH, int const m) + void enter_singlemap_mode (cGH * const cctkGH, + int const m, int const grouptype) { assert (is_level_mode()); + assert (mc_grouptype == -1); assert (m>=0 and m<maps); + assert (grouptype == CCTK_SCALAR or grouptype == CCTK_ARRAY + or grouptype == CCTK_GF); Checkpoint ("Entering singlemap mode"); + assert (mc_grouptype == -1); + mc_grouptype = grouptype; carpetGH.map = map = m; - if (maps > 1) { - // Set space delta - for (int d=0; d<dim; ++d) { - cctkGH->cctk_origin_space[d] = origin_space.at(map).at(mglevel)[d]; - cctkGH->cctk_delta_space[d] = delta_space.at(map)[d] * mglevelfact; + if (mc_grouptype == CCTK_GF) { + + if (maps > 1) { + // Set space delta + for (int d=0; d<dim; ++d) { + cctkGH->cctk_origin_space[d] = origin_space.at(map).at(mglevel)[d]; + cctkGH->cctk_delta_space[d] = delta_space.at(map)[d] * mglevelfact; + } } - } - - // Set grid shape - const ibbox& coarseext = vdd.at(map)->bases.at(mglevel).at(0 ).exterior; - const ibbox& baseext = vdd.at(map)->bases.at(mglevel).at(reflevel).exterior; - assert (all (baseext.lower() % baseext.stride() == 0)); - assert (all ((baseext.lower() - coarseext.lower()) % baseext.stride() == 0)); - ivect::ref(cctkGH->cctk_levoff) = (baseext.lower() - coarseext.lower()) / baseext.stride(); - ivect::ref(cctkGH->cctk_levoffdenom) = 1; - ivect::ref(cctkGH->cctk_gsh) = baseext.shape() / baseext.stride(); - assert (all (vdd.at(map)->ghosts[0] == vdd.at(map)->ghosts[1])); - ivect::ref(cctkGH->cctk_nghostzones) = vdd.at(map)->ghosts[0]; - - for (int group=0; group<CCTK_NumGroups(); ++group) { - if (CCTK_GroupTypeI(group) == CCTK_GF) { - ivect::ref(const_cast<int*>(groupdata.at(group).info.gsh)) - = ivect::ref(cctkGH->cctk_gsh); - ivect::ref(const_cast<int*>(groupdata.at(group).info.nghostzones)) - = ivect::ref(cctkGH->cctk_nghostzones); + + // Set grid shape + const ibbox& coarseext = vdd.at(map)->bases.at(mglevel).at(0 ).exterior; + const ibbox& baseext = vdd.at(map)->bases.at(mglevel).at(reflevel).exterior; + assert (all (baseext.lower() % baseext.stride() == 0)); + assert (all ((baseext.lower() - coarseext.lower()) % baseext.stride() == 0)); + ivect::ref(cctkGH->cctk_levoff) = (baseext.lower() - coarseext.lower()) / baseext.stride(); + ivect::ref(cctkGH->cctk_levoffdenom) = 1; + ivect::ref(cctkGH->cctk_gsh) = baseext.shape() / baseext.stride(); + assert (all (vdd.at(map)->ghosts[0] == vdd.at(map)->ghosts[1])); + ivect::ref(cctkGH->cctk_nghostzones) = vdd.at(map)->ghosts[0]; + + for (int group=0; group<CCTK_NumGroups(); ++group) { + if (CCTK_GroupTypeI(group) == CCTK_GF) { + ivect::ref(const_cast<int*>(groupdata.at(group).info.gsh)) + = ivect::ref(cctkGH->cctk_gsh); + ivect::ref(const_cast<int*>(groupdata.at(group).info.nghostzones)) + = ivect::ref(cctkGH->cctk_nghostzones); + } } - } + + } // if mc_grouptype assert (is_singlemap_mode()); } @@ -368,32 +378,40 @@ namespace Carpet { if (map == -1) return; // early return - if (maps > 1) { - // Save and unset space delta - for (int d=0; d<dim; ++d) { - origin_space.at(map).at(mglevel)[d] = cctkGH->cctk_origin_space[d]; - delta_space.at(map)[d] = cctkGH->cctk_delta_space[d] / mglevelfact; - cctkGH->cctk_origin_space[d] = -424242.0; - cctkGH->cctk_delta_space[d] = -424242.0; - } - } - - // Unset grid shape - ivect::ref(cctkGH->cctk_levoff) = deadbeef; - ivect::ref(cctkGH->cctk_levoffdenom) = 0; - ivect::ref(cctkGH->cctk_gsh) = deadbeef; -// ivect::ref(cctkGH->cctk_nghostzones) = deadbeef; - ivect::ref(cctkGH->cctk_nghostzones) = vdd.at(map)->ghosts[0]; + assert (mc_grouptype == CCTK_SCALAR or mc_grouptype == CCTK_ARRAY + or mc_grouptype == CCTK_GF); - for (int group=0; group<CCTK_NumGroups(); ++group) { - if (CCTK_GroupTypeI(group) == CCTK_GF) { - ivect::ref(const_cast<int*>(groupdata.at(group).info.gsh)) - = ivect::ref(cctkGH->cctk_gsh); - ivect::ref(const_cast<int*>(groupdata.at(group).info.nghostzones)) - = ivect::ref(cctkGH->cctk_nghostzones); + if (mc_grouptype == CCTK_GF) { + + if (maps > 1) { + // Save and unset space delta + for (int d=0; d<dim; ++d) { + origin_space.at(map).at(mglevel)[d] = cctkGH->cctk_origin_space[d]; + delta_space.at(map)[d] = cctkGH->cctk_delta_space[d] / mglevelfact; + cctkGH->cctk_origin_space[d] = -424242.0; + cctkGH->cctk_delta_space[d] = -424242.0; + } } - } + + // Unset grid shape + ivect::ref(cctkGH->cctk_levoff) = deadbeef; + ivect::ref(cctkGH->cctk_levoffdenom) = 0; + ivect::ref(cctkGH->cctk_gsh) = deadbeef; +// ivect::ref(cctkGH->cctk_nghostzones) = deadbeef; + ivect::ref(cctkGH->cctk_nghostzones) = vdd.at(map)->ghosts[0]; + + for (int group=0; group<CCTK_NumGroups(); ++group) { + if (CCTK_GroupTypeI(group) == CCTK_GF) { + ivect::ref(const_cast<int*>(groupdata.at(group).info.gsh)) + = ivect::ref(cctkGH->cctk_gsh); + ivect::ref(const_cast<int*>(groupdata.at(group).info.nghostzones)) + = ivect::ref(cctkGH->cctk_nghostzones); + } + } + + } // if mc_grouptype + mc_grouptype = -1; carpetGH.map = map = -1; assert (is_level_mode()); @@ -403,98 +421,107 @@ namespace Carpet { // Set local mode - void enter_local_mode (cGH * const cctkGH, int const c) + void enter_local_mode (cGH * const cctkGH, int const c, int const grouptype) { assert (is_singlemap_mode()); - assert (c>=0 and c<vhh.at(map)->components(reflevel)); + if (mc_grouptype == CCTK_GF) { + assert (c>=0 and c<vhh.at(map)->components(reflevel)); + } else { + assert (c>=0 and c<CCTK_nProcs(cctkGH)); + } Checkpoint ("Entering local mode"); + assert (grouptype == mc_grouptype); component = c; - // Set cGH fields - const ibbox& baseext = vdd.at(map)->bases.at(mglevel).at(reflevel).exterior; - const bbvect& obnds = vhh.at(map)->outer_boundaries().at(reflevel).at(component); - const ibbox& ext = vdd.at(map)->boxes.at(mglevel).at(reflevel).at(component).exterior; - - ivect::ref(cctkGH->cctk_lsh) = ext.shape() / ext.stride(); - ivect::ref(cctkGH->cctk_lbnd) - = (ext.lower() - baseext.lower()) / ext.stride(); - ivect::ref(cctkGH->cctk_ubnd) - = (ext.upper() - baseext.lower()) / ext.stride(); - ivect::ref(cctkGH->cctk_from) = 0; - ivect::ref(cctkGH->cctk_to) = ivect::ref(cctkGH->cctk_lsh); - - for (int d=0; d<dim; ++d) { - cctkGH->cctk_bbox[2*d ] = obnds[d][0]; - cctkGH->cctk_bbox[2*d+1] = obnds[d][1]; - } + if (mc_grouptype == CCTK_GF) { + + // Set cGH fields + const ibbox& baseext = vdd.at(map)->bases.at(mglevel).at(reflevel).exterior; + const bbvect& obnds = vhh.at(map)->outer_boundaries().at(reflevel).at(component); + const ibbox& ext = vdd.at(map)->boxes.at(mglevel).at(reflevel).at(component).exterior; + + ivect::ref(cctkGH->cctk_lsh) = ext.shape() / ext.stride(); + ivect::ref(cctkGH->cctk_lbnd) + = (ext.lower() - baseext.lower()) / ext.stride(); + ivect::ref(cctkGH->cctk_ubnd) + = (ext.upper() - baseext.lower()) / ext.stride(); + ivect::ref(cctkGH->cctk_from) = 0; + ivect::ref(cctkGH->cctk_to) = ivect::ref(cctkGH->cctk_lsh); - for (int stg=0; stg<CCTK_NSTAGGER; ++stg) { for (int d=0; d<dim; ++d) { - // TODO: support staggering - cctkGH->cctk_lssh[CCTK_LSSH_IDX(stg,d)] = cctkGH->cctk_lsh[d]; + cctkGH->cctk_bbox[2*d ] = obnds[d][0]; + cctkGH->cctk_bbox[2*d+1] = obnds[d][1]; } - } - - for (int d=0; d<dim; ++d) { - assert (cctkGH->cctk_lsh[d] >= 0); - assert (cctkGH->cctk_lsh[d] <= cctkGH->cctk_gsh[d]); - assert (cctkGH->cctk_lbnd[d] >= 0); - assert (cctkGH->cctk_lbnd[d] <= cctkGH->cctk_ubnd[d] + 1); - assert (cctkGH->cctk_ubnd[d] < cctkGH->cctk_gsh[d]); - assert (cctkGH->cctk_lbnd[d] + cctkGH->cctk_lsh[d] - 1 == cctkGH->cctk_ubnd[d]); - assert (cctkGH->cctk_lbnd[d] <= cctkGH->cctk_ubnd[d]+1); - assert (cctkGH->cctk_from[d] >= 0); - assert (cctkGH->cctk_from[d] <= cctkGH->cctk_to[d]); - assert (cctkGH->cctk_to[d] <= cctkGH->cctk_lsh[d]); - } - - for (int group=0; group<CCTK_NumGroups(); ++group) { - if (CCTK_GroupTypeI(group) == CCTK_GF) { - - ivect::ref(const_cast<int*>(groupdata.at(group).info.lsh)) - = ivect::ref(cctkGH->cctk_lsh); - ivect::ref(const_cast<int*>(groupdata.at(group).info.lbnd)) - = ivect::ref(cctkGH->cctk_lbnd); - ivect::ref(const_cast<int*>(groupdata.at(group).info.ubnd)) - = ivect::ref(cctkGH->cctk_ubnd); - + + for (int stg=0; stg<CCTK_NSTAGGER; ++stg) { for (int d=0; d<dim; ++d) { - const_cast<int*>(groupdata.at(group).info.bbox)[2*d ] - = cctkGH->cctk_bbox[2*d ]; - const_cast<int*>(groupdata.at(group).info.bbox)[2*d+1] - = cctkGH->cctk_bbox[2*d+1]; + // TODO: support staggering + cctkGH->cctk_lssh[CCTK_LSSH_IDX(stg,d)] = cctkGH->cctk_lsh[d]; } - - const int numvars = CCTK_NumVarsInGroupI (group); - if (numvars>0) { - const int firstvar = CCTK_FirstVarIndexI (group); - assert (firstvar>=0); - const int max_tl = CCTK_MaxTimeLevelsGI (group); - assert (max_tl>=0); - const int active_tl = CCTK_ActiveTimeLevelsGI (cctkGH, group); - assert (active_tl>=0 and active_tl<=max_tl); + } + + for (int d=0; d<dim; ++d) { + assert (cctkGH->cctk_lsh[d] >= 0); + assert (cctkGH->cctk_lsh[d] <= cctkGH->cctk_gsh[d]); + assert (cctkGH->cctk_lbnd[d] >= 0); + assert (cctkGH->cctk_lbnd[d] <= cctkGH->cctk_ubnd[d] + 1); + assert (cctkGH->cctk_ubnd[d] < cctkGH->cctk_gsh[d]); + assert (cctkGH->cctk_lbnd[d] + cctkGH->cctk_lsh[d] - 1 == cctkGH->cctk_ubnd[d]); + assert (cctkGH->cctk_lbnd[d] <= cctkGH->cctk_ubnd[d]+1); + assert (cctkGH->cctk_from[d] >= 0); + assert (cctkGH->cctk_from[d] <= cctkGH->cctk_to[d]); + assert (cctkGH->cctk_to[d] <= cctkGH->cctk_lsh[d]); + } + + for (int group=0; group<CCTK_NumGroups(); ++group) { + if (CCTK_GroupTypeI(group) == CCTK_GF) { -// assert (vhh.at(map)->is_local(reflevel,component)); + ivect::ref(const_cast<int*>(groupdata.at(group).info.lsh)) + = ivect::ref(cctkGH->cctk_lsh); + ivect::ref(const_cast<int*>(groupdata.at(group).info.lbnd)) + = ivect::ref(cctkGH->cctk_lbnd); + ivect::ref(const_cast<int*>(groupdata.at(group).info.ubnd)) + = ivect::ref(cctkGH->cctk_ubnd); - assert (group<(int)arrdata.size()); - for (int var=0; var<numvars; ++var) { - assert (firstvar+var<CCTK_NumVars()); - ggf * const ff = arrdata.at(group).at(map).data.at(var); - for (int tl=0; tl<max_tl; ++tl) { - if (ff and tl<active_tl) { - gdata * const data = (*ff) (tl, reflevel, component, mglevel); - assert (data); - cctkGH->data[firstvar+var][tl] = data->storage(); - } else { - cctkGH->data[firstvar+var][tl] = NULL; + for (int d=0; d<dim; ++d) { + const_cast<int*>(groupdata.at(group).info.bbox)[2*d ] + = cctkGH->cctk_bbox[2*d ]; + const_cast<int*>(groupdata.at(group).info.bbox)[2*d+1] + = cctkGH->cctk_bbox[2*d+1]; + } + + const int numvars = CCTK_NumVarsInGroupI (group); + if (numvars>0) { + const int firstvar = CCTK_FirstVarIndexI (group); + assert (firstvar>=0); + const int max_tl = CCTK_MaxTimeLevelsGI (group); + assert (max_tl>=0); + const int active_tl = CCTK_ActiveTimeLevelsGI (cctkGH, group); + assert (active_tl>=0 and active_tl<=max_tl); + + // assert (vhh.at(map)->is_local(reflevel,component)); + + assert (group<(int)arrdata.size()); + for (int var=0; var<numvars; ++var) { + assert (firstvar+var<CCTK_NumVars()); + ggf * const ff = arrdata.at(group).at(map).data.at(var); + for (int tl=0; tl<max_tl; ++tl) { + if (ff and tl<active_tl) { + gdata * const data = (*ff) (tl, reflevel, component, mglevel); + assert (data); + cctkGH->data[firstvar+var][tl] = data->storage(); + } else { + cctkGH->data[firstvar+var][tl] = NULL; + } } } } - } - - } // if grouptype - } // for group + + } // if grouptype + } // for group + + } // if mc_grouptype assert (is_local_mode()); } @@ -508,60 +535,64 @@ namespace Carpet { if (component == -1) return; // early return - // Unset cGH fields - ivect::ref(cctkGH->cctk_lsh) = deadbeef; - ivect::ref(cctkGH->cctk_lbnd) = -deadbeef; - ivect::ref(cctkGH->cctk_ubnd) = deadbeef; - ivect::ref(cctkGH->cctk_from) = -deadbeef; - ivect::ref(cctkGH->cctk_to) = deadbeef; - - for (int d=0; d<dim; ++d) { - cctkGH->cctk_bbox[2*d ] = deadbeef; - cctkGH->cctk_bbox[2*d+1] = deadbeef; - } + if (mc_grouptype == CCTK_GF) { + + // Unset cGH fields + ivect::ref(cctkGH->cctk_lsh) = deadbeef; + ivect::ref(cctkGH->cctk_lbnd) = -deadbeef; + ivect::ref(cctkGH->cctk_ubnd) = deadbeef; + ivect::ref(cctkGH->cctk_from) = -deadbeef; + ivect::ref(cctkGH->cctk_to) = deadbeef; - for (int stg=0; stg<CCTK_NSTAGGER; ++stg) { for (int d=0; d<dim; ++d) { - // TODO: support staggering - cctkGH->cctk_lssh[CCTK_LSSH_IDX(stg,d)] = cctkGH->cctk_lsh[d]; + cctkGH->cctk_bbox[2*d ] = deadbeef; + cctkGH->cctk_bbox[2*d+1] = deadbeef; } - } - - for (int group=0; group<CCTK_NumGroups(); ++group) { - if (CCTK_GroupTypeI(group) == CCTK_GF) { - - ivect::ref(const_cast<int*>(groupdata.at(group).info.lsh)) - = ivect::ref(cctkGH->cctk_lsh); - ivect::ref(const_cast<int*>(groupdata.at(group).info.lbnd)) - = ivect::ref(cctkGH->cctk_lbnd); - ivect::ref(const_cast<int*>(groupdata.at(group).info.ubnd)) - = ivect::ref(cctkGH->cctk_ubnd); - + + for (int stg=0; stg<CCTK_NSTAGGER; ++stg) { for (int d=0; d<dim; ++d) { - const_cast<int*>(groupdata.at(group).info.bbox)[2*d ] - = cctkGH->cctk_bbox[2*d ]; - const_cast<int*>(groupdata.at(group).info.bbox)[2*d+1] - = cctkGH->cctk_bbox[2*d+1]; + // TODO: support staggering + cctkGH->cctk_lssh[CCTK_LSSH_IDX(stg,d)] = cctkGH->cctk_lsh[d]; } - - const int numvars = CCTK_NumVarsInGroupI (group); - if (numvars>0) { - const int firstvar = CCTK_FirstVarIndexI (group); - assert (firstvar>=0); - const int max_tl = CCTK_MaxTimeLevelsGI (group); - assert (max_tl>=0); + } + + for (int group=0; group<CCTK_NumGroups(); ++group) { + if (CCTK_GroupTypeI(group) == CCTK_GF) { - assert (group<(int)arrdata.size()); - for (int var=0; var<numvars; ++var) { - assert (firstvar+var<CCTK_NumVars()); - for (int tl=0; tl<max_tl; ++tl) { - cctkGH->data[firstvar+var][tl] = NULL; + ivect::ref(const_cast<int*>(groupdata.at(group).info.lsh)) + = ivect::ref(cctkGH->cctk_lsh); + ivect::ref(const_cast<int*>(groupdata.at(group).info.lbnd)) + = ivect::ref(cctkGH->cctk_lbnd); + ivect::ref(const_cast<int*>(groupdata.at(group).info.ubnd)) + = ivect::ref(cctkGH->cctk_ubnd); + + for (int d=0; d<dim; ++d) { + const_cast<int*>(groupdata.at(group).info.bbox)[2*d ] + = cctkGH->cctk_bbox[2*d ]; + const_cast<int*>(groupdata.at(group).info.bbox)[2*d+1] + = cctkGH->cctk_bbox[2*d+1]; + } + + const int numvars = CCTK_NumVarsInGroupI (group); + if (numvars>0) { + const int firstvar = CCTK_FirstVarIndexI (group); + assert (firstvar>=0); + const int max_tl = CCTK_MaxTimeLevelsGI (group); + assert (max_tl>=0); + + assert (group<(int)arrdata.size()); + for (int var=0; var<numvars; ++var) { + assert (firstvar+var<CCTK_NumVars()); + for (int tl=0; tl<max_tl; ++tl) { + cctkGH->data[firstvar+var][tl] = NULL; + } } } - } - - } // if grouptype - } // for group + + } // if grouptype + } // for group + + } // if mc_grouptype component = -1; @@ -698,7 +729,7 @@ namespace Carpet { { assert (grouptype == CCTK_GF or grouptype == CCTK_ARRAY or grouptype == CCTK_SCALAR); - enter_singlemap_mode (cctkGH, m); + enter_singlemap_mode (cctkGH, m, grouptype); } map_iterator::~map_iterator () @@ -716,7 +747,7 @@ namespace Carpet { ++ m; if (not done()) { leave_singlemap_mode (cctkGH); - enter_singlemap_mode (cctkGH, m); + enter_singlemap_mode (cctkGH, m, grouptype); } } @@ -730,7 +761,7 @@ namespace Carpet { { assert (grouptype == CCTK_GF or grouptype == CCTK_ARRAY or grouptype == CCTK_SCALAR); - enter_local_mode (cctkGH, c); + enter_local_mode (cctkGH, c, grouptype); } component_iterator::~component_iterator () @@ -750,7 +781,7 @@ namespace Carpet { ++ c; if (not done()) { leave_local_mode (cctkGH); - enter_local_mode (cctkGH, c); + enter_local_mode (cctkGH, c, grouptype); } } @@ -787,9 +818,10 @@ namespace Carpet { } while (not done() and not (grouptype == CCTK_GF ? vhh.at(map)->is_local(reflevel, c) : c == CCTK_MyProc(cctkGH))); + if (not done()) { leave_local_mode (cctkGH); - enter_local_mode (cctkGH, c); + enter_local_mode (cctkGH, c, grouptype); } } @@ -816,7 +848,7 @@ namespace Carpet { { assert (is_singlemap_mode()); if (c != -1) { - enter_local_mode (cctkGH, c); + enter_local_mode (cctkGH, c, mc_grouptype); } } @@ -825,7 +857,8 @@ namespace Carpet { // Level escape level_escape::level_escape (cGH const * const cctkGH_) - : cctkGH(const_cast<cGH*>(cctkGH_)), m(map), c(component) + : cctkGH(const_cast<cGH*>(cctkGH_)), + grouptype(mc_grouptype), m(map), c(component) { assert (not is_meta_mode()); assert (not is_global_mode()); @@ -841,9 +874,9 @@ namespace Carpet { { assert (is_level_mode()); if (m != -1) { - enter_singlemap_mode (cctkGH, m); + enter_singlemap_mode (cctkGH, m, grouptype); if (c != -1) { - enter_local_mode (cctkGH, c); + enter_local_mode (cctkGH, c, grouptype); } } } @@ -853,7 +886,8 @@ namespace Carpet { // Global escape global_escape::global_escape (cGH const * const cctkGH_) - : cctkGH(const_cast<cGH*>(cctkGH_)), rl(reflevel), m(map), c(component) + : cctkGH(const_cast<cGH*>(cctkGH_)), + rl(reflevel), grouptype(mc_grouptype), m(map), c(component) { assert (not is_meta_mode()); if (not is_global_mode()) { @@ -873,9 +907,9 @@ namespace Carpet { if (rl != -1) { enter_level_mode (cctkGH, rl); if (m != -1) { - enter_singlemap_mode (cctkGH, m); + enter_singlemap_mode (cctkGH, m, grouptype); if (c != -1) { - enter_local_mode (cctkGH, c); + enter_local_mode (cctkGH, c, grouptype); } } } @@ -886,7 +920,8 @@ namespace Carpet { // Meta escape meta_escape::meta_escape (cGH const * const cctkGH_) - : cctkGH(const_cast<cGH*>(cctkGH_)), ml(mglevel), rl(reflevel), m(map), c(component) + : cctkGH(const_cast<cGH*>(cctkGH_)), + ml(mglevel), rl(reflevel), grouptype(mc_grouptype), m(map), c(component) { if (not is_meta_mode()) { if (not is_global_mode()) { @@ -910,9 +945,9 @@ namespace Carpet { if (rl != -1) { enter_level_mode (cctkGH, rl); if (m != -1) { - enter_singlemap_mode (cctkGH, m); + enter_singlemap_mode (cctkGH, m, grouptype); if (c != -1) { - enter_local_mode (cctkGH, c); + enter_local_mode (cctkGH, c, grouptype); } } } @@ -1072,11 +1107,12 @@ namespace Carpet { // map setter - map_setter::map_setter (cGH const * const cctkGH_, int const m) + map_setter::map_setter (cGH const * const cctkGH_, + int const m, int const grouptype) : cctkGH(const_cast<cGH*>(cctkGH_)) { assert (is_level_mode()); - enter_singlemap_mode (cctkGH, m); + enter_singlemap_mode (cctkGH, m, grouptype); } map_setter::~map_setter () @@ -1086,11 +1122,12 @@ namespace Carpet { // component setter - component_setter::component_setter (cGH const * const cctkGH_, int const c) + component_setter::component_setter (cGH const * const cctkGH_, + int const c, int const grouptype) : cctkGH(const_cast<cGH*>(cctkGH_)) { assert (is_singlemap_mode()); - enter_local_mode (cctkGH, c); + enter_local_mode (cctkGH, c, grouptype); } component_setter::~component_setter () diff --git a/Carpet/Carpet/src/modes.hh b/Carpet/Carpet/src/modes.hh index 25044cf23..09a23d4dd 100644 --- a/Carpet/Carpet/src/modes.hh +++ b/Carpet/Carpet/src/modes.hh @@ -43,10 +43,10 @@ namespace Carpet { void enter_level_mode (cGH * const cctkGH, int const rl); void leave_level_mode (cGH * const cctkGH); - void enter_singlemap_mode (cGH * const cctkGH, int const m); + void enter_singlemap_mode (cGH * const cctkGH, int const m, int const grouptype); void leave_singlemap_mode (cGH * const cctkGH); - void enter_local_mode (cGH * const cctkGH, int const c); + void enter_local_mode (cGH * const cctkGH, int const c, int const grouptype); void leave_local_mode (cGH * const cctkGH); @@ -239,6 +239,7 @@ namespace Carpet { class level_escape { cGH * cctkGH; + int grouptype; int m; int c; public: @@ -249,6 +250,7 @@ namespace Carpet { class global_escape { cGH * cctkGH; int rl; + int grouptype; int m; int c; public: @@ -260,6 +262,7 @@ namespace Carpet { cGH * cctkGH; int ml; int rl; + int grouptype; int m; int c; public: @@ -271,10 +274,10 @@ namespace Carpet { // Compatibility defines for the mode escapes -#define BEGIN_SINGLEMAP_MODE(cctkGH) \ +#define BEGIN_SINGLEMAP_MODE(cctkGH) \ do { \ bool singlemap_mode_ = true; \ - singlemap_escape esc_(cctkGH); \ + singlemap_escape esc_(cctkGH); \ { #define END_SINGLEMAP_MODE \ } \ @@ -282,10 +285,10 @@ namespace Carpet { singlemap_mode_ = false; \ } while (false) -#define BEGIN_LEVEL_MODE(cctkGH) \ +#define BEGIN_LEVEL_MODE(cctkGH) \ do { \ bool level_mode_ = true; \ - level_escape esc_(cctkGH); \ + level_escape esc_(cctkGH); \ { #define END_LEVEL_MODE \ } \ @@ -293,10 +296,10 @@ namespace Carpet { level_mode_ = false; \ } while (false) -#define BEGIN_GLOBAL_MODE(cctkGH) \ +#define BEGIN_GLOBAL_MODE(cctkGH) \ do { \ bool global_mode_ = true; \ - global_escape esc_(cctkGH); \ + global_escape esc_(cctkGH); \ { #define END_GLOBAL_MODE \ } \ @@ -304,10 +307,10 @@ namespace Carpet { global_mode_ = false; \ } while (false) -#define BEGIN_META_MODE(cctkGH) \ +#define BEGIN_META_MODE(cctkGH) \ do { \ bool meta_mode_ = true; \ - meta_escape esc_(cctkGH); \ + meta_escape esc_(cctkGH); \ { #define END_META_MODE \ } \ @@ -336,14 +339,16 @@ namespace Carpet { class map_setter { cGH * cctkGH; public: - map_setter (cGH const * const cctkGH, int const m); + map_setter (cGH const * const cctkGH, + int const m, int const grouptype); ~map_setter (); }; class component_setter { cGH * cctkGH; public: - component_setter (cGH const * const cctkGH, int const c); + component_setter (cGH const * const cctkGH, + int const c, int const grouptype); ~component_setter (); }; @@ -351,33 +356,33 @@ namespace Carpet { // Compatibility defines for the mode setters -#define ENTER_GLOBAL_MODE(cctkGH, ml) \ +#define ENTER_GLOBAL_MODE(cctkGH, ml) \ do { \ - mglevel_setter mg_setter_(cctkGH, ml); \ + mglevel_setter mg_setter_(cctkGH, ml); \ { #define LEAVE_GLOBAL_MODE \ } \ } while (false) -#define ENTER_LEVEL_MODE(cctkGH, rl) \ +#define ENTER_LEVEL_MODE(cctkGH, rl) \ do { \ - reflevel_setter ref_setter_(cctkGH, rl); \ + reflevel_setter ref_setter_(cctkGH, rl); \ { #define LEAVE_LEVEL_MODE \ } \ } while (false) -#define ENTER_SINGLEMAP_MODE(cctkGH, m) \ - do { \ - map_setter m_setter_(cctkGH, m); \ +#define ENTER_SINGLEMAP_MODE(cctkGH, m, grouptype) \ + do { \ + map_setter m_setter_(cctkGH, m, grouptype); \ { #define LEAVE_SINGLEMAP_MODE \ } \ } while (false) -#define ENTER_LOCAL_MODE(cctkGH, c) \ - do { \ - component_setter c_setter_(cctkGH, c); \ +#define ENTER_LOCAL_MODE(cctkGH, c, grouptype) \ + do { \ + component_setter c_setter_(cctkGH, c, grouptype); \ { #define LEAVE_LOCAL_MODE \ } \ diff --git a/Carpet/Carpet/src/variables.cc b/Carpet/Carpet/src/variables.cc index c7e16cb85..23e78132b 100644 --- a/Carpet/Carpet/src/variables.cc +++ b/Carpet/Carpet/src/variables.cc @@ -53,6 +53,7 @@ namespace Carpet { // Current position on the grid hierarchy int reflevel; int mglevel; + int mc_grouptype; int map; int component; diff --git a/Carpet/Carpet/src/variables.hh b/Carpet/Carpet/src/variables.hh index 18ad71894..d27839ce8 100644 --- a/Carpet/Carpet/src/variables.hh +++ b/Carpet/Carpet/src/variables.hh @@ -82,6 +82,7 @@ namespace Carpet { // Current position on the grid hierarchy extern int reflevel; extern int mglevel; + extern int mc_grouptype; // -1, CCTK_SCALAR/CCTK_ARRAY, CCTK_GF extern int map; extern int component; |