diff options
author | allen <allen@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2000-07-12 11:40:54 +0000 |
---|---|---|
committer | allen <allen@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2000-07-12 11:40:54 +0000 |
commit | eed305f5b914bc8849aeecd4f2bb66fa56f6fafb (patch) | |
tree | 84a15abeb5709b8e60f32b0fff5f52f2c9f482bc | |
parent | 41777d3027a7d8133aef387b067cb8e53250af6c (diff) |
New parameters for choosing lines and slices
New CCTK functions for coordinates
WARNING: Different default behaviour now for lines and slices from a
full grid
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@11 94b1c47f-dcfd-45ef-a468-0854c0e9e350
-rw-r--r-- | doc/documentation.tex | 2 | ||||
-rw-r--r-- | param.ccl | 175 | ||||
-rw-r--r-- | schedule.ccl | 10 | ||||
-rw-r--r-- | src/ChooseOutput.c | 321 | ||||
-rw-r--r-- | src/GHExtension.c | 199 | ||||
-rw-r--r-- | src/Output1D.c | 2 | ||||
-rw-r--r-- | src/Output2D.c | 2 | ||||
-rw-r--r-- | src/Startup.c | 1 | ||||
-rw-r--r-- | src/Write1D.c | 184 | ||||
-rw-r--r-- | src/Write2D.c | 23 | ||||
-rw-r--r-- | src/ioASCIIGH.h | 8 | ||||
-rw-r--r-- | src/make.code.defn | 8 |
12 files changed, 697 insertions, 238 deletions
diff --git a/doc/documentation.tex b/doc/documentation.tex index cfd5919..2563c0b 100644 --- a/doc/documentation.tex +++ b/doc/documentation.tex @@ -44,6 +44,8 @@ invoke IO methods by application thorns please see the documentation of thorn IOUtil and the flesh. % \section{Comments} + +IMPORTANT: Must select data to output AFTER spatial coordinates are set up % Since IOASCII uses parameters from IOUtil it also needs this IO skeleton thorn be compiled into Cactus and activated. @@ -64,10 +64,10 @@ KEYWORD out_format "Which format for ASCII output" STEERABLE = ALWAYS "f" :: "output in floating point notation" } "f" -####################### +############################ # Specific to 1D output # Choosing what output to do -####################### +############################ BOOLEAN out1D_x "Do 1D IOASCII output in the x-direction" STEERABLE = ALWAYS { } "yes" @@ -81,19 +81,95 @@ BOOLEAN out1D_d "Do 1D IOASCII output in the diagonal-direction" STEERABLE = ALW { } "yes" +CCTK_REAL out1D_xline_y "y-coord for 1D lines in x-direction" +{ + *:* :: "" +} 0.0 +CCTK_REAL out1D_xline_z "z-coord for 1D lines in x-direction" +{ + *:* :: "" +} 0.0 -############################################################################# -### import grid parameters -############################################################################# -shares: grid +CCTK_REAL out1D_yline_x "x-coord for 1D lines in y-direction" +{ + *:* :: "" +} 0.0 +CCTK_REAL out1D_yline_z "z-coord for 1D lines in y-direction" +{ + *:* :: "" +} 0.0 -USES KEYWORD domain "" +CCTK_REAL out1D_zline_x "x-coord for 1D lines in z-direction" { -} + *:* :: "" +} 0.0 +CCTK_REAL out1D_zline_y "y-coord for 1D lines in z-direction" +{ + *:* :: "" +} 0.0 -USES KEYWORD bitant_plane "" +CCTK_INT out1D_xline_yi "y-index (from 0) for 1D lines in x-direction" { -} + 0:* :: "" +} 0 +CCTK_INT out1D_xline_zi "z-index (from 0) for 1D lines in x-direction" +{ + 0:* :: "" +} 0 + +CCTK_INT out1D_yline_xi "x-index (from 0) for 1D lines in y-direction" +{ + 0:* :: "" +} 0 +CCTK_INT out1D_yline_zi "z-index (from 0) for 1D lines in y-direction" +{ + 0:* :: "" +} 0 + +CCTK_INT out1D_zline_xi "x-index (from 0) for 1D lines in z-direction" +{ + 0:* :: "" +} 0 +CCTK_INT out1D_zline_yi "y-index (from 0) for 1D lines in z-direction" +{ + 0:* :: "" +} 0 + + +############################ +# Specific to 2D output +# Choosing what output to do +############################ +CCTK_REAL out2D_yzplane_x "x-coord for 2D planes in yz" +{ + *:* :: "" +} 0.0 + +CCTK_REAL out2D_xzplane_y "y-coord for 2D planes in xz" +{ + *:* :: "" +} 0.0 + +CCTK_REAL out2D_xyplane_z "z-coord for 2D planes in xy" +{ + *:* :: "" +} 0.0 + +CCTK_INT out2D_xyplane_zi "z-index (from 0) for 2D planes in xy" +{ + 0:* :: "" +} 0 + +CCTK_INT out2D_xzplane_yi "y-index (from 0) for 2D planes in xz" +{ + 0:* :: "" +} 0 + +CCTK_INT out2D_yzplane_xi "x-index (from 0) for 2D planes in yz" +{ + 0:* :: "" +} 0 + ############################################################################# @@ -118,7 +194,84 @@ USES INT out_every "" } -################ +####################### +# What slices to output +####################### +USES CCTK_REAL out_xline_y "" +{ +: :: +} +USES CCTK_REAL out_xline_z "" +{ +: :: +} +USES CCTK_REAL out_yline_x "" +{ +: :: +} +USES CCTK_REAL out_yline_z "" +{ +: :: +} +USES CCTK_REAL out_zline_x "" +{ +: :: +} +USES CCTK_REAL out_zline_y "" +{ +: :: +} +USES CCTK_INT out_xline_yi "" +{ +: :: +} +USES CCTK_INT out_xline_zi "" +{ +: :: +} +USES CCTK_INT out_yline_xi "" +{ +: :: +} +USES CCTK_INT out_yline_zi "" +{ +: :: +} +USES CCTK_INT out_zline_xi "" +{ +: :: +} +USES CCTK_INT out_zline_yi "" +{ +: :: +} +USES CCTK_REAL out_yzplane_x "" +{ +: :: +} +USES CCTK_REAL out_xzplane_y "" +{ +: :: +} +USES CCTK_REAL out_xyplane_z "" +{ +: :: +} +USES CCTK_INT out_xyplane_zi "" +{ +: :: +} +USES CCTK_INT out_xzplane_yi "" +{ +: :: +} +USES CCTK_INT out_yzplane_xi "" +{ +: :: +} + + + # various things ################ USES BOOLEAN verbose "" diff --git a/schedule.ccl b/schedule.ccl index 6044fcb..c2f99f7 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -8,3 +8,13 @@ schedule IOASCII_Startup at STARTUP after IOUtil_Startup { LANG:C } "Startup routine" + +schedule IOASCII_Choose1D at BASEGRID after SpatialCoordinates +{ + LANG:C +} "Choose 1D output lines" + +schedule IOASCII_Choose2D at BASEGRID after SpatialCoordinates +{ + LANG:C +} "Choose 2D output planes"
\ No newline at end of file diff --git a/src/ChooseOutput.c b/src/ChooseOutput.c new file mode 100644 index 0000000..f166789 --- /dev/null +++ b/src/ChooseOutput.c @@ -0,0 +1,321 @@ +/*@@ + @file ChooseOutput.c + @author Gabrielle Allen + @date July 6 2000 + @desc + Choose what data to write for different IO methods in IOASCII + @enddesc + + @history + @hauthor + @hdesc + @version $Header$ +@@*/ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "CactusBase/IOUtil/src/ioGH.h" +#include "ioASCIIGH.h" + +static char *rcsid = "$Header$"; +CCTK_FILEVERSION(CactusBase_IOASCII_ChooseOutput_c) + +/*@@ + @routine IOASCII_Choose1D + @author Gabrielle Allen + @date July 6 2000 + @desc + Use parameters to choose the 1D slices through the output data. + @enddesc + + @history + @hauthor + @hdesc + @version $Header$ +@@*/ + +void IOASCII_Choose1D(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_PARAMETERS + + int i; + asciiioGH *myGH; /* IOASCII extension handle */ + CCTK_INT **origin_index; /* Specify output lines with indices */ + CCTK_REAL **origin_phys; /* Specify output lines with coordinates */ + cGroup groupinfo; /* variable's group info */ + + myGH = (asciiioGH *) cctkGH->extensions + [CCTK_GHExtensionHandle ("IOASCII")]; + + /* Set up lines to be output */ + origin_phys = (CCTK_REAL **)malloc(3*sizeof(CCTK_REAL *)); + origin_phys[0] = (CCTK_REAL *)malloc(3*sizeof(CCTK_REAL )); + origin_phys[1] = (CCTK_REAL *)malloc(3*sizeof(CCTK_REAL )); + origin_phys[2] = (CCTK_REAL *)malloc(3*sizeof(CCTK_REAL )); + + origin_index = (CCTK_INT **)malloc(3*sizeof(CCTK_INT *)); + origin_index[0] = (CCTK_INT *)malloc(3*sizeof(CCTK_INT )); + origin_index[1] = (CCTK_INT *)malloc(3*sizeof(CCTK_INT )); + origin_index[2] = (CCTK_INT *)malloc(3*sizeof(CCTK_INT )); + + /* Set parameters using + 1. Indices from IOASCII + 2. Indices from IOUtil + 3. Coords from IOASCII + 4. Coords from IOUtil + */ + + /* x-lines */ + if (CCTK_ParameterQueryTimesSet("out1D_xline_yi","IOASCII")>0) + { + origin_index[0][1] = out1D_xline_yi; + } + else if (CCTK_ParameterQueryTimesSet("out_xline_yi","IOUtil")>0) + { + origin_index[0][1] = out_xline_yi; + } + else + { + origin_index[0][1] = -1; + if (CCTK_ParameterQueryTimesSet("out1D_xline_y","IOASCII")>0) + { + origin_phys[0][1] = out1D_xline_y; + } + else + { + origin_phys[0][1] = out_xline_y; + } + } + + if (CCTK_ParameterQueryTimesSet("out1D_xline_zi","IOASCII")>0) + { + origin_index[0][2] = out1D_xline_zi; + } + else if (CCTK_ParameterQueryTimesSet("out_xline_zi","IOUtil")>0) + { + origin_index[0][2] = out_xline_zi; + } + else + { + origin_index[0][2] = -1; + if (CCTK_ParameterQueryTimesSet("out1D_xline_z","IOASCII")>0) + { + origin_phys[0][2] = out1D_xline_z; + } + else + { + origin_phys[0][2] = out_xline_z; + } + } + + + + /* y-lines */ + if (CCTK_ParameterQueryTimesSet("out1D_yline_xi","IOASCII")>0) + { + origin_index[1][0] = out1D_yline_xi; + } + else if (CCTK_ParameterQueryTimesSet("out_yline_xi","IOUtil")>0) + { + origin_index[1][0] = out_yline_xi; + } + else + { + origin_index[1][0] = -1; + if (CCTK_ParameterQueryTimesSet("out1D_yline_x","IOASCII")>0) + { + origin_phys[1][0] = out1D_yline_x; + } + else + { + origin_phys[1][0] = out_yline_x; + } + } + + if (CCTK_ParameterQueryTimesSet("out1D_yline_zi","IOASCII")>0) + { + origin_index[1][2] = out1D_yline_zi; + } + else if (CCTK_ParameterQueryTimesSet("out_yline_zi","IOUtil")>0) + { + origin_index[1][2] = out_yline_zi; + } + else + { + origin_index[1][2] = -1; + if (CCTK_ParameterQueryTimesSet("out1D_yline_z","IOASCII")>0) + { + origin_phys[1][2] = out1D_yline_z; + } + else + { + origin_phys[1][2] = out_yline_z; + } + } + + /* z-lines */ + if (CCTK_ParameterQueryTimesSet("out1D_zline_xi","IOASCII")>0) + { + origin_index[2][0] = out1D_zline_xi; + } + else if (CCTK_ParameterQueryTimesSet("out_zline_xi","IOUtil")>0) + { + origin_index[2][0] = out_zline_xi; + } + else + { + origin_index[2][0] = -1; + if (CCTK_ParameterQueryTimesSet("out1D_zline_x","IOASCII")>0) + { + origin_phys[2][0] = out1D_zline_x; + } + else + { + origin_phys[2][0] = out_zline_x; + } + } + + if (CCTK_ParameterQueryTimesSet("out1D_zline_yi","IOASCII")>0) + { + origin_index[2][1] = out1D_zline_yi; + } + else if (CCTK_ParameterQueryTimesSet("out_zline_yi","IOUtil")>0) + { + origin_index[2][1] = out_zline_yi; + } + else + { + origin_index[2][1] = -1; + if (CCTK_ParameterQueryTimesSet("out1D_zline_y","IOASCII")>0) + { + origin_phys[2][1] = out1D_zline_y; + } + else + { + origin_phys[2][1] = out_zline_y; + } + } + + for (i=1;i<=CCTK_MaxDim();i++) + { + IOUtil_1DLines (cctkGH, i, origin_index, + origin_phys, myGH->spxyz[i-1]); + } + + return; +} + + + +/*@@ + @routine IOASCII_Choose2D + @author Gabrielle Allen + @date July 6 2000 + @desc + Use parameters to choose the 2D planes through the output data. + @enddesc + + @history + @hauthor + @hdesc + @version $Header$ +@@*/ + +void IOASCII_Choose2D(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_PARAMETERS + + int i; + asciiioGH *myGH; /* IOASCII extension handle */ + CCTK_INT *origin_index; /* Specify output planes by indices */ + CCTK_REAL *origin_phys; /* Specify output planes by coordinates */ + cGroup groupinfo; /* Variable's group info */ + + myGH = (asciiioGH *) cctkGH->extensions + [CCTK_GHExtensionHandle ("IOASCII")]; + + /* Set up lines to be output */ + origin_phys = (CCTK_REAL *)malloc(3*sizeof(CCTK_REAL )); + origin_index = (CCTK_INT *)malloc(3*sizeof(CCTK_INT )); + + /* Set parameters using + 1. Indices from IOASCII + 2. Indices from IOUtil + 3. Coords from IOASCII + 4. Coords from IOUtil + */ + + if (CCTK_ParameterQueryTimesSet("out2D_yzplane_xi","IOASCII")>0) + { + origin_index[0] = out2D_yzplane_xi; + } + else if (CCTK_ParameterQueryTimesSet("out_yzplane_xi","IOUtil")>0) + { + origin_index[0] = out_yzplane_xi; + } + else + { + origin_index[0] = -1; + if (CCTK_ParameterQueryTimesSet("out2D_yzplane_x","IOASCII")>0) + { + origin_phys[0] = out2D_yzplane_x; + } + else + { + origin_phys[0] = out_yzplane_x; + } + } + + if (CCTK_ParameterQueryTimesSet("out2D_xzplane_yi","IOASCII")>0) + { + origin_index[1] = out2D_xzplane_yi; + } + else if (CCTK_ParameterQueryTimesSet("out_xzplane_yi","IOUtil")>0) + { + origin_index[1] = out_xzplane_yi; + } + else + { + origin_index[1] = -1; + if (CCTK_ParameterQueryTimesSet("out2D_xzplane_y","IOASCII")>0) + { + origin_phys[1] = out2D_xzplane_y; + } + else + { + origin_phys[1] = out_xzplane_y; + } + } + + if (CCTK_ParameterQueryTimesSet("out2D_xyplane_zi","IOASCII")>0) + { + origin_index[2] = out2D_xyplane_zi; + } + else if (CCTK_ParameterQueryTimesSet("out_xyplane_zi","IOUtil")>0) + { + origin_index[2] = out_xyplane_zi; + } + else + { + origin_index[2] = -1; + if (CCTK_ParameterQueryTimesSet("out2D_xyplane_z","IOASCII")>0) + { + origin_phys[2] = out2D_xyplane_z; + } + else + { + origin_phys[2] = out_xyplane_z; + } + } + + for (i=1;i<=CCTK_MaxDim();i++) + { + IOUtil_2DPlanes (cctkGH, i, origin_index, + origin_phys, myGH->sp2xyz[i-1]); + } + + return; +} + + diff --git a/src/GHExtension.c b/src/GHExtension.c index dda0ef8..043d964 100644 --- a/src/GHExtension.c +++ b/src/GHExtension.c @@ -6,16 +6,12 @@ IO GH extension stuff. @enddesc @history - @hauthor Thomas Radke @hdate 16 Mar 1999 - @hdesc Added parameters for 2D and 3D output - @hauthor Thomas Radke @hdate 01 Apr 1999 - @hdesc check parameter symmetry instead of grid in Automatic1DLines() - @hauthor Gerd Lanfermann @hdate 01 Apr 2000 - @hdesc fixed out in bitant / octant mode + @hauthor @hdate + @hdesc @endhistory @@*/ -/*#define DEBUGME*/ +/*#define DEBUG_IOASCII*/ #include <stdlib.h> #include <string.h> @@ -26,20 +22,31 @@ #include "CactusBase/IOUtil/src/ioGH.h" #include "ioASCIIGH.h" - -/* local function prototypes */ -void Automatic1DLines (cGH *GH); +static char *rcsid = "$Header$"; +CCTK_FILEVERSION(CactusBase_IOASCII_GHExtension_c) void *IOASCII_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) { asciiioGH *newGH; + int i; newGH = (asciiioGH *) malloc (sizeof (asciiioGH)); newGH->do_out1D = (char *) malloc (CCTK_NumVars () * sizeof (char)); newGH->do_out2D = (char *) malloc (CCTK_NumVars () * sizeof (char)); newGH->out1D_last = (int *) malloc (CCTK_NumVars () * sizeof (int)); newGH->out2D_last = (int *) malloc (CCTK_NumVars () * sizeof (int)); + newGH->spxyz = (int ***) malloc (CCTK_MaxDim() * sizeof (int **)); + newGH->sp2xyz = (int **) malloc (3 * sizeof (int *)); + for (i=0;i<CCTK_MaxDim();i++) + { + newGH->spxyz[i] = (int **) malloc (3 * sizeof (int *)); + newGH->spxyz[i][0] = (int *) malloc (3 * sizeof (int )); + newGH->spxyz[i][1] = (int *) malloc (3 * sizeof (int )); + newGH->spxyz[i][2] = (int *) malloc (3 * sizeof (int )); + + newGH->sp2xyz[i] = (int *) malloc (3 * sizeof (int )); + } return newGH; } @@ -68,8 +75,8 @@ int IOASCII_InitGH (cGH *GH) myGH->out2D_every = out2D_every; } - ParseVarsForOutput (out1D_vars, myGH->do_out1D); - ParseVarsForOutput (out2D_vars, myGH->do_out2D); + IOUtil_ParseVarsForOutput (out1D_vars, myGH->do_out1D); + IOUtil_ParseVarsForOutput (out2D_vars, myGH->do_out2D); /* Deal with the output directories */ /* Check whether "outdirXD" was set. @@ -86,18 +93,30 @@ int IOASCII_InitGH (cGH *GH) { i = CCTK_CreateDirectory (0755, myGH->outdir1D); if (i < 0) + { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Problem creating 1D output directory '%s'", myGH->outdir1D); + "IOASCII_InitGH: Problem creating 1D output directory '%s'", + myGH->outdir1D); + } if (i > 0) + { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, - "1D output directory '%s' already exists", myGH->outdir1D); + "IOASCII_InitGH: 1D output directory '%s' already exists", + myGH->outdir1D); + } i = CCTK_CreateDirectory (0755, myGH->outdir2D); if (i < 0) + { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Problem creating 2D output directory '%s'", myGH->outdir2D); + "IOASCII_InitGH: Problem creating 2D output directory '%s'", + myGH->outdir2D); + } if (i > 0) + { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, - "2D output directory '%s' already exists", myGH->outdir2D); + "IOASCII_InitGH: 2D output directory '%s' already exists", + myGH->outdir2D); + } } for (i=0; i<CCTK_NumVars(); i++) @@ -109,154 +128,6 @@ int IOASCII_InitGH (cGH *GH) myGH->filenameList1D = NULL; myGH->fileList_2D = NULL; - /* Set up lines to plot */ - Automatic1DLines (GH); - return 0; } - -/****************************************************************************/ -/* local routines */ -/****************************************************************************/ - /*@@ - @routine Automatic1DLines - @date Fri Apr 7 16:27:13 2000 - @author Gerd Lanfermann/Thomas Radke - @desc - 1D lines in Cactus are output along the center coordinate lines. - Here, the initial index to start the 1d slice is calculated and saved - int the GHextension, called IOASCII. - The structure spxyz[3][3]. (spxyz for slicing point ?), where the first - slot takes the direction to slice along (0~x, 1~y,...). The second - slot takes the starting coordinates. For example octant, - start at 1,1,1 (skip ghosts(0,0,0) and start "lower left corner"). - - @enddesc - @calls - @calledby - @history - - @endhistory - -@@*/ - -void Automatic1DLines (cGH *GH) -{ - DECLARE_CCTK_PARAMETERS - int dim, dir; - asciiioGH *myGH; - - - /* Get the handle for IOASCII extensions */ - myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; - - /* 1D lines for Full mode */ - if (CCTK_Equals (domain, "full")) - { - for (dir = 0; dir < 3; dir++) - for (dim = 0; dim < 3; dim++) - if (dim == dir) - myGH->spxyz [dir][dim] = 0; - else - myGH->spxyz [dir][dim] = GH->cctk_gsh [dim] >> 1; - } - /* 1D lines for Octant */ - else if (CCTK_Equals (domain, "octant")) - { - for (dir = 0; dir < 3; dir++) - for (dim = 0; dim < 3; dim++) - myGH->spxyz [dir][dim] = 0; - } - /* 1D lines for Bitant (xy,xz,yx) */ - else if (CCTK_Equals (domain, "bitant")) - { - if (CCTK_Equals (bitant_plane, "xy")) - { - /* slice X-line */ - myGH->spxyz[0][0] = 0; - myGH->spxyz[0][1] = GH->cctk_gsh [1] >> 1; - myGH->spxyz[0][2] = 0; - - /* slice Y-line */ - myGH->spxyz[1][0] = GH->cctk_gsh [0] >> 1; - myGH->spxyz[1][1] = 0; - myGH->spxyz[1][2] = 0; - - /* slice Z-line */ - myGH->spxyz[2][0] = GH->cctk_gsh [0] >> 1; - myGH->spxyz[2][1] = GH->cctk_gsh [1] >> 1; - myGH->spxyz[2][2] = 0; - } - else if (CCTK_Equals(bitant_plane, "xz")) - { - /* slice X-line */ - myGH->spxyz[0][0] = 0; - myGH->spxyz[0][1] = 0; - myGH->spxyz[0][2] = GH->cctk_gsh [2] >> 1; - - /* slice Y-line */ - myGH->spxyz[1][0] = GH->cctk_gsh [0] >> 1; - myGH->spxyz[1][1] = 0; - myGH->spxyz[1][2] = GH->cctk_gsh [2] >> 1; - - /* slice Z-line */ - myGH->spxyz[2][0] = GH->cctk_gsh [0] >> 1; - myGH->spxyz[2][1] = 0; - myGH->spxyz[2][2] = 0; - } - else if (CCTK_Equals(bitant_plane, "yz")) - { - /* slice X-line */ - myGH->spxyz[0][0] = 0; - myGH->spxyz[0][1] = GH->cctk_gsh [1] >> 1; - myGH->spxyz[0][2] = GH->cctk_gsh [2] >> 1; - - /* slice Y-line */ - myGH->spxyz[1][0] = 0; - myGH->spxyz[1][1] = 0; - myGH->spxyz[1][2] = GH->cctk_gsh [2] >> 1; - - /* slice Z-line */ - myGH->spxyz[2][0] = 0; - myGH->spxyz[2][1] = GH->cctk_gsh [1] >> 1; - myGH->spxyz[2][2] = 0; - } - else - { - CCTK_WARN(1,"1D slicing not possible for this bitant. Gibs nich"); - } - } - /* 1D lines for quadrant, very untested, hardcoded quadrant */ - else if (CCTK_Equals (domain, "quadrant")) - { - /* slice X-line */ - myGH->spxyz[0][0] = 0; - myGH->spxyz[0][1] = 0; - myGH->spxyz[0][2] = GH->cctk_gsh [2] >> 1; - - /* slice Y-line */ - myGH->spxyz[1][0] = 0; - myGH->spxyz[1][1] = 0; - myGH->spxyz[1][2] = GH->cctk_gsh [2] >> 1; - - /* slice Z-line */ - myGH->spxyz[2][0] = 0; - myGH->spxyz[2][1] = 0; - myGH->spxyz[2][2] = 0; - } - else - { - CCTK_WARN(1,"No 1D slicing for that grid layout supported"); - } - -#ifdef DEBUGME - printf("X Slicing center: %d %d %d \n", - myGH->spxyz[0][0], myGH->spxyz[0][1], myGH->spxyz[0][2]); - printf("Y Slicing center: %d %d %d \n", - myGH->spxyz[1][0], myGH->spxyz[1][1], myGH->spxyz[1][2]); - printf("Z Slicing center: %d %d %d \n", - myGH->spxyz[2][0], myGH->spxyz[2][1], myGH->spxyz[2][2]); -#endif - -} diff --git a/src/Output1D.c b/src/Output1D.c index 0ee1c66..a684e85 100644 --- a/src/Output1D.c +++ b/src/Output1D.c @@ -281,7 +281,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) /* re-parse the 'out1D_vars' parameter if it was changed */ if (paramdata->n_set != out1D_vars_lastset) { - ParseVarsForOutput (out1D_vars, myGH->do_out1D); + IOUtil_ParseVarsForOutput (out1D_vars, myGH->do_out1D); /* Save the last setting of 'out1D_vars' parameter */ out1D_vars_lastset = paramdata->n_set; diff --git a/src/Output2D.c b/src/Output2D.c index c009881..149befb 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -280,7 +280,7 @@ static void CheckSteerableParameters (asciiioGH *myGH) /* re-parse the 'out2D_vars' parameter if it was changed */ if (paramdata->n_set != out2D_vars_lastset) { - ParseVarsForOutput (out2D_vars, myGH->do_out2D); + IOUtil_ParseVarsForOutput (out2D_vars, myGH->do_out2D); /* Save the last setting of 'out2D_vars' parameter */ out2D_vars_lastset = paramdata->n_set; diff --git a/src/Startup.c b/src/Startup.c index 32ad4e9..ad7fc69 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -73,4 +73,5 @@ void IOASCII_Startup (void) CCTK_RegisterIOMethodOutputVarAs (IOMethod, IOASCII_Output2DVarAs); CCTK_RegisterIOMethodTimeToOutput (IOMethod, IOASCII_TimeFor2D); CCTK_RegisterIOMethodTriggerOutput (IOMethod, IOASCII_TriggerOutput2D); + } diff --git a/src/Write1D.c b/src/Write1D.c index 3629d6e..bfa561f 100644 --- a/src/Write1D.c +++ b/src/Write1D.c @@ -36,7 +36,7 @@ @version $Header$ @@*/ -/*$#define DEBUG_IOASCII$*/ +/*#define DEBUG_IOASCII*/ #include <stdio.h> @@ -52,10 +52,9 @@ #include "CactusPUGH/Hyperslab/src/Hyperslab.h" #include "ioASCIIGH.h" - /* the rcs ID and its dummy function to use it */ static char *rcsid = "$Header$"; -CCTK_FILEVERSION(CactusPUGHIO_IOASCII_Write1D_c) +CCTK_FILEVERSION(CactusBase_IOASCII_Write1D_c) /* macro to output a 1D line (with coordinates for GFs) as typed data */ @@ -78,6 +77,7 @@ CCTK_FILEVERSION(CactusPUGHIO_IOASCII_Write1D_c) { \ for (i = 0; i < hsize; i++) \ fprintf (file, format, \ + (double) (i), \ (c_type) cctk_extract_fn (typed_data [i])); \ } \ } @@ -120,22 +120,23 @@ CCTK_FILEVERSION(CactusPUGHIO_IOASCII_Write1D_c) void IOASCII_Write1D (cGH *GH, int index, const char *alias) { DECLARE_CCTK_PARAMETERS - asciiioGH *myGH; /* IOASCII extension handle */ - ioGH *ioUtilGH; /* IOUtil extension handle */ - int myproc; /* identify processor */ - int i, dir; /* Loopers */ - int timelevel; /* timelevel of variable to output */ - int groupindex; /* variable's group index */ - cGroup groupinfo; /* variable's group info */ - const char *header_fmt; /* header format string */ - const char *data_fmt_int; /* data format string for int types */ - const char *data_fmt_real; /* data format string for float types */ - FILE *file [8]; /* fds for x,y,z,d output (also COMPLEX)*/ - int Do_it [4]; /* flags indicating actual work */ - int coord_index [3]; /* x,y,z coordinate variable indices */ - int is_cubic; /* true if variable lives on cubic grid */ - CCTK_INT **groupsizes; /* the global sizes for array variables */ - + asciiioGH *myGH; /* IOASCII extension handle */ + ioGH *ioUtilGH; /* IOUtil extension handle */ + int Do_it [4]; /* flags indicating actual work */ + int coord_index [3]; /* x,y,z coordinate variable indices */ + int is_cubic; /* true if variable lives on cubic grid */ + int myproc; /* identify processor */ + int i, dir; /* Loopers */ + int timelevel; /* timelevel of variable to output */ + int groupindex; /* variable's group index */ + int **origin_index; /* Specify output lines with indices */ + int have_coords=1; /* boolean for existance of coordinates */ + CCTK_INT **groupsizes; /* the global sizes for array variables */ + cGroup groupinfo; /* variable's group info */ + const char *header_fmt; /* header format string */ + const char *data_fmt_int; /* data format string for int types */ + const char *data_fmt_real; /* data format string for float types */ + FILE *file [8]; /* fds for x,y,z,d output (also COMPLEX)*/ /* get the variable's group information */ groupindex = CCTK_GroupIndexFromVarI (index); @@ -147,11 +148,16 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) char *fullname = CCTK_FullName (index); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, - "No IOASCII 1D output for '%s' (no storage)", fullname); + "IOASCII_Write1D: No IOASCII_1D output for '%s' (no storage)", fullname); free (fullname); return; } + /* Get the handles for IOUtil and IOASCII extensions */ + ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; + myGH = (asciiioGH *) GH->extensions + [CCTK_GHExtensionHandle ("IOASCII")]; + /* see what slices should be output */ Do_it [0] = out1D_x && groupinfo.dim >= 1; Do_it [1] = out1D_y && groupinfo.dim >= 2; @@ -161,13 +167,17 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) if (groupinfo.grouptype == CCTK_GF) { for (i = 1; i < groupinfo.dim; i++) + { is_cubic &= GH->cctk_gsh [i] == GH->cctk_gsh [0]; + } } else { groupsizes = CCTK_GroupSizesI (groupindex); for (i = 1; i < groupinfo.dim; i++) + { is_cubic &= *groupsizes [i] == *groupsizes [0]; + } } Do_it [3] = out1D_d && groupinfo.dim == 3 && @@ -184,9 +194,13 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) if (CCTK_Equals (out_format, "f")) { if (CCTK_Equals (out_style, "gnuplot")) + { header_fmt = "\n\n#Time = %f\n"; + } else + { header_fmt = "\n\n\"Time = %f\n"; + } if (groupinfo.grouptype == CCTK_GF) { data_fmt_int = "%f\t\t%d\n"; @@ -194,8 +208,8 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) } else { - data_fmt_int = "%d\n"; - data_fmt_real = "%.13f\n"; + data_fmt_int = "%d\t\t%d\n"; + data_fmt_real = "%f\t\t%.13f\n"; } } else @@ -223,10 +237,6 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) fflush (stdout); #endif - /* Get the handles for IOUtil and IOASCII extensions */ - ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; - myGH = (asciiioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOASCII")]; - /* What processor are we on? */ myproc = CCTK_MyProc (GH); @@ -294,7 +304,8 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) if (! (file [n] = fopen (filename, openmode))) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Cannot open 1D output file '%s'", filename); + "IOASCII_Write1D: Cannot open 1D output file '%s'", + filename); } else { @@ -326,9 +337,46 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) } /* get the coordinate indices */ - coord_index [0] = CCTK_CoordIndex ("x"); - coord_index [1] = CCTK_CoordIndex ("y"); - coord_index [2] = CCTK_CoordIndex ("z"); + switch (groupinfo.dim) + { + case 1: + coord_index [0] = CCTK_CoordIndex (1,NULL,"cart1d"); + if (coord_index[0]<0) + { + have_coords = 0; + } + break; + case 2: + coord_index [0] = CCTK_CoordIndex (1,NULL,"cart2d"); + coord_index [1] = CCTK_CoordIndex (2,NULL,"cart2d"); + if (coord_index[0]<0 || coord_index[1]<0) + { + have_coords = 0; + } + break; + case 3: + coord_index [0] = CCTK_CoordIndex (1,NULL,"cart3d"); + coord_index [1] = CCTK_CoordIndex (2,NULL,"cart3d"); + coord_index [2] = CCTK_CoordIndex (3,NULL,"cart3d"); + if (coord_index[0]<0 || coord_index[1]<0 || coord_index[2]<0) + { + have_coords = 0; + } + break; + default: + CCTK_VWarn(4,__LINE__,__FILE__,"IOASCII", + "IOASCII_Write1D: Coord system for dim %d not supported", + groupinfo.dim); + have_coords = 0; + break; + } + + if (!have_coords) + { + CCTK_VWarn(8,__LINE__,__FILE__,"IOASCII", + "IOASCII_Write1D: No coordinate system found for %s", + CCTK_VarName(index)); + } /* get the current time level */ timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1; @@ -359,29 +407,38 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) if (dir < 3) { /* set the origin of the line */ - origin = myGH->spxyz [dir]; + origin = myGH->spxyz [groupinfo.dim-1][dir]; /* set the direction vector for the 1D line */ memset (directions, 0, sizeof (directions)); directions [dir] = 1; - /* get the current time level for the coordinates */ - coord_timelevel = CCTK_NumTimeLevelsFromVarI (coord_index [dir]) - 1; - if (coord_timelevel > 0) - coord_timelevel--; - - if (Hyperslab_GetHyperslab (GH, 0, coord_index [dir], coord_timelevel, - 1, origin, directions, &length, &downsample, - (void **) &coord_data, &hsize) < 0) - { - char *fullname = CCTK_FullName (coord_index [dir]); - - - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Failed to extract hyperslab for variable '%s'",fullname); - free (fullname); - continue; - } + if (have_coords) + { + /* get the current time level for the coordinates */ + coord_timelevel = CCTK_NumTimeLevelsFromVarI (coord_index [dir]) - 1; + if (coord_timelevel > 0) + coord_timelevel--; + + if (Hyperslab_GetHyperslab (GH, 0, coord_index [dir], + coord_timelevel, 1, origin, directions, + &length, &downsample, + (void **) &coord_data, &hsize) < 0) + { + char *fullname = CCTK_FullName (coord_index [dir]); + + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOASCII_Write1D: Failed to extract hyperslab for" + " variable '%s'", + fullname); + free (fullname); + continue; + } + } + else + { + coord_data = NULL; + } } else { @@ -390,7 +447,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) /* set the direction vector for the diagonal 1D line */ for (i = 0; i < 3; i++) + { directions [i] = 1; + } /* coordinates are calculated by output processor */ coord_data = NULL; @@ -416,10 +475,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) &data, &hsize) < 0) { char *fullname = CCTK_FullName (index); - - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Failed to extract hyperslab for variable '%s'", fullname); + "IOASCII_Write1D: Failed to extract hyperslab for " + "variable '%s'", fullname); free (fullname); if (coord_data) free (coord_data); @@ -431,7 +489,6 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) { CCTK_REAL lower, offset; - if (groupinfo.grouptype == CCTK_GF) { if (dir < 3) @@ -439,16 +496,33 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) /* get the staggering offset for the xyz coordinates */ offset = CCTK_StaggerDirIndex (dir, groupinfo.stagtype) * 0.5 * GH->cctk_delta_space [dir]; + if (!have_coords) + { + coord_data = (CCTK_REAL *) malloc (hsize * sizeof (CCTK_REAL)); + for (i = 0; i < hsize; i++) + { + coord_data [i] = i; + } + } } else { /* get the diagonal coordinates */ coord_data = (CCTK_REAL *) malloc (hsize * sizeof (CCTK_REAL)); - CCTK_CoordRange (GH, &lower, &offset, "x"); coord_data [0] = 0.0; - offset = GH->cctk_delta_space [0] * sqrt (3); + if (have_coords) + { + CCTK_CoordRange(GH,&lower,&offset,1,NULL,"cart3d"); + } + else + { + lower = 0.0; + } + offset = have_coords ? GH->cctk_delta_space [0] * sqrt (3) : sqrt(3); for (i = 1; i < hsize; i++) + { coord_data [i] = coord_data [i-1] + offset; + } offset = lower * sqrt (3); } } @@ -502,7 +576,9 @@ void IOASCII_Write1D (cGH *GH, int index, const char *alias) /* clean up */ free (data); if (coord_data) + { free (coord_data); + } } } /* end of loop through all directions */ diff --git a/src/Write2D.c b/src/Write2D.c index b3d54fe..6b927d2 100644 --- a/src/Write2D.c +++ b/src/Write2D.c @@ -212,9 +212,24 @@ FIXME: get rid of PUGH here } /* get the coordinate indices */ - coord_index [0] = CCTK_CoordIndex ("x"); - coord_index [1] = CCTK_CoordIndex ("y"); - coord_index [2] = CCTK_CoordIndex ("z"); + switch (groupinfo.dim) + { + case 1: + coord_index [0] = CCTK_CoordIndex (1,NULL,"cart1d"); + break; + case 2: + coord_index [0] = CCTK_CoordIndex (1,NULL,"cart2d"); + coord_index [1] = CCTK_CoordIndex (2,NULL,"cart2d"); + case 3: + coord_index [0] = CCTK_CoordIndex (1,NULL,"cart3d"); + coord_index [1] = CCTK_CoordIndex (2,NULL,"cart3d"); + coord_index [2] = CCTK_CoordIndex (3,NULL,"cart3d"); + break; + default: + CCTK_VWarn(4,__LINE__,__FILE__,"IOASCII", + "Cannot find appropriate coordinate system"); + break; + } /* get the coordinate timelevels */ for (dir = 0; dir < 3; dir++) @@ -256,7 +271,7 @@ FIXME: get rid of PUGH here /* set the origin using the slice center from IOUtil */ memset (origin, 0, GH->cctk_dim * sizeof (int)); - origin [dir] = ioUtilGH->sp2xyz [dir]; + origin [dir] = myGH->sp2xyz [groupinfo.dim-1][dir]; /* set the directions vector */ memset (directions, 0, sizeof (directions)); diff --git a/src/ioASCIIGH.h b/src/ioASCIIGH.h index 8593022..e2235f7 100644 --- a/src/ioASCIIGH.h +++ b/src/ioASCIIGH.h @@ -42,8 +42,12 @@ typedef struct IOASCIIGH { pNamedData *fileList_2D; /* for 1d lines, we define the index where to start the line: - spxyz[XYZdirection][xyzstart_index] */ - int spxyz[3][3]; + spxyz[maxdim][XYZdirection][xyzstart_index] */ + int ***spxyz; + + /* for 2d planes, we define the index where to locate the plane + sp2xyz[maxdim][perpendicular direction] */ + int **sp2xyz; } asciiioGH; diff --git a/src/make.code.defn b/src/make.code.defn index 2a4fafd..a8cd01d 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -2,4 +2,10 @@ # $Header$ # Source files in this directory -SRCS = Startup.c GHExtension.c Output1D.c Write1D.c Output2D.c Write2D.c +SRCS = Startup.c\ + ChooseOutput.c\ + GHExtension.c\ + Output1D.c\ + Write1D.c\ + Output2D.c\ + Write2D.c |