From 74337b94a430216c7d51d5db4c5daccf21c844b3 Mon Sep 17 00:00:00 2001 From: tradke Date: Fri, 12 Apr 2002 15:23:41 +0000 Subject: Added Frank's GetCartSym*() routines. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/CartGrid3D/trunk@149 c78560ca-4b45-4335-b268-5f3340f3cb52 --- src/GetSymmetry.c | 245 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Symmetry.h | 7 +- src/make.code.defn | 15 +--- 3 files changed, 252 insertions(+), 15 deletions(-) create mode 100644 src/GetSymmetry.c diff --git a/src/GetSymmetry.c b/src/GetSymmetry.c new file mode 100644 index 0000000..0083168 --- /dev/null +++ b/src/GetSymmetry.c @@ -0,0 +1,245 @@ +/*@@ + @file GetSymmetry.c + @date April 12 2002 + @author Frank Herrmann + @desc + This file contains the routines for getting symmetry information + code stolen from SetSymmetry.c + @enddesc + @version $Id$ +@@*/ + +#include + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "cctk_FortranString.h" +#include "Symmetry.h" + +static const char *rcsid = "$Header$"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_GetSymmetry_c) + +/******************************************************************** + ********************* Local Defines *********************** + ********************************************************************/ +#define MAX_DIM 3 +#define MAX_FACE 6 + + +/******************************************************************** + ********************* Local Routine Prototypes ********************* + ********************************************************************/ +void DecodeSymParameters3D(int sym[6]); + +void CCTK_FCALL CCTK_FNAME(GetCartSymVI) + (int *ierr, const cGH *GH, int *sym, const int *vi); +void CCTK_FCALL CCTK_FNAME(GetCartSymVN) + (int *ierr, const cGH *GH, int *sym, ONE_FORTSTRING_ARG); +void CCTK_FCALL CCTK_FNAME(GetCartSymGI) + (int *ierr, const cGH *GH, int *sym, const int *gi); +void CCTK_FCALL CCTK_FNAME(GetCartSymGN) + (int *ierr, const cGH *GH, int *sym, ONE_FORTSTRING_ARG); + + +/******************************************************************** + ********************* External Routines ********************** + ********************************************************************/ + +/*@@ + @routine GetCartSymmetry + @date Mon Mar 15 15:10:58 1999 + @author Frank Herrmann + @desc + This routine returns symmetry for variable index. + @enddesc +@@*/ +int GetCartSymVI(const cGH *GH, int *sym, int vi) +{ + int domainsym[MAX_FACE]; + SymmetryGHex *sGHex; + int dir; + DECLARE_CCTK_PARAMETERS + + + /* Pointer to the SymmetryGHextension */ + sGHex = (SymmetryGHex *)GH->extensions[CCTK_GHExtensionHandle("Symmetry")]; + + /* Reference the hash table in the GHex and get the kind of + * symmetry being applied + */ + +#ifdef SYM_DEBUG + printf("GetSymmetry: %s [%d,%d,%d]\n",CCTK_VarName(vi), + sym[0],sym[1],sym[2]); +#endif + + DecodeSymParameters3D(domainsym); + + for (dir=0; dirGFSym[vi][dir]; + } + else + { + CCTK_WARN(0,"symmetry not known");; + } + } + +#ifdef SYM_DEBUG + printf("GetSymmetry: %s [%d,%d,%d]\n\n",imp_gf, + sGHex->GFSym[vi][0],sGHex->GFSym[vi][2],sGHex->GFSym[vi][4]); +#endif + + return 0; +} + +void CCTK_FCALL CCTK_FNAME(GetCartSymVI) + (int *ierr, const cGH *GH, int *sym, const int *vi) +{ + *ierr = GetCartSymVI(GH, sym, *vi); +} + + +/*@@ + @routine GetCartSymVN + @date April 12 2002 + @author Frank Herrmann + @desc + Gets symmetry boundary conditions from variable index + @enddesc +@@*/ +int GetCartSymVN(const cGH *GH, int *sym, const char *vn) +{ + int vi; + vi = CCTK_VarIndex(vn); + + if (vi>-1) + { + return(GetCartSymVI(GH, sym, vi)); + } + else + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "Cannot find variable %s in GetCartSymVN",vn); + return(-1); + } +} + +void CCTK_FCALL CCTK_FNAME(GetCartSymVN) + (int *ierr, const cGH *GH, int *sym, ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE(vn) + *ierr = GetCartSymVN(GH, sym, vn); + free(vn); +} + + +/*@@ + @routine GetCartSymGI + @date April 12 2002 + @author Frank Herrmann + @desc + Gets symmetry boundary conditions from Group index + @enddesc +@@*/ +int GetCartSymGI(const cGH *GH, int *sym, int gi) +{ + int domainsym[MAX_FACE]; + SymmetryGHex *sGHex; + int first_vari,numvars,vi; + int dir; + DECLARE_CCTK_PARAMETERS + + + CCTK_WARN(3,"this code was not yet tested"); + + + sGHex =(SymmetryGHex *)GH->extensions[CCTK_GHExtensionHandle("Symmetry")]; + + first_vari = CCTK_FirstVarIndexI(gi); + numvars = CCTK_NumVarsInGroupI(gi); + + if (first_vari<0) + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "Cannot find group %s (grp.index: %d) in GetCartSymGI", + CCTK_GroupName(gi),first_vari); + return(-1); + } + + /* Reference the hash table in the GHex and get the kind of + * symmetry which was applied + */ + for (vi=first_vari; viGFSym[vi][dir]; + } + else + { + CCTK_WARN(1,"Symmetry not found"); + } + } + +#ifdef SYM_DEBUG + printf("GetSymmetry: %s [%d,%d,%d]\n\n",imp_gf, + sGHex->GFSym[vi][0], + sGHex->GFSym[vi][2], + sGHex->GFSym[vi][4]); +#endif + } + return(0); +} + +void CCTK_FCALL CCTK_FNAME(GetCartSymGI) + (int *ierr, const cGH *GH, int *sym, const int *gi) +{ + *ierr = GetCartSymGI(GH, sym, *gi); +} + + + /*@@ + @routine GetCartSymGN + @date April 12 2002 + @author Frank Herrmann + @desc + Gets symmetry boundary conditions from groupname + @enddesc +@@*/ +int GetCartSymGN(const cGH *GH, int *sym, const char *gn) +{ + int gi = CCTK_GroupIndex(gn); + + if (gi>-1) + { + return(GetCartSymGI(GH, sym, gi)); + } + else + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "Cannot find group %s in GetCartSymGN",gn); + return(-1); + } +} + +void CCTK_FCALL CCTK_FNAME(GetCartSymGN) + (int *ierr, const cGH *GH, int *sym, ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE(gn) + *ierr = GetCartSymGN(GH, sym, gn); + free(gn); +} diff --git a/src/Symmetry.h b/src/Symmetry.h index 502ae1a..e0b496a 100644 --- a/src/Symmetry.h +++ b/src/Symmetry.h @@ -13,8 +13,6 @@ * The information is used during evolution by Einstein_DoBound(GF), Einstein_DoSym(GF) @enddesc - @history - @endhistory @version $Header$ @@*/ @@ -40,6 +38,11 @@ extern "C" { #endif +int GetCartSymVI(const cGH *GH, int *sym, int vi); +int GetCartSymGI(const cGH *GH, int *sym, int vi); +int GetCartSymVN(const cGH *GH, int *sym, const char *vn); +int GetCartSymGN(const cGH *GH, int *sym, const char *vn); + int SetCartSymVI(cGH *GH, int *sym, int vi); int SetCartSymGI(cGH *GH, int *sym, int vi); int SetCartSymVN(cGH *GH, int *sym, const char *vn); diff --git a/src/make.code.defn b/src/make.code.defn index 0c6f9b4..ec04fdc 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -2,16 +2,5 @@ # $Header$ # Source files in this directory -SRCS = DecodeSymParameters.c\ - CartGrid3D.c\ - GHExtension.c\ - ParamCheck.c\ - Startup.c\ - SetSymmetry.c\ - Symmetry.c\ - SymmetryWrappers.c - - -# Subdirectories containing source files -SUBDIRS = - +SRCS = DecodeSymParameters.c CartGrid3D.c GHExtension.c GetSymmetry.c \ + ParamCheck.c Startup.c SetSymmetry.c Symmetry.c SymmetryWrappers.c -- cgit v1.2.3