diff options
author | schnetter <schnetter@c78560ca-4b45-4335-b268-5f3340f3cb52> | 2004-03-09 13:43:38 +0000 |
---|---|---|
committer | schnetter <schnetter@c78560ca-4b45-4335-b268-5f3340f3cb52> | 2004-03-09 13:43:38 +0000 |
commit | 1478cd3442978751eebae2ef6c23d9c3feb180f7 (patch) | |
tree | 07a291a8e9bfc81e8780416bff0df530efe66b05 /src | |
parent | d2e11529e75550df2c73dcc1c001908c6d3f6502 (diff) |
Use the new SymBase infrastructure to find out about symmetry boundaries.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/CartGrid3D/trunk@195 c78560ca-4b45-4335-b268-5f3340f3cb52
Diffstat (limited to 'src')
-rw-r--r-- | src/RegisterSymmetries.c | 41 | ||||
-rw-r--r-- | src/Symmetry.c | 74 | ||||
-rw-r--r-- | src/make.code.defn | 2 |
3 files changed, 115 insertions, 2 deletions
diff --git a/src/RegisterSymmetries.c b/src/RegisterSymmetries.c new file mode 100644 index 0000000..c679f3f --- /dev/null +++ b/src/RegisterSymmetries.c @@ -0,0 +1,41 @@ +/* $Header$ */ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +#include "Symmetry.h" + +void DecodeSymParameters3D(int sym[6]); + +void RegisterSymmetryBoundaries (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + int sym[6]; + int n; + CCTK_INT faces[6]; + CCTK_INT width[6]; + CCTK_INT handle; + CCTK_INT ierr; + + DecodeSymParameters3D (sym); + + for (n=0; n<6; ++n) { + faces[n] = sym[n]; + width[n] = cctk_nghostzones[n/2]; + } + + handle = SymmetryRegister ("reflection_symmetry"); + if (handle < 0) + { + CCTK_WARN (0, "Could not register symmetry boundary condition"); + } + + ierr = SymmetryRegisterGrid (cctkGH, handle, faces, width); + if (ierr < 0) + { + CCTK_WARN (0, "Could not register the symmetry boundaries -- probably some other thorn has already registered the same boundary faces for a different symmetry"); + } +} diff --git a/src/Symmetry.c b/src/Symmetry.c index 0a2cb58..546ce17 100644 --- a/src/Symmetry.c +++ b/src/Symmetry.c @@ -14,11 +14,13 @@ @version $Id$ @@*/ +#include <assert.h> #include <stdlib.h> #include "cctk.h" +#include "cctk_Arguments.h" #include "cctk_Parameters.h" -#include "cctk_FortranString.h" + #include "Symmetry.h" /* the rcs ID and its dummy function to use it */ @@ -85,6 +87,11 @@ int CartSymGI (const cGH *GH, int gindex) first_vindex = CCTK_FirstVarIndexI (gindex); if (numvars > 0 && first_vindex >= 0) { + char * groupname = CCTK_GroupName (gindex); + assert (groupname); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "You should not call the symmetry boundary condition routines for the group \"%s\" through the CartSym* routines any more. The symmetry boundary conditions are now applied automatically when a physical boundary condition is applied.", groupname); + free (groupname); retval = ApplySymmetry (GH, gindex, first_vindex, numvars); } else @@ -192,6 +199,11 @@ int CartSymVI (const cGH *GH, int vindex) gindex = CCTK_GroupIndexFromVarI (vindex); if (gindex >= 0) { + char * fullname = CCTK_FullName (vindex); + assert (fullname); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "You should not call the symmetry boundary condition routines for the variable \"%s\" through the CartSym* routines any more. The symmetry boundary conditions are now applied automatically when a physical boundary condition is applied.", fullname); + free (fullname); retval = ApplySymmetry (GH, gindex, vindex, 1); } else @@ -657,3 +669,63 @@ static int ApplySymmetry (const cGH *GH, int gindex, int first_vindex, return (retval); } + + + +/*@@ + @routine CartGrid3D_ApplyBC + @date Sat Feb 07 + @author Erik Schnetter + @desc Apply the symmetry boundary conditions + @enddesc +@@*/ + +void CartGrid3D_ApplyBC (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_ARGUMENTS; + + int nvars; + CCTK_INT * restrict indices; + CCTK_INT * restrict faces; + CCTK_INT * restrict widths; + CCTK_INT * restrict tables; + int vi; + int gi; + int i; + int ierr; + + assert (cctkGH); + + nvars = Boundary_SelectedGVs (cctkGH, 0, 0, 0, 0, 0, 0); + assert (nvars>=0); + + indices = malloc (nvars * sizeof *indices); + assert (indices); + faces = malloc (nvars * sizeof *faces); + assert (faces); + widths = malloc (nvars * sizeof *widths); + assert (widths); + tables = malloc (nvars * sizeof *tables); + assert (tables); + + ierr = Boundary_SelectedGVs + (cctkGH, nvars, indices, faces, widths, tables, 0); + assert (ierr == nvars); + + for (i=0; i<nvars; ++i) { + vi = indices[i]; + assert (vi>=0 && vi<CCTK_NumVars()); + + gi = CCTK_GroupIndexFromVarI (vi); + assert (gi>=0); + + ierr = ApplySymmetry (cctkGH, gi, vi, 1); + assert (!ierr); + } + + free (indices); + free (faces); + free (widths); + free (tables); + } diff --git a/src/make.code.defn b/src/make.code.defn index bf17dd1..5b09076 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -3,4 +3,4 @@ # Source files in this directory SRCS = Startup.c ParamCheck.c DecodeSymParameters.c CartGrid3D.c \ - GetSymmetry.c SetSymmetry.c Symmetry.c + GetSymmetry.c SetSymmetry.c Symmetry.c RegisterSymmetries.c |