aboutsummaryrefslogtreecommitdiff
path: root/src/Boundary.c
diff options
context:
space:
mode:
authorrideout <rideout@6a38eb6e-646e-4a02-a296-d141613ad6c4>2003-02-13 14:15:30 +0000
committerrideout <rideout@6a38eb6e-646e-4a02-a296-d141613ad6c4>2003-02-13 14:15:30 +0000
commitc9c45374ea511044d367b86cf677220862629464 (patch)
tree5fc9fb3e74f71f9f2a1a997e07370ed9aca9c174 /src/Boundary.c
parentb34d42fa292da448b9a16ff5fab86960fac040b4 (diff)
Add faces argument where required.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Boundary/trunk@195 6a38eb6e-646e-4a02-a296-d141613ad6c4
Diffstat (limited to 'src/Boundary.c')
-rw-r--r--src/Boundary.c155
1 files changed, 100 insertions, 55 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);