diff options
Diffstat (limited to 'src/RadiationBoundary.c')
-rw-r--r-- | src/RadiationBoundary.c | 185 |
1 files changed, 93 insertions, 92 deletions
diff --git a/src/RadiationBoundary.c b/src/RadiationBoundary.c index 6436f85..ffa3014 100644 --- a/src/RadiationBoundary.c +++ b/src/RadiationBoundary.c @@ -86,7 +86,7 @@ CCTK_FILEVERSION(CactusBase_Boundary_RadiationBoundary_c); static int ApplyBndRadiative (const cGH *GH, int stencil_dir, - const int *stencil_alldirs, + const CCTK_INT *stencil_alldirs, int dir, CCTK_REAL var0, CCTK_REAL speed, @@ -94,14 +94,14 @@ static int ApplyBndRadiative (const cGH *GH, int first_var_from, int num_vars); static int OldApplyBndRadiative (const cGH *GH, - int stencil_dir, - const int *stencil_alldirs, - int dir, - CCTK_REAL var0, - CCTK_REAL speed, - int first_var_to, - int first_var_from, - int num_vars); + int stencil_dir, + const int *stencil_alldirs, + int dir, + CCTK_REAL var0, + CCTK_REAL speed, + int first_var_to, + int first_var_from, + int num_vars); /******************************************************************** ******************** External Routines ************************ @@ -112,8 +112,8 @@ static int OldApplyBndRadiative (const cGH *GH, @date 6 Nov 2002 @author David Rideout @desc - Top level function which is registered as handling - the Radiative boundary condition + Top level function which is registered as handling + the Radiative boundary condition @enddesc @calls ApplyBndRadiative @@ -124,53 +124,54 @@ static int OldApplyBndRadiative (const cGH *GH, @endvar @var num_vars @vdesc number of variables passed in through var_indices[] - @vtype int + @vtype CCTK_INT @vio in @endvar @var var_indices - @vdesc array of variable indicies to which to apply this boundary + @vdesc array of variable indicies to which to apply this boundary condition - @vtype int * + @vtype CCTK_INT * @vio in @endvar @var faces @vdesc array of set of faces to which to apply the bc - @vtype int + @vtype CCTK_INT @vio in @endvar @var widths @vdesc array of boundary widths for each variable - @vtype int + @vtype CCTK_INT @vio in @endvar @var table_handles @vdesc array of table handles which hold extra arguments - @vtype int + @vtype CCTK_INT @vio in @endvar - @returntype int + @returntype CCTK_INT @returndesc return code of @seeroutine ApplyBndRadiative -21 error reading boundary width array from table - -22 wrong size boundary width array in table + -22 wrong size boundary width array in table @endreturndesc @@*/ -int BndRadiative(const cGH *GH, int num_vars, int *vars, int *faces, - int *widths, int *tables) +CCTK_INT BndRadiative(const cGH *GH, CCTK_INT num_vars, CCTK_INT *vars, + CCTK_INT *faces, CCTK_INT *widths, CCTK_INT *tables) { - int i, j, k, gi, gdim, max_gdim, value_type, value_size, err, retval; + int i, j, k, gi, gdim, max_gdim, err, retval; + CCTK_INT value_type, value_size; char *prev_time_level_name; /* variables to pass to ApplyBndRadiative */ - int *width_alldirs; /* width of boundary in all directions */ + CCTK_INT *width_alldirs; /* width of boundary 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 */ + CCTK_INT prev_time_level; /* variable index which holds the previous time level */ #ifdef DEBUG printf("BndRadiative() got passed: GH=%p, num_vars=%d:\n", (const void *) GH, - num_vars); + num_vars); printf("var index var name table handle\n"); for (i=0; i<num_vars; ++i) { @@ -196,9 +197,9 @@ int BndRadiative(const cGH *GH, int num_vars, int *vars, int *faces, printf("starting increment computation with group %d:\n", gi); printf("this group had %d members\n", CCTK_NumVarsInGroupI(gi)); #endif - while (i+j<num_vars && vars[i+j]==vars[i]+j && - CCTK_GroupIndexFromVarI(vars[i+j])==gi && tables[i+j]==tables[i] - && faces[i+j]==faces[i] && widths[i+j]==widths[i]) + while (i+j<num_vars && vars[i+j]==vars[i]+j && + CCTK_GroupIndexFromVarI(vars[i+j])==gi && tables[i+j]==tables[i] + && faces[i+j]==faces[i] && widths[i+j]==widths[i]) { ++j; } @@ -207,10 +208,10 @@ 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 " - "%s is not implemented yet. " - "Applying Radiative bcs to all (external) faces.", faces[i], - CCTK_VarName(vars[i])); + "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])); } dir = 0; /* apply bc to all faces */ @@ -221,7 +222,7 @@ int BndRadiative(const cGH *GH, int num_vars, int *vars, int *faces, speed = 1.; /* Look on table for possible non-default arguments - * (If any of these table look-ups fail, the value will be unchanged + * (If any of these table look-ups fail, the value will be unchanged * from its default value) */ /* Asymptotic value of function at infinity */ @@ -229,35 +230,34 @@ int BndRadiative(const cGH *GH, int num_vars, int *vars, int *faces, if (err == UTIL_ERROR_BAD_HANDLE) { CCTK_VWarn(5, __LINE__, __FILE__, CCTK_THORNSTRING, - "Invalid table handle passed for Radiative boundary " - "conditions for %s. Using all default values.", - CCTK_VarName(vars[i])); + "Invalid table handle passed for Radiative boundary " + "conditions for %s. Using all default values.", + CCTK_VarName(vars[i])); } else - { - /* Previous time level (for GVs which don't use Cactus time levels) - (to be deprecated) */ - if (Util_TableQueryValueInfo(tables[i], &value_type, &value_size, - "PREVIOUS TIME LEVEL")) + { + /* Previous time level (for GVs which don't use Cactus time levels) + (to be deprecated) */ + if (Util_TableQueryValueInfo(tables[i], &value_type, &value_size, + "PREVIOUS TIME LEVEL")) { - /* Key for previous time level is set */ - if (value_type==CCTK_VARIABLE_STRING) - { - prev_time_level_name = (char *) malloc(value_size*sizeof(char)); - 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, - "PREVIOUS TIME LEVEL"); - } else - { - CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Invalid data type for key \"PREVIOUS TIME LEVEL\" " - "Please use CCTK_STRING for the variable name, " - "or CCTK_INT for the variable index."); - } + /* Key for previous time level is set */ + if (value_type==CCTK_VARIABLE_STRING) + { + prev_time_level_name = malloc(value_size*sizeof(char)); + 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, "PREVIOUS TIME LEVEL"); + } else + { + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Invalid data type for key \"PREVIOUS TIME LEVEL\" " + "Please use CCTK_STRING for the variable name, " + "or CCTK_INT for the variable index."); + } } /* Wave speed */ @@ -269,43 +269,43 @@ int BndRadiative(const cGH *GH, int num_vars, int *vars, int *faces, gdim = CCTK_GroupDimI(gi); if (gdim > max_gdim) { - width_alldirs = realloc(width_alldirs, 2*gdim*sizeof(int)); + width_alldirs = realloc(width_alldirs, 2*gdim*sizeof(CCTK_INT)); max_gdim = gdim; } - /* fill it with values, either from table or the boundary_width + /* fill it with values, either from table or the boundary_width parameter */ if (widths[i]<0) { - err = Util_TableGetIntArray(tables[i], gdim, width_alldirs, - "BOUNDARY WIDTH"); + err = Util_TableGetIntArray(tables[i], gdim, width_alldirs, + "BOUNDARY WIDTH"); if (err<0) { - CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Error %d when reading boundary width array from table " - "for %s", err, CCTK_VarName(vars[i])); - return -21; + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Error %d when reading boundary width array from table " + "for %s", err, CCTK_VarName(vars[i])); + return -21; } else if (err!=2*gdim) { - CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Boundary width array for %s has %d elements, but %d " - "expected", CCTK_VarName(vars[i]), err, 2*gdim); - return -22; + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Boundary width array for %s has %d elements, but %d " + "expected", CCTK_VarName(vars[i]), err, 2*gdim); + return -22; } } else { for (k=0; k<2*gdim; ++k) { - width_alldirs[k] = widths[i]; + width_alldirs[k] = widths[i]; } } /* Apply the boundary condition */ if ((retval = ApplyBndRadiative(GH, 0, width_alldirs, dir, limit, speed, - vars[i], prev_time_level, j)) < 0) + vars[i], prev_time_level, j)) < 0) { CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, - "ApplyBndRadiative() returned %d", retval); + "ApplyBndRadiative() returned %d", retval); } } #ifdef DEBUG @@ -1570,7 +1570,7 @@ void CCTK_FCALL CCTK_FNAME (BndRadiativeVN) @@*/ static int ApplyBndRadiative (const cGH *GH, int width_dir, - const int *in_widths, + const CCTK_INT *in_widths, int dir, CCTK_REAL var0, CCTK_REAL speed, @@ -1652,7 +1652,7 @@ static int ApplyBndRadiative (const cGH *GH, if (indx < 0) { CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, - "Coordinate for system %s not found",coord_system_name); + "Coordinate for system %s not found",coord_system_name); return (-6); } coords[i] = GH->data[indx][0]; @@ -1672,7 +1672,7 @@ static int ApplyBndRadiative (const cGH *GH, if (indx < 0) { CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, - "Coordinate for system %s not found",coord_system_name); + "Coordinate for system %s not found",coord_system_name); return (-6); } coords[MAXDIM] = GH->data[indx][0]; @@ -1858,21 +1858,22 @@ static int ApplyBndRadiative (const cGH *GH, @@*/ int OldApplyBndRadiative(const cGH *GH, - int width_dir, - const int *stencil_alldirs, - int dir, - CCTK_REAL var0, - CCTK_REAL speed, - int first_var_to, - int first_var_from, - int num_vars) + int width_dir, + const int *stencil_alldirs, + int dir, + CCTK_REAL var0, + CCTK_REAL speed, + int first_var_to, + int first_var_from, + int num_vars) { - int retval, *boundary_widths, dim, i; + int i, dim, retval; + CCTK_INT *boundary_widths; static int warned; /* Convert stencil_alldirs to new format */ dim = CCTK_GroupDimFromVarI(first_var_to); - boundary_widths = (int *) malloc(2*dim*sizeof(int)); + boundary_widths = malloc(2*dim*sizeof(CCTK_INT)); for (i=0; i<2*dim; ++i) { boundary_widths[i] = stencil_alldirs[i/2]; @@ -1883,14 +1884,14 @@ int OldApplyBndRadiative(const cGH *GH, { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "Copied older d-element array of boundary widths into the " - "newer 2d-element format. Please use the new boundary " - "interface to avoid this."); + "newer 2d-element format. Please use the new boundary " + "interface to avoid this."); warned = 1; } /* Call ApplyBnd... with new boundary width array */ - retval = ApplyBndRadiative(GH, width_dir, boundary_widths, dir, var0, speed, - first_var_to, first_var_from, num_vars); + retval = ApplyBndRadiative(GH, width_dir, boundary_widths, dir, var0, speed, + first_var_to, first_var_from, num_vars); free(boundary_widths); return retval; |