[Commits] [svn:einsteintoolkit] HydroBase/ (Rev. 64)

rhaas at tapir.caltech.edu rhaas at tapir.caltech.edu
Fri May 17 12:39:55 CDT 2013


User: rhaas
Date: 2013/05/17 12:39 PM

Added:
 /trunk/src/
  ParamCheck.c

Modified:
 /trunk/
  param.ccl, schedule.ccl
 /trunk/src/
  make.code.defn

Log:
 HydroBase: add paramcheck for "read from file parameters"
 
 * add missing "read from file option" to initial_hydro

Directory Changes:

Directory: /svn:mime-type/
==========================

   + text/x-csrc

File Changes:

Directory: /trunk/src/
======================

File [added]: ParamCheck.c
Delta lines: +82 -0
===================================================================
--- trunk/src/ParamCheck.c	                        (rev 0)
+++ trunk/src/ParamCheck.c	2013-05-17 17:39:54 UTC (rev 64)
@@ -0,0 +1,82 @@
+#include <assert.h>
+#include <stdlib.h>
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+
+#include "util_String.h"
+
+static void callback (int idx, const char * optstring, void * callback_arg);
+
+/** Ensure that all HydroBase initial data that are supposed to be read
+    from a file are actually scheduled for the file reader.  */
+void HydroBase_ParamCheck (CCTK_ARGUMENTS)
+{
+  DECLARE_CCTK_ARGUMENTS;
+  DECLARE_CCTK_PARAMETERS;
+  
+  char * variable_is_read;
+  int i;
+  int nvars;
+
+  const struct { 
+    const char * paramname;
+    const char * paramvalue;
+    const char * varname;
+  } vars_to_read[] = {
+    {"initial_hydro", initial_hydro, "HydroBase::rho"},
+    {"initial_hydro", initial_hydro, "HydroBase::vel[0]"},
+    {"initial_hydro", initial_hydro, "HydroBase::vel[1]"},
+    {"initial_hydro", initial_hydro, "HydroBase::vel[2]"},
+    {"initial_hydro", initial_hydro, "HydroBase::eps"},
+    {"initial_hydro", initial_hydro, "HydroBase::press"},
+    {"initial_Aphi", initial_Aphi, "HydroBase::Aphi"},
+    {"initial_Avec", initial_Avec, "HydroBase::Avec[0]"},
+    {"initial_Avec", initial_Avec, "HydroBase::Avec[1]"},
+    {"initial_Avec", initial_Avec, "HydroBase::Avec[2]"},
+    {"initial_Bvec", initial_Bvec, "HydroBase::Bvec[0]"},
+    {"initial_Bvec", initial_Bvec, "HydroBase::Bvec[1]"},
+    {"initial_Bvec", initial_Bvec, "HydroBase::Bvec[2]"},
+    {"initial_Y_e", initial_Y_e, "HydroBase::Ye"},
+    {"initial_temperature", initial_temperature, "HydroBase::temperature"},
+    {"initial_entropy", initial_entropy, "HydroBase::entropy"},
+  };
+
+  variable_is_read = malloc (CCTK_NumVars());
+  assert (variable_is_read);
+  for (i=0; i<CCTK_NumVars(); ++i) {
+    variable_is_read[i] = 0;
+  }
+  
+  nvars = CCTK_TraverseString
+    (filereader_ID_vars, callback, variable_is_read, CCTK_GROUP_OR_VAR);
+  assert (nvars >= 0);
+  
+  for (i=0; i<(int)(sizeof(vars_to_read)/sizeof(vars_to_read[0])); ++i) {
+    if (CCTK_EQUALS(vars_to_read[i].paramvalue, "read from file")) {
+      int const ivar = CCTK_VarIndex (vars_to_read[i].varname);
+      assert (ivar >= 0);
+      if (! variable_is_read[ivar]) {
+        char * msg;
+        size_t written = Util_asprintf(&msg, 
+                                       "'%s' is initialised using the file reader by '%s', but has not been scheduled to be read.  Please set the parameter \"IO::filereader_ID_vars\" accordingly.",
+                                       vars_to_read[i].varname, 
+                                       vars_to_read[i].paramname); 
+        assert(written > 0);
+        CCTK_PARAMWARN (msg);
+        free(msg);
+      }
+    }
+  }
+  
+  free (variable_is_read);
+}
+
+/** Mark a variable as to be read from the file reader.  */
+static void callback (int idx, const char * optstring, void * callback_arg)
+{
+  assert (idx>=0 && idx<CCTK_NumVars());
+  ((char *)callback_arg)[idx] = 1;
+}
+



Property changes on: trunk/src/ParamCheck.c
___________________________________________________________________

File [modified]: make.code.defn
Delta lines: +1 -1
===================================================================
--- trunk/src/make.code.defn	2013-05-15 20:49:51 UTC (rev 63)
+++ trunk/src/make.code.defn	2013-05-17 17:39:54 UTC (rev 64)
@@ -1,7 +1,7 @@
 # Main make.code.defn file for thorn HydroBase
 
 # Source files in this directory
