User: rhaas Date: 2013/05/17 12:40 PM
Added: /branches/ET_2013_05/src/ ParamCheck.c
Modified: /branches/ET_2013_05/ param.ccl, schedule.ccl /branches/ET_2013_05/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: /branches/ET_2013_05/ ================================
Property changes on: branches/ET_2013_05 ___________________________________________________________________ Directory: /svn:mergeinfo/ ==========================
- /trunk:62 + /trunk:62,64
File Changes:
Directory: /branches/ET_2013_05/ ================================
File [modified]: param.ccl Delta lines: +11 -6 =================================================================== --- branches/ET_2013_05/param.ccl 2013-05-17 17:39:54 UTC (rev 64) +++ branches/ET_2013_05/param.ccl 2013-05-17 17:40:53 UTC (rev 65) @@ -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 =================================================================== --- branches/ET_2013_05/schedule.ccl 2013-05-17 17:39:54 UTC (rev 64) +++ branches/ET_2013_05/schedule.ccl 2013-05-17 17:40:53 UTC (rev 65) @@ -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"
Directory: /branches/ET_2013_05/src/ ====================================
File [added]: ParamCheck.c Delta lines: +82 -0 =================================================================== --- branches/ET_2013_05/src/ParamCheck.c (rev 0) +++ branches/ET_2013_05/src/ParamCheck.c 2013-05-17 17:40:53 UTC (rev 65) @@ -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; +} +
File [modified]: make.code.defn Delta lines: +1 -1 =================================================================== --- branches/ET_2013_05/src/make.code.defn 2013-05-17 17:39:54 UTC (rev 64) +++ branches/ET_2013_05/src/make.code.defn 2013-05-17 17:40:53 UTC (rev 65) @@ -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 =
commits@lists.einsteintoolkit.org