diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/cctk_GroupsOnGH.h | 7 | ||||
-rw-r--r-- | src/main/GroupsOnGH.c | 194 |
2 files changed, 201 insertions, 0 deletions
diff --git a/src/include/cctk_GroupsOnGH.h b/src/include/cctk_GroupsOnGH.h index 7db63b3f..e2e38c96 100644 --- a/src/include/cctk_GroupsOnGH.h +++ b/src/include/cctk_GroupsOnGH.h @@ -18,6 +18,8 @@ typedef struct GROUPDYNAMICDATA const int *lsh; const int *lbnd; const int *ubnd; +#define CCTK_GROUPDYNAMICDATA_HAS_LSSH + const int *lssh; const int *bbox; const int *nghostzones; int activetimelevels; @@ -53,6 +55,11 @@ int CCTK_GrouplshVN(const cGH *GH, int dim, int *lsh, const char *varname); int CCTK_GrouplshGI(const cGH *GH, int dim, int *lsh, int groupindex); int CCTK_GrouplshVI(const cGH *GH, int dim, int *lsh, int varindex); +int CCTK_GrouplsshGN(const cGH *GH, int dim, int *lssh, const char *groupname); +int CCTK_GrouplsshVN(const cGH *GH, int dim, int *lssh, const char *varname); +int CCTK_GrouplsshGI(const cGH *GH, int dim, int *lssh, int groupindex); +int CCTK_GrouplsshVI(const cGH *GH, int dim, int *lssh, int varindex); + int CCTK_GroupgshGN(const cGH *GH, int dim, int *gsh, const char *groupname); int CCTK_GroupgshVN(const cGH *GH, int dim, int *gsh, const char *varname); int CCTK_GroupgshGI(const cGH *GH, int dim, int *gsh, int groupindex); diff --git a/src/main/GroupsOnGH.c b/src/main/GroupsOnGH.c index 1269ba0d..5dc3dbd1 100644 --- a/src/main/GroupsOnGH.c +++ b/src/main/GroupsOnGH.c @@ -13,6 +13,7 @@ #include <string.h> #include "cctk_Comm.h" +#include "cctk_Constants.h" #include "cctk_Flesh.h" #include "cctk_FortranString.h" #include "cctk_Groups.h" @@ -108,6 +109,30 @@ void CCTK_FCALL CCTK_FNAME (CCTK_GrouplshVN) const int *dim, int *lsh, ONE_FORTSTRING_ARG); +void CCTK_FCALL CCTK_FNAME (CCTK_GrouplsshGI) + (int *ierr, + const cGH **cctkGH, + const int *dim, + int *lssh, + const int *groupindex); +void CCTK_FCALL CCTK_FNAME (CCTK_GrouplsshGN) + (int *ierr, + const cGH **cctkGH, + const int *dim, + int *lssh, + ONE_FORTSTRING_ARG); +void CCTK_FCALL CCTK_FNAME (CCTK_GrouplsshVI) + (int *ierr, + const cGH **cctkGH, + const int *dim, + int *lssh, + const int *varindex); +void CCTK_FCALL CCTK_FNAME (CCTK_GrouplsshVN) + (int *ierr, + const cGH **cctkGH, + const int *dim, + int *lssh, + ONE_FORTSTRING_ARG); void CCTK_FCALL CCTK_FNAME (CCTK_GroupgshGI) (int *ierr, const cGH **cctkGH, @@ -1201,6 +1226,174 @@ void CCTK_FCALL CCTK_FNAME (CCTK_GrouplshVN) /******************************************************************** + ******************** Group local stagger shape *************** + ********************************************************************/ + + /*@@ + @routine CCTK_GrouplsshGI + @date 2011-03-16 + @author Erik Schnetter + @desc + Returns the lssh for a variable group + @enddesc +@@*/ +int CCTK_GrouplsshGI(const cGH *cctkGH, + int size, + int *lssh, + int groupindex) +{ + int retval = 0; + int ierr; + int usesize = size; /* Actual number of integers copied */ + char *groupname; + cGroupDynamicData data; + + ierr = CCTK_GroupDynamicData(cctkGH,groupindex,&data); + + if (ierr == 0 && (data.dim == 0 || data.lssh)) + { + if (CCTK_NSTAGGER*data.dim != size) + { + retval = -1; + usesize = (CCTK_NSTAGGER*data.dim < size) ? CCTK_NSTAGGER*data.dim : size; + groupname = CCTK_GroupName (groupindex); + CCTK_VWarn(1,__LINE__,__FILE__,"Cactus", + "CCTK_GrouplsshGI: Incorrect size %d supplied, " + "group '%s' has dimension %d, copying %d integers", + size,groupname,data.dim,usesize); + free (groupname); + } + memcpy(lssh,(const int *)data.lssh,usesize*sizeof(int)); + } + else + { + retval = -2; + CCTK_VWarn(1,__LINE__,__FILE__,"Cactus", + "CCTK_GrouplsshGI: Data not available from driver thorn"); + } + return retval; +} + +void CCTK_FCALL CCTK_FNAME (CCTK_GrouplsshGI) + (int *ierr, + const cGH **cctkGH, + const int *size, + int *lssh, + const int *groupindex) +{ + *ierr = CCTK_GrouplsshGI (*cctkGH, *size, lssh, *groupindex); +} + + + +int CCTK_GrouplsshGN(const cGH *cctkGH, + int size, + int *lssh, + const char *groupname) +{ + int retval; + int gindex = CCTK_GroupIndex(groupname); + + if (gindex > -1) + { + retval = CCTK_GrouplsshGI(cctkGH,size,lssh,gindex); + } + else + { + retval = -4; + CCTK_VWarn(1,__LINE__,__FILE__,"Cactus", + "CCTK_GrouplsshGN: Group index not found for %s",groupname); + } + + return retval; +} + +void CCTK_FCALL CCTK_FNAME (CCTK_GrouplsshGN) + (int *ierr, + const cGH **cctkGH, + const int *size, + int *lssh, + ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE (groupname) + *ierr = CCTK_GrouplsshGN (*cctkGH, *size, lssh, groupname); + free (groupname); +} + + + +int CCTK_GrouplsshVI(const cGH *cctkGH, + int size, + int *lssh, + int varindex) +{ + int retval; + int gindex = CCTK_GroupIndexFromVarI(varindex); + + if (gindex > -1) + { + retval = CCTK_GrouplsshGI(cctkGH,size,lssh,gindex); + } + else + { + retval = -4; + CCTK_VWarn(1,__LINE__,__FILE__,"Cactus", + "CCTK_GrouplsshVI: Group index not found for variable index %d", + varindex); + } + + return retval; +} + +void CCTK_FCALL CCTK_FNAME (CCTK_GrouplsshVI) + (int *ierr, + const cGH **cctkGH, + const int *size, + int *lssh, + const int *varindex) +{ + *ierr = CCTK_GrouplsshVI (*cctkGH, *size, lssh, *varindex); +} + + + +int CCTK_GrouplsshVN(const cGH *cctkGH, + int size, + int *lssh, + const char *varname) +{ + int retval; + int gindex = CCTK_GroupIndexFromVar(varname); + + if (gindex > -1) + { + retval = CCTK_GrouplsshGI(cctkGH,size,lssh,gindex); + } + else + { + retval = -4; + CCTK_VWarn(1,__LINE__,__FILE__,"Cactus", + "CCTK_GrouplsshVN: Group index not found for %s",varname); + } + + return retval; +} + +void CCTK_FCALL CCTK_FNAME (CCTK_GrouplsshVN) + (int *ierr, + const cGH **cctkGH, + const int *size, + int *lssh, + ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE (varname) + *ierr = CCTK_GrouplsshVN (*cctkGH, *size, lssh, varname); + free (varname); +} + + + +/******************************************************************** ******************* Group Global Shape *********************** ********************************************************************/ @@ -1535,6 +1728,7 @@ void CCTK_FCALL CCTK_FNAME (CCTK_GroupnghostzonesVN) } + /******************************************************************** ******************** Group bbox *********************** ********************************************************************/ |