From 53c6439f7393ce244de3af416961cc4f63b0eacc 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/Boundary/trunk@266 6a38eb6e-646e-4a02-a296-d141613ad6c4 --- interface.ccl | 8 ++++++-- schedule.ccl | 3 ++- src/CopyBoundary.c | 30 +++++++++++++++++------------- src/FlatBoundary.c | 28 ++++++++++++++++------------ src/RadiationBoundary.c | 29 ++++++++++++++++------------- src/RobinBoundary.c | 29 ++++++++++++++++------------- src/ScalarBoundary.c | 34 +++++++++++++++++++--------------- src/StaticBoundary.c | 29 ++++++++++++++++------------- 8 files changed, 108 insertions(+), 82 deletions(-) diff --git a/interface.ccl b/interface.ccl index 558a1ab..10c81c7 100644 --- a/interface.ccl +++ b/interface.ccl @@ -2,11 +2,9 @@ # $Header$ implements: boundary -inherits: grid INCLUDES HEADER: Boundary.h in Boundary.h -USES INCLUDE HEADER: Symmetry.h # Implementation of new boundary spec: @@ -50,3 +48,9 @@ CCTK_INT FUNCTION Boundary_SelectedGVs(CCTK_POINTER_TO_CONST IN GH, \ CCTK_INT ARRAY OUT table_handles, CCTK_STRING IN bc_name) PROVIDES FUNCTION Boundary_SelectedGVs WITH Bdry_Boundary_SelectedGVs \ LANGUAGE C + + + +CCTK_INT FUNCTION \ + SymmetryTableHandleForGrid (CCTK_POINTER_TO_CONST IN cctkGH) +USES FUNCTION SymmetryTableHandleForGrid diff --git a/schedule.ccl b/schedule.ccl index 29a5db5..f6e85cc 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -6,7 +6,7 @@ schedule Boundary_Check at CCTK_PARAMCHECK LANG: C } "Check dimension of grid variables" -schedule Boundary_RegisterBCs at CCTK_BASEGRID +schedule Boundary_RegisterBCs at CCTK_WRAGH { LANG: C OPTIONS: global @@ -30,4 +30,5 @@ schedule Boundary_ApplyPhysicalBCs in BoundaryConditions schedule Boundary_ClearSelection in ApplyBCs { LANG: C + OPTIONS: level } "Unselect all grid variables for boundary conditions" diff --git a/src/CopyBoundary.c b/src/CopyBoundary.c index d26f099..d4d7bde 100644 --- a/src/CopyBoundary.c +++ b/src/CopyBoundary.c @@ -21,7 +21,6 @@ #include "util_ErrorCodes.h" #include "cctk_FortranString.h" -#include "Symmetry.h" #include "Boundary.h" /* the rcs ID and its dummy function to use it */ @@ -1097,7 +1096,10 @@ static int ApplyBndCopy (const cGH *GH, int var_to, var_from, vtypesize; int doBC[2*MAXDIM], dstag[MAXDIM], lsh[MAXDIM], lssh[MAXDIM]; CCTK_INT widths[2*MAXDIM]; - SymmetryGHex *sGHex; + CCTK_INT symtable; + CCTK_INT symbnd[2*MAXDIM]; + CCTK_INT is_physical[2*MAXDIM]; + CCTK_INT ierr; /* get the group index of the target variable */ @@ -1156,27 +1158,29 @@ static int ApplyBndCopy (const cGH *GH, timelvl_to = 0; timelvl_from = 0; - /* see if we have a symmetry array */ - sGHex = (SymmetryGHex *) CCTK_GHExtension (GH, "Symmetry"); - + /* see if we have a physical boundary */ + symtable = SymmetryTableHandleForGrid (GH); + if (symtable < 0) CCTK_WARN (0, "internal error"); + ierr = Util_TableGetIntArray (symtable, 2 * gdim, symbnd, "symmetry_handle"); + if (ierr != 2 * gdim) CCTK_WARN (0, "internal error"); + for (i = 0; i < 2 * gdim; i++) + { + is_physical[i] = symbnd[i] < 0; + } + /* now loop over all variables */ for (var_to = first_var_to, var_from = first_var_from; var_to < first_var_to + num_vars; var_to++, var_from++) { /* Apply condition if: - + boundary is not a symmetry boundary (no symmetry or unset(=unsed)) + boundary is a physical boundary + + boundary is an outer boundary + have enough grid points */ - memset (doBC, 1, sizeof (doBC)); - if (sGHex) + for (i = 0; i < 2 * gdim; i++) { - for (i = 0; i < 2 * gdim; i++) - { - doBC[i] = sGHex->GFSym[var_to][i] == GFSYM_NOSYM || - sGHex->GFSym[var_to][i] == GFSYM_UNSET; - } + doBC[i] = is_physical[i]; } for (i = 0; i < gdim; i++) { diff --git a/src/FlatBoundary.c b/src/FlatBoundary.c index 136785f..fcf3621 100644 --- a/src/FlatBoundary.c +++ b/src/FlatBoundary.c @@ -24,7 +24,6 @@ #include "cctk_Parameters.h" #include "cctk_FortranString.h" -#include "Symmetry.h" #include "Boundary.h" /* the rcs ID and its dummy function to use it */ @@ -925,7 +924,10 @@ static int ApplyBndFlat (const cGH *GH, int var, vtypesize, gindex, gdim, timelvl; int doBC[2*MAXDIM], dstag[MAXDIM], lsh[MAXDIM], lssh[MAXDIM]; CCTK_INT widths[2*MAXDIM]; - SymmetryGHex *sGHex; + CCTK_INT symtable; + CCTK_INT symbnd[2*MAXDIM]; + CCTK_INT is_physical[2*MAXDIM]; + CCTK_INT ierr; /* get the group index of the variables */ @@ -983,25 +985,27 @@ static int ApplyBndFlat (const cGH *GH, /* get the current timelevel */ timelvl = 0; - /* see if we have a symmetry array */ - sGHex = (SymmetryGHex *) CCTK_GHExtension (GH, "Symmetry"); + /* see if we have a physical boundary */ + symtable = SymmetryTableHandleForGrid (GH); + if (symtable < 0) CCTK_WARN (0, "internal error"); + ierr = Util_TableGetIntArray (symtable, 2 * gdim, symbnd, "symmetry_handle"); + if (ierr != 2 * gdim) CCTK_WARN (0, "internal error"); + for (i = 0; i < 2 * gdim; i++) + { + is_physical[i] = symbnd[i] < 0; + } /* now loop over all variables */ for (var = first_var; var < first_var + num_vars; var++) { /* Apply condition if: - + boundary is not a symmetry boundary (no symmetry or unset(=unsed)) + boundary is a physical boundary + + boundary is an outer boundary + have enough grid points */ - memset (doBC, 1, sizeof (doBC)); - if (sGHex) + for (i = 0; i < 2 * gdim; i++) { - for (i = 0; i < 2 * gdim; i++) - { - doBC[i] = sGHex->GFSym[var][i] == GFSYM_NOSYM || - sGHex->GFSym[var][i] == GFSYM_UNSET; - } + doBC[i] = is_physical[i]; } for (i = 0; i < gdim; i++) { diff --git a/src/RadiationBoundary.c b/src/RadiationBoundary.c index 47944d1..49fc1ef 100644 --- a/src/RadiationBoundary.c +++ b/src/RadiationBoundary.c @@ -74,7 +74,6 @@ #include "cctk_FortranString.h" #include "cctk_Parameters.h" -#include "Symmetry.h" #include "Boundary.h" /* #define DEBUG */ @@ -1477,11 +1476,14 @@ static int ApplyBndRadiative (const cGH *GH, int i, gdim, indx; int var_to, var_from; int timelvl_from; - SymmetryGHex *sGHex; char coord_system_name[10]; CCTK_REAL dxyz[MAXDIM], rho[MAXDIM]; const CCTK_REAL *xyzr[MAXDIM+1]; int doBC[2*MAXDIM], widths[2*MAXDIM], offset[MAXDIM]; + CCTK_INT symtable; + CCTK_INT symbnd[2*MAXDIM]; + CCTK_INT is_physical[2*MAXDIM]; + CCTK_INT ierr; CCTK_REAL dtv, dtvh, dtvvar0, dtvvar0H; void *to_ptr; const void *from_ptr; @@ -1573,8 +1575,15 @@ static int ApplyBndRadiative (const cGH *GH, xyzr[MAXDIM] = GH->data[indx][0]; - /* see if we have a symmetry array */ - sGHex = CCTK_GHExtension (GH, "Symmetry"); + /* see if we have a physical boundary */ + symtable = SymmetryTableHandleForGrid (GH); + if (symtable < 0) CCTK_WARN (0, "internal error"); + ierr = Util_TableGetIntArray (symtable, 2 * gdim, symbnd, "symmetry_handle"); + if (ierr != 2 * gdim) CCTK_WARN (0, "internal error"); + for (i = 0; i < 2 * gdim; i++) + { + is_physical[i] = symbnd[i] < 0; + } /* now loop over all variables */ for (var_to = first_var_to, var_from = first_var_from; @@ -1585,19 +1594,13 @@ static int ApplyBndRadiative (const cGH *GH, from_ptr = GH->data[var_from][timelvl_from]; /* Apply condition if: - + boundary is not a symmetry boundary - (no symmetry or unset(=unsed)) + boundary is a physical boundary + + boundary is an outer boundary + have enough grid points */ - memset (doBC, 1, sizeof (doBC)); - if (sGHex) + for (i = 0; i < 2 * MAXDIM; i++) { - for (i = 0; i < 2 * MAXDIM; i++) - { - doBC[i] = sGHex->GFSym[var_to][i] == GFSYM_NOSYM || - sGHex->GFSym[var_to][i] == GFSYM_UNSET; - } + doBC[i] = is_physical[i]; } for (i = 0; i < MAXDIM; i++) { diff --git a/src/RobinBoundary.c b/src/RobinBoundary.c index c5a0171..0161d59 100644 --- a/src/RobinBoundary.c +++ b/src/RobinBoundary.c @@ -13,7 +13,6 @@ @version $Id$ @@*/ -#include #include #include #include @@ -24,7 +23,6 @@ #include "cctk_Parameters.h" #include "cctk_FortranString.h" -#include "Symmetry.h" #include "Boundary.h" /* the rcs ID and its dummy function to use it */ @@ -809,7 +807,10 @@ static int ApplyBndRobin (const cGH *GH, { int var, vtype, dim, gdim; int doBC[2*MAXDIM]; - SymmetryGHex *sGHex; + CCTK_INT symtable; + CCTK_INT symbnd[2*MAXDIM]; + CCTK_INT is_physical[2*MAXDIM]; + CCTK_INT ierr; char coord_system_name[20]; double decay; const CCTK_REAL *x, *y, *z, *r; @@ -869,8 +870,15 @@ static int ApplyBndRobin (const cGH *GH, } r = GH->data[CCTK_CoordIndex (-1, "r", coord_system_name)][0]; - /* see if we have a symmetry array */ - sGHex = (SymmetryGHex *) CCTK_GHExtension (GH, "Symmetry"); + /* see if we have a physical boundary */ + symtable = SymmetryTableHandleForGrid (GH); + if (symtable < 0) CCTK_WARN (0, "internal error"); + ierr = Util_TableGetIntArray (symtable, 2 * gdim, symbnd, "symmetry_handle"); + if (ierr != 2 * gdim) CCTK_WARN (0, "internal error"); + for (dim = 0; dim < 2 * gdim; dim++) + { + is_physical[dim] = symbnd[dim] < 0; + } /* get the decay rate as a double */ decay = (double) npow; @@ -889,18 +897,13 @@ static int ApplyBndRobin (const cGH *GH, for (var = first_var; var < first_var + num_vars; var++) { /* Apply condition if: - + boundary is not a symmetry boundary (no symmetry or unset(=unsed)) + boundary is a physical boundary + + boundary is an outer boundary + have enough grid points */ - memset (doBC, 1, sizeof (doBC)); - if (sGHex) + for (dim = 0; dim < 2 * gdim; dim++) { - for (dim = 0; dim < 2 * gdim; dim++) - { - doBC[dim] = sGHex->GFSym[var][dim] == GFSYM_NOSYM || - sGHex->GFSym[var][dim] == GFSYM_UNSET; - } + doBC[dim] = is_physical[dim]; } for (dim = 0; dim < gdim; dim++) { diff --git a/src/ScalarBoundary.c b/src/ScalarBoundary.c index 81ee42f..d446f56 100644 --- a/src/ScalarBoundary.c +++ b/src/ScalarBoundary.c @@ -22,7 +22,6 @@ #include "cctk_Parameters.h" #include "cctk_FortranString.h" -#include "Symmetry.h" #include "Boundary.h" /* the rcs ID and its dummy function to use it */ @@ -1059,12 +1058,15 @@ static int ApplyBndScalar (const cGH *GH, int first_var, int num_vars) { + int ierr; int i, j, k; int gindex, gdim; int var, timelvl; int doBC[2*MAXDIM], dstag[MAXDIM], lsh[MAXDIM], lssh[MAXDIM]; CCTK_INT widths[2*MAXDIM]; - SymmetryGHex *sGHex; + CCTK_INT symtable; + CCTK_INT symbnd[2*MAXDIM]; + CCTK_INT is_physical[2*MAXDIM]; /* check the direction parameter */ if (abs (dir) > MAXDIM) @@ -1075,11 +1077,11 @@ static int ApplyBndScalar (const cGH *GH, return (-1); } - /* get the group index and dimensionality */ + /* get the group index and dimension */ gindex = CCTK_GroupIndexFromVarI (first_var); gdim = CCTK_GroupDimI (gindex); - /* check the dimensionality */ + /* check the dimension */ if (gdim > MAXDIM) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, @@ -1119,25 +1121,27 @@ static int ApplyBndScalar (const cGH *GH, /* get the current timelevel */ timelvl = 0; - /* see if we have a symmetry array */ - sGHex = (SymmetryGHex *) CCTK_GHExtension (GH, "Symmetry"); + /* see if we have a physical boundary */ + symtable = SymmetryTableHandleForGrid (GH); + if (symtable < 0) CCTK_WARN (0, "internal error"); + ierr = Util_TableGetIntArray (symtable, 2 * gdim, symbnd, "symmetry_handle"); + if (ierr != 2 * gdim) CCTK_WARN (0, "internal error"); + for (i = 0; i < 2 * gdim; i++) + { + is_physical[i] = symbnd[i] < 0; + } /* now loop over all variables */ for (var = first_var; var < first_var + num_vars; var++) { /* Apply condition if: - + boundary is not a symmetry boundary (no symmetry or unset(=unsed)) + boundary is a physical boundary + + boundary is an outer boundary + have enough grid points */ - memset (doBC, 1, sizeof (doBC)); - if (sGHex) + for (i = 0; i < 2 * gdim; i++) { - for (i = 0; i < 2 * gdim; i++) - { - doBC[i] = sGHex->GFSym[var][i] == GFSYM_NOSYM || - sGHex->GFSym[var][i] == GFSYM_UNSET; - } + doBC[i] = is_physical[i]; } for (i = 0; i < gdim; i++) { @@ -1155,7 +1159,7 @@ static int ApplyBndScalar (const cGH *GH, switch (CCTK_VarTypeI (var)) { /* FIXME: can't pass an empty preprocessor constant as a macro argument - on some systems (eg. MacOS X), so we have to define it outside */ + on some systems (e.g. MacOS X), so we have to define it outside */ #define NUMBER_PART case CCTK_VARIABLE_CHAR: SCALAR_BOUNDARY (CCTK_CHAR, CCTK_CHAR); break; diff --git a/src/StaticBoundary.c b/src/StaticBoundary.c index a70ff69..f5d7b65 100644 --- a/src/StaticBoundary.c +++ b/src/StaticBoundary.c @@ -16,7 +16,6 @@ #include "util_ErrorCodes.h" #include "cctk_FortranString.h" -#include "Symmetry.h" #include "Boundary.h" /* the rcs ID and its dummy function to use it */ @@ -931,13 +930,16 @@ static int ApplyBndStatic (const cGH *GH, int first_var, int num_vars) { + int ierr; int i, j, k; int timelvl_to, timelvl_from; int gindex, gdim; int var, vtypesize; int doBC[2*MAXDIM], dstag[MAXDIM], lsh[MAXDIM], lssh[MAXDIM]; CCTK_INT widths[2*MAXDIM]; - SymmetryGHex *sGHex; + CCTK_INT symtable; + CCTK_INT symbnd[2*MAXDIM]; + CCTK_INT is_physical[2*MAXDIM]; /* Only apply boundary condition if more than one timelevel */ if (CCTK_MaxTimeLevelsVI(first_var) == 1) @@ -1001,8 +1003,15 @@ static int ApplyBndStatic (const cGH *GH, timelvl_to = 0; timelvl_from = 1; - /* see if we have a symmetry array */ - sGHex = CCTK_GHExtension (GH, "Symmetry"); + /* see if we have a physical boundary */ + symtable = SymmetryTableHandleForGrid (GH); + if (symtable < 0) CCTK_WARN (0, "internal error"); + ierr = Util_TableGetIntArray (symtable, 2 * gdim, symbnd, "symmetry_handle"); + if (ierr != 2 * gdim) CCTK_WARN (0, "internal error"); + for (i = 0; i < 2 * gdim; i++) + { + is_physical[i] = symbnd[i] < 0; + } /* now loop over all variables */ for (var = first_var; @@ -1010,18 +1019,12 @@ static int ApplyBndStatic (const cGH *GH, var++) { /* Apply condition if: - + boundary is not a symmetry boundary (no symmetry or unset(=unsed)) - + boundary is a physical boundary + + boundary is an outer boundary + have enough grid points */ - memset (doBC, 1, sizeof (doBC)); - if (sGHex) + for (i = 0; i < 2 * gdim; i++) { - for (i = 0; i < 2 * gdim; i++) - { - doBC[i] = sGHex->GFSym[var][i] == GFSYM_NOSYM || - sGHex->GFSym[var][i] == GFSYM_UNSET; - } + doBC[i] = is_physical[i]; } for (i = 0; i < gdim; i++) { -- cgit v1.2.3