From 1478cd3442978751eebae2ef6c23d9c3feb180f7 Mon Sep 17 00:00:00 2001 From: schnetter Date: Tue, 9 Mar 2004 13:43:38 +0000 Subject: 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 --- interface.ccl | 27 ++++++++++++++++++ par/byrange_full.par | 2 +- schedule.ccl | 11 +++++++ src/RegisterSymmetries.c | 41 +++++++++++++++++++++++++++ src/Symmetry.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++- src/make.code.defn | 2 +- 6 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 src/RegisterSymmetries.c diff --git a/interface.ccl b/interface.ccl index 3c44d2c..c18370f 100644 --- a/interface.ccl +++ b/interface.ccl @@ -32,6 +32,33 @@ USES FUNCTION ConvertFromPhysicalBoundary +# Register the symmetry boundaries +CCTK_INT FUNCTION SymmetryRegister (CCTK_STRING IN sym_name) +USES FUNCTION SymmetryRegister + +CCTK_INT FUNCTION \ + SymmetryRegisterGrid \ + (CCTK_POINTER IN cctkGH, \ + CCTK_INT IN sym_handle, \ + CCTK_INT IN ARRAY which_faces, \ # array [N_FACES] + CCTK_INT IN ARRAY symmetry_zone_width) # array [N_FACES] +USES FUNCTION SymmetryRegisterGrid + + + +# Apply the symmetry boundary conditions +CCTK_INT FUNCTION Boundary_SelectedGVs \ + (CCTK_POINTER_TO_CONST IN GH, \ + CCTK_INT IN array_size, \ + CCTK_INT ARRAY OUT var_indicies, \ + CCTK_INT ARRAY OUT faces, \ + CCTK_INT ARRAY OUT boundary_widths, \ + CCTK_INT ARRAY OUT table_handles, \ + CCTK_STRING IN bc_name) +USES FUNCTION Boundary_SelectedGVs + + + public: REAL gridspacings type=SCALAR diff --git a/par/byrange_full.par b/par/byrange_full.par index fadbd61..97181e8 100644 --- a/par/byrange_full.par +++ b/par/byrange_full.par @@ -1,7 +1,7 @@ !DESC "Create coordinates by range on a full grid" -ActiveThorns = "pugh pughslab CartGrid3D CoordBase ioutil ioascii" +ActiveThorns = "pugh pughslab CartGrid3D CoordBase SymBase ioutil ioascii" driver::global_nsize = 10 diff --git a/schedule.ccl b/schedule.ccl index 412c47b..c0d5421 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -13,6 +13,12 @@ schedule RegisterCartGrid3DCoords at CCTK_WRAGH LANG:C } "Register coordinates for the Cartesian grid" +schedule RegisterSymmetryBoundaries in SymmetryRegister +{ + LANG:C + OPTIONS: meta +} "Register symmetry boundaries" + schedule ParamCheck_CartGrid3D at CCTK_PARAMCHECK { LANG:C @@ -22,3 +28,8 @@ schedule CartGrid3D as SpatialCoordinates at CCTK_BASEGRID { LANG:C } "Set up spatial 3D Cartesian coordinates on the GH" + +schedule CartGrid3D_ApplyBC in BoundaryConditions +{ + LANG: C +} "Apply symmetry boundary conditions" 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 #include #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=0 && vi=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 -- cgit v1.2.3