aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrideout <rideout@6a38eb6e-646e-4a02-a296-d141613ad6c4>2003-02-14 00:46:06 +0000
committerrideout <rideout@6a38eb6e-646e-4a02-a296-d141613ad6c4>2003-02-14 00:46:06 +0000
commitf93380441909a9c02fd7002a7071ee2f0b519f2f (patch)
treeeccc11dc7b7bc3eabd43b2a80d7f6f3ed2111438
parent7d93d9515961a769c22c32fd425d37439206f912 (diff)
Provide wrappers for all boundary conditions provided by thorn
Boundary, so that they can be 'selected for bc' under the new boundary interface. The details of default arguments and table keys will be documented in the thorn guide. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Boundary/trunk@198 6a38eb6e-646e-4a02-a296-d141613ad6c4
-rw-r--r--src/Boundary.h35
-rw-r--r--src/CopyBoundary.c176
-rw-r--r--src/FlatBoundary.c136
-rw-r--r--src/RadiationBoundary.c6
-rw-r--r--src/Register.c92
-rw-r--r--src/RobinBoundary.c153
-rw-r--r--src/ScalarBoundary.c146
-rw-r--r--src/StaticBoundary.c143
8 files changed, 819 insertions, 68 deletions
diff --git a/src/Boundary.h b/src/Boundary.h
index d4ae90a..d39438f 100644
--- a/src/Boundary.h
+++ b/src/Boundary.h
@@ -22,6 +22,11 @@ int BndNone(const cGH *GH, int num_vars, int *var_indicies, int *faces,
int *table_handle);
/* Scalar boundaries */
+
+/* prototype for routine registed as providing 'Scalar' boundary condition */
+int BndScalar(const cGH *GH, int num_vars, int *var_indicies, int *faces,
+ int *table_handle);
+
int BndScalarDirGI (const cGH *GH,
int stencil_size,
int dir,
@@ -61,7 +66,12 @@ int BndScalarVN (const cGH *GH,
const char *vname);
-/* Copying boundaries */
+/* Copying boundaries */
+
+/* prototype for routine registed as providing 'Copy' boundary condition */
+int BndCopy(const cGH *GH, int num_vars, int *var_indicies, int *faces,
+ int *table_handle);
+
int BndCopyDirGI (const cGH *GH,
int stencil_size,
int dir,
@@ -101,6 +111,11 @@ int BndCopyVN (const cGH *GH,
const char *vname_from);
/* Static boundaries */
+
+/* prototype for routine registed as providing 'Static' boundary condition */
+int BndStatic(const cGH *GH, int num_vars, int *var_indicies, int *faces,
+ int *table_handle);
+
int BndStaticDirGI (const cGH *GH,
int stencil_size,
int dir,
@@ -134,9 +149,9 @@ int BndStaticVN (const cGH *GH,
/* Radiative boundaries */
-/* prototype for routine registed as providing radiative boundary conditions */
+/* prototype for routine registed as providing 'Radiative' boundary conditions */
int BndRadiative(const cGH *GH, int num_vars, int *var_indicies, int *faces,
- int *table_handle);
+ int *table_handle);
int BndRadiativeDirGI (const cGH *GH,
int stencil_size,
@@ -193,7 +208,12 @@ int BndRadiativeVN (const cGH *GH,
const char *vname_from);
-/* Robin boundaries */
+/* Robin boundaries */
+
+/* prototype for routine registed as providing 'Robin' boundary condition */
+int BndRobin(const cGH *GH, int num_vars, int *var_indicies, int *faces,
+ int *table_handle);
+
int BndRobinGI (const cGH *GH,
const int *stencil,
CCTK_REAL finf,
@@ -216,7 +236,12 @@ int BndRobinVN (const cGH *GH,
const char *vname);
-/* Flat boundaries */
+/* Flat boundaries */
+
+/* prototype for routine registed as providing 'Flat' boundary condition */
+int BndFlat(const cGH *GH, int num_vars, int *var_indicies, int *faces,
+ int *table_handle);
+
int BndFlatDirGI (const cGH *GH,
int stencil_size,
int dir,
diff --git a/src/CopyBoundary.c b/src/CopyBoundary.c
index 9be745a..864a490 100644
--- a/src/CopyBoundary.c
+++ b/src/CopyBoundary.c
@@ -17,6 +17,9 @@
#include <string.h>
#include "cctk.h"
+#include "cctk_Faces.h"
+#include "util_Table.h"
+#include "util_ErrorCodes.h"
#include "cctk_FortranString.h"
#include "Symmetry.h"
@@ -24,12 +27,175 @@
/* the rcs ID and its dummy function to use it */
static const char *rcsid = "$Header$";
-CCTK_FILEVERSION(CactusBase_Boundary_CopyBoundary_c)
+CCTK_FILEVERSION(CactusBase_Boundary_CopyBoundary_c);
+
+static int ApplyBndCopy (const cGH *GH,
+ int stencil_dir,
+ const int *stencil_alldirs,
+ int dir,
+ int first_var_to,
+ int first_var_from,
+ int num_vars);
/********************************************************************
******************** External Routines ************************
********************************************************************/
+
+/*@@
+ @routine BndCopy
+ @date 13 Feb 2003
+ @author David Rideout
+ @desc
+ Top level function which is registered as handling
+ the Copy boundary condition
+ @enddesc
+ @calls ApplyBndCopy
+ @var GH
+ @vdesc Pointer to CCTK grid hierarchy
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var num_vars
+ @vdesc number of variables passed in through var_indices[]
+ @vtype int
+ @vio in
+ @endvar
+ @var var_indices
+ @vdesc array of variable indicies to which to apply this boundary
+ condition
+ @vtype int *
+ @vio in
+ @endvar
+ @var faces
+ @vdesc array of set of faces to which to apply the bc
+ @vtype int
+ @vio in
+ @endvar
+ @var table_handles
+ @vdesc array of table handles which hold extra arguments
+ @vtype int
+ @vio in
+ @endvar
+ @returntype int
+ @returndesc
+ return code of @seeroutine ApplyBndScalar
+ -11 invalid table handle
+ -12 no "COPY FROM" key in table
+ @endreturndesc
+@@*/
+
+int BndCopy(const cGH *GH, int num_vars, int *vars, int *faces, int *tables)
+{
+ int i, j, k, gdim, max_gdim, err, value_type, value_size, retval;
+ char *copy_from_name;
+
+ /* variables to pass to ApplyBndCopy */
+ /*int stencil_dir;*/ /* width of stencil in direction dir, not needed */
+ int *stencil_alldirs; /* width of stencil in all directions */
+ int dir; /* direction in which to apply bc */
+ int copy_from; /* variable (index) from which to copy the boundary data */
+
+ retval = 0; stencil_alldirs = NULL;
+
+ /* loop through variables, j at a time */
+ for (i=0; i<num_vars; i+=j) {
+
+ /* find other adjacent vars which are selected for identical bcs */
+ j=1;
+ while (i+j<num_vars && vars[i+j]==vars[i]+j && tables[i+j]==tables[i] &&
+ faces[i+j]==faces[i])
+ {
+ ++j;
+ }
+
+ /* Check to see if faces specification is valid */
+ if (faces[i] != CCTK_ALL_FACES)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Faces specification %d for Copy boundary conditions on "
+ "%s is not implemented yet. "
+ "Applying radiative bcs to all (external) faces.", faces[i],
+ CCTK_VarName(vars[i]));
+ }
+ dir = 0; /* apply bc to all faces */
+
+ /* Set up default arguments for ApplyBndCopy */
+ /* Allocate memory and populate stencil width array */
+ gdim = CCTK_GroupDimFromVarI(vars[i]);
+ if (!stencil_alldirs)
+ {
+ stencil_alldirs = (int *) malloc(gdim*sizeof(int));
+ max_gdim = gdim;
+ } else if (gdim > max_gdim)
+ {
+ realloc(stencil_alldirs, gdim*sizeof(int));
+ max_gdim = gdim;
+ }
+ for (k=0; k<gdim; ++k)
+ {
+ stencil_alldirs[k] = 1;
+ }
+
+ /* Look on table for copy-from variable and possible non-default arguments
+ */
+ /* Stencil width array */
+ err = Util_TableGetIntArray(tables[i], gdim, stencil_alldirs,
+ "STENCIL WIDTH");
+ if (err == UTIL_ERROR_BAD_HANDLE)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Invalid table handle passed for Copy boundary "
+ "conditions for %s. Name or index of variable to copy from "
+ "must be provided via key \"COPY FROM\". Aborting.",
+ CCTK_VarName(vars[i]));
+ return -11;
+ } else
+ {
+ if (Util_TableQueryValueInfo(tables[i], &value_type, &value_size,
+ "COPY FROM"))
+ {
+ if (value_type==CCTK_VARIABLE_STRING)
+ {
+ copy_from_name = (char *) malloc(value_size*sizeof(char));
+ Util_TableGetString(tables[i], value_size, copy_from_name,
+ "COPY FROM");
+ copy_from = CCTK_VarIndex(copy_from_name);
+ free(copy_from_name);
+ } else if (value_type==CCTK_VARIABLE_INT)
+ {
+ Util_TableGetInt(tables[i], &copy_from,
+ "COPY FROM");
+ } else
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Invalid data type for key \"COPY FROM\" "
+ "Please use CCTK_STRING for the variable name, "
+ "or CCTK_INT for the variable index.");
+ }
+ } else
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "No key \"COPY FROM\" provided in table. Please enter the "
+ "name or index of variable to copy from into the table "
+ "under this key. Aborting.");
+ return -12;
+ }
+ }
+
+ if (!retval && (retval = ApplyBndCopy(GH, 0, stencil_alldirs, dir,
+ vars[i], copy_from, j)) < 0)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "ApplyBndCopy() returned %d", retval);
+ }
+ }
+ free(stencil_alldirs);
+
+ return retval;
+}
+
+
/* prototypes for external C routines are declared in header Boundary.h
here only follow the fortran wrapper prototypes */
void CCTK_FCALL CCTK_FNAME (BndCopyDirVI)
@@ -85,14 +251,6 @@ void CCTK_FCALL CCTK_FNAME (BndCopyGN)
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static int ApplyBndCopy (const cGH *GH,
- int stencil_dir,
- const int *stencil_alldirs,
- int dir,
- int first_var_to,
- int first_var_from,
- int num_vars);
-
/*@@
@routine BndCopyDirVI
diff --git a/src/FlatBoundary.c b/src/FlatBoundary.c
index 63166ef..08657d5 100644
--- a/src/FlatBoundary.c
+++ b/src/FlatBoundary.c
@@ -19,6 +19,9 @@
#include <string.h>
#include "cctk.h"
+#include "cctk_Faces.h"
+#include "util_Table.h"
+#include "util_ErrorCodes.h"
#include "cctk_Parameters.h"
#include "cctk_FortranString.h"
@@ -27,12 +30,136 @@
/* the rcs ID and its dummy function to use it */
static const char *rcsid = "$Header$";
-CCTK_FILEVERSION(CactusBase_Boundary_FlatBoundary_c)
+CCTK_FILEVERSION(CactusBase_Boundary_FlatBoundary_c);
+
+static int ApplyBndFlat (const cGH *GH,
+ int stencil_dir,
+ const int *stencil_alldirs,
+ int dir,
+ int first_var,
+ int num_vars);
/********************************************************************
******************** External Routines ************************
********************************************************************/
+/*@@
+ @routine BndFlat
+ @date 13 Feb 2003
+ @author David Rideout
+ @desc
+ Top level function which is registered as handling
+ the Flat boundary condition
+ @enddesc
+ @calls ApplyBndFlat
+ @var GH
+ @vdesc Pointer to CCTK grid hierarchy
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var num_vars
+ @vdesc number of variables passed in through var_indices[]
+ @vtype int
+ @vio in
+ @endvar
+ @var var_indices
+ @vdesc array of variable indicies to which to apply this boundary
+ condition
+ @vtype int *
+ @vio in
+ @endvar
+ @var faces
+ @vdesc array of set of faces to which to apply the bc
+ @vtype int
+ @vio in
+ @endvar
+ @var table_handles
+ @vdesc array of table handles which hold extra arguments
+ @vtype int
+ @vio in
+ @endvar
+ @returntype int
+ @returndesc
+ return code of @seeroutine ApplyBndScalar
+ @endreturndesc
+@@*/
+
+int BndFlat(const cGH *GH, int num_vars, int *vars, int *faces, int *tables)
+{
+ int i, j, k, gdim, max_gdim, err, retval;
+
+ /* variables to pass to ApplyBndFlat */
+ /*int stencil_dir;*/ /* width of stencil in direction dir, not needed */
+ int *stencil_alldirs; /* width of stencil in all directions */
+ int dir; /* direction in which to apply bc */
+
+ retval = 0; stencil_alldirs = NULL;
+
+ /* loop through variables, j at a time */
+ for (i=0; i<num_vars; i+=j) {
+
+ /* find other adjacent vars which are selected for identical bcs */
+ j=1;
+ while (i+j<num_vars && vars[i+j]==vars[i]+j && tables[i+j]==tables[i] &&
+ faces[i+j]==faces[i])
+ {
+ ++j;
+ }
+
+ /* Check to see if faces specification is valid */
+ if (faces[i] != CCTK_ALL_FACES)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Faces specification %d for Flat boundary conditions on "
+ "%s is not implemented yet. "
+ "Applying radiative bcs to all (external) faces.", faces[i],
+ CCTK_VarName(vars[i]));
+ }
+ dir = 0; /* apply bc to all faces */
+
+ /* Set up default arguments for ApplyBndFlat */
+ /* Allocate memory and populate stencil width array */
+ gdim = CCTK_GroupDimFromVarI(vars[i]);
+ if (!stencil_alldirs)
+ {
+ stencil_alldirs = (int *) malloc(gdim*sizeof(int));
+ max_gdim = gdim;
+ } else if (gdim > max_gdim)
+ {
+ realloc(stencil_alldirs, gdim*sizeof(int));
+ max_gdim = gdim;
+ }
+ for (k=0; k<gdim; ++k)
+ {
+ stencil_alldirs[k] = 1;
+ }
+
+ /* Look on table for possible non-default arguments
+ * (If any of these table look-ups fail, the value will be unchanged
+ * from its default value)
+ */
+ /* Stencil width array */
+ err = Util_TableGetIntArray(tables[i], gdim, stencil_alldirs,
+ "STENCIL WIDTH");
+ if (err == UTIL_ERROR_BAD_HANDLE)
+ {
+ CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Invalid table handle passed for Flat boundary "
+ "conditions for %s. Using all default values.",
+ CCTK_VarName(vars[i]));
+ }
+
+ if ((retval = ApplyBndFlat(GH, 0, stencil_alldirs, dir, vars[i], j)) < 0)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "ApplyBndFlat() returned %d", retval);
+ }
+ }
+ free(stencil_alldirs);
+
+ return retval;
+}
+
/* prototypes for external C routines are declared in header Boundary.h
here only follow the fortran wrapper prototypes */
void CCTK_FCALL CCTK_FNAME (BndFlatDirGI)
@@ -84,13 +211,6 @@ void CCTK_FCALL CCTK_FNAME (BndFlatVN)
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static int ApplyBndFlat (const cGH *GH,
- int stencil_dir,
- const int *stencil_alldirs,
- int dir,
- int first_var,
- int num_vars);
-
/*@@
@routine BndFlatDirGI
diff --git a/src/RadiationBoundary.c b/src/RadiationBoundary.c
index 7f83635..aee8f52 100644
--- a/src/RadiationBoundary.c
+++ b/src/RadiationBoundary.c
@@ -142,7 +142,7 @@ static int ApplyBndRadiative (const cGH *GH,
int BndRadiative(const cGH *GH, int num_vars, int *vars, int *faces,
int *tables)
{
- int i, j, k, value_type, value_size, err, prev_time_level,
+ int i, j, k, value_type, value_size, err,
gdim, max_gdim, retval;
char *prev_time_level_name;
@@ -151,6 +151,7 @@ int BndRadiative(const cGH *GH, int num_vars, int *vars, int *faces,
int *stencil_alldirs; /* width of stencil in all directions */
int dir; /* direction in which to apply bc */
CCTK_REAL limit, speed;
+ int prev_time_level; /* variable (index) which holds the previous time level */
#ifdef DEBUG
printf("BndRadiative(): got passed GH=%p, num_vars=%d, var_indices[0]=%d, table_handles[0]=%d\n", (const void *) GH, num_vars, var_indices[0], table_handles[0]);
@@ -173,7 +174,7 @@ int BndRadiative(const cGH *GH, int num_vars, int *vars, int *faces,
if (faces[i] != CCTK_ALL_FACES)
{
CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Faces specification %d for radiative boundary conditions on "
+ "Faces specification %d for Radiative boundary conditions on "
"%s is not implemented yet. "
"Applying radiative bcs to all (external) faces.", faces[i],
CCTK_VarName(vars[i]));
@@ -227,6 +228,7 @@ int BndRadiative(const cGH *GH, int num_vars, int *vars, int *faces,
Util_TableGetString(tables[i], value_size, prev_time_level_name,
"PREVIOUS TIME LEVEL");
prev_time_level = CCTK_VarIndex(prev_time_level_name);
+ free(prev_time_level_name);
} else if (value_type==CCTK_VARIABLE_INT)
{
Util_TableGetInt(tables[i], &prev_time_level,
diff --git a/src/Register.c b/src/Register.c
index c060b72..0bd0252 100644
--- a/src/Register.c
+++ b/src/Register.c
@@ -10,6 +10,7 @@
#include "cctk.h"
#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
#include "util_Table.h"
#include "Boundary.h"
@@ -28,7 +29,7 @@ CCTK_FILEVERSION(CactusBase_Boundary_Register_c);
void Boundary_RegisterBCs(CCTK_ARGUMENTS);
/********************************************************************
- ***************** Aliased Routine Prototypes *********************
+ ***************** Aliased Routine Prototypes ***********************
********************************************************************/
/********************************************************************
@@ -44,11 +45,11 @@ void Boundary_RegisterBCs(CCTK_ARGUMENTS);
********************************************************************/
/********************************************************************
- ********************* Aliased Routines **********************
+ ********************* Aliased Routines ***********************
********************************************************************/
/********************************************************************
- ********************* Scheduled Routines **********************
+ ********************* Scheduled Routines *********************
********************************************************************/
/*@@
@@ -70,22 +71,79 @@ void Boundary_RegisterBCs(CCTK_ARGUMENTS);
@@*/
void Boundary_RegisterBCs(CCTK_ARGUMENTS) {
- int err;
-
- err = Boundary_RegisterPhysicalBC(cctkGH, (CCTK_FPOINTER) &BndRadiative,
- "Radiative");
- if (err) {
- CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Boundary_RegisterPhysicalBC(cctkGH, &BndRadiative, "
- "\"Radiative\") returned %d", err);
+ DECLARE_CCTK_PARAMETERS;
+ int err;
+
+ if (register_scalar)
+ {
+ err = Boundary_RegisterPhysicalBC(cctkGH, (CCTK_FPOINTER) &BndScalar,
+ "Scalar");
+ if (err)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Error %d when registering routine to handle \"Scalar\" "
+ "boundary condition", err);
+ }
}
- err = Boundary_RegisterPhysicalBC(cctkGH, (CCTK_FPOINTER) &BndNone,
- "None");
- if (err) {
- CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Boundary_RegisterPhysicalBC(cctkGH, &BndNone, "
- "\"None\") returned %d", err);
+ if (register_radiation)
+ {
+ err = Boundary_RegisterPhysicalBC(cctkGH, (CCTK_FPOINTER) &BndRadiative,
+ "Radiative");
+ if (err)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Error %d when registering routine to handle \"Radiative\" "
+ "boundary condition", err);
+ }
+ }
+
+ if (register_copy)
+ {
+ err = Boundary_RegisterPhysicalBC(cctkGH, (CCTK_FPOINTER) &BndCopy,
+ "Copy");
+ if (err)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Error %d when registering routine to handle \"Copy\" "
+ "boundary condition", err);
+ }
+ }
+
+ if (register_robin)
+ {
+ err = Boundary_RegisterPhysicalBC(cctkGH, (CCTK_FPOINTER) &BndRobin,
+ "Robin");
+ if (err)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Error %d when registering routine to handle \"Robin\" "
+ "boundary condition", err);
+ }
+ }
+
+ if (register_static)
+ {
+ err = Boundary_RegisterPhysicalBC(cctkGH, (CCTK_FPOINTER) &BndStatic,
+ "Static");
+ if (err)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Error %d when registering routine to handle \"Static\" "
+ "boundary condition", err);
+ }
+ }
+
+ if (register_none)
+ {
+ err = Boundary_RegisterPhysicalBC(cctkGH, (CCTK_FPOINTER) &BndNone,
+ "None");
+ if (err)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Error %d when registering routine to handle \"None\" "
+ "boundary condition", err);
+ }
}
}
diff --git a/src/RobinBoundary.c b/src/RobinBoundary.c
index 9e1c963..3efe8f4 100644
--- a/src/RobinBoundary.c
+++ b/src/RobinBoundary.c
@@ -18,6 +18,9 @@
#include <string.h>
#include "cctk.h"
+#include "cctk_Faces.h"
+#include "util_Table.h"
+#include "util_ErrorCodes.h"
#include "cctk_Parameters.h"
#include "cctk_FortranString.h"
@@ -26,12 +29,151 @@
/* the rcs ID and its dummy function to use it */
static const char *rcsid = "$Header$";
-CCTK_FILEVERSION(CactusBase_Boundary_RobinBoundary_c)
+CCTK_FILEVERSION(CactusBase_Boundary_RobinBoundary_c);
+
+static int ApplyBndRobin (const cGH *GH,
+ const int *stencil,
+ CCTK_REAL finf,
+ int npow,
+ int first_var,
+ int num_vars);
/********************************************************************
******************** External Routines ************************
********************************************************************/
+/*@@
+ @routine BndRobin
+ @date 14 Feb 2003
+ @author David Rideout
+ @desc
+ Top level function which is registered as handling
+ this boundary condition
+ @enddesc
+ @calls ApplyBndRobin
+ @var GH
+ @vdesc Pointer to CCTK grid hierarchy
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var num_vars
+ @vdesc number of variables passed in through var_indices[]
+ @vtype int
+ @vio in
+ @endvar
+ @var var_indices
+ @vdesc array of variable indicies to which to apply this boundary
+ condition
+ @vtype int *
+ @vio in
+ @endvar
+ @var faces
+ @vdesc array of set of faces to which to apply the bc
+ @vtype int
+ @vio in
+ @endvar
+ @var table_handles
+ @vdesc array of table handles which hold extra arguments
+ @vtype int
+ @vio in
+ @endvar
+ @returntype int
+ @returndesc
+ return code of @seeroutine ApplyBndRobin <BR>
+ @endreturndesc
+@@*/
+
+int BndRobin(const cGH *GH, int num_vars, int *vars, int *faces, int *tables)
+{
+ int i, j, k, err, gdim, max_gdim, retval;
+
+ /* variables to pass to ApplyBndRobin */
+ int *stencil; /* width of stencil in all directions */
+ CCTK_REAL finf; /* value of function at infinity */
+ int npow; /* decay rate */
+
+#ifdef DEBUG
+ printf("BndRobin(): got passed GH=%p, num_vars=%d, var_indices[0]=%d, table_handles[0]=%d\n", (const void *) GH, num_vars, var_indices[0], table_handles[0]);
+#endif
+
+ retval = 0; stencil = NULL;
+
+ /* loop through variables, j at a time */
+ for (i=0; i<num_vars; i+=j) {
+
+ /* find other adjacent vars which are selected for identical bcs */
+ j=1;
+ while (i+j<num_vars && vars[i+j]==vars[i]+j && tables[i+j]==tables[i] &&
+ faces[i+j]==faces[i])
+ {
+ ++j;
+ }
+
+ /* Check to see if faces specification is valid */
+ if (faces[i] != CCTK_ALL_FACES)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Faces specification %d for Robin boundary conditions on "
+ "%s is not implemented yet. "
+ "Applying radiative bcs to all (external) faces.", faces[i],
+ CCTK_VarName(vars[i]));
+ }
+
+ /* Set up default arguments for ApplyBndRobin */
+ /* Allocate memory and populate stencil width array */
+ gdim = CCTK_GroupDimFromVarI(vars[i]);
+ if (!stencil)
+ {
+ stencil = (int *) malloc(gdim*sizeof(int));
+ max_gdim = gdim;
+ } else if (gdim > max_gdim)
+ {
+ realloc(stencil, gdim*sizeof(int));
+ max_gdim = gdim;
+ }
+ for (k=0; k<gdim; ++k)
+ {
+ stencil[k] = 1;
+ }
+ /* Defaults for remainder of arguments */
+ finf = 1.;
+ npow = 1;
+
+ /* Look on table for possible non-default arguments
+ * (If any of these table look-ups fail, the value will be unchanged
+ * from its default value)
+ */
+ /* Asymptotic value of function at infinity */
+ err = Util_TableGetReal(tables[i], &finf, "FINF");
+ if (err == UTIL_ERROR_BAD_HANDLE)
+ {
+ CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Invalid table handle passed for Robin boundary "
+ "conditions for %s. Using all default values.",
+ CCTK_VarName(vars[i]));
+ } else
+ {
+ /* Stencil width array */
+ Util_TableGetIntArray(tables[i], gdim, stencil, "STENCIL WIDTH");
+
+ /* Decay power */
+ Util_TableGetInt(tables[i], &npow, "DECAY POWER");
+ }
+
+ if ((retval = ApplyBndRobin(GH, stencil, finf, npow, vars[i], j)) < 0)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "ApplyBndRobin() returned %d", retval);
+ }
+ }
+#ifdef DEBUG
+ printf("BndRobin(): returning %d\n",retval);
+#endif
+ free(stencil);
+
+ return retval;
+}
+
/* prototypes for external C routines are declared in header Boundary.h
here only follow the fortran wrapper prototypes */
void CCTK_FCALL CCTK_FNAME (BndRobinGI)
@@ -67,13 +209,6 @@ void CCTK_FCALL CCTK_FNAME (BndRobinVN)
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static int ApplyBndRobin (const cGH *GH,
- const int *stencil,
- CCTK_REAL finf,
- int npow,
- int first_var,
- int num_vars);
-
/*@@
@routine BndRobinGI
@@ -112,7 +247,7 @@ static int ApplyBndRobin (const cGH *GH,
@returntype int
@returndesc
- return code of @seeroutine ApplyBndRobin <BR>
+ return code of @seeroutine ApplyBndRobin
-1 if invalid group index was given
@endreturndesc
@@*/
diff --git a/src/ScalarBoundary.c b/src/ScalarBoundary.c
index 01d78ca..88fa8c9 100644
--- a/src/ScalarBoundary.c
+++ b/src/ScalarBoundary.c
@@ -17,6 +17,9 @@
#include <string.h>
#include "cctk.h"
+#include "cctk_Faces.h"
+#include "util_Table.h"
+#include "util_ErrorCodes.h"
#include "cctk_Parameters.h"
#include "cctk_FortranString.h"
@@ -25,12 +28,144 @@
/* the rcs ID and its dummy function to use it */
static const char *rcsid = "$Header$";
-CCTK_FILEVERSION(CactusBase_Boundary_ScalarBoundary_c)
+CCTK_FILEVERSION(CactusBase_Boundary_ScalarBoundary_c);
+static int ApplyBndScalar (const cGH *GH,
+ int stencil_dir,
+ const int *stencil_alldirs,
+ int dir,
+ CCTK_REAL scalar,
+ int first_var,
+ int num_vars);
/********************************************************************
******************** External Routines ************************
********************************************************************/
+
+/*@@
+ @routine BndScalar
+ @date 13 Feb 2003
+ @author David Rideout
+ @desc
+ Top level function which is registered as handling
+ the Scalar boundary condition
+ @enddesc
+ @calls ApplyBndScalar
+ @var GH
+ @vdesc Pointer to CCTK grid hierarchy
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var num_vars
+ @vdesc number of variables passed in through var_indices[]
+ @vtype int
+ @vio in
+ @endvar
+ @var var_indices
+ @vdesc array of variable indicies to which to apply this boundary
+ condition
+ @vtype int *
+ @vio in
+ @endvar
+ @var faces
+ @vdesc array of set of faces to which to apply the bc
+ @vtype int
+ @vio in
+ @endvar
+ @var table_handles
+ @vdesc array of table handles which hold extra arguments
+ @vtype int
+ @vio in
+ @endvar
+ @returntype int
+ @returndesc
+ return code of @seeroutine ApplyBndScalar
+ @endreturndesc
+@@*/
+
+int BndScalar(const cGH *GH, int num_vars, int *vars, int *faces, int *tables)
+{
+ int i, j, k, gdim, max_gdim, err, retval;
+
+ /* variables to pass to ApplyBndScalar */
+ /*int stencil_dir;*/ /* width of stencil in direction dir, not needed */
+ int *stencil_alldirs; /* width of stencil in all directions */
+ int dir; /* direction in which to apply bc */
+ CCTK_REAL scalar;
+
+ retval = 0; stencil_alldirs = NULL;
+
+ /* loop through variables, j at a time */
+ for (i=0; i<num_vars; i+=j) {
+
+ /* find other adjacent vars which are selected for identical bcs */
+ j=1;
+ while (i+j<num_vars && vars[i+j]==vars[i]+j && tables[i+j]==tables[i] &&
+ faces[i+j]==faces[i])
+ {
+ ++j;
+ }
+
+ /* Check to see if faces specification is valid */
+ if (faces[i] != CCTK_ALL_FACES)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Faces specification %d for Scalar boundary conditions on "
+ "%s is not implemented yet. "
+ "Applying radiative bcs to all (external) faces.", faces[i],
+ CCTK_VarName(vars[i]));
+ }
+ dir = 0; /* apply bc to all faces */
+
+ /* Set up default arguments for ApplyBndScalar */
+ /* Allocate memory and populate stencil width array */
+ gdim = CCTK_GroupDimFromVarI(vars[i]);
+ if (!stencil_alldirs)
+ {
+ stencil_alldirs = (int *) malloc(gdim*sizeof(int));
+ max_gdim = gdim;
+ } else if (gdim > max_gdim)
+ {
+ realloc(stencil_alldirs, gdim*sizeof(int));
+ max_gdim = gdim;
+ }
+ for (k=0; k<gdim; ++k)
+ {
+ stencil_alldirs[k] = 1;
+ }
+ /* Defaults for remainder of arguments */
+ scalar = 0.;
+
+ /* Look on table for possible non-default arguments
+ * (If any of these table look-ups fail, the value will be unchanged
+ * from its default value)
+ */
+ /* Scalar value */
+ err = Util_TableGetReal(tables[i], &scalar, "SCALAR");
+ if (err == UTIL_ERROR_BAD_HANDLE)
+ {
+ CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Invalid table handle passed for Scalar boundary "
+ "conditions for %s. Using all default values.",
+ CCTK_VarName(vars[i]));
+ } else
+ {
+ /* Stencil width array */
+ Util_TableGetIntArray(tables[i], gdim, stencil_alldirs, "STENCIL WIDTH");
+ }
+
+ if ((retval = ApplyBndScalar(GH, 0, stencil_alldirs, dir, scalar, vars[i],
+ j)) < 0)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "ApplyBndScalar() returned %d", retval);
+ }
+ }
+ free(stencil_alldirs);
+
+ return retval;
+}
+
/* prototypes for external C routines are declared in header Boundary.h
here only follow the fortran wrapper prototypes */
void CCTK_FCALL CCTK_FNAME (BndScalarDirVI)
@@ -89,15 +224,6 @@ void CCTK_FCALL CCTK_FNAME (BndScalarVN)
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static int ApplyBndScalar (const cGH *GH,
- int stencil_dir,
- const int *stencil_alldirs,
- int dir,
- CCTK_REAL scalar,
- int first_var,
- int num_vars);
-
-
/*@@
@routine BndScalarDirVI
@date Tue Jan 16 2001
diff --git a/src/StaticBoundary.c b/src/StaticBoundary.c
index 873bbc7..e36f95a 100644
--- a/src/StaticBoundary.c
+++ b/src/StaticBoundary.c
@@ -12,6 +12,9 @@
#include <string.h>
#include "cctk.h"
+#include "cctk_Faces.h"
+#include "util_Table.h"
+#include "util_ErrorCodes.h"
#include "cctk_FortranString.h"
#include "Symmetry.h"
@@ -19,12 +22,143 @@
/* the rcs ID and its dummy function to use it */
static const char *rcsid = "$Header$";
-CCTK_FILEVERSION(CactusBase_Boundary_StaticBoundary_c)
+CCTK_FILEVERSION(CactusBase_Boundary_StaticBoundary_c);
+
+static int ApplyBndStatic (const cGH *GH,
+ int stencil_dir,
+ const int *stencil_alldirs,
+ int dir,
+ int first_var,
+ int num_vars);
/********************************************************************
******************** External Routines ************************
********************************************************************/
+/*@@
+ @routine BndStatic
+ @date 14 Feb 2003
+ @author David Rideout
+ @desc
+ Top level function which is registered as handling
+ this boundary condition
+ @enddesc
+ @calls ApplyBndStatic
+ @var GH
+ @vdesc Pointer to CCTK grid hierarchy
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var num_vars
+ @vdesc number of variables passed in through var_indices[]
+ @vtype int
+ @vio in
+ @endvar
+ @var var_indices
+ @vdesc array of variable indicies to which to apply this boundary
+ condition
+ @vtype int *
+ @vio in
+ @endvar
+ @var faces
+ @vdesc array of set of faces to which to apply the bc
+ @vtype int
+ @vio in
+ @endvar
+ @var table_handles
+ @vdesc array of table handles which hold extra arguments
+ @vtype int
+ @vio in
+ @endvar
+ @returntype int
+ @returndesc
+ return code of @seeroutine ApplyBndStatic <BR>
+ @endreturndesc
+@@*/
+
+int BndStatic(const cGH *GH, int num_vars, int *vars, int *faces, int *tables)
+{
+ int i, j, k, err, gdim, max_gdim, retval;
+
+ /* variables to pass to ApplyBndStatic */
+ /*int stencil_dir;*/ /* width of stencil in direction dir, not needed */
+ int *stencil; /* width of stencil in all directions */
+ int dir; /* direction in which to apply bc */
+
+#ifdef DEBUG
+ printf("BndStatic(): got passed GH=%p, num_vars=%d, var_indices[0]=%d, table_handles[0]=%d\n", (const void *) GH, num_vars, var_indices[0], table_handles[0]);
+#endif
+
+ retval = 0; stencil = NULL;
+
+ /* loop through variables, j at a time */
+ for (i=0; i<num_vars; i+=j) {
+
+ /* find other adjacent vars which are selected for identical bcs */
+ j=1;
+ while (i+j<num_vars && vars[i+j]==vars[i]+j && tables[i+j]==tables[i] &&
+ faces[i+j]==faces[i])
+ {
+ ++j;
+ }
+
+ /* Check to see if faces specification is valid */
+ if (faces[i] != CCTK_ALL_FACES)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Faces specification %d for Static boundary conditions on "
+ "%s is not implemented yet. "
+ "Applying radiative bcs to all (external) faces.", faces[i],
+ CCTK_VarName(vars[i]));
+ }
+ dir = 0;
+
+ /* Set up default arguments for ApplyBndStatic */
+ /* Allocate memory and populate stencil width array */
+ gdim = CCTK_GroupDimFromVarI(vars[i]);
+ if (!stencil)
+ {
+ stencil = (int *) malloc(gdim*sizeof(int));
+ max_gdim = gdim;
+ } else if (gdim > max_gdim)
+ {
+ realloc(stencil, gdim*sizeof(int));
+ max_gdim = gdim;
+ }
+ for (k=0; k<gdim; ++k)
+ {
+ stencil[k] = 1;
+ }
+
+ /* Look on table for possible non-default arguments
+ * (If any of these table look-ups fail, the value will be unchanged
+ * from its default value)
+ */
+ /* Stencil width array */
+ err = Util_TableGetIntArray(tables[i], gdim, stencil, "STENCIL WIDTH");
+ if (err == UTIL_ERROR_BAD_HANDLE)
+ {
+ CCTK_VWarn(3, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Invalid table handle passed for Static boundary "
+ "conditions for %s. Using all default values.",
+ CCTK_VarName(vars[i]));
+ }
+
+ if ((retval = ApplyBndStatic(GH, 0, stencil, dir, vars[i], j)) < 0)
+ {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "ApplyBndStatic() returned %d", retval);
+ }
+ }
+#ifdef DEBUG
+ printf("BndStatic(): returning %d\n",retval);
+#endif
+ free(stencil);
+
+ return retval;
+}
+
+
/* prototypes for external C routines are declared in header Boundary.h
here only follow the fortran wrapper prototypes */
void CCTK_FCALL CCTK_FNAME (BndStaticDirVI)
@@ -76,13 +210,6 @@ void CCTK_FCALL CCTK_FNAME (BndStaticGN)
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static int ApplyBndStatic (const cGH *GH,
- int stencil_dir,
- const int *stencil_alldirs,
- int dir,
- int first_var,
- int num_vars);
-
/*@@
@routine BndStaticDirVI