diff options
Diffstat (limited to 'src/GenericRK.c')
-rw-r--r-- | src/GenericRK.c | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/src/GenericRK.c b/src/GenericRK.c index 417f2e4..13bad9e 100644 --- a/src/GenericRK.c +++ b/src/GenericRK.c @@ -93,6 +93,8 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS) CCTK_REAL *RHSVar; CCTK_REAL *ScratchVar; + CCTK_INT arrayscratchlocation; + totalsize = cctk_lsh[0] * cctk_lsh[1] * cctk_lsh[2]; beta = RKBetaCoefficients[MoL_Intermediate_Steps - @@ -284,6 +286,8 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS) /* Real arrays */ + arrayscratchlocation = 0; + for (var = 0; var < MoLNumEvolvedArrayVariables; var++) { @@ -324,23 +328,23 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS) if (scratchstep) { - ScratchVar = &ScratchSpace[(var * MoL_Num_Scratch_Levels + - scratchindex) * totalsize]; + ScratchVar = &ArrayScratchSpace[scratchindex*(MoL_Max_Evolved_Array_Size+1) + + arrayscratchlocation]; #ifdef MOLDEBUG printf("Reading from scratch space, initial address %ld index %d\n", - ScratchVar, (var * MoL_Num_Scratch_Levels + - scratchindex) * totalsize); + ScratchVar, scratchindex*(MoL_Max_Evolved_Array_Size+1) + + arrayscratchlocation); #endif } else { ScratchVar = (CCTK_REAL*)CCTK_VarDataPtrI(cctkGH, 1, - EvolvedVariableIndex[var]); + EvolvedArrayVariableIndex[var]); } if ( (alpha > MoL_Tiny)||(alpha < -MoL_Tiny) ) { - for (index = 0; index < totalsize; index++) + for (index = 0; index < arraytotalsize; index++) { UpdateVar[index] += alpha * ScratchVar[index]; #ifdef MOLDEBUG @@ -351,25 +355,44 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS) } } - + + arrayscratchlocation += arraytotalsize; + } + arrayscratchlocation = 0; + if (*MoL_Intermediate_Step > 1) { - for (var = 0; var < MoLNumEvolvedVariables; var++) + for (var = 0; var < MoLNumEvolvedArrayVariables; var++) { UpdateVar = (CCTK_REAL *)CCTK_VarDataPtrI(cctkGH, 0, - EvolvedVariableIndex[var]); - ScratchVar = &ScratchSpace[(var * MoL_Num_Scratch_Levels + - MoL_Intermediate_Steps - - (*MoL_Intermediate_Step)) * totalsize]; + EvolvedArrayVariableIndex[var]); + ScratchVar = &ArrayScratchSpace[(MoL_Intermediate_Steps - + (*MoL_Intermediate_Step)) * (MoL_Max_Evolved_Array_Size+1) + + arrayscratchlocation]; + groupindex = CCTK_GroupIndexFromVarI(EvolvedArrayVariableIndex[var]); + ierr = CCTK_GroupDynamicData(cctkGH, groupindex, + &arraydata); + if (ierr) + { + CCTK_VWarn(0, __LINE__, __FILE__, "MoL", + "The driver does not return group information for group '%s'.", + CCTK_GroupName(groupindex)); + } + arraytotalsize = 1; + for (arraydim = 0; arraydim < arraydata.dim; arraydim++) + { + arraytotalsize *= arraydata.lsh[arraydim]; + } + #ifdef MOLDEBUG printf("Writing to scratch space, initial address %ld, index %d \n", - ScratchVar, (var * MoL_Num_Scratch_Levels + - MoL_Intermediate_Steps - - (*MoL_Intermediate_Step)) * totalsize); + ScratchVar, (MoL_Intermediate_Steps - + (*MoL_Intermediate_Step)) * (MoL_Max_Evolved_Array_Size+1) + + arrayscratchlocation); #endif - for (index = 0; index < totalsize; index++) + for (index = 0; index < arraytotalsize; index++) { ScratchVar[index] = UpdateVar[index]; #ifdef MOLDEBUG @@ -377,6 +400,7 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS) var, index, (*MoL_Intermediate_Step), ScratchVar[index]); #endif } + arrayscratchlocation += arraytotalsize; } } |