aboutsummaryrefslogtreecommitdiff
path: root/src/GenericRK.c
diff options
context:
space:
mode:
authorhawke <hawke@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2006-07-28 09:46:54 +0000
committerhawke <hawke@578cdeb0-5ea1-4b81-8215-5a3b8777ee0b>2006-07-28 09:46:54 +0000
commit5b12759aff89d3e5854999776b169112e8510111 (patch)
tree7f2936e183a00ae4ceab05e35b25d9416e38e3b8 /src/GenericRK.c
parentec098f5dadd15c70908dcbd07b484f04f926ebea (diff)
Fix for evolving arrays on multi-processors with the generic RK
method. This fix should use minimal memory, and works even when there is no storage for the array on the local processor. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/MoL/trunk@115 578cdeb0-5ea1-4b81-8215-5a3b8777ee0b
Diffstat (limited to 'src/GenericRK.c')
-rw-r--r--src/GenericRK.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/GenericRK.c b/src/GenericRK.c
index 60648f1..58185ca 100644
--- a/src/GenericRK.c
+++ b/src/GenericRK.c
@@ -73,7 +73,7 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS)
cGroupDynamicData arraydata;
CCTK_INT groupindex, ierr;
- CCTK_INT arraytotalsize, arraydim;
+ CCTK_INT arraytotalsize, arraydim, singlearraysize;
/* FIXME */
@@ -346,6 +346,28 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS)
arrayscratchlocation = 0;
+ arraytotalsize = MoL_Max_Evolved_Array_Size;
+ if (MoL_Num_Scratch_Levels)
+ {
+ groupindex = CCTK_GroupIndex("MOL::ARRAYSCRATCHSPACE");
+ ierr = CCTK_GroupDynamicData(cctkGH, groupindex,
+ &arraydata);
+ if (ierr)
+ {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "The driver does not return group information "
+ "for group '%s' (%d).",
+ CCTK_GroupName(groupindex), ierr);
+ }
+ arraytotalsize = 1;
+ for (arraydim = 0; arraydim < arraydata.dim; arraydim++)
+ {
+ arraytotalsize *= arraydata.lsh[arraydim];
+ }
+ }
+ singlearraysize = arraytotalsize / MoLNumEvolvedArrayVariables;
+
+
for (var = 0; var < MoLNumEvolvedArrayVariables; var++)
{
@@ -387,14 +409,19 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS)
if (scratchstep)
{
- ScratchVar = &ArrayScratchSpace[scratchindex*
- (MoL_Max_Evolved_Array_Size+1) +
+/* ScratchVar = &ArrayScratchSpace[scratchindex* */
+/* (MoL_Max_Evolved_Array_Size+1) + */
+/* arrayscratchlocation]; */
+ ScratchVar = &ArrayScratchSpace[scratchindex*singlearraysize +
arrayscratchlocation];
#ifdef MOLDEBUG
if (CCTK_EQUALS(verbose,"extreme"))
{
+/* printf("Reading from scratch space, initial address %ld index %d\n", */
+/* ScratchVar, scratchindex*(MoL_Max_Evolved_Array_Size+1) + */
+/* arrayscratchlocation); */
printf("Reading from scratch space, initial address %ld index %d\n",
- ScratchVar, scratchindex*(MoL_Max_Evolved_Array_Size+1) +
+ ScratchVar, scratchindex*singlearraysize +
arrayscratchlocation);
}
#endif
@@ -438,7 +465,8 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS)
EvolvedArrayVariableIndex[var]);
ScratchVar = &ArrayScratchSpace[(MoL_Intermediate_Steps -
(*MoL_Intermediate_Step)) *
- (MoL_Max_Evolved_Array_Size+1) +
+ singlearraysize +
+/* (MoL_Max_Evolved_Array_Size+1) + */
arrayscratchlocation];
groupindex = CCTK_GroupIndexFromVarI(EvolvedArrayVariableIndex[var]);
ierr = CCTK_GroupDynamicData(cctkGH, groupindex,
@@ -460,7 +488,8 @@ void MoL_GenericRKAdd(CCTK_ARGUMENTS)
printf("Writing to scratch space, initial address %ld, index %d \n",
ScratchVar, (MoL_Intermediate_Steps -
(*MoL_Intermediate_Step)) *
- (MoL_Max_Evolved_Array_Size+1) +
+ singlearraysize +
+/* (MoL_Max_Evolved_Array_Size+1) + */
arrayscratchlocation);
#endif
for (index = 0; index < arraytotalsize; index++)