diff options
author | rideout <rideout@eec4d7dc-71c2-46d6-addf-10296150bf52> | 2003-01-08 19:05:36 +0000 |
---|---|---|
committer | rideout <rideout@eec4d7dc-71c2-46d6-addf-10296150bf52> | 2003-01-08 19:05:36 +0000 |
commit | f17b4ea1b3f576723e3baba5aeb5c155415cbc34 (patch) | |
tree | 009ea786abb2b193e29c96c671ac8d442f48c850 /src | |
parent | 60f46b24f30e5494aab515cd48abe686e2d17836 (diff) |
Routine to execute the Cartoon bcs on all selected vars.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Cartoon2D/trunk@64 eec4d7dc-71c2-46d6-addf-10296150bf52
Diffstat (limited to 'src')
-rw-r--r-- | src/ApplyCartoon.c | 174 | ||||
-rw-r--r-- | src/Cartoon2D.h | 10 | ||||
-rw-r--r-- | src/make.code.defn | 3 |
3 files changed, 185 insertions, 2 deletions
diff --git a/src/ApplyCartoon.c b/src/ApplyCartoon.c new file mode 100644 index 0000000..9238bb0 --- /dev/null +++ b/src/ApplyCartoon.c @@ -0,0 +1,174 @@ + /*@@ + @file ApplyCartoon.c + @date 6 Jan 2003 + @author David Rideout + @desc + Applies the Cartoon boundary condition to all variables + selected for a bc. + @enddesc + @version $Header$ + @@*/ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "util_Table.h" +#include "Cartoon2D.h" +#include "Cartoon2D_tensors.h" +#include <stdlib.h> + +static const char *rcsid = "$Header$"; + +CCTK_FILEVERSION(BetaThorns_Cartoon2D_ApplyCartoon_c); + +/******************************************************************** + ********************* Local Data Types *********************** + ********************************************************************/ +/* #define DEBUG 1 */ +#define TENSORTYPE_BUFF_SIZE 7 + +/******************************************************************** + ********************* Local Routine Prototypes ********************* + ********************************************************************/ + +/******************************************************************** + ***************** Aliased Routine Prototypes *********************** + ********************************************************************/ + +/******************************************************************** + ***************** Scheduled Routine Prototypes ********************* + ********************************************************************/ + +void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS); + +/******************************************************************** + ********************* Other Routine Prototypes ********************* + ********************************************************************/ + +/******************************************************************** + ********************* Local Data ***************************** + ********************************************************************/ + +/******************************************************************** + ********************* Aliased Routines ********************** + ********************************************************************/ + +/******************************************************************** + ********************* Scheduled Routines ********************** + ********************************************************************/ + + /*@@ + @routine Cartoon_ApplyBoundaries + @date 6 Jan 2003 + @author David Rideout + @desc + This will apply the Cartoon boundary condition to all + variables selected for any (physical) boundary condition. + @enddesc + @calls + @history + @endhistory + @var CCTK_ARGUMENTS + @vdesc Cactus argument list + @vtype CCTK_* + @vio in + @endvar + @returntype void + @returndesc + @endreturndesc +@@*/ + +void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS) { + DECLARE_CCTK_ARGUMENTS; + int num_vars, *vars, *tables, err, i, gi, group_tags_table; + char tensortype[TENSORTYPE_BUFF_SIZE]; + + /* Allocate memory to hold selected bcs */ + num_vars = Boundary_SelectedGVs(cctkGH, 0, NULL, NULL, NULL); +#ifdef DEBUG + printf("Cartoon_ApplyBoundaries: num_vars is %d\n",num_vars); +#endif + vars = (int *) malloc(num_vars*sizeof(int)); + tables = (int *) malloc(num_vars*sizeof(int)); + + /* get all selected vars */ + err = Boundary_SelectedGVs(cctkGH, num_vars, vars, tables, NULL); + if (err != num_vars) + { + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Boundary_SelectedGVs returned %d selected variables, but %d " + "expected", err, num_vars); + } + + /* Apply CartoonBC to each of them. */ + /* One should probably check to see that the entire group has been + * selected, since Cartoon operates on an entire group at a time. + * For now I'll just skip a variable if it is not a 'group leader'. + */ + for (i=0; i<num_vars; ++i) { +#ifdef DEBUG + printf("Cartoon_ApplyBoundaries: i=%d applying cartoon to vi %d\n",i, + vars[i]); +#endif + gi = CCTK_GroupIndexFromVarI(vars[i]); + if (gi<0) { + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Invalid variable index %d registered for a boundary " + "condition", gi); + } + if (vars[i] != CCTK_FirstVarIndexI(gi)) + { + /* not a group leader -- skip to next var index */ + continue; + } + + /* Here one should check that the entire group is registered, + * using CCTK_NumVarsInGroupI. + */ + + /* Get table handle for group tags table */ + group_tags_table = CCTK_GroupTagsTableI(gi); + if (group_tags_table<0) { + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Tags table for variable group %s is %d", CCTK_GroupName(gi), + group_tags_table); + } + + /* Get tensor type from group tags table */ + err = Util_TableGetString(group_tags_table, TENSORTYPE_BUFF_SIZE, + tensortype, "tensortypealias"); + if (err<0) + { + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Error in TAGS table for variable group %s", + CCTK_GroupName(gi)); + } +#ifdef DEBUG + printf("Cartoon_ApplyBoundaries: tensor type is %s\n",tensortype); +#endif + + /* Here one should check that the group's size is correct for the + * specified tensortype. + */ + + /* Call BndCartoon2DVI, passing the appropriate tensor type integer + macro */ + if (CCTK_Equals(tensortype, "scalar")) + { + BndCartoon2DVI(cctkGH, TENSORTYPE_SCALAR, vars[i]); + } else if (CCTK_Equals(tensortype, "u")) + { + BndCartoon2DVI(cctkGH, TENSORTYPE_U, vars[i]); + } else if (CCTK_Equals(tensortype, "dd_sym")) + { + BndCartoon2DVI(cctkGH, TENSORTYPE_DDSYM, vars[i]); + } else + { + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "invalid tensor type for group %s", CCTK_GroupName(gi)); + } + } + + /* Free data */ + free(vars); + free(tables); +} diff --git a/src/Cartoon2D.h b/src/Cartoon2D.h new file mode 100644 index 0000000..930c647 --- /dev/null +++ b/src/Cartoon2D.h @@ -0,0 +1,10 @@ +/* Function prototypes */ +#ifdef __cplusplus +extern "C" { +#endif + +int BndCartoon2DVI(const cGH *GH, int tensortype, int vi); + +#ifdef __cplusplus +} +#endif diff --git a/src/make.code.defn b/src/make.code.defn index b277a29..fa17e28 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -2,8 +2,7 @@ # $Header$ # Source files in this directory -SRCS = CheckParameters.c Cartoon2DBC.c interpolate.c SetSym.c SetGrid.c +SRCS = CheckParameters.c Cartoon2DBC.c interpolate.c SetSym.c SetGrid.c ApplyCartoon.c # Subdirectories containing source files SUBDIRS = - |