aboutsummaryrefslogtreecommitdiff
path: root/src/GetSymmetry.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/GetSymmetry.c')
-rw-r--r--src/GetSymmetry.c245
1 files changed, 245 insertions, 0 deletions
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 <stdlib.h>
+
+#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; dir<MAX_FACE; ++dir)
+ {
+ if (domainsym[dir])
+ {
+ sym[dir/2]=sGHex->GFSym[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; vi<first_vari+numvars; vi++)
+ {
+
+#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; dir<MAX_FACE; dir++)
+ {
+ if (domainsym[dir])
+ {
+ sym[dir/2]=sGHex->GFSym[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);
+}