diff options
-rw-r--r-- | Carpet/Carpet/src/carpet.cc | 326 | ||||
-rw-r--r-- | Carpet/Carpet/src/carpet.hh | 31 | ||||
-rw-r--r-- | Carpet/CarpetIOASCII/src/ioascii.cc | 36 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/bbox.cc | 34 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/bbox.hh | 15 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/bboxset.cc | 6 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/bboxset.hh | 4 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dh.cc | 18 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gdata.cc | 13 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/ggf.cc | 5 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gh.cc | 11 | ||||
-rw-r--r-- | CarpetExtra/WaveToyF77/par/wavetoyf77.par | 8 | ||||
-rw-r--r-- | CarpetExtra/WaveToyF77/par/wavetoyf77_rad.par | 4 | ||||
-rw-r--r-- | CarpetExtra/WaveToyF77/par/wavetoyf77_rad_rl2.par | 43 |
14 files changed, 322 insertions, 232 deletions
diff --git a/Carpet/Carpet/src/carpet.cc b/Carpet/Carpet/src/carpet.cc index 6224784b3..48320d2ce 100644 --- a/Carpet/Carpet/src/carpet.cc +++ b/Carpet/Carpet/src/carpet.cc @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.6 2001/03/11 10:32:30 eschnett Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.7 2001/03/12 16:54:17 eschnett Exp $ /* It is assumed that the number of components of all arrays is equal to the number of components of the grid functions, and that their @@ -32,7 +32,7 @@ #include "carpet.hh" -static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.6 2001/03/11 10:32:30 eschnett Exp $"; +static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Attic/carpet.cc,v 1.7 2001/03/12 16:54:17 eschnett Exp $"; @@ -54,8 +54,24 @@ namespace Carpet { // handle from CCTK_RegisterGHExtension int GHExtension; + // time step on base grid + CCTK_REAL base_delta_time; + + // active time level + int activetimelevel; // 0 for current, 1 for next + + // current position on the grid hierarchy + int mglevel; + int reflevel; + int component; + + // current refinement factor + int reflevelfactor; + + + // data for scalars - vector<vector<vector<void*> > > scdata;// [group][var][tl] + vector<vector<vector<void*> > > scdata;// [group][var][ti] // data for arrays vector<arrdesc> arrdata; // [group] @@ -69,14 +85,6 @@ namespace Carpet { // data for grid functions vector<gfdesc> gfdata; // [group] - // active time level - int activetimelevel; // 0 for current, 1 for next - - // current position on the grid hierarchy - int mglevel; - int reflevel; - int component; - int CarpetStartup() @@ -130,12 +138,12 @@ namespace Carpet { // grid size const int stride - = (int)floor(pow(refinement_factor, max_refinement_levels) + 0.5); + = (int)floor(pow(refinement_factor, max_refinement_levels-1) + 0.5); vect<int,dim> npoints; if (global_nsize == -1) { - npoints = vect<int,dim>(global_nx, global_ny, global_nz); + npoints = vect<int,dim>(global_nx, global_ny, global_nz); } else { - npoints = vect<int,dim>(global_nsize, global_nsize, global_nsize); + npoints = vect<int,dim>(global_nsize, global_nsize, global_nsize); } const vect<int,dim> str(stride); @@ -151,7 +159,7 @@ namespace Carpet { // allocate time hierarchy tt = new th<dim> - (*hh, (int)floor(pow(refinement_factor, max_refinement_levels) + 0.5)); + (*hh, (int)floor(pow(refinement_factor, max_refinement_levels-1) + 0.5)); // allocate data hierarchy dd = new dh<dim>(*hh, lghosts, ughosts); @@ -171,8 +179,8 @@ namespace Carpet { for (int var=0; var<(int)scdata[group].size(); ++var) { const int n = (CCTK_FirstVarIndexI(group) + var); scdata[group][var].resize(CCTK_NumTimeLevelsFromVarI(n)); - for (int tl=0; tl<(int)scdata[group][var].size(); ++tl) { - scdata[group][var][tl] = 0; + for (int ti=0; ti<(int)scdata[group][var].size(); ++ti) { + scdata[group][var][ti] = 0; } } break; @@ -193,7 +201,7 @@ namespace Carpet { arrdata[group].tt = new th<dim> (*hh, - (int)floor(pow(refinement_factor, max_refinement_levels) + 0.5)); + (int)floor(pow(refinement_factor, max_refinement_levels-1) + 0.5)); vect<int,dim> alghosts, aughosts; for (int d=0; d<dim; ++d) { @@ -234,7 +242,7 @@ namespace Carpet { // initialise cgh cgh->cctk_convlevel = mglevel; for (int d=0; d<dim; ++d) { - cgh->cctk_levfac[d] = (int)floor(pow(hh->reffact, reflevel)+0.5); + cgh->cctk_levfac[d] = 1; } // Recompose grid hierarchy @@ -296,6 +304,14 @@ namespace Carpet { // Set up the grid CCTK_ScheduleTraverse ("CCTK_BASEGRID", cgh, CallFunction); + if (reflevel==0) { + base_delta_time = cgh->cctk_delta_time; + } else { +// assert (abs(cgh->cctk_delta_time - base_delta_time / reflevelfactor) +// < 1e-6 * base_delta_time); + // This fixes a bug in CactusBase/Time + cgh->cctk_delta_time = base_delta_time / reflevelfactor; + } // Set up the initial data CCTK_ScheduleTraverse ("CCTK_INITIAL", cgh, CallFunction); @@ -307,11 +323,16 @@ namespace Carpet { // Recurse if (reflevel < hh->reflevels()-1) { - reflevel_up (cgh); + ++reflevel; + enact_reflevel (cgh); RecursiveInitialise (cgh); - reflevel_down (cgh); + --reflevel; + enact_reflevel (cgh); } + // Restrict + Restrict (cgh); + // Poststep CCTK_ScheduleTraverse ("CCTK_POSTSTEP", cgh, CallFunction); @@ -373,17 +394,43 @@ namespace Carpet { // Recurse if (reflevel < hh->reflevels()-1) { - reflevel_up (cgh); + + const CCTK_REAL old_delta_time = cgh->cctk_delta_time; + const CCTK_REAL old_time = cgh->cctk_time; + const int oldactivetimelevel = activetimelevel; + + ++reflevel; + enact_reflevel (cgh); + activetimelevel = 0; + for (int i=0; i<hh->reffact; ++i) { RecursiveEvolve (cgh); + assert (abs(cgh->cctk_time - (old_time + (i+1) * cgh->cctk_delta_time)) + < 1e-6 * old_delta_time); } - reflevel_down (cgh); + + --reflevel; + enact_reflevel (cgh); + activetimelevel = oldactivetimelevel; + + assert (abs(cgh->cctk_delta_time - old_delta_time) + < 1e-6 * old_delta_time); + assert (abs(cgh->cctk_time - (old_time + old_delta_time)) + < 1e-6 * old_delta_time); + } else { + cgh->cctk_time += cgh->cctk_delta_time; + } - // Restrict - Restrict (cgh); + // Advance level times + tt->advance_time (reflevel, mglevel); + for (int array=0; array<(int)arrdata.size(); ++array) { + if (arrdata[array].tt) { + arrdata[array].tt->advance_time (reflevel, mglevel); + } + } // Cycle time levels CycleTimeLevels (cgh); @@ -392,6 +439,9 @@ namespace Carpet { assert (activetimelevel == 1); activetimelevel = 0; + // Restrict + Restrict (cgh); + // Poststep CCTK_ScheduleTraverse ("CCTK_POSTSTEP", cgh, CallFunction); @@ -438,9 +488,11 @@ namespace Carpet { // Recurse if (reflevel < hh->reflevels()-1) { - reflevel_up (cgh); + ++reflevel; + enact_reflevel (cgh); RecursiveShutdown (cgh); - reflevel_down (cgh); + --reflevel; + enact_reflevel (cgh); } // Terminate @@ -535,7 +587,7 @@ namespace Carpet { // set Cactus pointers to data for (int n=0; n<CCTK_NumVars(); ++n) { - for (int tl=0; tl<CCTK_NumTimeLevelsFromVarI(n); ++tl) { + for (int ti=0; ti<CCTK_NumTimeLevelsFromVarI(n); ++ti) { const int group = CCTK_GroupIndexFromVarI(n); assert (group>=0); @@ -551,14 +603,14 @@ namespace Carpet { // scalar variables can be accessed assert (group<(int)scdata.size()); assert (var<(int)scdata[group].size()); - assert (tl<(int)scdata[group][var].size()); - cgh->data[n][tl] = scdata[group][var][tl]; + assert (ti<(int)scdata[group][var].size()); + cgh->data[n][ti] = scdata[group][var][ti]; break; case CCTK_ARRAY: case CCTK_GF: // arrays and grid functions cannot be accessed - cgh->data[n][tl] = 0; + cgh->data[n][ti] = 0; break; default: @@ -568,11 +620,11 @@ namespace Carpet { } else { // group has no storage - cgh->data[n][tl] = 0; + cgh->data[n][ti] = 0; } - } // for tl + } // for ti } // for n // traverse @@ -585,15 +637,11 @@ namespace Carpet { assert (component==-1); for (component=0; component<hh->components(reflevel); ++component) { - // maybe: traverse only if the component is local to the processor - // maybe not, because arrays might have different distribution - // than grid functions - // this requires that all processors have the same number of // local components if (hh->is_local(reflevel, component)) { - // set Cactus parameters to pseudo values + // set Cactus parameters for (int d=0; d<dim; ++d) { typedef bbox<int,dim> ibbox; const ibbox ext = dd->boxes[reflevel][component][mglevel].exterior; @@ -626,20 +674,15 @@ namespace Carpet { switch (CCTK_GroupTypeFromVarI(n0)) { case CCTK_SCALAR: break; - case CCTK_ARRAY: - if (arrdata[group].hh->is_local(reflevel, component)) { - const bbox<int,dim> ext = - arrdata[group].dd-> - boxes[reflevel][component][mglevel].exterior; - for (int d=0; d<dim; ++d) { - arrdata[group].size[d] = ext.shape()[d] / ext.stride()[d]; - } - } else { - for (int d=0; d<dim; ++d) { - arrdata[group].size[d] = 0; - } + case CCTK_ARRAY: { + const bbox<int,dim> ext = + arrdata[group].dd-> + boxes[reflevel][component][mglevel].exterior; + for (int d=0; d<dim; ++d) { + arrdata[group].size[d] = ext.shape()[d] / ext.stride()[d]; } break; + } case CCTK_GF: break; default: @@ -649,12 +692,14 @@ namespace Carpet { // set Cactus pointers to data for (int n=0; n<CCTK_NumVars(); ++n) { - for (int tl=0; tl<CCTK_NumTimeLevelsFromVarI(n); ++tl) { + for (int ti=0; ti<CCTK_NumTimeLevelsFromVarI(n); ++ti) { const int group = CCTK_GroupIndexFromVarI(n); assert (group>=0); const int var = n - CCTK_FirstVarIndexI(group); assert (var>=0); + const int tmin = min(0, 2 - CCTK_NumTimeLevelsFromVarI(n)); + const int tl = tmin + ti; if (CCTK_QueryGroupStorageI(cgh, group)) { // group has storage @@ -664,39 +709,41 @@ namespace Carpet { case CCTK_SCALAR: assert (group<(int)scdata.size()); assert (var<(int)scdata[group].size()); - assert (tl<(int)scdata[group][var].size()); - cgh->data[n][tl] = scdata[group][var][tl]; + assert (ti<(int)scdata[group][var].size()); + cgh->data[n][ti] = scdata[group][var][ti]; break; case CCTK_ARRAY: assert (group<(int)arrdata.size()); assert (var<(int)arrdata[group].data.size()); - cgh->data[n][tl] = - ((*arrdata[group].data[var])(tl,reflevel,component,mglevel) - ->storage()); + cgh->data[n][ti] + = ((*arrdata[group].data[var]) + (tl, reflevel, component, mglevel) + ->storage()); break; case CCTK_GF: assert (group<(int)gfdata.size()); assert (var<(int)gfdata[group].data.size()); - cgh->data[n][tl] = - ((*gfdata[group].data[var])(tl,reflevel,component,mglevel) - ->storage()); + cgh->data[n][ti] + = ((*gfdata[group].data[var]) + (tl, reflevel, component, mglevel) + ->storage()); break; default: abort(); } - assert (cgh->data[n][tl]); + assert (cgh->data[n][ti]); } else { // group has no storage - cgh->data[n][tl] = 0; + cgh->data[n][ti] = 0; } // if ! has storage - } // for tl + } // for ti } // for n const int res = CCTK_CallFunction (function, attribute, data); @@ -713,40 +760,6 @@ namespace Carpet { // return 0: let the flesh do the synchronisation, if necessary return 0; - -#if 0 - // synchronise, because our bbox information was wrong - for (int group=0; group<CCTK_NumGroups(); ++group) { - SyncGroup (cgh, CCTK_GroupName(group)); - } - - // return 1: we did synchronise - return 1; -#endif - } - - - - void reflevel_up (cGH* cgh) - { - // Check - assert (reflevel < hh->reflevels()-1); - assert (mglevel == 0); - - // Change - cgh->cctk_delta_time /= hh->reffact; - ++reflevel; - } - - void reflevel_down (cGH* cgh) - { - // Check - assert (reflevel > 0); - assert (mglevel == 0); - - // Change - cgh->cctk_delta_time *= hh->reffact; - --reflevel; } @@ -767,9 +780,7 @@ namespace Carpet { return -1; } - const int n0 = CCTK_FirstVarIndexI(group); - const int tl = max(0, (CCTK_NumTimeLevelsFromVarI(n0) - + activetimelevel - 2)); + const int tl = activetimelevel; switch (CCTK_GroupTypeI(group)) { @@ -826,6 +837,17 @@ namespace Carpet { // previously. const int retval = CCTK_QueryGroupStorageI (cgh, group); + // There is a difference between the Cactus time levels and the + // Carpet time levels. If there are n time levels, then the + // Cactus time levels are numbered 0 ... n-1, with the current + // time level being max(0,n-2). In Carpet, the time levels are + // numbered 1-max(1,n-1) ... min(1,n-1), where the current time + // level is always 0. + const int n0 = CCTK_FirstVarIndexI(group); + const int num_tl = CCTK_NumTimeLevelsFromVarI(n0); + const int tmin = min(0, 2 - num_tl); + const int tmax = tmin + num_tl - 1; + switch (CCTK_GroupTypeI(group)) { case CCTK_SCALAR: @@ -835,12 +857,12 @@ namespace Carpet { break; } for (int var=0; var<(int)scdata[group].size(); ++var) { - const int n = CCTK_FirstVarIndexI(group) + var; - for (int tl=0; tl<(int)scdata[group][tl].size(); ++tl) { + for (int ti=0; ti<(int)scdata[group][var].size(); ++ti) { + const int n = n0 + var; switch (CCTK_VarTypeI(n)) { #define TYPECASE(N,T) \ case N: \ - scdata[group][var][tl] = new T; \ + scdata[group][var][ti] = new T; \ break; #include "typecase" #undef TYPECASE @@ -858,13 +880,13 @@ namespace Carpet { break; } for (int var=0; var<(int)arrdata[group].data.size(); ++var) { - const int n = CCTK_FirstVarIndexI(group) + var; + const int n = n0 + var; switch (CCTK_VarTypeI(n)) { #define TYPECASE(N,T) \ case N: \ arrdata[group].data[var] = new gf<T,dim> \ (CCTK_VarName(n), *arrdata[group].tt, *arrdata[group].dd, \ - 0, CCTK_NumTimeLevelsFromVarI(n)-1); \ + tmin, tmax); \ break; #include "typecase" #undef TYPECASE @@ -881,13 +903,12 @@ namespace Carpet { break; } for (int var=0; var<(int)gfdata[group].data.size(); ++var) { - const int n = CCTK_FirstVarIndexI(group) + var; + const int n = n0 + var; switch (CCTK_VarTypeI(n)) { #define TYPECASE(N,T) \ case N: \ gfdata[group].data[var] = new gf<T,dim> \ - (CCTK_VarName(n), *tt, *dd, \ - 0, CCTK_NumTimeLevelsFromVarI(n)-1); \ + (CCTK_VarName(n), *tt, *dd, tmin, tmax); \ break; #include "typecase" #undef TYPECASE @@ -925,18 +946,18 @@ namespace Carpet { } for (int var=0; var<(int)scdata[group].size(); ++var) { const int n = CCTK_FirstVarIndexI(group) + var; - for (int tl=0; tl<(int)scdata[group][tl].size(); ++tl) { + for (int ti=0; ti<(int)scdata[group][var].size(); ++ti) { switch (CCTK_VarTypeI(n)) { #define TYPECASE(N,T) \ case N: \ - delete (T*)scdata[group][var][tl]; \ + delete (T*)scdata[group][var][ti]; \ break; #include "typecase" #undef TYPECASE default: abort(); } - scdata[group][var][tl] = 0; + scdata[group][var][ti] = 0; } } break; @@ -1077,8 +1098,8 @@ namespace Carpet { assert (group<(int)scdata.size()); assert (var<(int)scdata[group].size()); const int sz = CCTK_VarTypeSize(CCTK_VarTypeI(n)); - for (int tl=0; tl<CCTK_NumTimeLevelsFromVarI(n)-1; ++tl) { - memcpy (scdata[group][var][tl], scdata[group][var][tl+1], sz); + for (int ti=0; ti<CCTK_NumTimeLevelsFromVarI(n)-1; ++ti) { + memcpy (scdata[group][var][ti], scdata[group][var][ti+1], sz); } break; } @@ -1086,7 +1107,9 @@ namespace Carpet { assert (group<(int)arrdata.size()); assert (var<(int)arrdata[group].data.size()); for (int c=0; c<arrdata[group].hh->components(reflevel); ++c) { - for (int tl=0; tl<CCTK_NumTimeLevelsFromVarI(n)-1; ++tl) { + for (int ti=0; ti<CCTK_NumTimeLevelsFromVarI(n)-1; ++ti) { + const int tmin = min(0, 2 - CCTK_NumTimeLevelsFromVarI(n)); + const int tl = tmin + ti; arrdata[group].data[var]->copy(tl, reflevel, c, mglevel); } } @@ -1096,7 +1119,9 @@ namespace Carpet { assert (group<(int)gfdata.size()); assert (var<(int)gfdata[group].data.size()); for (int c=0; c<hh->components(reflevel); ++c) { - for (int tl=0; tl<CCTK_NumTimeLevelsFromVarI(n)-1; ++tl) { + for (int ti=0; ti<CCTK_NumTimeLevelsFromVarI(n)-1; ++ti) { + const int tmin = min(0, 2 - CCTK_NumTimeLevelsFromVarI(n)); + const int tl = tmin + ti; gfdata[group].data[var]->copy(tl, reflevel, c, mglevel); } } @@ -1120,38 +1145,40 @@ namespace Carpet { if (reflevel == hh->reflevels()-1) return; - for (component=0; component<hh->components(reflevel); ++component) { - for (int group=0; group<CCTK_NumGroups(); ++group) { + for (int group=0; group<CCTK_NumGroups(); ++group) { + + const int tl = activetimelevel; + + switch (CCTK_GroupTypeI(group)) { - const int n0 = CCTK_FirstVarIndexI(group); - const int tl = max(0, (CCTK_NumTimeLevelsFromVarI(n0) - + activetimelevel - 2)); + case CCTK_SCALAR: + break; - switch (CCTK_GroupTypeI(group)) { - - case CCTK_SCALAR: - break; - - case CCTK_ARRAY: - for (int var=0; var<(int)arrdata[group].data.size(); ++var) { + case CCTK_ARRAY: + for (int var=0; var<(int)arrdata[group].data.size(); ++var) { + for (int c=0; c<hh->components(reflevel); ++c) { arrdata[group].data[var]->ref_restrict - (tl, reflevel, component, mglevel); + (tl, reflevel, c, mglevel); } - break; - - case CCTK_GF: - for (int var=0; var<(int)gfdata[group].data.size(); ++var) { + } + break; + + case CCTK_GF: + for (int var=0; var<(int)gfdata[group].data.size(); ++var) { + for (int c=0; c<hh->components(reflevel); ++c) { gfdata[group].data[var]->ref_restrict - (tl, reflevel, component, mglevel); + (tl, reflevel, c, mglevel); } - break; - - default: - abort(); } + break; + + default: + abort(); } - } - component = -1; + + SyncGroup (cgh, CCTK_GroupName(group)); + + } // loop over groups } @@ -1261,9 +1288,9 @@ namespace Carpet { case CCTK_SCALAR: { assert (group<(int)scdata.size()); assert (var<(int)scdata[group].size()); - const int tl=0; - assert (tl<(int)scdata[group][var].size()); - return scdata[group][var][tl] != 0; + const int ti=0; + assert (ti<(int)scdata[group][var].size()); + return scdata[group][var][ti] != 0; } case CCTK_ARRAY: { @@ -1303,6 +1330,23 @@ namespace Carpet { + void enact_reflevel (cGH* cgh) + { + // Check + assert (reflevel>=0 && reflevel<hh->reflevels()); + assert (mglevel == 0); + assert (component == -1); + + // Change + reflevelfactor = (int)floor(pow(hh->reffact, reflevel)+0.5); + cgh->cctk_delta_time = base_delta_time / reflevelfactor; + for (int d=0; d<dim; ++d) { + cgh->cctk_levfac[d] = reflevelfactor; + } + } + + + MPI_Comm CarpetMPICommunicator () { return dist::comm; diff --git a/Carpet/Carpet/src/carpet.hh b/Carpet/Carpet/src/carpet.hh index a3cadb4c5..df114d39f 100644 --- a/Carpet/Carpet/src/carpet.hh +++ b/Carpet/Carpet/src/carpet.hh @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet.hh,v 1.3 2001/03/10 20:55:03 eschnett Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet.hh,v 1.4 2001/03/12 16:54:18 eschnett Exp $ #include <vector> @@ -21,6 +21,22 @@ namespace Carpet { // handle from CCTK_RegisterGHExtension extern int GHExtension; + // time step on base grid + extern CCTK_REAL base_delta_time; + + // active time level + extern int activetimelevel; // 0 for current, 1 for next + + // current position on the grid hierarchy + extern int mglevel; + extern int reflevel; + extern int component; + + // current refinement factor + extern int reflevelfactor; + + + // data for scalars extern vector<vector<vector<void*> > > scdata;// [group][var][tl] @@ -47,14 +63,6 @@ namespace Carpet { }; extern vector<gfdesc> gfdata; // [group] - // active time level - extern int activetimelevel; // 0 for current, 1 for next - - // current position on the grid hierarchy - extern int mglevel; - extern int reflevel; - extern int component; - // scheduled functions @@ -70,9 +78,6 @@ namespace Carpet { int Shutdown (tFleshConfig *config); int CallFunction (void *function, cFunctionData *attribute, void *data); - void reflevel_up (cGH* cgh); - void reflevel_down (cGH* cgh); - int SyncGroup (cGH *cgh, const char *groupname); int EnableGroupStorage (cGH *cgh, const char *groupname); int DisableGroupStorage (cGH *cgh, const char *groupname); @@ -90,6 +95,8 @@ namespace Carpet { // Helper functions + void enact_reflevel (cGH *cgh); + extern "C" { MPI_Comm CarpetMPICommunicator(); } diff --git a/Carpet/CarpetIOASCII/src/ioascii.cc b/Carpet/CarpetIOASCII/src/ioascii.cc index 91dfb4161..b3fcd8dbe 100644 --- a/Carpet/CarpetIOASCII/src/ioascii.cc +++ b/Carpet/CarpetIOASCII/src/ioascii.cc @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.3 2001/03/05 21:48:33 eschnett Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.4 2001/03/12 16:54:25 eschnett Exp $ #include <cassert> #include <cstdio> @@ -111,7 +111,7 @@ int IOASCII<outdim>::OutputVarAs (cGH* const cgh, const char* const varname, assert (n0>=0 && n0<CCTK_NumVars()); const int var = n - n0; assert (var>=0 && var<CCTK_NumVars()); - const int tl = max(0, CCTK_NumTimeLevelsFromVarI(n) - 2); + const int tl = 0; switch (CCTK_GroupTypeI(group)) { @@ -293,6 +293,8 @@ int IOASCII<outdim>::OutputVarAs (cGH* const cgh, const char* const varname, assert (mglevel>=0); assert (reflevel==0); for (reflevel=0; reflevel<hh->reflevels(); ++reflevel) { + enact_reflevel (cgh); + assert (component==-1); for (component=0; component<hh->components(reflevel); ++component) { @@ -317,15 +319,36 @@ int IOASCII<outdim>::OutputVarAs (cGH* const cgh, const char* const varname, const generic_data<dim>* const data = (*ff) (tl, reflevel, component, mglevel); - const vect<int,dim> offset1 = offset * data->extent().stride(); + const vect<int,dim> offset1 = (offset * data->extent().stride() + * vect<int,dim>(reflevelfactor)); data->write_ascii (filename, cgh->cctk_iteration, offset1, dirs, tl, reflevel, component, mglevel); - } + } // Loop over components component = -1; - } + + // Append EOL after every complete set of components + if (CCTK_MyProc(cgh)==0) { + ofstream file(filename, ios::app); + assert (file.good()); + file << endl; + file.close(); + assert (file.good()); + } + + } // Loop over refinement levels reflevel = 0; + enact_reflevel (cgh); + + // Append EOL after every complete set of refinement levels + if (CCTK_MyProc(cgh)==0) { + ofstream file(filename, ios::app); + assert (file.good()); + file << endl; + file.close(); + assert (file.good()); + } } // if (desired) @@ -484,7 +507,8 @@ int IOASCII<outdim>::CoordToOffset (cGH* cgh, int dir, double coord) const int npoints = cgh->cctk_gsh[dir-1]; - int cindex = (int)floor((coord - lower) / (upper - lower) * npoints + 0.75); + const CCTK_REAL rindex = (coord - lower) / (upper - lower) * npoints; + const int cindex = (int)floor(rindex + 0.5 + 1e-6); assert (cindex>=0 && cindex<npoints); return cindex; diff --git a/Carpet/CarpetLib/src/bbox.cc b/Carpet/CarpetLib/src/bbox.cc index 7ae17fe5d..de281f582 100644 --- a/Carpet/CarpetLib/src/bbox.cc +++ b/Carpet/CarpetLib/src/bbox.cc @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.3 2001/03/07 13:00:57 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.4 2001/03/12 16:54:25 eschnett Exp $ ***************************************************************************/ @@ -133,14 +133,14 @@ bbox<T,D> bbox<T,D>::operator& (const bbox& b) const { // Containment template<class T, int D> -bool bbox<T,D>::contained_in (const bbox& b) const { +bool bbox<T,D>::is_contained_in (const bbox& b) const { // no alignment check return all(lower()>=b.lower() && upper()<=b.upper()); } // Alignment check template<class T, int D> -bool bbox<T,D>::aligned_with (const bbox& b) const { +bool bbox<T,D>::is_aligned_with (const bbox& b) const { return all(stride()==b.stride() && (lower()-b.lower()) % stride() == 0); } @@ -175,42 +175,18 @@ bbox<T,D> bbox<T,D>::contracted_for (const bbox& b) const { return bbox(lo,up,str); } -// Set operations // Smallest bbox containing both boxes template<class T, int D> -bbox<T,D> bbox<T,D>::operator* (const bbox& b) const { +bbox<T,D> bbox<T,D>::expanded_containing (const bbox& b) const { if (empty()) return b; if (b.empty()) return *this; - assert (aligned_with(b)); + assert (is_aligned_with(b)); const vect<T,D> lo = min(lower(), b.lower()); const vect<T,D> up = max(upper(), b.upper()); const vect<T,D> str = min(stride(), b.stride()); return bbox(lo,up,str); } -template<class T, int D> -bbox<T,D>& bbox<T,D>::operator*= (const bbox& b) { - *this = *this * b; - return *this; -} - -// Largest bbox inside both boxes -template<class T, int D> -bbox<T,D> bbox<T,D>::operator+ (const bbox& b) const { - if (empty() || b.empty()) return bbox(); - assert (aligned_with(b)); - const vect<T,D> lo = max(lower(), b.lower()); - const vect<T,D> up = min(upper(), b.upper()); - const vect<T,D> str = min(stride(), b.stride()); - return bbox(lo,up,str); -} - -template<class T, int D> -bbox<T,D>& bbox<T,D>::operator+= (const bbox& b) { - *this = *this + b; - return *this; -} - // Iterators template<class T, int D> bbox<T,D>::iterator::iterator (const bbox& box, const vect<T,D>& pos) diff --git a/Carpet/CarpetLib/src/bbox.hh b/Carpet/CarpetLib/src/bbox.hh index 95afb992e..14aeb7895 100644 --- a/Carpet/CarpetLib/src/bbox.hh +++ b/Carpet/CarpetLib/src/bbox.hh @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.hh,v 1.4 2001/03/10 20:55:06 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.hh,v 1.5 2001/03/12 16:54:25 eschnett Exp $ ***************************************************************************/ @@ -81,10 +81,10 @@ public: bbox operator& (const bbox& b) const; // Containment - bool contained_in (const bbox& b) const; + bool is_contained_in (const bbox& b) const; // Alignment check - bool aligned_with (const bbox& b) const; + bool is_aligned_with (const bbox& b) const; // Expand the bbox a little by multiples of the stride bbox expand (const vect<T,D>& lo, const vect<T,D>& hi) const; @@ -95,15 +95,8 @@ public: // Find the largest b-compatible box inside *this bbox contracted_for (const bbox& b) const; - // Set operations - // TODO: rename these; they clash with the bboxset operations - // (and name them & and | instead) // Smallest bbox containing both boxes - bbox operator* (const bbox& b) const; - bbox& operator*= (const bbox& b); - // Largest bbox inside both boxes - bbox operator+ (const bbox& b) const; - bbox& operator+= (const bbox& b); + bbox expanded_containing (const bbox<T,D>& b) const; // Iterators class iterator { diff --git a/Carpet/CarpetLib/src/bboxset.cc b/Carpet/CarpetLib/src/bboxset.cc index b76dc67b6..0e3a08e3d 100644 --- a/Carpet/CarpetLib/src/bboxset.cc +++ b/Carpet/CarpetLib/src/bboxset.cc @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bboxset.cc,v 1.2 2001/03/10 20:55:06 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bboxset.cc,v 1.3 2001/03/12 16:54:25 eschnett Exp $ ***************************************************************************/ @@ -59,7 +59,7 @@ template<class T, int D> bool bboxset<T,D>::invariant () const { for (const_iterator bi=begin(); bi!=end(); ++bi) { if ((*bi).empty()) return false; - if (! (*bi).aligned_with(*bs.begin())) return false; + if (! (*bi).is_aligned_with(*bs.begin())) return false; // check for overlap (quadratic -- expensive) int cnt=0; for (const_iterator bi2=bi; bi2!=end(); ++bi2) { @@ -212,7 +212,7 @@ bboxset<T,D>& bboxset<T,D>::operator&= (const bboxset& s) { // Difference template<class T, int D> bboxset<T,D> operator- (const bbox<T,D>& b1, const bbox<T,D>& b2) { - assert (b1.aligned_with(b2)); + assert (b1.is_aligned_with(b2)); if (b1.empty()) return bboxset<T,D>(); if (b2.empty()) return bboxset<T,D>(b1); const vect<T,D> str = b1.stride(); diff --git a/Carpet/CarpetLib/src/bboxset.hh b/Carpet/CarpetLib/src/bboxset.hh index 98aa3fb65..dae3d3f3f 100644 --- a/Carpet/CarpetLib/src/bboxset.hh +++ b/Carpet/CarpetLib/src/bboxset.hh @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bboxset.hh,v 1.2 2001/03/10 20:55:06 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bboxset.hh,v 1.3 2001/03/12 16:54:25 eschnett Exp $ ***************************************************************************/ @@ -34,8 +34,6 @@ // Forward definition template<class T, int D> class bboxset; -// TODO: add more functions for the other operators -// (but cf. bbox<T,D> first!) template<class T,int D> bboxset<T,D> operator- (const bbox<T,D>& b1, const bbox<T,D>& b2); template<class T,int D> diff --git a/Carpet/CarpetLib/src/dh.cc b/Carpet/CarpetLib/src/dh.cc index 756f37cad..73937df81 100644 --- a/Carpet/CarpetLib/src/dh.cc +++ b/Carpet/CarpetLib/src/dh.cc @@ -6,7 +6,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/dh.cc,v 1.4 2001/03/10 20:55:06 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/dh.cc,v 1.5 2001/03/12 16:54:25 eschnett Exp $ ***************************************************************************/ @@ -142,7 +142,7 @@ void dh<D>::recompose () { // coarse grid, and may use the exterior of the fine grid) const ibbox recv = intr; const ibbox send = recv.expanded_for(extrf); - assert (send.contained_in(extrf)); + assert (send.is_contained_in(extrf)); boxes[rl][c][ml-1].send_mg_coarse.push_back(send); boxes[rl][c][ml ].recv_mg_fine .push_back(recv); } @@ -180,7 +180,7 @@ void dh<D>::recompose () { // grid) const ibbox recv = extr.contracted_for(intrf) & intrf; const ibbox send = recv.expanded_for(extr); - assert (send.contained_in(extr)); + assert (send.is_contained_in(extr)); boxes[rl+1][cc][ml].recv_ref_coarse[c ].push_back(recv); boxes[rl ][c ][ml].send_ref_fine [cc].push_back(send); } @@ -196,7 +196,7 @@ void dh<D>::recompose () { // the fine grid) const ibbox recv = extr.contracted_for(bndf) & bndf; const ibbox send = recv.expanded_for(extr); - assert (send.contained_in(extr)); + assert (send.is_contained_in(extr)); boxes[rl+1][cc][ml].recv_ref_bnd_coarse[c ].push_back(recv); boxes[rl ][c ][ml].send_ref_bnd_fine [cc].push_back(send); } @@ -244,8 +244,12 @@ void dh<D>::recompose () { bases[rl][ml].exterior = ibbox(); bases[rl][ml].interior = ibbox(); for (int c=0; c<h.components(rl); ++c) { - bases[rl][ml].exterior *= boxes[rl][c][ml].exterior; - bases[rl][ml].interior *= boxes[rl][c][ml].interior; + bases[rl][ml].exterior + = (bases[rl][ml].exterior + .expanded_containing(boxes[rl][c][ml].exterior)); + bases[rl][ml].interior + = (bases[rl][ml].interior + .expanded_containing(boxes[rl][c][ml].interior)); } bases[rl][ml].boundaries = bases[rl][ml].exterior - bases[rl][ml].interior; @@ -281,7 +285,7 @@ void dh<D>::recompose () { } for (int rl=0; rl<h.reflevels(); ++rl) { if (h.components(rl)>0) { - for (int ml=0; ml<h.mglevels(rl,c); ++ml) { + for (int ml=0; ml<h.mglevels(rl,0); ++ml) { cout << endl; cout << "dh bases:" << endl; cout << "rl=" << rl << " ml=" << ml << endl; diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc index 288eb9aa6..fa852b881 100644 --- a/Carpet/CarpetLib/src/gdata.cc +++ b/Carpet/CarpetLib/src/gdata.cc @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.5 2001/03/10 20:55:06 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.6 2001/03/12 16:54:25 eschnett Exp $ ***************************************************************************/ @@ -70,12 +70,11 @@ void generic_data<D>::write_ascii (const string name, const int time, file << setprecision(15); - file << "#" << endl - << "# iteration " << time << endl + file << "# iteration " << time << endl << "# time level " << tl << " refinement level " << rl << " component " << c << " multigrid level " << ml << endl << "# column format: it tl rl c ml"; - assert (D<=3); + assert (D>=1 && D<=3); for (int d=0; d<D; ++d) file << " " << "xyz"[d]; file << " data" << endl; @@ -104,7 +103,11 @@ void generic_data<D>::write_ascii (const string name, const int time, } } - } // if ext contains org + } else { + + file << "#" << endl; + + } // if ! ext contains org file.close(); assert (file.good()); diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc index c7fb2bd7d..b8948dc3f 100644 --- a/Carpet/CarpetLib/src/ggf.cc +++ b/Carpet/CarpetLib/src/ggf.cc @@ -6,7 +6,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.cc,v 1.2 2001/03/05 21:48:38 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/ggf.cc,v 1.3 2001/03/12 16:54:25 eschnett Exp $ ***************************************************************************/ @@ -359,10 +359,8 @@ void generic_gf<D>::ref_bnd_prolongate (int tl, int rl, int c, int ml) { double time = (t.time(tl,rl,ml) - t.get_time(rl-1,ml)) / (double)t.get_delta(rl-1, ml); const int tl2 = (int)floor(time); - cout << "### ref_bnd_prolongate tl=" << tl << " rl=" << rl << " c=" << c << " ml=" << ml << " time=" << time << " tl2=" << tl2 << endl; assert (tl2>=tmin && tl2<=tmax); if (time==tl2) { - cout << "### (copycat)" << endl; copycat (tl ,rl ,c,ml, &dh<D>::dboxes::recv_ref_bnd_coarse, tl2,rl-1, ml, &dh<D>::dboxes::send_ref_bnd_fine); } else { @@ -370,7 +368,6 @@ void generic_gf<D>::ref_bnd_prolongate (int tl, int rl, int c, int ml) { assert (tl3>=tmin && tl3<=tmax); const double fact2 = 1 - (time - tl2); const double fact3 = 1 - fact2; - cout << "### (intercat) tl3=" << tl3 << " fact2=" << fact2 << " fact3=" << fact3 << endl; intercat (tl,rl,c,ml, &dh<D>::dboxes::recv_ref_bnd_coarse, tl2,fact2, tl3,fact3, rl-1,ml, &dh<D>::dboxes::send_ref_bnd_fine); diff --git a/Carpet/CarpetLib/src/gh.cc b/Carpet/CarpetLib/src/gh.cc index 13a674931..0239111df 100644 --- a/Carpet/CarpetLib/src/gh.cc +++ b/Carpet/CarpetLib/src/gh.cc @@ -7,7 +7,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.cc,v 1.2 2001/03/07 13:00:57 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.cc,v 1.3 2001/03/12 16:54:25 eschnett Exp $ ***************************************************************************/ @@ -80,7 +80,7 @@ void gh<D>::recompose (const rexts& exts, const rprocs& procs) { == ivect(mgfact) * extents[rl][c][ml-1].stride())); assert (extents[rl][c][ml] .contracted_for(extents[rl][c][ml-1]) - .contained_in(extents[rl][c][ml-1])); + .is_contained_in(extents[rl][c][ml-1])); } } } @@ -92,7 +92,7 @@ void gh<D>::recompose (const rexts& exts, const rprocs& procs) { for (int ml=0; ml<mglevels(rl,c); ++ml) { assert (all(extents[rl][c][ml].stride() == extents[rl][0][ml].stride())); - assert (extents[rl][c][ml].aligned_with(extents[rl][0][ml])); + assert (extents[rl][c][ml].is_aligned_with(extents[rl][0][ml])); } } } @@ -100,7 +100,7 @@ void gh<D>::recompose (const rexts& exts, const rprocs& procs) { // Check base grid extent if (reflevels()>0) { for (int c=0; c<components(0); ++c) { - assert (extents[0][c][0].contained_in(baseextent)); + assert (extents[0][c][0].is_contained_in(baseextent)); } } @@ -134,7 +134,8 @@ void gh<D>::recompose (const rexts& exts, const rprocs& procs) { for (int ml=0; ml<mglevels(rl,0); ++ml) { bases[rl][ml] = ibbox(); for (int c=0; c<components(rl); ++c) { - bases[rl][ml] *= extents[rl][c][ml]; + bases[rl][ml] + = bases[rl][ml].expanded_containing(extents[rl][c][ml]); } } } diff --git a/CarpetExtra/WaveToyF77/par/wavetoyf77.par b/CarpetExtra/WaveToyF77/par/wavetoyf77.par index b2e616756..5c446c63e 100644 --- a/CarpetExtra/WaveToyF77/par/wavetoyf77.par +++ b/CarpetExtra/WaveToyF77/par/wavetoyf77.par @@ -7,10 +7,12 @@ # @enddesc # @@*/ # -# $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/WaveToyF77/par/wavetoyf77.par,v 1.4 2001/03/07 13:02:00 eschnett Exp $ +# $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/WaveToyF77/par/wavetoyf77.par,v 1.5 2001/03/12 16:54:25 eschnett Exp $ ActiveThorns = "Boundary IOBasic IOUtil Time Cart3d Carpet CarpetIOASCII CarpetLib IDScalarWave WaveToyF77" +Carpet::verbose = no + Time::dtfac = 0.5 Carpet::global_nx = 21 @@ -35,6 +37,4 @@ IOBasic::outInfo_every = 1 #IOBasic::outScalar_style = gnuplot IOASCII::out1D_every = 1 -IOASCII::out1D_vars = "wavetoy::phi" - -Carpet::verbose = no +IOASCII::out1D_vars = "wavetoy::phi grid::coordinates" diff --git a/CarpetExtra/WaveToyF77/par/wavetoyf77_rad.par b/CarpetExtra/WaveToyF77/par/wavetoyf77_rad.par index 4a208e11e..9062b47ee 100644 --- a/CarpetExtra/WaveToyF77/par/wavetoyf77_rad.par +++ b/CarpetExtra/WaveToyF77/par/wavetoyf77_rad.par @@ -7,7 +7,7 @@ # @enddesc # @@*/ # -# $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/WaveToyF77/par/wavetoyf77_rad.par,v 1.2 2001/03/07 13:02:01 eschnett Exp $ +# $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/WaveToyF77/par/wavetoyf77_rad.par,v 1.3 2001/03/12 16:54:25 eschnett Exp $ ActiveThorns = "Boundary IOBasic IOUtil Time Cart3d Carpet CarpetIOASCII CarpetLib CarpetSlab IDScalarWave WaveToyF77" @@ -32,7 +32,7 @@ IOBasic::outinfo_every = 10 #IOBasic::outScalar_vars = "wavetoy::phi" IOASCII::out1D_every = 2 -IOASCII::out1D_vars = "wavetoy::phi " +IOASCII::out1D_vars = "wavetoy::phi grid::coordinates" WaveToyF77::bound = radiation diff --git a/CarpetExtra/WaveToyF77/par/wavetoyf77_rad_rl2.par b/CarpetExtra/WaveToyF77/par/wavetoyf77_rad_rl2.par new file mode 100644 index 000000000..2198a8451 --- /dev/null +++ b/CarpetExtra/WaveToyF77/par/wavetoyf77_rad_rl2.par @@ -0,0 +1,43 @@ +# /*@@ +# @file wavetoyf77_rad_rl2.par +# @date 2001-03-11 +# @author Erik Schnetter +# @desc +# Wavetoy parameter file demonstrating radiation boundaries in octant mode +# @enddesc +# @@*/ +# +# $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/WaveToyF77/par/Attic/wavetoyf77_rad_rl2.par,v 1.1 2001/03/12 16:54:25 eschnett Exp $ + +ActiveThorns = "Boundary IOBasic IOUtil Time Cart3d Carpet CarpetIOASCII CarpetLib CarpetSlab IDScalarWave WaveToyF77" + +Cactus::cctk_itlast = 120 + +Time::dtfac = 0.5 + +Carpet::global_nx = 30 +Carpet::global_ny = 30 +Carpet::global_nz = 30 + +Carpet::max_refinement_levels = 2 + +grid::type = byspacing +grid::mode = octant +grid::dxyz = 0.3 + +IO::outdir = "wavetoyf77_rad_rl2" + +IOBasic::outinfo_every = 10 +#IOBasic::outinfo_vars = "wavetoy::phi" + +#IOBasic::outScalar_every = 2 +#IOBasic::outScalar_vars = "wavetoy::phi" + +IOASCII::out1D_every = 2 +IOASCII::out1D_vars = "wavetoy::phi grid::coordinates" + +WaveToyF77::bound = radiation + +IDScalarWave::initial_data = gaussian +IDScalarWave::sigma = 2.8 +IDScalarWave::radius = 0 |