diff options
author | jthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416> | 2002-02-27 14:28:36 +0000 |
---|---|---|
committer | jthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416> | 2002-02-27 14:28:36 +0000 |
commit | 717d39a68230908f36b7098e66d0dd76dd067148 (patch) | |
tree | 397cda867657459ef518b65cd87def3517958253 /src/GeneralizedPolynomial-Uniform/util.c | |
parent | ac713b27a07fa17689464ac2e9e7275169f116ea (diff) |
initial checkin of new LocalInterp thorn
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@2 df1f8a13-aa1d-4dd4-9681-27ded5b42416
Diffstat (limited to 'src/GeneralizedPolynomial-Uniform/util.c')
-rw-r--r-- | src/GeneralizedPolynomial-Uniform/util.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/src/GeneralizedPolynomial-Uniform/util.c b/src/GeneralizedPolynomial-Uniform/util.c new file mode 100644 index 0000000..443fa1b --- /dev/null +++ b/src/GeneralizedPolynomial-Uniform/util.c @@ -0,0 +1,109 @@ + /*@@ + @file util.c + @date 23 Oct 2001 + @author Jonathan Thornburg <jthorn@aei.mpg.de> + @desc + Utility routines for generalized interpolation. + + This file contains various utility routines for the interpolator. + @enddesc + @version $Id$ + @@*/ + +#include <limits.h> +#include <stdlib.h> +#include <stdio.h> +#include <math.h> + +#ifndef LOCALINTERP_STANDALONE_BUILD + #include "cctk.h" +#endif + +#include "InterpLocalUniform.h" + +/* the rcs ID and its dummy function to use it */ +static const char *rcsid = "$Header$"; +#ifndef LOCALINTERP_STANDALONE_BUILD + CCTK_FILEVERSION(CactusBase_LocalInterp_src_GeneralizedPolynomialUniform_util_c) +#endif + +/******************************************************************************/ + +/*@@ + @routine LocalInterp_zero_int_array + @date 23 Oct 2001 + @author Jonathan Thornburg <jthorn@aei.mpg.de> + @desc This function sets a CCTK_INT array to all zeros. + @enddesc + + @var N + @vdesc The number of elements in the array. + @vtype CCTK_INT N + @endvar + + @var array + @vdesc (A pointer to) the array + @vtype CCTK_INT array[] + @vio out + @endvar + @@*/ +void LocalInterp_zero_int_array(int N, CCTK_INT array[]) +{ +int i; + + for (i = 0 ; i < N ; ++i) + { + array[i] = 0; + } +} + +/******************************************************************************/ + +/*@@ + @routine LocalInterp_decode_N_parts + @date 22 Jan 2002 + @author Jonathan Thornburg <jthorn@aei.mpg.de> + @desc This function decodes a CCTK_VARIABLE_* variable type code + (cctk_Constants.h) to determine whether the type is real + or complex. + @enddesc + + @var type_code + @vdesc The type code to be decoded + @vtype int + @endvar + + @returntype int + @returndesc This function returns + 1 if the data type represents a real number of some sort + (includes integers) + 2 if the data type represents a complex number + 0 if the data type doesn't represent a number, + eg strings and pointers + -1 if the data type is invalid + @endreturndesc + @@*/ +int LocalInterp_decode_N_parts(int type_code) +{ +switch (type_code) + { +case CCTK_VARIABLE_VOID: return 0; +case CCTK_VARIABLE_BYTE: return 1; +case CCTK_VARIABLE_INT: return 1; +case CCTK_VARIABLE_INT2: return 1; +case CCTK_VARIABLE_INT4: return 1; +case CCTK_VARIABLE_INT8: return 1; +case CCTK_VARIABLE_REAL: return 1; +case CCTK_VARIABLE_REAL4: return 1; +case CCTK_VARIABLE_REAL8: return 1; +case CCTK_VARIABLE_REAL16: return 1; +case CCTK_VARIABLE_COMPLEX: return 2; +case CCTK_VARIABLE_COMPLEX8: return 2; +case CCTK_VARIABLE_COMPLEX16: return 2; +case CCTK_VARIABLE_COMPLEX32: return 2; +case CCTK_VARIABLE_STRING: return 0; +case CCTK_VARIABLE_POINTER: return 0; +case CCTK_VARIABLE_FN_POINTER: return 0; +default: return -1; + } +} |