From f93380441909a9c02fd7002a7071ee2f0b519f2f Mon Sep 17 00:00:00 2001 From: rideout Date: Fri, 14 Feb 2003 00:46:06 +0000 Subject: 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 --- src/Boundary.h | 35 ++++++++-- src/CopyBoundary.c | 176 +++++++++++++++++++++++++++++++++++++++++++++--- src/FlatBoundary.c | 136 ++++++++++++++++++++++++++++++++++--- src/RadiationBoundary.c | 6 +- src/Register.c | 92 ++++++++++++++++++++----- src/RobinBoundary.c | 153 ++++++++++++++++++++++++++++++++++++++--- src/ScalarBoundary.c | 146 ++++++++++++++++++++++++++++++++++++--- src/StaticBoundary.c | 143 ++++++++++++++++++++++++++++++++++++--- 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 #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 max_gdim) + { + realloc(stencil_alldirs, gdim*sizeof(int)); + max_gdim = gdim; + } + for (k=0; k #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 max_gdim) + { + realloc(stencil_alldirs, gdim*sizeof(int)); + max_gdim = gdim; + } + for (k=0; k #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
+ @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 max_gdim) + { + realloc(stencil, gdim*sizeof(int)); + max_gdim = gdim; + } + for (k=0; k + 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 #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 max_gdim) + { + realloc(stencil_alldirs, gdim*sizeof(int)); + max_gdim = gdim; + } + for (k=0; k #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
+ @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 max_gdim) + { + realloc(stencil, gdim*sizeof(int)); + max_gdim = gdim; + } + for (k=0; k