aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpollney <pollney@eec4d7dc-71c2-46d6-addf-10296150bf52>2002-04-16 12:51:00 +0000
committerpollney <pollney@eec4d7dc-71c2-46d6-addf-10296150bf52>2002-04-16 12:51:00 +0000
commitfa27bcd40b4adaab057f75124866887996c2c202 (patch)
tree6063f071dd176357c4a6fa939c0a79c604825f0e /src
parent3938143b77634afac657b55f93a07b6f7953f75f (diff)
Added a routine for ensuring that the grid set up in the parameter file
is cactus compatible. If the new parameter "allow_grid_resize" is set, then cartoon will now actually modify the grid that was specified by the user. Though not really a nice solution, it is potentially less annoying than having the user try to figure out appropriate grid dimensions themselves. The old test suite for cartoon (test_cartoon.par) was not a very good example, as it actually set up an less-than-optimal grid (with bitant specified in the wrong plane), and could only run on 2-processors. So I've removed it and replaced it with a pair of new test suites which demonstrate cartoon in "full" and "bitant" mode using the new grid resizing mechanism. Documentation as such does not exist yet, but will in the fullness of time. For the time being, please refer to the sample parameter files in the test directory to see how to set things up. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Cartoon2D/trunk@26 eec4d7dc-71c2-46d6-addf-10296150bf52
Diffstat (limited to 'src')
-rw-r--r--src/SetGrid.c228
-rw-r--r--src/SetSym.c2
-rw-r--r--src/make.code.defn2
3 files changed, 230 insertions, 2 deletions
diff --git a/src/SetGrid.c b/src/SetGrid.c
new file mode 100644
index 0000000..dd8a7fe
--- /dev/null
+++ b/src/SetGrid.c
@@ -0,0 +1,228 @@
+/*@@
+ @file SetGrid.c
+ @date April 2002
+ @author Denis Pollney
+ @desc
+ Reset the grid sizes before they are set by CartGrid3D, so
+ that they have sensible cartoon-compatible values.
+ @enddesc
+ @@*/
+
+#include <string.h>
+
+#include "cctk.h"
+#include "cctk_Parameter.h"
+#include "cctk_Parameters.h"
+
+static const char
+*rcsid = "$Id$";
+
+ /*@@
+ @routine Cartoon_SetGrid
+ @date April 2002
+ @author Denis Pollney
+ @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
+ @@*/
+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;
+ double xmin, xmax, ymin, ymax, zmin, zmax;
+
+
+ /*
+ * Determine the y ghostzone size.
+ */
+ s = (int*) CCTK_ParameterGet("ghost_size_y", "pugh", p_type);
+ if (s == NULL)
+ CCTK_WARN(0, "pugh::ghost_size_y must be set explicitly");
+
+ cartoon_ny = 2 * (*s) + 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");
+ }
+ else
+ {
+ ny = nx;
+ nz = nx;
+ }
+
+ /*
+ * 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);
+ }
+
+
+ /*
+ * 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.
+ */
+ 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);
+ sprintf(p_val, "%f\0", xmax);
+ ierr = CCTK_ParameterSet("xmax", "cartgrid3d", p_val);
+
+ /*
+ * 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\"");
+
+ ymax = (*s) * (*dy);
+ ymin = -ymax;
+
+ CCTK_VInfo(CCTK_THORNSTRING, "Setting y-range to [%f, %f]", ymin, ymax);
+
+ sprintf(p_val, "%f\0", ymin);
+ ierr = CCTK_ParameterSet("ymin", "cartgrid3d", p_val);
+ sprintf(p_val, "%f\0", ymax);
+ ierr = CCTK_ParameterSet("ymax", "cartgrid3d", p_val);
+
+ /*
+ * 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);
+ sprintf(p_val, "%f\0", zmax);
+ ierr = CCTK_ParameterSet("zmax", "cartgrid3d", p_val);
+ }
+}
diff --git a/src/SetSym.c b/src/SetSym.c
index c4b6cb1..423b0b0 100644
--- a/src/SetSym.c
+++ b/src/SetSym.c
@@ -21,7 +21,7 @@ static const char
*rcsid = "$Id$";
/*@@
- @routine Cartoon_IgnoreSym
+ @routine Cartoon_ResetSym
@date October 2001
@author Denis Pollney
@desc
diff --git a/src/make.code.defn b/src/make.code.defn
index 1777124..b277a29 100644
--- a/src/make.code.defn
+++ b/src/make.code.defn
@@ -2,7 +2,7 @@
# $Header$
# Source files in this directory
-SRCS = CheckParameters.c Cartoon2DBC.c interpolate.c SetSym.c
+SRCS = CheckParameters.c Cartoon2DBC.c interpolate.c SetSym.c SetGrid.c
# Subdirectories containing source files
SUBDIRS =