aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrideout <rideout@c78560ca-4b45-4335-b268-5f3340f3cb52>2003-08-22 20:56:08 +0000
committerrideout <rideout@c78560ca-4b45-4335-b268-5f3340f3cb52>2003-08-22 20:56:08 +0000
commitceeea059e17832467c9688b14ce226f8ab47e22b (patch)
tree4ee3191b513d60333a3ed452e094249ad3916674 /src
parentd867c60478ca01d2b0c2ec3ee2bcc792f6447b0c (diff)
Update to use CoordBase. Registration of spher3d is deprecated.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/CartGrid3D/trunk@180 c78560ca-4b45-4335-b268-5f3340f3cb52
Diffstat (limited to 'src')
-rw-r--r--src/CartGrid3D.c190
-rw-r--r--src/Startup.c147
2 files changed, 311 insertions, 26 deletions
diff --git a/src/CartGrid3D.c b/src/CartGrid3D.c
index 55f9074..3e348e9 100644
--- a/src/CartGrid3D.c
+++ b/src/CartGrid3D.c
@@ -17,23 +17,65 @@
#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
+#include "util_Table.h"
+
#include "Symmetry.h"
+#include "CoordBase.h"
static const char *rcsid = "$Header$";
-CCTK_FILEVERSION(CactusBase_CartGrid3D_CartGrid3D_c)
-
-void DecodeSymParameters3D(int sym[6]);
-void CartGrid3D(CCTK_ARGUMENTS);
+CCTK_FILEVERSION(CactusBase_CartGrid3D_CartGrid3D_c);
+/********************************************************************
+ ********************* Macro Definitions **************************
+ ********************************************************************/
#define max(a,b) ((a) > (b) ? (a) : (b))
#define SQR(a) ((a)*(a))
+/********************************************************************
+ ********************* Scheduled Routine Prototypes ***************
+ ********************************************************************/
+void CartGrid3D(CCTK_ARGUMENTS);
+
+/********************************************************************
+ ********************* External Routine Prototypes ****************
+ ********************************************************************/
+void DecodeSymParameters3D(int sym[6]);
+
+/********************************************************************
+ ********************* Local Routine Prototypes *******************
+ ********************************************************************/
+
+/********************************************************************
+ ********************* Scheduled Routines *************************
+ ********************************************************************/
+ /*@@
+ @routine CartGrid3D
+ @date Oct 1999?
+ @author Tom Goodale? Gabrielle Allen?
+ @desc
+ Sets up Cartesian coordinates.
+ @enddesc
+ @calls DecodeSymParameters3D, CCTK_Equals, CCTK_WARN,
+ CCTK_CoordRegisterRange, CCTK_CoordRegisterRangePhysIndex,
+ CCTK_INFO, Coord_CoordHandle, Util_TableSetReal,
+ Util_TableSetString, Util_TableSetInt
+ @history
+ @endhistory
+
+ @var CCTK_ARGUMENTS
+ @vdesc Cactus argument list
+ @vtype
+ @vio in/out
+ @vcomment
+ @endvar
+
+ @returntype void
+@@*/
void CartGrid3D(CCTK_ARGUMENTS)
{
-
- DECLARE_CCTK_ARGUMENTS
- DECLARE_CCTK_PARAMETERS
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
int iconv, i, j, k;
double dconv;
@@ -48,6 +90,8 @@ void CartGrid3D(CCTK_ARGUMENTS)
int domainsym[6];
int cntstag[3];
+ CCTK_INT coord_handle;
+
lowerx = upperx = lowery = uppery = lowerz = upperz = 0;
lowerxi = upperxi = loweryi = upperyi = lowerzi = upperzi = 0;
@@ -186,7 +230,7 @@ void CartGrid3D(CCTK_ARGUMENTS)
/* Grid spacing on coarsest grid */
/* TODO: Put the coordinates into arrays, and loop over the
- dimensions. That gets ride of all the triplicated code. */
+ dimensions. That gets rid of all the triplicated code. */
if (domainsym[0])
{
if (cntstag[0])
@@ -456,6 +500,111 @@ void CartGrid3D(CCTK_ARGUMENTS)
} /* if (coarsest refinement level) */
+ /* Set up coordinate tables */
+ /* cart3d x */
+ /* Should this be done in a function?
+ WriteCoordinateTable(cctkGH, "cart3d"); */
+ coord_handle = Coord_CoordHandle(cctkGH, "x", "cart3d");
+ if (coord_handle<0)
+ {
+ CCTK_WARN(0, "Error retreiving coordinate handle for x of cart3d");
+ }
+ ierr = Util_TableSetReal (coord_handle, lowerx, "PHYSICALMIN"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, lowerx, "COMPMIN");
+ ierr += Util_TableSetReal (coord_handle, upperx, "PHYSICALMAX"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, upperx, "COMPMAX");
+ ierr += Util_TableSetString (coord_handle, "uniform", "TYPE");
+ ierr += Util_TableSetString (coord_handle, "no", "TIMEDEPENDENT");
+ ierr += Util_TableSetString (coord_handle, "CCTK_REAL", "DATATYPE");
+ ierr += Util_TableSetInt (coord_handle, CCTK_VarIndex("grid::x"),
+ "GAINDEX");
+ ierr += Util_TableSetReal (coord_handle, cctk_delta_space[0], "DELTA");
+
+ /* cart3d y */
+ coord_handle = Coord_CoordHandle(cctkGH, "y", "cart3d");
+ if (coord_handle<0)
+ {
+ CCTK_WARN(0, "Error retreiving coordinate handle for y of cart3d");
+ }
+ ierr = Util_TableSetReal (coord_handle, lowery, "PHYSICALMIN"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, lowery, "COMPMIN");
+ ierr += Util_TableSetReal (coord_handle, uppery, "PHYSICALMAX"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, uppery, "COMPMAX");
+ ierr += Util_TableSetString (coord_handle, "uniform", "TYPE");
+ ierr += Util_TableSetString (coord_handle, "no", "TIMEDEPENDENT");
+ ierr += Util_TableSetString (coord_handle, "CCTK_REAL", "DATATYPE");
+ ierr += Util_TableSetInt (coord_handle, CCTK_VarIndex("grid::y"),
+ "GAINDEX");
+ ierr += Util_TableSetReal (coord_handle, cctk_delta_space[1], "DELTA");
+
+ /* cart3d z */
+ coord_handle = Coord_CoordHandle(cctkGH, "z", "cart3d");
+ if (coord_handle<0)
+ {
+ CCTK_WARN(0, "Error retreiving coordinate handle for z of cart3d");
+ }
+ ierr = Util_TableSetReal (coord_handle, lowerz, "PHYSICALMIN"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, lowerz, "COMPMIN");
+ ierr += Util_TableSetReal (coord_handle, upperz, "PHYSICALMAX"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, upperz, "COMPMAX");
+ ierr += Util_TableSetString (coord_handle, "uniform", "TYPE");
+ ierr += Util_TableSetString (coord_handle, "no", "TIMEDEPENDENT");
+ ierr += Util_TableSetString (coord_handle, "CCTK_REAL", "DATATYPE");
+ ierr += Util_TableSetInt (coord_handle, CCTK_VarIndex("grid::z"),
+ "GAINDEX");
+ ierr += Util_TableSetReal (coord_handle, cctk_delta_space[2], "DELTA");
+
+ /* cart2d x */
+ //WriteCoordinateTable(cctkGH, "cart3d");
+ coord_handle = Coord_CoordHandle(cctkGH, "x", "cart2d");
+ if (coord_handle<0)
+ {
+ CCTK_WARN(0, "Error retreiving coordinate handle for x of cart2d");
+ }
+ ierr = Util_TableSetReal (coord_handle, lowerx, "PHYSICALMIN"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, lowerx, "COMPMIN");
+ ierr += Util_TableSetReal (coord_handle, upperx, "PHYSICALMAX"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, upperx, "COMPMAX");
+ ierr += Util_TableSetString (coord_handle, "uniform", "TYPE");
+ ierr += Util_TableSetString (coord_handle, "no", "TIMEDEPENDENT");
+ ierr += Util_TableSetString (coord_handle, "CCTK_REAL", "DATATYPE");
+ ierr += Util_TableSetInt (coord_handle, CCTK_VarIndex("grid::x"),
+ "GAINDEX");
+ ierr += Util_TableSetReal (coord_handle, cctk_delta_space[0], "DELTA");
+
+ /* cart2d y */
+ coord_handle = Coord_CoordHandle(cctkGH, "y", "cart2d");
+ if (coord_handle<0)
+ {
+ CCTK_WARN(0, "Error retreiving coordinate handle for y of cart2d");
+ }
+ ierr = Util_TableSetReal (coord_handle, lowery, "PHYSICALMIN"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, lowery, "COMPMIN");
+ ierr += Util_TableSetReal (coord_handle, uppery, "PHYSICALMAX"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, uppery, "COMPMAX");
+ ierr += Util_TableSetString (coord_handle, "uniform", "TYPE");
+ ierr += Util_TableSetString (coord_handle, "no", "TIMEDEPENDENT");
+ ierr += Util_TableSetString (coord_handle, "CCTK_REAL", "DATATYPE");
+ ierr += Util_TableSetInt (coord_handle, CCTK_VarIndex("grid::y"),
+ "GAINDEX");
+ ierr += Util_TableSetReal (coord_handle, cctk_delta_space[1], "DELTA");
+
+ /* cart1d x */
+ coord_handle = Coord_CoordHandle(cctkGH, "x", "cart1d");
+ if (coord_handle<0)
+ {
+ CCTK_WARN(0, "Error retreiving coordinate handle for x of cart1d");
+ }
+ ierr = Util_TableSetReal (coord_handle, lowerx, "PHYSICALMIN"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, lowerx, "COMPMIN");
+ ierr += Util_TableSetReal (coord_handle, upperx, "PHYSICALMAX"); /* ?? */
+ ierr += Util_TableSetReal (coord_handle, upperx, "COMPMAX");
+ ierr += Util_TableSetString (coord_handle, "uniform", "TYPE");
+ ierr += Util_TableSetString (coord_handle, "no", "TIMEDEPENDENT");
+ ierr += Util_TableSetString (coord_handle, "CCTK_REAL", "DATATYPE");
+ ierr += Util_TableSetInt (coord_handle, CCTK_VarIndex("grid::x"),
+ "GAINDEX");
+ ierr += Util_TableSetReal (coord_handle, cctk_delta_space[0], "DELTA");
#ifdef CARTGRID3D_DEBUG
@@ -477,3 +626,28 @@ void CartGrid3D(CCTK_ARGUMENTS)
#endif
}
+
+/********************************************************************
+ ********************* Local Routines *****************************
+ ********************************************************************/
+
+ /*@@
+ @routine WriteCoordinateTable
+ @date Aug 2003
+ @author David Rideout
+ @desc
+ Writes coordinate table for a registered coordinate system
+ @enddesc
+ @calls
+ @history
+ @endhistory
+
+ @var ...
+ @vdesc ...
+ @vtype ...
+ @vio in/out
+ @vcomment
+ @endvar
+
+ @returntype void
+@@*/
diff --git a/src/Startup.c b/src/Startup.c
index 6ec32df..722f4bb 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -11,26 +11,32 @@
#include <stdlib.h>
#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "util_Table.h"
+
+#include "CoordBase.h"
#include "Symmetry.h"
/* the rcs ID and its dummy function to use it */
static const char *rcsid = "$Header$";
-CCTK_FILEVERSION(CactusBase_CartGrid3D_Startup_c)
+CCTK_FILEVERSION(CactusBase_CartGrid3D_Startup_c);
/********************************************************************
- ******************** External Routines ************************
+ ******************** External Prototypes **********************
********************************************************************/
void SymmetryStartup (void);
-int RegisterCartGrid3DCoords (void);
-
+int RegisterCartGrid3DCoords (CCTK_ARGUMENTS);
/********************************************************************
- ******************** Internal Routines ************************
+ ******************** Internal Prototypes **********************
********************************************************************/
static void *SetupGH (tFleshConfig *config, int convlevel, cGH *GH);
-
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
/*@@
@routine SymmetryStartup
@date Mon Mar 15 15:49:16 1999
@@ -41,6 +47,10 @@ static void *SetupGH (tFleshConfig *config, int convlevel, cGH *GH);
@enddesc
@calls CCTK_RegisterGHExtension
CCTK_RegisterGHExtensionSetupGH
+ @history
+ @endhistory
+
+ @returntype void
@@*/
void SymmetryStartup (void)
{
@@ -53,8 +63,10 @@ void SymmetryStartup (void)
@routine RegisterCartGrid3DCoords
@date
@author Gabrielle Allen
- @desc
- Routine registers the coordinates provided by CartGrid3D
+ @desc
+ Routine registers the coordinates provided by
+ CartGrid3D, using both the new and old APIs. The old
+ CCTK_ API is deprecated.
@enddesc
@calls CCTK_CoordRegisterSystem
CCTK_CoordRegisterData
@@ -64,37 +76,136 @@ void SymmetryStartup (void)
0 for success, or negative in case of errors
@endreturndesc
@@*/
-int RegisterCartGrid3DCoords (void)
+int RegisterCartGrid3DCoords (CCTK_ARGUMENTS)
{
- int nerrors;
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ int ierr, coord_system_handle, retval;
+ retval = 0;
+
+ /* Register coordinate systems */
+ ierr = Coord_SystemRegister(cctkGH, 3, "cart3d");
+ ierr += Coord_SystemRegister(cctkGH, 2, "cart2d");
+ ierr += Coord_SystemRegister(cctkGH, 1, "cart1d");
+ if (ierr < 0)
+ {
+ CCTK_WARN(0, "Error registering cartnd coordinate systems");
+ retval = ierr;
+ }
+ else
+ {
+
+ /* Register coordinates for cart3d */
+ coord_system_handle = Coord_SystemHandle(cctkGH, "cart3d");
+ if (coord_system_handle<0)
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "Error obtaining system handle for cart3d");
+ }
+ ierr = Coord_CoordRegister(cctkGH, coord_system_handle, 1, "x");
+ ierr += Coord_CoordRegister(cctkGH, coord_system_handle, 2, "y");
+ ierr += Coord_CoordRegister(cctkGH, coord_system_handle, 3, "z");
+ if (ierr < 0)
+ {
+ CCTK_WARN(0, "Error registering cart3d coordinates");
+ retval += ierr;
+ }
+
+ /* Fill out rest of coordinate system table for cart3d */
+ ierr = Util_TableSetString(coord_system_handle, "uniform", "TYPE");
+ if (ierr < 0)
+ {
+ CCTK_WARN(1, "Error registering cart3d type");
+ retval += ierr;
+ }
+
+ /* Register coordinates for cart2d */
+ coord_system_handle = Coord_SystemHandle(cctkGH, "cart2d");
+ if (coord_system_handle<0)
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "Error obtaining system handle for cart2d");
+ }
+ ierr = Coord_CoordRegister(cctkGH, coord_system_handle, 1, "x");
+ ierr += Coord_CoordRegister(cctkGH, coord_system_handle, 2, "y");
+ if (ierr < 0)
+ {
+ CCTK_WARN(0, "Error registering cart2d coordinates");
+ retval += ierr;
+ }
+
+ /* Fill out rest of coordinate system table for cart2d */
+ ierr = Util_TableSetString(coord_system_handle, "uniform", "TYPE");
+ if (ierr < 0)
+ {
+ CCTK_WARN(1, "Error registering cart2d type");
+ retval += ierr;
+ }
+
+ /* Register coordinate for cart1d */
+ coord_system_handle = Coord_SystemHandle(cctkGH, "cart1d");
+ if (coord_system_handle<0)
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "Error obtaining system handle for cart1d");
+ }
+ ierr = Coord_CoordRegister(cctkGH, coord_system_handle, 1, "x");
+ if (ierr < 0)
+ {
+ CCTK_WARN(0, "Error registering cart1d coordinate");
+ retval += ierr;
+ }
+
+ /* Fill out rest of coordinate system table for cart1d */
+ ierr = Util_TableSetString(coord_system_handle, "uniform", "TYPE");
+ if (ierr < 0)
+ {
+ CCTK_WARN(1, "Error registering cart1d type");
+ retval += ierr;
+ }
+
+ /* Register cartnd as the default coordinate systems */
+ if (register_default_coordinate_systems)
+ {
+ ierr = Coord_SetDefaultSystem(cctkGH, "cart3d");
+ ierr += Coord_SetDefaultSystem(cctkGH, "cart2d");
+ ierr += Coord_SetDefaultSystem(cctkGH, "cart1d");
+ if (ierr < 0)
+ {
+ CCTK_WARN(1, "Error registering cartnd as default coordinate systems");
+ retval += ierr;
+ }
+ }
+ }
- nerrors = 0;
- CCTK_CoordRegisterSystem (3, "cart3d");
- CCTK_CoordRegisterSystem (3, "spher3d");
+ /* Register coordinates under the old API */
+ retval += CCTK_CoordRegisterSystem(3,"cart3d");
+ retval += CCTK_CoordRegisterSystem(3,"spher3d");
if (CCTK_CoordRegisterData (1, "grid::x", "x", "cart3d") < 0)
{
CCTK_WARN (1, "Problem with registering coordinate x");
- nerrors--;
+ retval--;
}
if (CCTK_CoordRegisterData (2, "grid::y", "y", "cart3d") < 0)
{
CCTK_WARN (1, "Problem with registering coordinate y");
- nerrors--;
+ retval--;
}
if (CCTK_CoordRegisterData (3, "grid::z", "z", "cart3d") < 0)
{
CCTK_WARN (1, "Problem with registering coordinate z");
- nerrors--;
+ retval--;
}
if (CCTK_CoordRegisterData (1, "grid::r", "r", "spher3d") < 0)
{
CCTK_WARN (1, "Problem with registering coordinate r");
- nerrors--;
+ retval--;
}
- return (nerrors);
+ return retval;
}