-SRCS = StartUp.c Initialisation.c
+SRCS = StartUp.c Initialisation.c ParamCheck.c
 
 # Subdirectories containing source files
 SUBDIRS = 

Directory: /trunk/
==================

File [modified]: param.ccl
Delta lines: +11 -6
===================================================================
--- trunk/param.ccl	2013-05-15 20:49:51 UTC (rev 63)
+++ trunk/param.ccl	2013-05-17 17:39:54 UTC (rev 64)
@@ -4,11 +4,16 @@
 
 USES KEYWORD initial_data_setup_method
 
+SHARES: IO
+
+USES STRING filereader_ID_vars
+
 RESTRICTED:
 
 KEYWORD initial_hydro "The hydro initial data"
 {
   "zero" :: "hydro variables are set to vacuum (without atmosphere)"
+  "read from file" :: "Read the initial data using the IOUtil file reader.  Note that this only allows you to read the data from a file, it does not actually do it.  You still have to programme the IOUtil file reader accordingly."
 } "zero"
 
 KEYWORD evolution_method "The hydro evolution method"
@@ -34,7 +39,7 @@
 {
   "none" :: "inactive"
   "one"  :: "initially set to one"
-  "read from file" :: "do nothing, filereader will provide data"
+  "read from file" :: "Read the initial data using the IOUtil file reader.  Note that this only allows you to read the data from a file, it does not actually do it.  You still have to programme the IOUtil file reader accordingly."
 } "none"
 
 KEYWORD Y_e_evolution_method "Evolution method for Y_e"
@@ -58,21 +63,21 @@
 {
   "none" :: "inactive"
   "zero" :: "initially set to zero"
-  "read from file" :: "do nothing, filereader will provide data"
+  "read from file" :: "Read the initial data using the IOUtil file reader.  Note that this only allows you to read the data from a file, it does not actually do it.  You still have to programme the IOUtil file reader accordingly."
 } "none"
 
 KEYWORD initial_Avec "Initial value for Avec"
 {
   "none" :: "inactive"
   "zero" :: "initially set to zero"
-  "read from file" :: "do nothing, filereader will provide data"
+  "read from file" :: "Read the initial data using the IOUtil file reader.  Note that this only allows you to read the data from a file, it does not actually do it.  You still have to programme the IOUtil file reader accordingly."
 } "none"
 
 KEYWORD initial_Aphi "Initial value for Aphi"
 {
   "none" :: "inactive"
   "zero" :: "initially set to zero"
-  "read from file" :: "do nothing, filereader will provide data"
+  "read from file" :: "Read the initial data using the IOUtil file reader.  Note that this only allows you to read the data from a file, it does not actually do it.  You still have to programme the IOUtil file reader accordingly."
 } "none"
 
 KEYWORD Bvec_evolution_method "Evolution method for Bvec"
@@ -91,14 +96,14 @@
 {
   "none"  :: "inactive"
   "zero"  :: "initially set to zero"
-  "read from file" :: "do nothing, filereader will provide data"
+  "read from file" :: "Read the initial data using the IOUtil file reader.  Note that this only allows you to read the data from a file, it does not actually do it.  You still have to programme the IOUtil file reader accordingly."
 } "none"
 
 KEYWORD initial_entropy "Initial value for entropy"
 {
   "none"  :: "inactive"
   "zero"  :: "initially set to zero"
-  "read from file" :: "do nothing, filereader will provide data"
+  "read from file" :: "Read the initial data using the IOUtil file reader.  Note that this only allows you to read the data from a file, it does not actually do it.  You still have to programme the IOUtil file reader accordingly."
 } "none"
 
 

File [modified]: schedule.ccl
Delta lines: +14 -0
===================================================================
--- trunk/schedule.ccl	2013-05-15 20:49:51 UTC (rev 63)
+++ trunk/schedule.ccl	2013-05-17 17:39:54 UTC (rev 64)
@@ -114,6 +114,20 @@
   LANG: C
 } "Startup banner"
 
+if(CCTK_EQUALS(initial_hydro, "read from file") ||
+   CCTK_EQUALS(initial_Aphi, "read from file") ||
+   CCTK_EQUALS(initial_Avec, "read from file") ||
+   CCTK_EQUALS(initial_Bvec, "read from file") ||
+   CCTK_EQUALS(initial_Y_e, "read from file") ||
+   CCTK_EQUALS(initial_temperature, "read from file") ||
+   CCTK_EQUALS(initial_entropy, "read from file"))
+{
+schedule HydroBase_ParamCheck AT PARAMCHECK
+{
+  LANG: C
+} "check that hydrobase parameters are consistent"
+}
+
 schedule group HydroBase_RHS in MoL_CalcRHS
 {
 } "Groups for scheduling tasks for calculating RHS of hydro variables"



More information about the Commits mailing list