aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@eec4d7dc-71c2-46d6-addf-10296150bf52>2002-06-04 10:02:36 +0000
committertradke <tradke@eec4d7dc-71c2-46d6-addf-10296150bf52>2002-06-04 10:02:36 +0000
commit2d5202b3879368e983ac58c7124a730d4fee4933 (patch)
treee90e80f75e1343df056723b181a6045b54247be8
parente8686ad4c335ae8b1d8571dda41eb1ea0a55beeb (diff)
Fixed wrong datatypes for variables (CCTK_INT <-> int, CCTK_REAL <-> double).
Also fixed parameter get/set code in grid resizing routine. This fixes code crashes on the T3E. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Cartoon2D/trunk@48 eec4d7dc-71c2-46d6-addf-10296150bf52
-rw-r--r--src/Cartoon2DBC.c94
-rw-r--r--src/SetGrid.c368
-rw-r--r--src/SetSym.c13
-rw-r--r--src/interpolate.c4
4 files changed, 244 insertions, 235 deletions
diff --git a/src/Cartoon2DBC.c b/src/Cartoon2DBC.c
index 7f247c2..2695ff4 100644
--- a/src/Cartoon2DBC.c
+++ b/src/Cartoon2DBC.c
@@ -28,16 +28,19 @@ static const char *rcsid = "$Id$";
CCTK_FILEVERSION(BetaThorns_Cartoon2D_Cartoon2DBC_c)
-CCTK_INT BndCartoon2DVN(cGH *GH, CCTK_INT tensortype, const char *var);
-CCTK_INT BndCartoon2DVI(cGH *GH, CCTK_INT tensortype, CCTK_INT vi);
-CCTK_REAL Cartoon2DInterp(cGH *GH, CCTK_REAL *f, CCTK_INT i, CCTK_INT di,
- CCTK_INT ijk, CCTK_REAL x);
-CCTK_REAL interpolate_local(CCTK_INT order, CCTK_REAL x0, CCTK_REAL dx,
+int BndCartoon2DGN(const cGH *GH, int tensortype, const char *group);
+int BndCartoon2DVN(const cGH *GH, int tensortype, const char *var);
+int BndCartoon2DVI(const cGH *GH, int tensortype, int vi);
+static CCTK_REAL Cartoon2DInterp(const cGH *GH, CCTK_REAL *f, int i, int di,
+ int ijk, CCTK_REAL x);
+CCTK_REAL interpolate_local(int order, CCTK_REAL x0, CCTK_REAL dx,
CCTK_REAL y[], CCTK_REAL x);
-void CCTK_FCALL CCTK_FNAME(BndCartoon2DVI)(CCTK_INT *retval, cGH *GH,
- CCTK_INT *tensortype, CCTK_INT *vi);
-void CCTK_FCALL CCTK_FNAME(BndCartoon2DVN)(CCTK_INT *retval, cGH *GH,
- CCTK_INT *tensortype, ONE_FORTSTRING_ARG);
+void CCTK_FCALL CCTK_FNAME(BndCartoon2DVI)(int *retval, const cGH *GH,
+ int *tensortype, int *vi);
+void CCTK_FCALL CCTK_FNAME(BndCartoon2DVN)(int *retval, const cGH *GH,
+ int *tensortype, ONE_FORTSTRING_ARG);
+void CCTK_FCALL CCTK_FNAME(BndCartoon2DGN)
+ (int *retval, const cGH *GH, int *tensortype, ONE_FORTSTRING_ARG);
/* set boundaries of a grid tensor assuming axisymmetry
@@ -55,18 +58,24 @@ void CCTK_FCALL CCTK_FNAME(BndCartoon2DVN)(CCTK_INT *retval, cGH *GH,
cos(phi) etc with messy signs
*/
-CCTK_INT BndCartoon2DVI(cGH *GH, CCTK_INT tensortype, CCTK_INT vi)
+int BndCartoon2DVI(const cGH *GH, int tensortype, int vi)
{
DECLARE_CCTK_PARAMETERS
+ /*** FIXME: can CCTK_SyncGroup() have a 'const cGH *' parameter ?? ***/
+ union
+ {
+ const cGH *const_ptr;
+ cGH *non_const_ptr;
+ } GH_fake_const;
static int xindx=-1;
- CCTK_INT i, j, k, di, dj, ijk;
- CCTK_INT jj, n, s;
- CCTK_INT lnx, lnz, ny;
- CCTK_INT n_tensortype;
- CCTK_INT timelevel;
+ int i, j, k, di, dj, ijk;
+ int jj, n, s;
+ int lnx, lnz, ny;
+ int n_tensortype;
+ int timelevel;
CCTK_REAL *xp;
CCTK_REAL x, y, rho;
CCTK_REAL lx0, dx0, dy0;
@@ -88,6 +97,7 @@ CCTK_INT BndCartoon2DVI(cGH *GH, CCTK_INT tensortype, CCTK_INT vi)
break;
default:
CCTK_WARN(0,"Tensor type not recognized by Cartoon2D.");
+ n_tensortype = 0;
}
s = GH->cctk_nghostzones[0];
@@ -114,8 +124,11 @@ CCTK_INT BndCartoon2DVI(cGH *GH, CCTK_INT tensortype, CCTK_INT vi)
/* y = 0 */
j = ny/2;
+ /* this union helps us to avoid compiler warning about discarding
+ the const qualifier from a pointer target type */
+ GH_fake_const.const_ptr = GH;
/* make sure that the input data is synced */
- CCTK_SyncGroup(GH, CCTK_GroupNameFromVarI(vi));
+ CCTK_SyncGroup(GH_fake_const.non_const_ptr, CCTK_GroupNameFromVarI(vi));
/* z-direction: include lower and upper boundary */
for (k = 0; k < lnz; k++)
@@ -214,21 +227,26 @@ CCTK_INT BndCartoon2DVI(cGH *GH, CCTK_INT tensortype, CCTK_INT vi)
if (dj == 0) {i -= s; ijk -= s; dj = jj*lnx;}
}
+ /* this union helps us to avoid compiler warning about discarding
+ the const qualifier from a pointer target type */
+ GH_fake_const.const_ptr = GH;
/* syncs needed after interpolation (actually only for x direction) */
- CCTK_SyncGroup(GH, CCTK_GroupNameFromVarI(vi));
+ CCTK_SyncGroup(GH_fake_const.non_const_ptr, CCTK_GroupNameFromVarI(vi));
return(0);
}
-void CCTK_FCALL CCTK_FNAME(BndCartoon2DVI)(CCTK_INT *retval, cGH *GH, CCTK_INT *tensortype, CCTK_INT *vi) {
+void CCTK_FCALL CCTK_FNAME(BndCartoon2DVI)
+ (int *retval, const cGH *GH, int *tensortype, int *vi)
+{
*retval = BndCartoon2DVI(GH, *tensortype, *vi);
}
-CCTK_INT BndCartoon2DVN(cGH *GH, CCTK_INT tensortype, const char *impvarname)
+int BndCartoon2DVN(const cGH *GH, int tensortype, const char *impvarname)
{
DECLARE_CCTK_PARAMETERS
- CCTK_INT vi;
+ int vi;
if (verbose) printf("cartoon2D called for %s\n", impvarname);
vi = CCTK_VarIndex(impvarname);
@@ -236,17 +254,18 @@ CCTK_INT BndCartoon2DVN(cGH *GH, CCTK_INT tensortype, const char *impvarname)
return(BndCartoon2DVI(GH, tensortype, vi));
}
-void CCTK_FCALL CCTK_FNAME(BndCartoon2DVN)(CCTK_INT *retval, cGH *GH, CCTK_INT *tensortype, ONE_FORTSTRING_ARG) {
+void CCTK_FCALL CCTK_FNAME(BndCartoon2DVN)
+ (int *retval, const cGH *GH, int *tensortype, ONE_FORTSTRING_ARG)
+{
ONE_FORTSTRING_CREATE(impvarname)
*retval = BndCartoon2DVN(GH, *tensortype, impvarname);
free(impvarname);
}
-CCTK_INT BndCartoon2DGN(cGH *GH, CCTK_INT tensortype, const char *group)
+int BndCartoon2DGN(const cGH *GH, int tensortype, const char *group)
{
DECLARE_CCTK_PARAMETERS
-
- CCTK_INT n_tensortype;
+ int n_tensortype;
if (verbose) printf("cartoon2D called for %s\n", group);
@@ -262,28 +281,29 @@ CCTK_INT BndCartoon2DGN(cGH *GH, CCTK_INT tensortype, const char *group)
break;
default:
CCTK_WARN(0,"Tensor type not recognized by Cartoon2D.");
+ n_tensortype = 0;
}
- if(CCTK_NumVarsInGroup(group) != n_tensortype){
- char *msg;
- msg = malloc(1024*sizeof(char));
- sprintf(msg, "%s should have only %d component(s).\n",
- group, n_tensortype);
- CCTK_WARN(0,msg);
- free(msg);
+ if(CCTK_NumVarsInGroup(group) != n_tensortype)
+ {
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "%s should have only %d component(s).", group, n_tensortype);
}
return(BndCartoon2DVI(GH, tensortype, CCTK_FirstVarIndex(group)));
}
-void CCTK_FCALL CCTK_FNAME(BndCartoon2DGN)(CCTK_INT *retval, cGH *GH, CCTK_INT *tensortype, ONE_FORTSTRING_ARG) {
+
+void CCTK_FCALL CCTK_FNAME(BndCartoon2DGN)
+ (int *retval, const cGH *GH, int *tensortype, ONE_FORTSTRING_ARG)
+{
ONE_FORTSTRING_CREATE(group)
*retval = BndCartoon2DGN(GH, *tensortype, group);
free(group);
}
/* interpolation on x-axis */
-CCTK_REAL Cartoon2DInterp(cGH *GH, CCTK_REAL *f, CCTK_INT i, CCTK_INT di,
- CCTK_INT ijk, CCTK_REAL x)
+static CCTK_REAL Cartoon2DInterp(const cGH *GH, CCTK_REAL *f, int i, int di,
+ int ijk, CCTK_REAL x)
{
DECLARE_CCTK_PARAMETERS
@@ -293,8 +313,10 @@ CCTK_REAL Cartoon2DInterp(cGH *GH, CCTK_REAL *f, CCTK_INT i, CCTK_INT di,
CCTK_REAL lx0, dx0;
CCTK_REAL y[6], r;
CCTK_REAL *xp;
- CCTK_INT lnx;
- CCTK_INT n, offset;
+ int lnx;
+ int n, offset;
+
+ (void) (di + 0);
lnx = GH->cctk_lsh[0];
diff --git a/src/SetGrid.c b/src/SetGrid.c
index 406b138..3c142f2 100644
--- a/src/SetGrid.c
+++ b/src/SetGrid.c
@@ -2,10 +2,11 @@
@file SetGrid.c
@date April 2002
@author Denis Pollney
- @desc
+ @desc
Reset the grid sizes before they are set by CartGrid3D, so
that they have sensible cartoon-compatible values.
@enddesc
+ @version $Id$
@@*/
#include <string.h>
@@ -48,237 +49,216 @@ void Cartoon2D_SetGrid(void);
@routine Cartoon_SetGrid
@date April 2002
@author Denis Pollney
- @desc
+ @desc
Resets the grid dimensions in a cartoon-compatible way if
- the user has specified grid::type="byspacing".
-
- Generally, "byspacing" would put the z-axis in the middle
- of the x range. However, for cartoon, it is required to
- be at the edge of the range with only some zombie-zones
- extending across. This routine ensures that this is the
- case, by fixing the x range and re-specifying nx so that
- the dx value which was specified by the user is unchanged.
- The y range is reset to be a width of 1 plus space for the
- zombie points.
-
- In the process, a couple of other parameters such as
- grid::bitant_plane and grid::avoid_originy are also checked
- to ensure that they are cartoon-compatible.
-
- If the grid type is specified to be "byrange", then this
- routine does nothing and it is up to the user to choose
- appropriate ranges for what they want to do.
-
- Note that this routine currently needs to be scheduled at
- CCTK_RECOVER_PARAMETERS, because this is the only place where
- it is still possible to modify non-steerable parameters.
- @enddesc
+ the user has specified grid::type="byspacing".
+
+ Generally, "byspacing" would put the z-axis in the middle
+ of the x range. However, for cartoon, it is required to
+ be at the edge of the range with only some zombie-zones
+ extending across. This routine ensures that this is the
+ case, by fixing the x range and re-specifying nx so that
+ the dx value which was specified by the user is unchanged.
+ The y range is reset to be a width of 1 plus space for the
+ zombie points.
+
+ In the process, a couple of other parameters such as
+ grid::bitant_plane and grid::avoid_originy are also checked
+ to ensure that they are cartoon-compatible.
+
+ If the grid type is specified to be "byrange", then this
+ routine does nothing and it is up to the user to choose
+ appropriate ranges for what they want to do.
+
+ Note that this routine currently needs to be scheduled at
+ CCTK_RECOVER_PARAMETERS, because this is the only place where
+ it is still possible to modify non-steerable parameters.
+ @enddesc
@@*/
void Cartoon2D_SetGrid(void)
{
DECLARE_CCTK_PARAMETERS
- int* s = NULL;
- int* p_type = NULL;
- int* nx = NULL;
- int* ny = NULL;
- int* nz = NULL;
- int* ghost_z = NULL;
- double* dx = NULL;
- double* dy = NULL;
- double* dz = NULL;
- int cartoon_ny;
- int ierr;
- char p_val[80];
- char* domain;
- char* plane;
- char* avoid_y0;
+ const CCTK_INT *cctk_int_ptr;
+ const CCTK_REAL *cctk_real_ptr;
+ int nx, ny, nz, ghost_size_y, avoid_y0, cartoon_ny;
+ double dx, dy, dz;
double xmin, xmax, ymin, ymax, zmin, zmax;
+ char p_val[80];
+ const char *domain, *plane;
/*
* Determine the y ghostzone size.
*/
- s = (int*) CCTK_ParameterGet("ghost_size_y", "pugh", p_type);
- if (s == NULL)
+ cctk_int_ptr = (const CCTK_INT *) CCTK_ParameterGet("ghost_size_y", "pugh", NULL);
+ if (cctk_int_ptr == NULL)
CCTK_WARN(0, "pugh::ghost_size_y must be set explicitly");
- cartoon_ny = 2 * (*s) + 1;
+ ghost_size_y = *cctk_int_ptr;
+ cartoon_ny = 2 * ghost_size_y + 1;
/*
* Get the x,y,z grid sizes.
*/
- nx = (int*) CCTK_ParameterGet("global_nsize", "pugh", p_type);
- if ((nx == NULL) || (*nx == -1))
- {
- nx = (int*) CCTK_ParameterGet("global_nx", "pugh", p_type);
- if ((nx==NULL) || (*nx == -1))
- CCTK_WARN(0, "Couldn't determine global_nx");
-
- ny = (int*) CCTK_ParameterGet("global_ny", "pugh", p_type);
- if ((ny == NULL) || (*ny == -1))
- CCTK_WARN(0, "Couldn't determine global_nx");
-
- nz = (int*) CCTK_ParameterGet("global_nz", "pugh", p_type);
- if ((nz == NULL) || (*nz == -1))
- CCTK_WARN(0, "Couldn't determine global_nz");
- }
+ cctk_int_ptr = (const CCTK_INT *) CCTK_ParameterGet("global_nsize", "pugh", NULL);
+ if ((cctk_int_ptr == NULL) || (*cctk_int_ptr == -1))
+ {
+ nx = *(const CCTK_INT *) CCTK_ParameterGet("global_nx", "pugh", NULL);
+ ny = *(const CCTK_INT *) CCTK_ParameterGet("global_ny", "pugh", NULL);
+ nz = *(const CCTK_INT *) CCTK_ParameterGet("global_nz", "pugh", NULL);
+ }
else
- {
- ny = nx;
- nz = nx;
- }
+ {
+ nx = ny = nz = *cctk_int_ptr;
+ }
/*
* Reset the y grid size to be one layer thick, plus twice the ghostzone
* size.
*/
- if (*ny != cartoon_ny)
- {
- CCTK_VInfo(CCTK_THORNSTRING, "Resetting pugh::global_ny to %d\n",
- cartoon_ny);
- sprintf(p_val, "%d\0", cartoon_ny);
- CCTK_ParameterSet("global_ny", "pugh", p_val);
- }
+ if (ny != cartoon_ny)
+ {
+ CCTK_VInfo(CCTK_THORNSTRING, "Resetting pugh::global_ny to %d", cartoon_ny);
+ sprintf(p_val, "%d", cartoon_ny);
+ CCTK_ParameterSet("global_ny", "pugh", p_val);
+ }
/*
* Reset the grid sizes if the user has specified a "byspacing" grid.
*/
if (strcmp(CCTK_ParameterValString("type", "cartgrid3d"), "byrange"))
+ {
+ /*
+ * We need to set the grid spacings explicitly, so from now on
+ * consider the grid to be 'byrange'.
+ */
+ CCTK_ParameterSet("type", "cartgrid3d", "byrange");
+
+ /*
+ * Get the x,y,z grid spacing.
+ */
+ cctk_real_ptr = (const CCTK_REAL *) CCTK_ParameterGet("dxyz", "cartgrid3d", NULL);
+ if (cctk_real_ptr == NULL)
{
- /*
- * We need to set the grid spacings explicitly, so from now on
- * consider the grid to be 'byrange'.
- */
- CCTK_ParameterSet("type", "cartgrid3d", "byrange");
-
- /*
- * Get the x,y,z grid spacing.
- */
- dx = (double*) CCTK_ParameterGet("dxyz", "cartgrid3d", p_type);
- if (dx == NULL)
- {
- dx = (double*) CCTK_ParameterGet("dx", "cartgrid3d", p_type);
- dy = (double*) CCTK_ParameterGet("dy", "cartgrid3d", p_type);
- dz = (double*) CCTK_ParameterGet("dz", "cartgrid3d", p_type);
-
- if (dx == NULL)
- CCTK_WARN(0, "Couldn't determine dx value");
- if (dy == NULL)
- CCTK_WARN(0, "Couldn't determine dy value");
- if (dz == NULL)
- CCTK_WARN(0, "Couldn't determine dz value");
- }
- else
- {
- dy = dx;
- dz = dx;
- }
-
- /*
- * Set the x grid dimensions.
- */
- *nx += (*s + 1);
- xmin = -((*s)-0.5) * (*dx);
- xmax = xmin + (*nx-1) * (*dx);
-
- CCTK_VInfo(CCTK_THORNSTRING, "Setting x-range to [%f, %f]", xmin, xmax);
-
- sprintf(p_val, "%f\0", xmin);
- ierr = CCTK_ParameterSet("xmin", "cartgrid3d", p_val);
- if (ierr < 0)
- {
- CCTK_WARN(0,"Error setting parameter");
- }
- sprintf(p_val, "%f\0", xmax);
- ierr = CCTK_ParameterSet("xmax", "cartgrid3d", p_val);
- if (ierr < 0)
- {
- CCTK_WARN(0,"Error setting parameter");
- }
+ dx = *(const CCTK_REAL *) CCTK_ParameterGet("dx", "cartgrid3d", NULL);
+ dy = *(const CCTK_REAL *) CCTK_ParameterGet("dy", "cartgrid3d", NULL);
+ dz = *(const CCTK_REAL *) CCTK_ParameterGet("dz", "cartgrid3d", NULL);
+ }
+ else
+ {
+ dx = dy = dz = *cctk_real_ptr;
+ }
- /*
- * Set the y grid dimensions.
- */
- avoid_y0 = CCTK_ParameterValString("avoid_originy", "cartgrid3d");
- if (strcmp(avoid_y0, "no"))
- CCTK_WARN(0, "Cartoon2D requires grid::avoid_originy=\"no\"");
+ /*
+ * Set the x grid dimensions.
+ */
+ nx += ghost_size_y + 1;
+ CCTK_VInfo(CCTK_THORNSTRING, "Adding pugh::ghost_size_y+1 to pugh::global_nx", nx);
+ sprintf(p_val, "%d", nx);
+ CCTK_ParameterSet("global_nx", "pugh", p_val);
- ymax = (*s) * (*dy);
- ymin = -ymax;
+ xmin = -(ghost_size_y-0.5) * dx;
+ xmax = xmin + (nx-1) * dx;
- CCTK_VInfo(CCTK_THORNSTRING, "Setting y-range to [%f, %f]", ymin, ymax);
+ CCTK_VInfo(CCTK_THORNSTRING, "Setting x-range to [%f, %f]", xmin, xmax);
- sprintf(p_val, "%f\0", ymin);
- ierr = CCTK_ParameterSet("ymin", "cartgrid3d", p_val);
- if (ierr < 0)
- {
- CCTK_WARN(0,"Error setting parameter");
- }
- sprintf(p_val, "%f\0", ymax);
- ierr = CCTK_ParameterSet("ymax", "cartgrid3d", p_val);
- if (ierr < 0)
- {
- CCTK_WARN(0,"Error setting parameter");
- }
-
- /*
- * Set the z grid dimensions for bitant mode.
- */
-
- domain = CCTK_ParameterValString("domain", "cartgrid3d");
- if (!strcmp(domain, "bitant"))
- {
- plane = CCTK_ParameterValString("bitant_plane", "cartgrid3d");
- if (strcmp(plane, "xy"))
- CCTK_WARN(0, "Cartoon2D requires grid::bitant_plane=\"xy\"");
-
- ghost_z = (int*) CCTK_ParameterGet("ghost_size", "pugh", p_type);
- if ((ghost_z == NULL) || (*ghost_z < 0))
- ghost_z = (int*) CCTK_ParameterGet("ghost_size_z", "pugh", p_type);
-
- (*nz) += 1;
- zmax = (*nz-0.5) * (*dz);
- zmin = -zmax;
-
- if ((ghost_z != NULL) && (*ghost_z > 0))
- (*nz) += (*ghost_z);
- }
-
- else if (!strcmp(domain, "full"))
- {
- (*nz) += 2;
- zmax = (*nz-1) * (*dz)/2;
- zmin = -zmax;
- }
-
- else
- {
- CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cartoon2D is unable to handle grid::domain=\"%s\"",
- domain);
- }
-
- CCTK_VInfo(CCTK_THORNSTRING, "Setting z-range to [%f,%f]", zmin, zmax);
-
- sprintf(p_val, "%f\0", zmin);
- ierr = CCTK_ParameterSet("zmin", "cartgrid3d", p_val);
- if (ierr < 0)
- {
- CCTK_WARN(0,"Error setting parameter");
- }
- sprintf(p_val, "%f\0", zmax);
- ierr = CCTK_ParameterSet("zmax", "cartgrid3d", p_val);
- if (ierr < 0)
+ sprintf(p_val, "%f", xmin);
+ if (CCTK_ParameterSet("xmin", "cartgrid3d", p_val) < 0)
+ {
+ CCTK_WARN(0,"Error setting parameter");
+ }
+ sprintf(p_val, "%f", xmax);
+ if (CCTK_ParameterSet("xmax", "cartgrid3d", p_val) < 0)
+ {
+ CCTK_WARN(0,"Error setting parameter");
+ }
+
+ /*
+ * Set the y grid dimensions.
+ */
+ avoid_y0 = *(const CCTK_INT *) CCTK_ParameterGet("avoid_originy", "cartgrid3d", NULL);
+ if (avoid_y0)
+ CCTK_WARN(0, "Cartoon2D requires grid::avoid_originy=\"no\"");
+
+ ymax = ghost_size_y * dy;
+ ymin = -ymax;
+
+ CCTK_VInfo(CCTK_THORNSTRING, "Setting y-range to [%f, %f]", ymin, ymax);
+
+ sprintf(p_val, "%f", ymin);
+ if (CCTK_ParameterSet("ymin", "cartgrid3d", p_val) < 0)
+ {
+ CCTK_WARN(0,"Error setting parameter");
+ }
+ sprintf(p_val, "%f", ymax);
+ if (CCTK_ParameterSet("ymax", "cartgrid3d", p_val) < 0)
+ {
+ CCTK_WARN(0,"Error setting parameter");
+ }
+
+ /*
+ * Set the z grid dimensions for bitant mode.
+ */
+
+ zmin = zmax = 0;
+ domain = *(const char **) CCTK_ParameterGet("domain", "cartgrid3d", NULL);
+ if (!strcmp(domain, "bitant"))
+ {
+ plane = *(const char **) CCTK_ParameterGet("bitant_plane", "cartgrid3d", NULL);
+ if (strcmp(plane, "xy"))
+ CCTK_WARN(0, "Cartoon2D requires grid::bitant_plane=\"xy\"");
+
+ cctk_int_ptr = (const CCTK_INT *) CCTK_ParameterGet("ghost_size", "pugh", NULL);
+ if ((cctk_int_ptr == NULL) || (*cctk_int_ptr < 0))
+ cctk_int_ptr = (const CCTK_INT *) CCTK_ParameterGet("ghost_size_z", "pugh", NULL);
+
+ nz += 1;
+ CCTK_VInfo(CCTK_THORNSTRING, "Increasing PUGH::global_nz by 1");
+ sprintf(p_val, "%d", nz);
+ CCTK_ParameterSet("global_nz", "pugh", p_val);
+
+ zmax = (nz-0.5) * dz;
+ zmin = -zmax;
+
+ if ((cctk_int_ptr != NULL) && (*cctk_int_ptr > 0))
{
- CCTK_WARN(0,"Error setting parameter");
+ nz += (*cctk_int_ptr);
+ CCTK_VInfo(CCTK_THORNSTRING, "Increasing PUGH::global_nz by "
+ "PUGH::ghost_size_z");
+ sprintf(p_val, "%d", nz);
+ CCTK_ParameterSet("global_nz", "pugh", p_val);
}
}
-}
+ else if (!strcmp(domain, "full"))
+ {
+ nz += 2;
+ CCTK_VInfo(CCTK_THORNSTRING, "Increasing PUGH::global_nz by 2");
+ sprintf(p_val, "%d", nz);
+ CCTK_ParameterSet("global_nz", "pugh", p_val);
+ zmax = (nz-1) * dz/2;
+ zmin = -zmax;
+ }
+ else
+ {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cartoon2D is unable to handle grid::domain=\"%s\"",
+ domain);
+ }
-/********************************************************************
- ********************* Local Routines *************************
- ********************************************************************/
+ CCTK_VInfo(CCTK_THORNSTRING, "Setting z-range to [%f,%f]", zmin, zmax);
+ sprintf(p_val, "%f", zmin);
+ if (CCTK_ParameterSet("zmin", "cartgrid3d", p_val) < 0)
+ {
+ CCTK_WARN(0,"Error setting parameter");
+ }
+ sprintf(p_val, "%f", zmax);
+ if (CCTK_ParameterSet("zmax", "cartgrid3d", p_val) < 0)
+ {
+ CCTK_WARN(0,"Error setting parameter");
+ }
+ }
+}
diff --git a/src/SetSym.c b/src/SetSym.c
index ee181eb..31d39d3 100644
--- a/src/SetSym.c
+++ b/src/SetSym.c
@@ -8,6 +8,8 @@
@enddesc
@@*/
+#include <stdlib.h>
+
#include "cGH.h"
#include "CactusBase/CartGrid3D/src/Symmetry.h"
@@ -221,7 +223,12 @@ Cartoon_SetSym_BSSN(CCTK_ARGUMENTS)
}
- free(evolution_system);
- free(evolution_method);
-
+ if (evolution_system)
+ {
+ free(evolution_system);
+ }
+ if (evolution_method)
+ {
+ free(evolution_method);
+ }
}
diff --git a/src/interpolate.c b/src/interpolate.c
index 13e7f6f..8a39c44 100644
--- a/src/interpolate.c
+++ b/src/interpolate.c
@@ -20,7 +20,7 @@
#define PRIVATE
#define PUBLIC
-CCTK_REAL interpolate_local(CCTK_INT order, CCTK_REAL x0, CCTK_REAL dx,
+CCTK_REAL interpolate_local(int order, CCTK_REAL x0, CCTK_REAL dx,
CCTK_REAL y[], CCTK_REAL x);
/* prototypes for private functions defined in this file */
@@ -67,7 +67,7 @@ PRIVATE CCTK_REAL interpolate_local_order5(CCTK_REAL x0, CCTK_REAL dx,
* y[0...order] = (in) The y data array.
* x = (in) The x coordinate for the interpolation.
*/
-PUBLIC CCTK_REAL interpolate_local(CCTK_INT order,
+PUBLIC CCTK_REAL interpolate_local(int order,
CCTK_REAL x0, CCTK_REAL dx,
CCTK_REAL y[],
CCTK_REAL x)