aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet/src/Cycle.cc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2010-03-18 15:10:52 -0700
committerBarry Wardell <barry.wardell@gmail.com>2011-12-14 16:45:33 +0000
commit0707cfeb82f565afec604f39202dafcbef889db0 (patch)
tree820f1ac0bc04d5f9827e4e00bf1efccb6d76727e /Carpet/Carpet/src/Cycle.cc
parent6b2d5314e79a5547f2fdd1dc4898bdeef74da9f2 (diff)
Re-organise time level handling
Store the current Cactus time (and not a fake Carpet time) in the th "time hiearchy". This removes the now redundant "leveltimes" data structure in Carpet. Add past time levels to th, so that it can store the time for past time levels instead of assuming the time step size is constant. This allows changing the time step size during evolution. Share the time hierarchy between all maps, instead of having one time hierarchy per map. Simplify the time level cycling and time stepping code used during evolution. Improve structure of the code that loops over time levels for certain schedule bins. Introduce a new Carpet variable "timelevel", similar to "reflevel". This also makes it possible to avoid time interpolation for the past time levels during regridding. The past time levels of the fine grid then remain aligned (in time) with the past time levels of the coarse grid. This is controlled by a new parameter "time_interpolation_during_regridding", which defaults to "yes" for backwards compatibility. Simplify the three time level initialisation. Instead of initialising all three time levels by taking altogether three time steps (forwards and backwards), initialise only one past time level by taking one time step backwards. The remaining time level is initialised during the first time step of the evolution, which begins by cycling time levels, which drops the non-initialised last time level anyway. Update Carpet and the mode handling correspondingly. Update the CarpetIOHDF5 checkpoint format correspondingly. Update CarpetInterp, CarpetReduce, and CarpetRegrid2 correspondingly. Update CarpetJacobi and CarpetMG correspondingly.
Diffstat (limited to 'Carpet/Carpet/src/Cycle.cc')
-rw-r--r--Carpet/Carpet/src/Cycle.cc98
1 files changed, 88 insertions, 10 deletions
diff --git a/Carpet/Carpet/src/Cycle.cc b/Carpet/Carpet/src/Cycle.cc
index acf4d19db..582a966e5 100644
--- a/Carpet/Carpet/src/Cycle.cc
+++ b/Carpet/Carpet/src/Cycle.cc
@@ -17,17 +17,21 @@ namespace Carpet {
- void CycleTimeLevels (const cGH* cgh)
+ void CycleTimeLevels (cGH* const cctkGH)
{
DECLARE_CCTK_PARAMETERS;
Checkpoint ("CycleTimeLevels");
assert (is_level_mode());
+ assert (timelevel == 0);
+ tt->advance_time (mglevel, reflevel);
+ cctkGH->cctk_time = tt->get_time (mglevel, reflevel, timelevel);
+
for (int group=0; group<CCTK_NumGroups(); ++group) {
- if (CCTK_QueryGroupStorageI(cgh, group)) {
+ if (CCTK_QueryGroupStorageI(cctkGH, group)) {
- int const activetimelevels = CCTK_ActiveTimeLevelsGI (cgh, group);
+ int const activetimelevels = CCTK_ActiveTimeLevelsGI (cctkGH, group);
if (activetimelevels > 1) {
if (activetimelevels < prolongation_order_time+1) {
char * const groupname = CCTK_GroupName (group);
@@ -62,7 +66,7 @@ namespace Carpet {
{
int const varindex = firstvarindex + var;
for (int tl=0; tl<numtimelevels; ++tl) {
- cgh->data[varindex][tl]
+ cctkGH->data[varindex][tl]
= (tl < groupdata.AT(group).info.activetimelevels
? ((*arrdata.AT(group).AT(0).data.AT(var))
(tl, 0, 0, 0)->storage())
@@ -82,17 +86,91 @@ namespace Carpet {
- void FlipTimeLevels (const cGH* cgh)
+ void UncycleTimeLevels (cGH* const cctkGH)
+ {
+ DECLARE_CCTK_PARAMETERS;
+
+ Checkpoint ("UncycleTimeLevels");
+ assert (is_level_mode());
+
+ assert (timelevel == 0);
+ tt->retreat_time (mglevel, reflevel);
+ cctkGH->cctk_time = tt->get_time (mglevel, reflevel, timelevel);
+
+ for (int group=0; group<CCTK_NumGroups(); ++group) {
+ if (CCTK_QueryGroupStorageI(cctkGH, group)) {
+
+ int const activetimelevels = CCTK_ActiveTimeLevelsGI (cctkGH, group);
+ if (activetimelevels > 1) {
+ if (activetimelevels < prolongation_order_time+1) {
+ char * const groupname = CCTK_GroupName (group);
+ CCTK_VWarn (CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Group \"%s\" has %d only active time levels. Groups with more than one active time level need at least %d active time levels for prolongation_order_time=%d",
+ groupname,
+ activetimelevels, int(prolongation_order_time+1),
+ int(prolongation_order_time));
+ free (groupname);
+ }
+ }
+
+ switch (CCTK_GroupTypeI(group)) {
+
+ case CCTK_GF:
+ assert (reflevel>=0 and reflevel<reflevels);
+ for (int m=0; m<(int)arrdata.AT(group).size(); ++m) {
+ for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
+ arrdata.AT(group).AT(m).data.AT(var)->
+ uncycle_all (reflevel, mglevel);
+ }
+ }
+ break;
+
+ case CCTK_SCALAR:
+ case CCTK_ARRAY:
+ if (do_global_mode) {
+ int const numtimelevels = CCTK_NumTimeLevelsI (group);
+ int const firstvarindex = CCTK_FirstVarIndexI (group);
+ for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
+ arrdata.AT(group).AT(0).data.AT(var)->uncycle_all (0, mglevel);
+ {
+ int const varindex = firstvarindex + var;
+ for (int tl=0; tl<numtimelevels; ++tl) {
+ cctkGH->data[varindex][tl]
+ = (tl < groupdata.AT(group).info.activetimelevels
+ ? ((*arrdata.AT(group).AT(0).data.AT(var))
+ (tl, 0, 0, 0)->storage())
+ : NULL);
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ assert (0);
+ } // switch grouptype
+ } // if storage
+ } // for group
+ }
+
+
+
+ void FlipTimeLevels (cGH* const cctkGH)
{
DECLARE_CCTK_PARAMETERS;
Checkpoint ("FlipTimeLevels");
assert (is_level_mode());
+ assert (timelevel == 0);
+ tt->flip_timelevels (mglevel, reflevel);
+ cctkGH->cctk_time = tt->get_time (mglevel, reflevel, timelevel);
+ cctkGH->cctk_delta_time *= -1;
+
for (int group=0; group<CCTK_NumGroups(); ++group) {
- if (CCTK_QueryGroupStorageI(cgh, group)) {
+ if (CCTK_QueryGroupStorageI(cctkGH, group)) {
- int const activetimelevels = CCTK_ActiveTimeLevelsGI (cgh, group);
+ int const activetimelevels = CCTK_ActiveTimeLevelsGI (cctkGH, group);
if (activetimelevels > 1) {
if (activetimelevels < prolongation_order_time+1) {
char * const groupname = CCTK_GroupName (group);
@@ -127,7 +205,7 @@ namespace Carpet {
{
int const varindex = firstvarindex + var;
for (int tl=0; tl<numtimelevels; ++tl) {
- cgh->data[varindex][tl]
+ cctkGH->data[varindex][tl]
= (tl < groupdata.AT(group).info.activetimelevels
? ((*arrdata.AT(group).AT(0).data.AT(var))
(tl, 0, 0, 0)->storage())
@@ -147,13 +225,13 @@ namespace Carpet {
- void FillTimeLevels (const cGH* cgh)
+ void FillTimeLevels (const cGH* const cctkGH)
{
Checkpoint ("FillTimeLevels");
assert (is_level_mode());
for (int group=0; group<CCTK_NumGroups(); ++group) {
- if (CCTK_QueryGroupStorageI(cgh, group)) {
+ if (CCTK_QueryGroupStorageI(cctkGH, group)) {
switch (CCTK_GroupTypeI(group)) {
case CCTK_GF: