From ceeea059e17832467c9688b14ce226f8ab47e22b Mon Sep 17 00:00:00 2001 From: rideout Date: Fri, 22 Aug 2003 20:56:08 +0000 Subject: 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 --- README | 9 ++- doc/documentation.tex | 4 +- interface.ccl | 4 ++ param.ccl | 6 +- schedule.ccl | 4 +- src/CartGrid3D.c | 190 +++++++++++++++++++++++++++++++++++++++++++++++--- src/Startup.c | 147 +++++++++++++++++++++++++++++++++----- 7 files changed, 328 insertions(+), 36 deletions(-) diff --git a/README b/README index 161a486..58d0a8f 100644 --- a/README +++ b/README @@ -10,7 +10,12 @@ provides a method for registering symmetries of Grid Functions across the grid axes, and a call for applying symmetry boundary conditions. -2. Additional information +CartGrid3d also registers a coordinate system spher3d, under the old +API, but this is deprecated. Spherical coordinate systems will be +provided by another thorn in the future. + -This thorn currently only works in 3D +2. Additional information +This thorn currently only works in 3D, in that it creates 3D grid functions. +It registers Cartesian coordinate systems of 1, 2, and 3 dimensions. diff --git a/doc/documentation.tex b/doc/documentation.tex index c8dcf7d..79228b9 100644 --- a/doc/documentation.tex +++ b/doc/documentation.tex @@ -209,8 +209,8 @@ has the integer array indices $[2,32]$ (C) or $[3,33]$ (Fortran). \section{Coordinates} -\verb|CartGrid3D| defines (registers) two coordinate systems: -\verb|cart3d| and \verb|spher3d|. +\verb|CartGrid3D| defines (registers) four coordinate systems: +\verb|cart3d|, \verb|cart2d|, \verb|cart1d|, and \verb|spher3d|. The Cartesian coordinates supplied by this thorn are grid functions with the standard names \verb|x|, \verb|y|, and \verb|z|. To use diff --git a/interface.ccl b/interface.ccl index 4185a2d..eaa3f22 100644 --- a/interface.ccl +++ b/interface.ccl @@ -2,8 +2,10 @@ # $Header$ implements: grid +inherits: coordbase INCLUDE HEADER: Symmetry.h in Symmetry.h +uses include header: CoordBase.h public: @@ -15,4 +17,6 @@ REAL gridspacings type=SCALAR REAL coordinates type=GF { x, y, z, r +# will become: +# coord_x, coord_y, coord_z } "3D Cartesian grid coordinates" diff --git a/param.ccl b/param.ccl index f17943a..ba2f3bd 100644 --- a/param.ccl +++ b/param.ccl @@ -51,7 +51,9 @@ BOOLEAN avoid_origin "Don't place grid points on the coordinate origin/axes" : :: "" } "yes" - +BOOLEAN register_default_coordinate_systems "register cartnd as the default coordinate systems" +{ +} "yes" restricted: @@ -177,5 +179,3 @@ BOOLEAN symmetry_zmax "Symmetry boundary condition on upper z boundary" { : :: "Logical" } "no" - - diff --git a/schedule.ccl b/schedule.ccl index b22a687..412c47b 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -8,7 +8,7 @@ schedule SymmetryStartup at CCTK_STARTUP LANG: C } "Register GH Extension for GridSymmetry" -schedule RegisterCartGrid3DCoords at CCTK_STARTUP +schedule RegisterCartGrid3DCoords at CCTK_WRAGH { LANG:C } "Register coordinates for the Cartesian grid" @@ -22,5 +22,3 @@ schedule CartGrid3D as SpatialCoordinates at CCTK_BASEGRID { LANG:C } "Set up spatial 3D Cartesian coordinates on the GH" - - 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 #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; } -- cgit v1.2.3