diff options
author | rideout <rideout@6a38eb6e-646e-4a02-a296-d141613ad6c4> | 2003-02-13 14:15:30 +0000 |
---|---|---|
committer | rideout <rideout@6a38eb6e-646e-4a02-a296-d141613ad6c4> | 2003-02-13 14:15:30 +0000 |
commit | c9c45374ea511044d367b86cf677220862629464 (patch) | |
tree | 5fc9fb3e74f71f9f2a1a997e07370ed9aca9c174 | |
parent | b34d42fa292da448b9a16ff5fab86960fac040b4 (diff) |
Add faces argument where required.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Boundary/trunk@195 6a38eb6e-646e-4a02-a296-d141613ad6c4
-rw-r--r-- | src/Boundary.c | 155 | ||||
-rw-r--r-- | src/Boundary.h | 9 | ||||
-rw-r--r-- | src/NoneBoundary.c | 9 |
3 files changed, 112 insertions, 61 deletions
diff --git a/src/Boundary.c b/src/Boundary.c index 5fb842a..af9def7 100644 --- a/src/Boundary.c +++ b/src/Boundary.c @@ -12,6 +12,7 @@ #include <stdlib.h> #include "cctk.h" +#include "cctk_Faces.h" #include "cctk_Arguments.h" #include "util_Table.h" #include "util_String.h" @@ -27,7 +28,7 @@ CCTK_FILEVERSION(CactusBase_Boundary_Boundary_c); /* #define DEBUG 1 */ /* pointer to function which implements a physical boundary condition: */ -typedef int (*phys_bc_fn_ptr)(const cGH *, int, int *, int *); +typedef int (*phys_bc_fn_ptr)(const cGH *, int, int *, int *, int *); /* Linked list for holding variables selected for a bc: * Entries are sorted in the order they appear in struct BCVAR, @@ -39,6 +40,7 @@ struct BCVAR char *bc_name; /* CCTK_FPOINTER bc_fn_pointer; // store fn pointers, since they are easier to sort? */ + int faces; int table; int var_index; }; @@ -77,28 +79,33 @@ static int entry_less_than(struct BCVAR *new, struct BCVAR *current); ********************************************************************/ CCTK_INT Bdry_Boundary_RegisterPhysicalBC(CCTK_POINTER GH, - CCTK_FPOINTER fn_pointer, - CCTK_STRING bc_name); -CCTK_INT Bdry_Boundary_SelectVarForBC(CCTK_POINTER GH, - CCTK_INT table_handle, - CCTK_STRING var_name, + CCTK_FPOINTER fn_pointer, CCTK_STRING bc_name); +CCTK_INT Bdry_Boundary_SelectVarForBC(CCTK_POINTER GH, + CCTK_INT faces, + CCTK_INT table_handle, + CCTK_STRING var_name, + CCTK_STRING bc_name); CCTK_INT Bdry_Boundary_SelectVarForBCI(CCTK_POINTER GH, - CCTK_INT table_handle, - CCTK_INT var_index, - CCTK_STRING bc_name); -CCTK_INT Bdry_Boundary_SelectGroupForBC(CCTK_POINTER GH, - CCTK_INT table_handle, - CCTK_STRING group_name, - CCTK_STRING bc_name); + CCTK_INT faces, + CCTK_INT table_handle, + CCTK_INT var_index, + CCTK_STRING bc_name); +CCTK_INT Bdry_Boundary_SelectGroupForBC(CCTK_POINTER GH, + CCTK_INT faces, + CCTK_INT table_handle, + CCTK_STRING group_name, + CCTK_STRING bc_name); CCTK_INT Bdry_Boundary_SelectGroupForBCI(CCTK_POINTER GH, - CCTK_INT table_handle, - CCTK_INT group_index, - CCTK_STRING bc_name); + CCTK_INT faces, + CCTK_INT table_handle, + CCTK_INT group_index, + CCTK_STRING bc_name); CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER GH, CCTK_INT array_size, - CCTK_POINTER var_indices, - CCTK_POINTER table_handles, - CCTK_STRING bc_name); + CCTK_POINTER var_indices, + CCTK_POINTER faces, + CCTK_POINTER table_handles, + CCTK_STRING bc_name); /******************************************************************** ***************** Scheduled Routine Prototypes ********************* @@ -168,8 +175,8 @@ static struct BCDATA *bcdata_list = NULL; @endreturndesc @@*/ CCTK_INT Bdry_Boundary_RegisterPhysicalBC(CCTK_POINTER GH, - CCTK_FPOINTER fn_pointer, - CCTK_STRING bc_name) + CCTK_FPOINTER fn_pointer, + CCTK_STRING bc_name) { int retval; @@ -243,6 +250,11 @@ CCTK_INT Bdry_Boundary_RegisterPhysicalBC(CCTK_POINTER GH, @vtype CCTK_POINTER @vio in @endvar + @var faces + @vdesc set of faces to which to apply the boundary condition + @vtype CCTK_INT + @vio in + @endvar @var table_handle @vdesc handle of table which holds arguments to be passed to bc @vtype CCTK_INT @@ -252,7 +264,7 @@ CCTK_INT Bdry_Boundary_RegisterPhysicalBC(CCTK_POINTER GH, @vdesc name of variable to which to apply bc @vtype CCTK_STRING @vio in - @endvar + @endvar @var bc_name @vdesc name of bc to apply @vtype CCTK_STRING @@ -266,9 +278,10 @@ CCTK_INT Bdry_Boundary_RegisterPhysicalBC(CCTK_POINTER GH, @endreturndesc @@*/ CCTK_INT Bdry_Boundary_SelectVarForBC(CCTK_POINTER GH, - CCTK_INT table_handle, - CCTK_STRING var_name, - CCTK_STRING bc_name) + CCTK_INT faces, + CCTK_INT table_handle, + CCTK_STRING var_name, + CCTK_STRING bc_name) { int retval, var_index; @@ -282,7 +295,7 @@ CCTK_INT Bdry_Boundary_SelectVarForBC(CCTK_POINTER GH, retval = -3; } else { - retval = Bdry_Boundary_SelectVarForBCI(GH, table_handle, var_index, + retval = Bdry_Boundary_SelectVarForBCI(GH, faces, table_handle, var_index, bc_name); } @@ -305,6 +318,11 @@ CCTK_INT Bdry_Boundary_SelectVarForBC(CCTK_POINTER GH, @vtype CCTK_POINTER @vio in @endvar + @var faces + @vdesc set of faces to which to apply the boundary condition + @vtype CCTK_INT + @vio in + @endvar @var table_handle @vdesc handle of table which holds arguments to be passed to bc @vtype CCTK_INT @@ -329,9 +347,10 @@ CCTK_INT Bdry_Boundary_SelectVarForBC(CCTK_POINTER GH, @endreturndesc @@*/ CCTK_INT Bdry_Boundary_SelectVarForBCI(CCTK_POINTER GH, - CCTK_INT table_handle, - CCTK_INT var_index, - CCTK_STRING bc_name) + CCTK_INT faces, + CCTK_INT table_handle, + CCTK_INT var_index, + CCTK_STRING bc_name) { int retval; struct BCVAR *new_entry; @@ -377,6 +396,7 @@ CCTK_INT Bdry_Boundary_SelectVarForBCI(CCTK_POINTER GH, /* populate new entry with data */ new_entry -> bc_name = Util_Strdup(bc_name); + new_entry -> faces = faces; new_entry -> table = table_handle; new_entry -> var_index = var_index; /* new_entry -> next_entry will be filled in later */ @@ -515,6 +535,8 @@ CCTK_INT Bdry_Boundary_SelectVarForBCI(CCTK_POINTER GH, @desc Used to select a Cactus variable group to have boundary conditions applied, using the group name. + Table handle and faces must be the same for each member of the + group. @enddesc @calls @history @@ -524,6 +546,11 @@ CCTK_INT Bdry_Boundary_SelectVarForBCI(CCTK_POINTER GH, @vtype CCTK_POINTER @vio in @endvar + @var faces + @vdesc set of faces to which to apply bc + @vtype CCTK_INT + @vio in + @endvar @var table_handle @vdesc handle of table which holds arguments to be passed to bc @vtype CCTK_INT @@ -547,9 +574,10 @@ CCTK_INT Bdry_Boundary_SelectVarForBCI(CCTK_POINTER GH, @endreturndesc @@*/ CCTK_INT Bdry_Boundary_SelectGroupForBC(CCTK_POINTER GH, - CCTK_INT table_handle, - CCTK_STRING group_name, - CCTK_STRING bc_name) + CCTK_INT faces, + CCTK_INT table_handle, + CCTK_STRING group_name, + CCTK_STRING bc_name) { int retval, gi; @@ -569,7 +597,7 @@ CCTK_INT Bdry_Boundary_SelectGroupForBC(CCTK_POINTER GH, } else { /* call Bdry_Boundary_SelectGroupForBCI() */ - retval = Bdry_Boundary_SelectGroupForBCI(GH, table_handle, gi, + retval = Bdry_Boundary_SelectGroupForBCI(GH, faces, table_handle, gi, bc_name); } @@ -592,6 +620,11 @@ CCTK_INT Bdry_Boundary_SelectGroupForBC(CCTK_POINTER GH, @vtype CCTK_POINTER @vio in @endvar + @var faces + @vdesc set of faces to which to apply bc + @vtype CCTK_INT + @vio in + @endvar @var table_handle @vdesc handle of table which holds arguments to be passed to bc @vtype CCTK_INT @@ -615,9 +648,10 @@ CCTK_INT Bdry_Boundary_SelectGroupForBC(CCTK_POINTER GH, @endreturndesc @@*/ CCTK_INT Bdry_Boundary_SelectGroupForBCI(CCTK_POINTER GH, - CCTK_INT table_handle, - CCTK_INT group_index, - CCTK_STRING bc_name) + CCTK_INT faces, + CCTK_INT table_handle, + CCTK_INT group_index, + CCTK_STRING bc_name) { int num_vars, vi, max_vi, retval; @@ -635,7 +669,8 @@ CCTK_INT Bdry_Boundary_SelectGroupForBCI(CCTK_POINTER GH, max_vi = vi + num_vars; for (; vi<max_vi; ++vi) { - retval = Bdry_Boundary_SelectVarForBCI(GH, table_handle, vi, bc_name); + retval = Bdry_Boundary_SelectVarForBCI(GH, faces, table_handle, vi, + bc_name); } return retval; @@ -667,6 +702,12 @@ CCTK_INT Bdry_Boundary_SelectGroupForBCI(CCTK_POINTER GH, @vtype CCTK_INT @vio out @endvar + @var faces + @vdesc array into which a set of selected faces for variables selected + for bc will be placed + @vtype CCTK_INT + @vio out + @endvar @var table_handles @vdesc array into which table_handles for variables selected for bc will be placed @@ -685,10 +726,11 @@ CCTK_INT Bdry_Boundary_SelectGroupForBCI(CCTK_POINTER GH, @endreturndesc @@*/ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER GH, - CCTK_INT array_size, - CCTK_POINTER var_indices, - CCTK_POINTER table_handles, - CCTK_STRING bc_name) + CCTK_INT array_size, + CCTK_POINTER var_indices, + CCTK_POINTER faces, + CCTK_POINTER table_handles, + CCTK_STRING bc_name) { int retval, i; struct BCVAR *current; @@ -713,7 +755,7 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER GH, #ifdef DEBUG printf("Boundary_SelectedGVs: looping through bcdata list\n" - " current_bcdata->bc_name=\"%s\"\n", + " current_bcdata->bc_name=\"%s\"\n", current_bcdata->bc_name); #endif @@ -748,8 +790,7 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER GH, } #ifdef DEBUG - printf("Boundary_SelectedGVs: initializing current to %p\n", - current); + printf("Boundary_SelectedGVs: initializing current to %p\n", current); #endif /* If current is still NULL, bc_name did not match any entry in the * bcdata list, i.e. no variables were selected for this bc. @@ -779,6 +820,7 @@ CCTK_INT Bdry_Boundary_SelectedGVs(CCTK_POINTER GH, { if (i < array_size) { + ((int *) faces)[i] = current->faces; ((int *) table_handles)[i] = current->table; ((int *) var_indices)[i] = current->var_index; } @@ -831,7 +873,7 @@ void Boundary_ApplyPhysicalBCs(CCTK_ARGUMENTS) { DECLARE_CCTK_ARGUMENTS; phys_bc_fn_ptr bc_fn; - int num_vars, *vars, *tables, err, max_num_vars; + int num_vars, *vars, *faces, *tables, err, max_num_vars; struct BCDATA *current_bcdata; max_num_vars = 0; @@ -856,18 +898,20 @@ void Boundary_ApplyPhysicalBCs(CCTK_ARGUMENTS) max_num_vars = num_vars; /* store new maximum */ if (vars) { - /* reallocate vars and tables if necessary */ + /* reallocate arrays if necessary */ realloc(vars, num_vars*sizeof(int)); + realloc(faces, num_vars*sizeof(int)); realloc(tables, num_vars*sizeof(int)); } else { vars = (int *) malloc(num_vars*sizeof(int)); + faces = (int *) malloc(num_vars*sizeof(int)); tables = (int *) malloc(num_vars*sizeof(int)); } } /* get selected vars for this bc_name*/ - err = Bdry_Boundary_SelectedGVs(cctkGH, num_vars, vars, tables, + err = Bdry_Boundary_SelectedGVs(cctkGH, num_vars, vars, faces, tables, current_bcdata->bc_name); if (err<0) /* This is a redundant test for now, Bdry_Boundary_SelectedGVs never returns <0 */ @@ -904,7 +948,7 @@ void Boundary_ApplyPhysicalBCs(CCTK_ARGUMENTS) " cctkGH %p, num_vars %d, vars, tables\n", (void *) bc_fn, (const void *) cctkGH, num_vars); #endif - err = (*bc_fn)(cctkGH, num_vars, vars, tables); + err = (*bc_fn)(cctkGH, num_vars, vars, faces, tables); if (err<0) { CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, @@ -917,6 +961,7 @@ void Boundary_ApplyPhysicalBCs(CCTK_ARGUMENTS) if (vars) { free(vars); + free(faces); free(tables); } } @@ -925,22 +970,22 @@ void Boundary_ApplyPhysicalBCs(CCTK_ARGUMENTS) @routine Boundary_ClearSelection @date Sun Nov 3 19:51:37 CET 2002 @author David Rideout - @desc + @desc Clears all boundary condition selections. - @enddesc - @calls - @history - @endhistory + @enddesc + @calls + @history + @endhistory @@*/ -void Boundary_ClearSelection(void) +void Boundary_ClearSelection(void) { struct BCVAR *current, *next; struct BCDATA *current_bcdata, *next_bcdata; /* Free selections list */ next = selections_list; - for (current = selections_list; next; current = next) + for (current = selections_list; next; current = next) { next = current->next_entry; free(current->bc_name); diff --git a/src/Boundary.h b/src/Boundary.h index 5db4b35..d4ae90a 100644 --- a/src/Boundary.h +++ b/src/Boundary.h @@ -18,7 +18,8 @@ extern "C" #endif /* prototype for routine registed as providing 'None' boundary condition */ -int BndNone(const cGH *GH, int num_vars, int *var_indicies, int *table_handle); +int BndNone(const cGH *GH, int num_vars, int *var_indicies, int *faces, + int *table_handle); /* Scalar boundaries */ int BndScalarDirGI (const cGH *GH, @@ -134,8 +135,8 @@ int BndStaticVN (const cGH *GH, /* Radiative boundaries */ /* prototype for routine registed as providing radiative boundary conditions */ -int BndRadiative(const cGH *GH, int num_vars, int *var_indicies, - int *table_handle); +int BndRadiative(const cGH *GH, int num_vars, int *var_indicies, int *faces, + int *table_handle); int BndRadiativeDirGI (const cGH *GH, int stencil_size, @@ -246,10 +247,8 @@ int BndFlatVN (const cGH *GH, const int *stencil, const char *vname); - #ifdef __cplusplus } #endif - #endif /* _BOUNDARY_H_ */ diff --git a/src/NoneBoundary.c b/src/NoneBoundary.c index b4706e5..59d1267 100644 --- a/src/NoneBoundary.c +++ b/src/NoneBoundary.c @@ -59,6 +59,11 @@ CCTK_FILEVERSION(CactusBase_Boundary_NoneBoundary_c); @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 @@ -70,7 +75,8 @@ CCTK_FILEVERSION(CactusBase_Boundary_NoneBoundary_c); @endreturndesc @@*/ -int BndNone(const cGH *GH, int num_vars, int *var_indices, int *table_handles) +int BndNone(const cGH *GH, int num_vars, int *var_indices, int *faces, + int *table_handles) { #ifdef DEBUG printf("BndNone(): 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]); @@ -80,6 +86,7 @@ int BndNone(const cGH *GH, int num_vars, int *var_indices, int *table_handles) GH = GH; num_vars = num_vars; var_indices = var_indices; + faces = faces; table_handles = table_handles; return 0; |