aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
authorswhite <schnetter@cct.lsu.edu>2004-11-29 15:37:00 +0000
committerswhite <schnetter@cct.lsu.edu>2004-11-29 15:37:00 +0000
commit33c18621420779f6a1a507670cf75db547767251 (patch)
tree5d5068a222e369ca0b7d4d9f9b39872d855fe480 /Carpet
parentf45221dc3bc1216f35871b3b465a95ba5ca3fadb (diff)
Comm
Pulled several large functional ranges out of SyncGroup, leaving this function to hold the controlling logic. Got rid of evil returns in the midst of complicated code. darcs-hash:20041129153732-32473-640947f787526223897aeb3c79b2e523d0d02471.gz
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/Carpet/src/Comm.cc184
1 files changed, 108 insertions, 76 deletions
diff --git a/Carpet/Carpet/src/Comm.cc b/Carpet/Carpet/src/Comm.cc
index 7648780b6..2c217ab5f 100644
--- a/Carpet/Carpet/src/Comm.cc
+++ b/Carpet/Carpet/src/Comm.cc
@@ -21,11 +21,17 @@ namespace Carpet {
using namespace std;
+ static int CheckSyncGroupConsistency ( const cGH* cgh,
+ const char *groupname );
+ static void ProlongateGroupBoundaries ( const cGH* cgh,
+ CCTK_REAL initial_time, int group );
+ static void SyncGFGroup ( const cGH* cgh, comm_state<dim> &state, int group );
+ static void SyncGFARRAY ( const cGH* cgh, comm_state<dim> &state, int group );
int SyncGroup (const cGH* cgh, const char* groupname)
{
DECLARE_CCTK_PARAMETERS;
-
+ int retval = 0;
const int group = CCTK_GroupIndex(groupname);
assert (group>=0 && group<CCTK_NumGroups());
assert (group<(int)arrdata.size());
@@ -33,48 +39,12 @@ namespace Carpet {
Checkpoint ("SyncGroup \"%s\" time=%g", groupname, (double)cgh->cctk_time);
const int grouptype = CCTK_GroupTypeI(group);
+ retval = CheckSyncGroupConsistency ( cgh, groupname);
+ if( retval != 0 )
+ goto quits;
- if (grouptype == CCTK_GF) {
- if (reflevel == -1) {
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot synchronise in global mode "
- "(Tried to synchronise group \"%s\")",
- groupname);
- }
- if (map != -1 && component == -1) {
- if (maps == 1) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Synchronising group \"%s\" in singlemap mode",
- groupname);
- } else {
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot synchronise in singlemap mode "
- "(Tried to synchronise group \"%s\")",
- groupname);
- }
- }
- if (component != -1) {
- if (maps == 1 && vhh.at(map)->local_components(reflevel) == 1) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Synchronising group \"%s\" in local mode",
- groupname);
- } else {
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot synchronise in local mode "
- "(Tried to synchronise group \"%s\")",
- groupname);
- }
- }
- }
-
- if (! CCTK_QueryGroupStorageI(cgh, group)) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot synchronise group \"%s\" because it has no storage",
- groupname);
- return -1;
- }
-
- if (CCTK_NumVarsInGroupI(group) == 0) return 0;
+ if (CCTK_NumVarsInGroupI(group) == 0)
+ goto quits;
const int n0 = CCTK_FirstVarIndexI(group);
assert (n0>=0);
@@ -89,23 +59,8 @@ namespace Carpet {
case CCTK_GF:
assert (reflevel>=0 && reflevel<reflevels);
if (reflevel > 0) {
-
- // use the current time here (which may be modified by the
- // user)
- const CCTK_REAL time
- = (cgh->cctk_time - cctk_initial_time) / delta_time;
-
- for (comm_state<dim> state; !state.done(); state.step()) {
- for (int m=0; m<(int)arrdata.at(group).size(); ++m) {
- for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
- for (int c=0; c<vhh.at(m)->components(reflevel); ++c) {
- arrdata.at(group).at(m).data.at(var)->ref_bnd_prolongate
- (state, tl, reflevel, c, mglevel, time);
- }
- }
- }
- } // for state
- } // if reflevel>0
+ ProlongateGroupBoundaries ( cgh, cctk_initial_time, group );
+ }
break;
case CCTK_SCALAR:
@@ -115,39 +70,116 @@ namespace Carpet {
default:
assert (0);
- } // switch grouptype
- } // if do_prolongate
+ }
+ }
// Sync
for (comm_state<dim> state; !state.done(); state.step()) {
switch (CCTK_GroupTypeI(group)) {
case CCTK_GF:
- for (int m=0; m<(int)arrdata.at(group).size(); ++m) {
- for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
- for (int c=0; c<vhh.at(m)->components(reflevel); ++c) {
- arrdata.at(group).at(m).data.at(var)->sync
- (state, tl, reflevel, c, mglevel);
- }
- }
- }
+ SyncGFGroup ( cgh, state, group );
break;
case CCTK_SCALAR:
case CCTK_ARRAY:
- for (int var=0; var<(int)arrdata.at(group).at(0).data.size(); ++var) {
- arrdata.at(group).at(0).data.at(var)->sync (state, 0, 0, 0, 0);
- }
+ SyncGFARRAY ( cgh, state, group );
break;
default:
assert (0);
- } // switch grouptype
- } // for state
-
- return 0;
+ }
+ }
+ quits:
+ return retval;
}
+ void ProlongateGroupBoundaries ( const cGH* cgh, CCTK_REAL initial_time,
+ int group )
+ {
+ // use the current time here (which may be modified by the user)
+ const CCTK_REAL time = (cgh->cctk_time - initial_time) / delta_time;
+ const int tl = 0;
+
+ for (comm_state<dim> state; !state.done(); state.step()) {
+ for (int m=0; m<(int)arrdata.at(group).size(); ++m) {
+ for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
+ for (int c=0; c<vhh.at(m)->components(reflevel); ++c) {
+ arrdata.at(group).at(m).data.at(var)->ref_bnd_prolongate
+ (state, tl, reflevel, c, mglevel, time);
+ }
+ }
+ }
+ }
+ }
+
+ void SyncGFGroup ( const cGH* cgh, comm_state<dim> &state, int group )
+ {
+ const int tl = 0;
+ for (int m=0; m<(int)arrdata.at(group).size(); ++m) {
+ for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
+ for (int c=0; c<vhh.at(m)->components(reflevel); ++c) {
+ arrdata.at(group).at(m).data.at(var)->sync
+ (state, tl, reflevel, c, mglevel);
+ }
+ }
+ }
+ }
+
+ void SyncGFARRAY ( const cGH* cgh, comm_state<dim> &state, int group )
+ {
+ for (int var=0; var<(int)arrdata.at(group).at(0).data.size(); ++var) {
+ arrdata.at(group).at(0).data.at(var)->sync (state, 0, 0, 0, 0);
+ }
+ }
+
+ int CheckSyncGroupConsistency ( const cGH* cgh,const char *groupname )
+ {
+ int retval = 0;
+ const int group = CCTK_GroupIndex(groupname);
+ const int grouptype = CCTK_GroupTypeI(group);
+
+ if (grouptype == CCTK_GF) {
+ if (reflevel == -1) {
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cannot synchronise in global mode "
+ "(Tried to synchronise group \"%s\")",
+ groupname);
+ }
+ if (map != -1 && component == -1) {
+ if (maps == 1) {
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Synchronising group \"%s\" in singlemap mode",
+ groupname);
+ } else {
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cannot synchronise in singlemap mode "
+ "(Tried to synchronise group \"%s\")",
+ groupname);
+ }
+ }
+ if (component != -1) {
+ if (maps == 1 && vhh.at(map)->local_components(reflevel) == 1) {
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Synchronising group \"%s\" in local mode",
+ groupname);
+ } else {
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cannot synchronise in local mode "
+ "(Tried to synchronise group \"%s\")",
+ groupname);
+ }
+ }
+ }
+
+ if (! CCTK_QueryGroupStorageI(cgh, group)) {
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cannot synchronise group \"%s\" because it has no storage",
+ groupname);
+ retval = -1;
+ }
+ return retval;
+ }
int EnableGroupComm (const cGH* cgh, const char* groupname)