aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhaas <rhaas@57fe0bb3-ccba-405f-9b23-de0201f165b7>2013-05-17 17:39:54 +0000
committerrhaas <rhaas@57fe0bb3-ccba-405f-9b23-de0201f165b7>2013-05-17 17:39:54 +0000
commitbc0686abb3264a6ae0d2adae5b9f4943a9b0611e (patch)
tree77c0964117d8a25996a02f3b0bbebc91971bfff5
parent2b16ca44e05a6bf994c6f493fadaf9c76570d83b (diff)
HydroBase: add paramcheck for "read from file parameters"
* add missing "read from file option" to initial_hydro git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinBase/HydroBase/trunk@64 57fe0bb3-ccba-405f-9b23-de0201f165b7
-rwxr-xr-xparam.ccl17
-rwxr-xr-xschedule.ccl14
-rw-r--r--src/ParamCheck.c82
-rwxr-xr-xsrc/make.code.defn2
4 files changed, 108 insertions, 7 deletions
diff --git a/param.ccl b/param.ccl
index 1e109dd..e1001c5 100755
--- a/param.ccl
+++ b/param.ccl
@@ -4,11 +4,16 @@ SHARES: InitBase
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 @@ KEYWORD initial_Y_e "Initial value for Y_e"
{
"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 @@ KEYWORD initial_Bvec "Initial value for Bvec"
{
"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 @@ KEYWORD initial_temperature "Initial value for temperature"
{
"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"
diff --git a/schedule.ccl b/schedule.ccl
index 960de04..7cf56a3 100755
--- a/schedule.ccl
+++ b/schedule.ccl
@@ -114,6 +114,20 @@ schedule HydroBase_StartUp at CCTK_STARTUP
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"
diff --git a/src/ParamCheck.c b/src/ParamCheck.c
new file mode 100644
index 0000000..6e1ff22
--- /dev/null
+++ b/src/ParamCheck.c
@@ -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;
+}
+
diff --git a/src/make.code.defn b/src/make.code.defn
index 4d8b77f..7e82b9b 100755
--- a/src/make.code.defn
+++ b/src/make.code.defn
@@ -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 =