aboutsummaryrefslogtreecommitdiff
path: root/src/GeneralizedPolynomial-Uniform/molecule_posn.c
diff options
context:
space:
mode:
authorjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-08-19 14:30:44 +0000
committerjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-08-19 14:30:44 +0000
commit6f561b6c721a72830342b0eebe204635d6167987 (patch)
treeac977703eb1469bf898ec79721fafb3c52dad2af /src/GeneralizedPolynomial-Uniform/molecule_posn.c
parent25498e53288336c7f176305f036ecad05a87913c (diff)
This commit changes the semantics of the out_of_range_tolerance[]
parameter-table entry to allow the min/max ends of the grid to be handled differently. (We'll need this for the multiprocessor interpolation.) ***** IMPORTANT ***** This change is *NOT* backwards-compatible: if you are calling CCTK_InterpLocalUniform() from this thorn (CactusBase/LocalInterp), and you have set out_of_range_tolerance[] to a non-default value, you must (slightly) change your code, or else you'll get an error return from the interpolator. If you don't use out_of_range_tolerance[] , then you don't need to do anything. The semantics of out_of_range_tolerance[] are now as follows: @var out_of_range_tolerance @vdesc Specifies how out-of-range interpolation points should be handled. The array elements are matched up with the axes and minimum/maximum ends of the grid in the order [x_min, x_max, y_min, y_max, z_min, z_max, ...]. An array value TOL is interpreted as follows: If TOL >= 0.0, then an interpolation point is considered to be "out of range" if and only if the interpolation point is > TOL * coord_delta[axis] outside the grid in this coordinate direction. If TOL == -1.0, then an interpolation point is considered to be "out of range" if and only if a centered molecule (or more generally, a molecule whose centering is chosen pretending that the grid is of infinite extent), would require data from outside the grid in this direction. Other values of TOL are illegal (reserved for future use). @vtype const CCTK_REAL out_of_range_tolerance[2*N_dims] @endvar The change is that it used to have only N_dims elements, one for each axis -- now there are 2*N_dims elements, one for each min/max end of each axis. ---------------------------------------------------------------------- Modified Files: doc/documentation.tex src/GeneralizedPolynomial-Uniform/InterpLocalUniform.c src/GeneralizedPolynomial-Uniform/InterpLocalUniform.h src/GeneralizedPolynomial-Uniform/interpolate.maple src/GeneralizedPolynomial-Uniform/molecule_posn.c src/GeneralizedPolynomial-Uniform/template.c src/GeneralizedPolynomial-Uniform/test_molecule_posn.c git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@88 df1f8a13-aa1d-4dd4-9681-27ded5b42416
Diffstat (limited to 'src/GeneralizedPolynomial-Uniform/molecule_posn.c')
-rw-r--r--src/GeneralizedPolynomial-Uniform/molecule_posn.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/src/GeneralizedPolynomial-Uniform/molecule_posn.c b/src/GeneralizedPolynomial-Uniform/molecule_posn.c
index f67922e..44e78fc 100644
--- a/src/GeneralizedPolynomial-Uniform/molecule_posn.c
+++ b/src/GeneralizedPolynomial-Uniform/molecule_posn.c
@@ -93,9 +93,15 @@ static const char *rcsid = "$Header$";
@vtype int grid_i_max
@endvar
- @var out_of_range_tolerance
+ @var molecule_size
+ @vdesc The size (number of points) of the molecule.
+ @vtype int molecule_size
+ @endvar
+
+ @var out_of_range_tolerance_min, out_of_range_tolerance_max
@vdesc Specifies how out-of-range interpolation points should
- be handled:
+ be handled for the {minimum,maximum} ends of the grid
+ respectively.
If out_of_range_tolerance >= 0.0,
then an interpolation point is considered to be
"out of range" if and only if the interpolation
@@ -106,12 +112,7 @@ static const char *rcsid = "$Header$";
"out of range" if and only if a centered molecule
would require data from outside the grid.
Other values of out_of_range_tolerance are illegal.
- @vtype fp
- @endvar
-
- @var molecule_size
- @vdesc The size (number of points) of the molecule.
- @vtype int molecule_size
+ @vtype fp out_of_range_tolerance_min, out_of_range_tolerance_max
@endvar
@var x
@@ -128,17 +129,11 @@ static const char *rcsid = "$Header$";
@vio pointer to out
@endvar
- @var molecule_m_min
- @vdesc A pointer to an int where this function should store the minimum
- molecule coordinate m of the molecule; or NULL to skip storing this.
- @vtype int *molecule_m_min
- @vio pointer to out
- @endvar
-
- @var p_molecule_m_max
- @vdesc A pointer to an int where this function should store the maximum
- molecule coordinate m of the molecule; or NULL to skip storing this.
- @vtype int *molecle_m_max
+ @var molecule_m_min, molecule_m_max
+ @vdesc A pointer to an int where this function should store the
+ {minimum,maximum} molecule coordinate m of the molecule;
+ or NULL to skip storing this.
+ @vtype int *molecule_m_min, *molecule_m_max
@vio pointer to out
@endvar
@@ -155,8 +150,9 @@ static const char *rcsid = "$Header$";
@@*/
int LocalInterp_molecule_posn(fp grid_origin, fp grid_delta,
int grid_i_min, int grid_i_max,
- fp out_of_range_tolerance,
int molecule_size,
+ fp out_of_range_tolerance_min,
+ fp out_of_range_tolerance_max,
fp x,
fp *x_rel,
int *molecule_m_min, int *molecule_m_max)
@@ -169,14 +165,17 @@ const int m_min = m_max - molecule_size + 1; /* a negative number */
const fp fp_i = (x - grid_origin) / grid_delta;
/* is point x out-of-range? */
-if (out_of_range_tolerance >= 0.0)
+if (out_of_range_tolerance_min >= 0.0)
then {
const fp fp_effective_grid_i_min
- = ((fp) grid_i_min) - out_of_range_tolerance;
- const fp fp_effective_grid_i_max
- = ((fp) grid_i_max) + out_of_range_tolerance;
+ = ((fp) grid_i_min) - out_of_range_tolerance_min;
if (fp_i < fp_effective_grid_i_min)
then return INT_MIN; /*** ERROR RETURN ***/
+ }
+if (out_of_range_tolerance_max >= 0.0)
+ then {
+ const fp fp_effective_grid_i_max
+ = ((fp) grid_i_max) + out_of_range_tolerance_max;
if (fp_i > fp_effective_grid_i_max)
then return INT_MAX; /*** ERROR RETURN ***/
}
@@ -194,13 +193,10 @@ const int centered_i_min = i_center + m_min;
const int centered_i_max = i_center + m_max;
/* check if off-centered molecules are forbidden? */
-if (out_of_range_tolerance == -1.0)
- then {
- if (centered_i_min < grid_i_min)
- then return INT_MIN; /*** ERROR RETURN ***/
- if (centered_i_max > grid_i_max)
- then return INT_MAX; /*** ERROR RETURN ***/
- }
+if ((out_of_range_tolerance_min == -1.0) && (centered_i_min < grid_i_min))
+ then return INT_MIN; /*** ERROR RETURN ***/
+if ((out_of_range_tolerance_max == -1.0) && (centered_i_max > grid_i_max))
+ then return INT_MAX; /*** ERROR RETURN ***/
/* off-center as needed if we're close to the edge of the grid */
{