diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2003-07-07 13:17:56 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2003-07-07 13:17:56 +0000 |
commit | f328e64bb16ebe3c2a64bb1b15601206c6b70b3f (patch) | |
tree | 6a54c88cb064dc6b541787ad590f4dc75542f7ab | |
parent | 06d86f26e4b38c3aa06d6e26136fc7309452dcaf (diff) |
add code to automagically generate control files for Thomas Radke's
new OpenDX macros (which can read AHFinderDirect gnuplot-format output files)
> Update of /numrelcvs/AEIPhysics/Visualization/OpenDX/Macros
> In directory cvsserv:/tmp/cvs-serv29388
>
> Added Files:
> ImportAHFinderDirectGnuplot.net
> ImportAHFinderDirectGnuplotPatch.net
> Log Message:
>
> Macros which can read the AHFinderDirect gnuplot output files
> directly into OpenDX.
There is a new Boolean parameter output_OpenDX_control_files
to control whether the control files (one per horizon) should be written,
but this defaults to true, so you don't need to do anything special to get
the control files.
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@1125 f88db872-0e4f-0410-b76b-b9085cfa78c5
-rw-r--r-- | param.ccl | 26 | ||||
-rw-r--r-- | src/driver/Newton.cc | 10 | ||||
-rw-r--r-- | src/driver/driver.hh | 9 | ||||
-rw-r--r-- | src/driver/io.cc | 48 | ||||
-rw-r--r-- | src/driver/setup.cc | 3 |
5 files changed, 93 insertions, 3 deletions
@@ -311,9 +311,9 @@ string HDF5_file_name_extension "extension for HDF5 data files" # where # - the first %s is the base file name, # - the first %d is the global Cactus time iteration number cctk_iteration, -# - the second %d is the apparent horizon number, ande +# - the second %d is the apparent horizon number, # - the optional third %d is the horizon finder iteration number -# - the second %s is the file name extension as set by the +# - the second %s is the file name extension # {ASCII,HDF5}_data_file_name_extension # @@ -334,6 +334,28 @@ string Delta_h_base_file_name \ .+ :: "any nonempty string" } "Delta_h" +# +# Thomas Radke has written a set of OpenDX macros to read AHFinderDirect +# ASCII (gnuplot) format files. These macros require a "control file" +# for each patch to specify some of the patch metadata. +# +# If we write them, the control file names are given by a printf() format +# "%s.ah%d.%s", where +# - the first %s is h_base_file_name +# - the %d is the apparent horizon number +# - the second %s is the file name extension OpenDX_control_file_name_extension +# +boolean output_OpenDX_control_files \ + "should we output OpenDX control files to allow reading of AHFinderDirect \ + 'ASCII (gnuplot)' format data files?" +{ +} "true" +string OpenDX_control_file_name_extension \ + "file name extension for OpenDX control files" +{ +.+ :: "any nonempty string" +} "dx" + ######################################## # diff --git a/src/driver/Newton.cc b/src/driver/Newton.cc index 7dddda7..059265c 100644 --- a/src/driver/Newton.cc +++ b/src/driver/Newton.cc @@ -355,10 +355,18 @@ if (hs.has_genuine_horizons()) if (found_this_horizon) then { if (IO_info.output_h) - then output_gridfn(*ps_ptr, gfns::gfn__h, + then { + // if this is the first time we've output h for this + // horizon, maybe output an OpenDX control file? + if (IO_info.output_OpenDX_control_files + && !AH_data_ptr->OpenDX_control_file_written) + then output_OpenDX_control_file(*ps_ptr, + IO_info, hn); + output_gridfn(*ps_ptr, gfns::gfn__h, IO_info, IO_info.h_base_file_name, hn, verbose_info .print_algorithm_highlights); + } if (IO_info.output_Theta) then output_gridfn(*ps_ptr, gfns::gfn__Theta, IO_info, IO_info.Theta_base_file_name, diff --git a/src/driver/driver.hh b/src/driver/driver.hh index 5826fa0..146b49f 100644 --- a/src/driver/driver.hh +++ b/src/driver/driver.hh @@ -135,6 +135,8 @@ struct IO_info const char* Theta_base_file_name; const char* Delta_h_base_file_name; const char* Jacobian_base_file_name; + bool output_OpenDX_control_files; + const char* OpenDX_control_file_name_extension; bool output_BH_diagnostics; const char* BH_diagnostics_base_file_name; @@ -277,6 +279,10 @@ struct AH_data struct initial_guess_info initial_guess_info; bool found_flag; // did we find this horizon (successfully) + bool OpenDX_control_file_written; // have we written an + // OpenDX control file + // (for this horizon) yet? + struct BH_diagnostics BH_diagnostics; FILE *BH_diagnostics_fileptr; @@ -380,6 +386,9 @@ void input_gridfn__explicit_name(patch_system& ps, int unknown_gfn, void output_gridfn(patch_system& ps, int unknown_gfn, const struct IO_info& IO_info, const char base_file_name[], int hn, bool print_msg_flag, int AHF_iteration = 0); +void output_OpenDX_control_file(const patch_system& ps, + const struct IO_info& IO_info, + int hn); void output_Jacobians(const patch_system& ps, const Jacobian* Jac_NP_ptr, const Jacobian* Jac_SD_FDdr_ptr, diff --git a/src/driver/io.cc b/src/driver/io.cc index 82fc532..e9b737c 100644 --- a/src/driver/io.cc +++ b/src/driver/io.cc @@ -4,6 +4,7 @@ // input_gridfn - read an angular grid function from an input file // input_gridfn__explicit_name - ... with the input file explicitly named // output_gridfn - write an angular grid function to an output file +// output_OpenDX_control_file - write an OpenDX control file for an output file // output_Jacobians - write a Jacobian matrix or matrices to an output file // /// io_file_name - compute file name for angular-gridfn I/O file @@ -193,6 +194,53 @@ default: //****************************************************************************** // +// This function outputs an OpenDX control file to allow Thomas Radke's +// OpenDX macros to read in a "ASCII (gnuplot)" data file produced by +// output_gridfn() . +// +void output_OpenDX_control_file(const patch_system& ps, + const struct IO_info& IO_info, + int hn) +{ +const int N_file_name_buffer = 200; +static char file_name_buffer[N_file_name_buffer]; +snprintf(file_name_buffer, N_file_name_buffer, + "%s.ah%d.%s", + IO_info.h_base_file_name, hn, + IO_info.OpenDX_control_file_name_extension); + +FILE *fileptr = fopen(file_name_buffer, "w"); +if (fileptr == NULL) + then CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING, + "output_Jacobians(): can't open output file \"%s\"!", + file_name_buffer); /*NOTREACHED*/ + +fprintf(fileptr, "# list the size of each patch (N_rho x N_sigma)\n"); + for (int pn = 0 ; pn < ps.N_patches() ; ++pn) + { + const patch& p = ps.ith_patch(pn); + fprintf(fileptr, "object \"%s patch\" class array ", p.name()); + fprintf(fileptr, "type int rank 1 shape 2 items 1 data follows %d %d\n", + p.effective_N_irho(IO_info.output_ghost_zones_for_h), + p.effective_N_isigma(IO_info.output_ghost_zones_for_h)); + } +fprintf(fileptr, "\n"); + +fprintf(fileptr, "# collect all patch sizes into a single OpenDX group\n"); +fprintf(fileptr, "# for the ImportAHFinderDirectGnuplot macro to read\n"); +fprintf(fileptr, "object \"patchsizes\" class group\n"); + for (int pn = 0 ; pn < ps.N_patches() ; ++pn) + { + const patch& p = ps.ith_patch(pn); + fprintf(fileptr, "member %d value \"%s patch\"\n", pn, p.name()); + } + +fclose(fileptr); +} + +//****************************************************************************** + +// // This function prints one or two Jacobian matrices (and their difference // in the latter case) to a named output file. // diff --git a/src/driver/setup.cc b/src/driver/setup.cc index f7137e1..4058bbe 100644 --- a/src/driver/setup.cc +++ b/src/driver/setup.cc @@ -308,6 +308,8 @@ IO_info.h_base_file_name = h_base_file_name; IO_info.Theta_base_file_name = Theta_base_file_name; IO_info.Delta_h_base_file_name = Delta_h_base_file_name; IO_info.Jacobian_base_file_name = Jacobian_base_file_name; +IO_info.output_OpenDX_control_files = (output_OpenDX_control_files != 0); +IO_info.OpenDX_control_file_name_extension = OpenDX_control_file_name_extension; IO_info.output_BH_diagnostics = (output_BH_diagnostics != 0); IO_info.BH_diagnostics_base_file_name = BH_diagnostics_base_file_name; IO_info.BH_diagnostics_file_name_extension = BH_diagnostics_file_name_extension; @@ -553,6 +555,7 @@ if (strlen(surface_interpolator_name) > 0) } AH_data.found_flag = false; + AH_data.OpenDX_control_file_written = false; AH_data.BH_diagnostics_fileptr = NULL; } } |