From d54c808b6b468a890e6673f8eb122635e9874333 Mon Sep 17 00:00:00 2001 From: Philipp Nuske <philipp.nuske@mailbox.org> Date: Fri, 3 Feb 2012 14:15:43 +0000 Subject: [PATCH] - Changed the tests such that the common text block (error / help) comes from start.hh. - Disable property printing by default: more clear - Add tests for 3p3c(ni) models git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@7623 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/common/start.hh | 153 +++++++++++++++-------- test/boxmodels/1p/test_1p.cc | 49 +++----- test/boxmodels/1p2c/test_1p2c.cc | 49 +++----- test/boxmodels/2p/test_2p.cc | 58 ++++----- test/boxmodels/2p2c/test_2p2c.cc | 49 +++----- test/boxmodels/2p2c/test_2p2c.input | 48 +++++++ test/boxmodels/2p2cni/test_2p2cni.cc | 49 +++----- test/boxmodels/2pni/test_2pni.cc | 50 ++++---- test/boxmodels/3p3c/test_3p3c.cc | 30 ++++- test/boxmodels/3p3c/test_3p3c.input | 24 ++++ test/boxmodels/3p3cni/kuevetteproblem.hh | 6 +- test/boxmodels/3p3cni/test_3p3cni.cc | 36 +++++- test/boxmodels/3p3cni/test_3p3cni.input | 24 ++++ test/boxmodels/MpNc/test_MpNc.cc | 49 +++----- test/boxmodels/richards/test_richards.cc | 49 +++----- 15 files changed, 429 insertions(+), 294 deletions(-) create mode 100644 test/boxmodels/2p2c/test_2p2c.input create mode 100644 test/boxmodels/3p3c/test_3p3c.input create mode 100644 test/boxmodels/3p3cni/test_3p3cni.input diff --git a/dumux/common/start.hh b/dumux/common/start.hh index abcae22020..e0b429839a 100644 --- a/dumux/common/start.hh +++ b/dumux/common/start.hh @@ -75,18 +75,6 @@ void printUsageGrid(const char *progname) exit(1); } -/*! - * \brief Print a usage string for simulations using - * Dumux::startWithGrid() as their main() function. - * - * \param progname The name of the executable - */ -void printUsageInputFile(const char *progname) -{ - std::cout << "usage: " << progname << " [--restart restartTime] inputfile\n"; - exit(1); -} - /*! * \ingroup Start * \brief Provides a default main function for simulations requiring @@ -260,7 +248,7 @@ std::string readOptions_(int argc, char **argv, Dune::ParameterTree ¶mTree) for (int i = 1; i < argc; ++i) { if (argv[i][0] != '-') { std::ostringstream oss; - oss << "Command line argument " << i << " (='" << argv[i] << "') is invalid."; + oss << "\n -> Command line argument " << i << " (='" << argv[i] << "') is invalid. <- \n\n\n\n"; return oss.str(); } @@ -275,8 +263,8 @@ std::string readOptions_(int argc, char **argv, Dune::ParameterTree ¶mTree) if (s.size() == 0 || s[0] == '=') { std::ostringstream oss; - oss << "Parameter name of argument " << i << " (='" << argv[i] << "')" - << " is empty."; + oss << "\n -> Parameter name of argument " << i << " (='" << argv[i] << "')" + << " is empty. <- \n\n\n\n"; return oss.str(); } @@ -305,15 +293,15 @@ std::string readOptions_(int argc, char **argv, Dune::ParameterTree ¶mTree) if (s.size() == j) { std::ostringstream oss; - oss << "Parameter name of argument " << i << " ('" << argv[i] << "')" - << " is invalid (ends with a '-' character)."; + oss << "\n -> Parameter name of argument " << i << " ('" << argv[i] << "')" + << " is invalid (ends with a '-' character). <- \n\n\n\n"; return oss.str(); } else if (s[j] == '-') { std::ostringstream oss; - oss << "Malformed parameter name name in argument " << i << " ('" << argv[i] << "'): " - << "'--' in parameter name."; + oss << "\n -> Malformed parameter name name in argument " << i << " ('" << argv[i] << "'): " + << "'--' in parameter name. <- \n\n\n\n"; return oss.str(); } s[j] = toupper(s[j]); @@ -328,7 +316,7 @@ std::string readOptions_(int argc, char **argv, Dune::ParameterTree ¶mTree) if (argc == i + 1 || argv[i+1][0] == '-') { std::ostringstream oss; - oss << "No argument given for parameter '" << argv[i] << "'!"; + oss << "\n -> No argument given for parameter '" << argv[i] << "'! <- \n\n\n\n"; return oss.str(); } @@ -342,6 +330,40 @@ std::string readOptions_(int argc, char **argv, Dune::ParameterTree ¶mTree) return ""; } + +/*! + * \ingroup Start + * + * \brief Provides a general text block, that is part of error/ help messages. + * + * \return The string that is the help / error message. + */ +std::string usageTextBlock() +{ + return "Mandatory options include:\n" + "\t--t-end=ENDTIME The time of the end of the simlation [s]\n" + "\t--dt-initial=STEPSIZE The initial time step size [s]\n" + "\n" + "Alternativ supported syntax:\n" + "\t-tEnd ENDTIME The time of the end of the simlation [s]\n" + "\t-dtInitial STEPSIZE The initial time step size [s]\n" + "\n" + "If --parameter-file is specified parameters can also be defined there. In this case,\n" + "camel case is used for the parameters (e.g.: --t-end becomes tEnd). Parameters\n" + "specified on the command line have priority over those in the parameter file.\n" + "Important optional options include:\n" + "\t--help,-h Print this usage message and exit\n" + "\t--print-parameters[=true|false] Print the run-time modifiable parameters _after_ \n" + "\t the simulation [default: true]\n" + "\t--print-properties[=true|false] Print the compile-time parameters _before_ \n" + "\t the simulation [default: false]\n" + "\t--parameter-file=FILENAME File with parameter definitions\n" + "\t--restart=RESTARTTIME Restart simulation from a restart file\n" + "\n" + "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" + "\n"; +} + /*! * \ingroup Start * @@ -375,14 +397,14 @@ int startWithParameters_(int argc, // check whether the user did not specify any parameter. in this // case print the usage message if (argc == 1) { - std::cout<< "\nNo parameter file given. \n" + std::cout<< "\n No parameter file given. \n" << "Defaulting to './parameter.input' for input file.\n"; std::ifstream parameterFile; // check whether the parameter file exists. parameterFile.open("parameter.input"); if (not parameterFile.is_open()){ - std::cout<< "\n Could not open file './parameter.input'.\n\n"; - usage(argv[0], ""); + std::cout<< "\n\t -> Could not open file './parameter.input'. <- \n\n\n\n"; + usage(argv[0], usageTextBlock()); return 0; } parameterFile.close(); @@ -393,7 +415,7 @@ int startWithParameters_(int argc, for (int i = 1; i < argc; ++i) { if (std::string("--help") == argv[i] || std::string("-h") == argv[i]) { - usage(argv[0], ""); + usage(argv[0], usageTextBlock()); return 0; } } @@ -402,7 +424,9 @@ int startWithParameters_(int argc, typedef typename GET_PROP(TypeTag, ParameterTree) ParameterTree; std::string s = readOptions_(argc, argv, ParameterTree::tree()); if (!s.empty()) { - usage(argv[0], s); + std::string usageMessage = s ; + usageMessage += usageTextBlock(); + usage(argv[0], usageMessage); return 0; } @@ -420,10 +444,10 @@ int startWithParameters_(int argc, // check whether the parameter file exists. parameterFile.open(inputFileName); if (not parameterFile.is_open()){ - std::cout<< "\n Could not open file" + std::cout<< "\n\t -> Could not open file" << inputFileName - << "\n\n"; - usage(argv[0], ""); + << ". <- \n\n\n\n"; + usage(argv[0], usageTextBlock()); return 0; } parameterFile.close(); @@ -433,7 +457,7 @@ int startWithParameters_(int argc, /*overwrite=*/false); } - bool printProps = true; + bool printProps = false; if (ParameterTree::tree().hasKey("PrintProperties")) printProps = GET_RUNTIME_PARAM(TypeTag, bool, PrintProperies); @@ -456,17 +480,32 @@ int startWithParameters_(int argc, // try to create a grid (from the given grid file) try { GridCreator::makeGrid(); } - catch (...) { usage(argv[1], "Creation of the grid failed!"); throw; } + catch (...) { + std::string usageMessage = "\n\t -> Creation of the grid failed! <- \n\n\n\n"; + usageMessage += usageTextBlock(); + usage(argv[0], usageMessage); + throw; + } // read the initial time step and the end time double tEnd; double dt; try { tEnd = GET_RUNTIME_PARAM(TypeTag, Scalar, tEnd); } - catch (...) { usage(argv[1], "Mandatory parameter '--t-end' not specified!"); throw; } + catch (...) { + std::string usageMessage = "\n\t -> Mandatory parameter '--t-end' not specified! <- \n\n\n\n"; + usageMessage += usageTextBlock(); + usage(argv[0], usageMessage); + throw; + } try { dt = GET_RUNTIME_PARAM(TypeTag, Scalar, dtInitial); } - catch (...) { usage(argv[1], "Mandatory parameter '--dt-initial' not specified!"); throw; } + catch (...) { + std::string usageMessage = "\n\t -> Mandatory parameter '--dt-initial' not specified! <- \n\n\n\n"; + usageMessage += usageTextBlock(); + usage(argv[0], usageMessage); + throw; + } // instantiate and run the concrete problem TimeManager timeManager; @@ -478,8 +517,11 @@ int startWithParameters_(int argc, Dumux::Parameters::print<TypeTag>(); } return 1; + + } + /*! * \ingroup Start * @@ -541,7 +583,7 @@ int startWithParameters(int argc, * \ingroup Start * * \brief Provides a main function which reads in parameters from the - * command line and a parameter file. The Grid however is created + * command line and a parameter file. The grid however, is created * in the 'real' main function. * * \tparam TypeTag The type tag of the problem which needs to be solved @@ -585,8 +627,8 @@ int startWithParametersProvideMyOwnGrid_(int argc, // check whether the parameter file exists. parameterFile.open("parameter.input"); if (not parameterFile.is_open()){ - std::cout<< "\n Could not open file './parameter.input'.\n\n"; - usage(argv[0], ""); + std::cout<< "\n\t -> Could not open file './parameter.input'. <- \n\n\n\n"; + usage(argv[0], usageTextBlock()); exit(1); } parameterFile.close(); @@ -597,7 +639,7 @@ int startWithParametersProvideMyOwnGrid_(int argc, for (int i = 1; i < argc; ++i) { if (std::string("--help") == argv[i] || std::string("-h") == argv[i]) { - usage(argv[0], ""); + usage(argv[0], usageTextBlock()); exit(0); } } @@ -606,7 +648,9 @@ int startWithParametersProvideMyOwnGrid_(int argc, typedef typename GET_PROP(TypeTag, ParameterTree) ParameterTree; std::string s = readOptions_(argc, argv, ParameterTree::tree()); if (!s.empty()) { - usage(argv[0], s); + std::string usageMessage = s ; + usageMessage += usageTextBlock(); + usage(argv[0], usageMessage); exit(1); } @@ -624,10 +668,10 @@ int startWithParametersProvideMyOwnGrid_(int argc, // check whether the parameter file exists. parameterFile.open(inputFileName); if (not parameterFile.is_open()){ - std::cout<< "\n Could not open file" + std::cout<< "\n\t -> Could not open file" << inputFileName - << "\n\n"; - usage(argv[0], ""); + << ". <- \n\n\n\n"; + usage(argv[0], usageTextBlock()); exit(1); } parameterFile.close(); @@ -638,7 +682,7 @@ int startWithParametersProvideMyOwnGrid_(int argc, } - bool printProps = true; + bool printProps = false; if (ParameterTree::tree().hasKey("PrintProperties")) printProps = GET_RUNTIME_PARAM(TypeTag, bool, PrintProperies); @@ -652,19 +696,20 @@ int startWithParametersProvideMyOwnGrid_(int argc, restartTime = GET_RUNTIME_PARAM(TypeTag, Scalar, restart); } - // read the PrintParams parameter - bool printParams = true; - if (ParameterTree::tree().hasKey("PrintParameters")) - printParams = GET_RUNTIME_PARAM(TypeTag, bool, PrintParameters); - try { tEnd = GET_RUNTIME_PARAM(TypeTag, Scalar, tEnd); } - catch (...) { usage(argv[1], "Mandatory parameter '--t-end' not specified!"); throw; } + catch (...) { + std::string usageMessage = "\n\t -> Mandatory parameter '--t-end' not specified! <- \n\n\n\n"; + usageMessage += usageTextBlock(); + usage(argv[0], usageMessage); + throw; + } try { dt = GET_RUNTIME_PARAM(TypeTag, Scalar, dtInitial); } - catch (...) { usage(argv[1], "Mandatory parameter '--dt-initial' not specified!"); throw; } - - if (printParams && mpiHelper.rank() == 0) { - Dumux::Parameters::print<TypeTag>(); + catch (...) { + std::string usageMessage = "\n\t -> Mandatory parameter '--dt-initial' not specified! <- \n\n\n\n"; + usageMessage += usageTextBlock(); + usage(argv[0], usageMessage); + throw; } return 0; @@ -705,15 +750,15 @@ int startWithParametersProvideMyOwnGrid(int argc, } catch (Dumux::ParameterException &e) { std::cerr << e << ". Abort!\n"; - return 1; + exit(1); } catch (Dune::Exception &e) { std::cerr << "Dune reported error: " << e << std::endl; - return 2; + exit(2); } catch (...) { std::cerr << "Unknown exception thrown!\n"; - return 3; + exit(3); } } else diff --git a/test/boxmodels/1p/test_1p.cc b/test/boxmodels/1p/test_1p.cc index 96b7574c0e..643c7fcf8a 100644 --- a/test/boxmodels/1p/test_1p.cc +++ b/test/boxmodels/1p/test_1p.cc @@ -29,40 +29,31 @@ #include "1ptestproblem.hh" #include <dumux/common/start.hh> +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ void usage(const char *progName, const std::string &errorMsg) { if (errorMsg.size() > 0) { - std::cout << errorMsg << "\n" + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial, --grid-file\n" + "(or -tEnd, -dtInitial, -gridFile)\n" + "\n" + "\t--grid-file=FILENAME The file name of the file containing the grid \n" + "\t definition in DGF format\n" ; + + std::cout << errorMessageOut << "\n"; } - std::cout - << "Usage: " << progName << " [options]\n" - << "Mandatory options are:\n" - << "\t--t-end=ENDTIME The time of the end of the simlation [s]\n" - << "\t--dt-initial=STEPSIZE The initial time step size [s]\n" - << "\t--grid-file=FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "Alternativ supported syntax:\n" - << "\t-tEnd ENDTIME The time of the end of the simlation [s]\n" - << "\t-dtInitial STEPSIZE The initial time step size [s]\n" - << "\t-gridFile FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "If --parameter-file is specified parameters can also be defined there. In this case,\n" - << "camel case is used for the parameters (e.g.: --grid-file becomes gridFile). Parameters\n" - << "specified on the command line have priority over those in the parameter file.\n" - << "Important optional options include:\n" - << "\t--help,-h Print this usage message and exit\n" - << "\t--print-parameters[=true|false] Print the run-time modifiable parameters _after_ \n" - << "\t the simulation [default: true]\n" - << "\t--print-properties[=true|false] Print the compile-time parameters _before_ \n" - << "\t the simulation [default: true]\n" - << "\t--parameter-file=FILENAME File with parameter definitions\n" - << "\t--restart=RESTARTTIME Restart simulation from a restart file\n" - << "\n" - << "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" - << "\n"; } int main(int argc, char** argv) diff --git a/test/boxmodels/1p2c/test_1p2c.cc b/test/boxmodels/1p2c/test_1p2c.cc index 3cb47b26c8..e9df4cd7f3 100644 --- a/test/boxmodels/1p2c/test_1p2c.cc +++ b/test/boxmodels/1p2c/test_1p2c.cc @@ -30,40 +30,31 @@ #include "tissue_tumor_problem.hh" #include <dumux/common/start.hh> +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ void usage(const char *progName, const std::string &errorMsg) { if (errorMsg.size() > 0) { - std::cout << errorMsg << "\n" + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial, --grid-file\n" + "(or -tEnd, -dtInitial, -gridFile)\n" + "\n" + "\t--grid-file=FILENAME The file name of the file containing the grid \n" + "\t definition in DGF format\n" ; + + std::cout << errorMessageOut << "\n"; } - std::cout - << "Usage: " << progName << " [options]\n" - << "Mandatory options are:\n" - << "\t--t-end=ENDTIME The time of the end of the simlation [s]\n" - << "\t--dt-initial=STEPSIZE The initial time step size [s]\n" - << "\t--grid-file=FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "Alternativ supported syntax:\n" - << "\t-tEnd ENDTIME The time of the end of the simlation [s]\n" - << "\t-dtInitial STEPSIZE The initial time step size [s]\n" - << "\t-gridFile FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "If --parameter-file is specified parameters can also be defined there. In this case,\n" - << "camel case is used for the parameters (e.g.: --grid-file becomes gridFile). Parameters\n" - << "specified on the command line have priority over those in the parameter file.\n" - << "Important optional options include:\n" - << "\t--help,-h Print this usage message and exit\n" - << "\t--print-parameters[=true|false] Print the run-time modifiable parameters _after_ \n" - << "\t the simulation [default: true]\n" - << "\t--print-properties[=true|false] Print the compile-time parameters _before_ \n" - << "\t the simulation [default: true]\n" - << "\t--parameter-file=FILENAME File with parameter definitions\n" - << "\t--restart=RESTARTTIME Restart simulation from a restart file\n" - << "\n" - << "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" - << "\n"; } int main(int argc, char** argv) diff --git a/test/boxmodels/2p/test_2p.cc b/test/boxmodels/2p/test_2p.cc index 5e644cda47..d2eb46bd2a 100644 --- a/test/boxmodels/2p/test_2p.cc +++ b/test/boxmodels/2p/test_2p.cc @@ -38,36 +38,29 @@ #include <iostream> +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ void usage(const char *progName, const std::string &errorMsg) { if (errorMsg.size() > 0) { - std::cout << errorMsg << "\n" + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial\n" + "(or -tEnd, -dtInitial)\n" + "\n"; + + std::cout << errorMessageOut << "\n"; } - std::cout - << "Usage: " << progName << " [options]\n" - << "Mandatory options are:\n" - << "\t--t-end=ENDTIME The time of the end of the simlation [s]\n" - << "\t--dt-initial=STEPSIZE The initial time step size [s]\n" - << "\n" - << "If --parameter-file is specified parameters can also be defined there. In this case,\n" - << "camel case is used for the parameters (e.g.: --grid-file becomes gridFile). Parameters\n" - << "specified on the command line have priority over those in the parameter file.\n" - << "Important optional options include:\n" - << "\t--help,-h Print this usage message and exit\n" - << "\t--print-parameters[=true|false] Print the run-time modifiable parameters _after_ \n" - << "\t the simulation [default: true]\n" - << "\t--print-properties[=true|false] Print the compile-time parameters _before_ \n" - << "\t the simulation [default: true]\n" - << "\t--parameter-file=FILENAME File with parameter definitions\n" - << "\t--restart=RESTARTTIME Restart simulation from a restart file\n" - << "\n" - << "All parameters can also be specified using the alternative syntax:\n" - << "\t-tEnd ENDTIME The time of the end of the simlation [s]\n" - << "\t-dtInitial STEPSIZE The initial time step size [s]\n" - << "\n" - << "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" - << "\n"; } @@ -193,11 +186,8 @@ int main(int argc, char** argv) static const int dim = Grid::dimension; - // print all properties - Dumux::Properties::print<TypeTag>(); - // initialize MPI, finalize is done automatically on exit - Dune::MPIHelper::instance(argc, argv); + const Dune::MPIHelper& mpiHelper = Dune::MPIHelper::instance(argc, argv); Scalar tEnd, dt; Scalar restartTime=0; @@ -267,6 +257,16 @@ int main(int argc, char** argv) timeManager.init(problem, restartTime, dt, tEnd, restart); timeManager.run(); + // read the PrintParams parameter + bool printParams = true ; + typedef typename GET_PROP(TypeTag, ParameterTree) ParameterTree; + if (ParameterTree::tree().hasKey("PrintParameters")) + printParams = GET_RUNTIME_PARAM(TypeTag, bool, PrintParameters); + + if (printParams && mpiHelper.rank() == 0) { + Dumux::Parameters::print<TypeTag>(); + } + return 0; #ifdef NDEBUG diff --git a/test/boxmodels/2p2c/test_2p2c.cc b/test/boxmodels/2p2c/test_2p2c.cc index 3b34c90a6b..dbde5ff351 100644 --- a/test/boxmodels/2p2c/test_2p2c.cc +++ b/test/boxmodels/2p2c/test_2p2c.cc @@ -28,40 +28,31 @@ #include "injectionproblem.hh" #include <dumux/common/start.hh> +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ void usage(const char *progName, const std::string &errorMsg) { if (errorMsg.size() > 0) { - std::cout << errorMsg << "\n" + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial, --grid-file\n" + "(or -tEnd, -dtInitial, -gridFile)\n" + "\n" + "\t--grid-file=FILENAME The file name of the file containing the grid \n" + "\t definition in DGF format\n" ; + + std::cout << errorMessageOut << "\n"; } - std::cout - << "Usage: " << progName << " [options]\n" - << "Mandatory options are:\n" - << "\t--t-end=ENDTIME The time of the end of the simlation [s]\n" - << "\t--dt-initial=STEPSIZE The initial time step size [s]\n" - << "\t--grid-file=FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "Alternativ supported syntax:\n" - << "\t-tEnd ENDTIME The time of the end of the simlation [s]\n" - << "\t-dtInitial STEPSIZE The initial time step size [s]\n" - << "\t-gridFile FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "If --parameter-file is specified parameters can also be defined there. In this case,\n" - << "camel case is used for the parameters (e.g.: --grid-file becomes gridFile). Parameters\n" - << "specified on the command line have priority over those in the parameter file.\n" - << "Important optional options include:\n" - << "\t--help,-h Print this usage message and exit\n" - << "\t--print-parameters[=true|false] Print the run-time modifiable parameters _after_ \n" - << "\t the simulation [default: true]\n" - << "\t--print-properties[=true|false] Print the compile-time parameters _before_ \n" - << "\t the simulation [default: true]\n" - << "\t--parameter-file=FILENAME File with parameter definitions\n" - << "\t--restart=RESTARTTIME Restart simulation from a restart file\n" - << "\n" - << "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" - << "\n"; } int main(int argc, char** argv) diff --git a/test/boxmodels/2p2c/test_2p2c.input b/test/boxmodels/2p2c/test_2p2c.input new file mode 100644 index 0000000000..d64fd1d9d3 --- /dev/null +++ b/test/boxmodels/2p2c/test_2p2c.input @@ -0,0 +1,48 @@ +########################################################################### +# Parameter file for test_2p2c # +# Everything behind a '#' is a comment # +# Groups can be ordered e.g. : [BoundaryConditions] # +# Parameters in groups have to be accessed hierarchically e.g.: FluidSystem.pressureLow # +########################################################################### + +##################################################################### +# Mandatory arguments # +##################################################################### +dtInitial=250 # [s] +tEnd=1e4 # [s] +gridFile=./grids/test_2p2c.dgf # relative path to the grid file + +##################################################################### +# Simulation restart # +# # +# DuMux simulations can be restarted from *.drs files # +# Set restart to the value of a specific file, e.g.: 'restart = 27184.1' # +# for the restart file # +# name_time=27184.1_rank=0.drs # +# Please comment in the below value, if restart is desired. # +##################################################################### +# restart= ... + +##################################################################### +# FluidSystem # +##################################################################### +[FluidSystem] +nTemperature = 3 # [-] number of tabularization entries +nPressure = 200 # [-] number of tabularization entries +pressureLow = 1e5 # [Pa] low end for tabularization of fluid properties +pressureHigh = 3e7 # [Pa] high end for tabularization of fluid properties +temperatureLow = 312.15 # [Pa] low end for tabularization of fluid properties +temperatureHigh = 314.15 # [Pa] high end for tabularization of fluid properties + +##################################################################### +# Simulation Control # +##################################################################### +[SimulationControl] +name = injection # [-] the name of the output files + +##################################################################### +# InitialConditions # +##################################################################### +[InitialConditions] +temperature = 313.15 # [K] initial temperature in the reservoir 273.15 + 40 +depthBOR = 2700 # [m] depth below ground surface \ No newline at end of file diff --git a/test/boxmodels/2p2cni/test_2p2cni.cc b/test/boxmodels/2p2cni/test_2p2cni.cc index c3b439e81e..7a5c4fc085 100644 --- a/test/boxmodels/2p2cni/test_2p2cni.cc +++ b/test/boxmodels/2p2cni/test_2p2cni.cc @@ -31,40 +31,31 @@ #include "waterairproblem.hh" #include <dumux/common/start.hh> +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ void usage(const char *progName, const std::string &errorMsg) { if (errorMsg.size() > 0) { - std::cout << errorMsg << "\n" + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial, --grid-file\n" + "(or -tEnd, -dtInitial, -gridFile)\n" + "\n" + "\t--grid-file=FILENAME The file name of the file containing the grid \n" + "\t definition in DGF format\n" ; + + std::cout << errorMessageOut << "\n"; } - std::cout - << "Usage: " << progName << " [options]\n" - << "Mandatory options are:\n" - << "\t--t-end=ENDTIME The time of the end of the simlation [s]\n" - << "\t--dt-initial=STEPSIZE The initial time step size [s]\n" - << "\t--grid-file=FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "Alternativ supported syntax:\n" - << "\t-tEnd ENDTIME The time of the end of the simlation [s]\n" - << "\t-dtInitial STEPSIZE The initial time step size [s]\n" - << "\t-gridFile FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "If --parameter-file is specified parameters can also be defined there. In this case,\n" - << "camel case is used for the parameters (e.g.: --grid-file becomes gridFile). Parameters\n" - << "specified on the command line have priority over those in the parameter file.\n" - << "Important optional options include:\n" - << "\t--help,-h Print this usage message and exit\n" - << "\t--print-parameters[=true|false] Print the run-time modifiable parameters _after_ \n" - << "\t the simulation [default: true]\n" - << "\t--print-properties[=true|false] Print the compile-time parameters _before_ \n" - << "\t the simulation [default: true]\n" - << "\t--parameter-file=FILENAME File with parameter definitions\n" - << "\t--restart=RESTARTTIME Restart simulation from a restart file\n" - << "\n" - << "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" - << "\n"; } int main(int argc, char** argv) diff --git a/test/boxmodels/2pni/test_2pni.cc b/test/boxmodels/2pni/test_2pni.cc index af8cd079a7..13a9587e83 100644 --- a/test/boxmodels/2pni/test_2pni.cc +++ b/test/boxmodels/2pni/test_2pni.cc @@ -30,40 +30,32 @@ #include "injectionproblem2pni.hh" #include <dumux/common/start.hh> + +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ void usage(const char *progName, const std::string &errorMsg) { if (errorMsg.size() > 0) { - std::cout << errorMsg << "\n" + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial, --grid-file\n" + "(or -tEnd, -dtInitial, -gridFile)\n" + "\n" + "\t--grid-file=FILENAME The file name of the file containing the grid \n" + "\t definition in DGF format\n" ; + + std::cout << errorMessageOut << "\n"; } - std::cout - << "Usage: " << progName << " [options]\n" - << "Mandatory options are:\n" - << "\t--t-end=ENDTIME The time of the end of the simlation [s]\n" - << "\t--dt-initial=STEPSIZE The initial time step size [s]\n" - << "\t--grid-file=FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "Alternativ supported syntax:\n" - << "\t-tEnd ENDTIME The time of the end of the simlation [s]\n" - << "\t-dtInitial STEPSIZE The initial time step size [s]\n" - << "\t-gridFile FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "If --parameter-file is specified parameters can also be defined there. In this case,\n" - << "camel case is used for the parameters (e.g.: --grid-file becomes gridFile). Parameters\n" - << "specified on the command line have priority over those in the parameter file.\n" - << "Important optional options include:\n" - << "\t--help,-h Print this usage message and exit\n" - << "\t--print-parameters[=true|false] Print the run-time modifiable parameters _after_ \n" - << "\t the simulation [default: true]\n" - << "\t--print-properties[=true|false] Print the compile-time parameters _before_ \n" - << "\t the simulation [default: true]\n" - << "\t--parameter-file=FILENAME File with parameter definitions\n" - << "\t--restart=RESTARTTIME Restart simulation from a restart file\n" - << "\n" - << "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" - << "\n"; } int main(int argc, char** argv) diff --git a/test/boxmodels/3p3c/test_3p3c.cc b/test/boxmodels/3p3c/test_3p3c.cc index 73eae94242..9c3867815c 100644 --- a/test/boxmodels/3p3c/test_3p3c.cc +++ b/test/boxmodels/3p3c/test_3p3c.cc @@ -32,8 +32,36 @@ #include "infiltrationproblem.hh" #include <dumux/common/start.hh> +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ +void usage(const char *progName, const std::string &errorMsg) +{ + if (errorMsg.size() > 0) { + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial, --grid-file\n" + "(or -tEnd, -dtInitial, -gridFile)\n" + "\n" + "\t--grid-file=FILENAME The file name of the file containing the grid \n" + "\t definition in DGF format\n" ; + + std::cout << errorMessageOut + << "\n"; + } +} + int main(int argc, char** argv) { typedef TTAG(InfiltrationProblem) ProblemTypeTag; - return Dumux::startFromDGF<ProblemTypeTag>(argc, argv); + return Dumux::startWithParameters<ProblemTypeTag>(argc, argv, usage); } + diff --git a/test/boxmodels/3p3c/test_3p3c.input b/test/boxmodels/3p3c/test_3p3c.input new file mode 100644 index 0000000000..17c138a38a --- /dev/null +++ b/test/boxmodels/3p3c/test_3p3c.input @@ -0,0 +1,24 @@ +############################################################# +# Parameter file for test_3p3c # +# Everything behind a '#' is a comment # +# Groups can be ordered e.g. : [BoundaryConditions], # +# see ../2p2c/ for a more detailed example # +############################################################# + +############################################################# +# Mandatory arguments # +############################################################# +dtInitial =60 # [s] +tEnd =864000 # [s] +gridFile =./grids/test_3p3c.dgf + +##################################################################### +# Simulation restart # +# # +# DuMux simulations can be restarted from *.drs files # +# Set restart to the value of a specific file, e.g.: 'restart = 27184.1' # +# for the restart file # +# name_time=27184.1_rank=0.drs # +# Please comment in the below value, if restart is desired. # +##################################################################### +# restart= ... \ No newline at end of file diff --git a/test/boxmodels/3p3cni/kuevetteproblem.hh b/test/boxmodels/3p3cni/kuevetteproblem.hh index cd76803307..39d631ee0e 100644 --- a/test/boxmodels/3p3cni/kuevetteproblem.hh +++ b/test/boxmodels/3p3cni/kuevetteproblem.hh @@ -64,7 +64,7 @@ SET_PROP(KuevetteProblem, Problem) }; // Set the fluid system -SET_TYPE_PROP(KuevetteProblem, +SET_TYPE_PROP(KuevetteProblem, FluidSystem, Dumux::FluidSystems::H2OAirMesitylene<typename GET_PROP_TYPE(TypeTag, Scalar)>); @@ -141,7 +141,6 @@ public: */ KuevetteProblem(TimeManager &timeManager, const GridView &gridView) : ParentType(timeManager, gridView) - , eps_(1e-6) { FluidSystem::init(); } @@ -165,6 +164,7 @@ public: values = 0; } + // \} /*! @@ -305,7 +305,7 @@ private: } } - const Scalar eps_; + static constexpr Scalar eps_ = 1e-6; }; } //end namespace diff --git a/test/boxmodels/3p3cni/test_3p3cni.cc b/test/boxmodels/3p3cni/test_3p3cni.cc index ac966dc754..8d1ce6fd0f 100644 --- a/test/boxmodels/3p3cni/test_3p3cni.cc +++ b/test/boxmodels/3p3cni/test_3p3cni.cc @@ -26,16 +26,44 @@ /*! * \file * - * \brief test for the holle2p2cni box model + * \brief test for the 3p3cni box model */ #include "config.h" #include "kuevetteproblem.hh" -#include "columnxylolproblem.hh" +//#include "columnxylolproblem.hh" #include <dumux/common/start.hh> + +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ +void usage(const char *progName, const std::string &errorMsg) +{ + if (errorMsg.size() > 0) { + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial, --grid-file\n" + "(or -tEnd, -dtInitial, -gridFile)\n" + "\n" + "\t--grid-file=FILENAME The file name of the file containing the grid \n" + "\t definition in DGF format\n" ; + + std::cout << errorMessageOut + << "\n"; + } +} + int main(int argc, char** argv) { typedef TTAG(KuevetteProblem) ProblemTypeTag; - // typedef TTAG(ColumnProblem) ProblemTypeTag; - return Dumux::startFromDGF<ProblemTypeTag>(argc, argv); +// typedef TTAG(ColumnProblem) ProblemTypeTag; + return Dumux::startWithParameters<ProblemTypeTag>(argc, argv, usage); } diff --git a/test/boxmodels/3p3cni/test_3p3cni.input b/test/boxmodels/3p3cni/test_3p3cni.input new file mode 100644 index 0000000000..19f66c5b37 --- /dev/null +++ b/test/boxmodels/3p3cni/test_3p3cni.input @@ -0,0 +1,24 @@ +############################################################# +# Parameter file for test_3p2cni # +# Everything behind a '#' is a comment # +# Groups can be ordered e.g. : [BoundaryConditions], # +# see ../2p2c/ for a more detailed example # +############################################################# + +############################################################# +# Mandatory arguments # +############################################################# +dtInitial =1 # [s] +tEnd =1800 # [s] +gridFile =./grids/kuev_2p2cni.dgf + +##################################################################### +# Simulation restart # +# # +# DuMux simulations can be restarted from *.drs files # +# Set restart to the value of a specific file, e.g.: 'restart = 27184.1' # +# for the restart file # +# name_time=27184.1_rank=0.drs # +# Please comment in the below value, if restart is desired. # +##################################################################### +# restart= ... \ No newline at end of file diff --git a/test/boxmodels/MpNc/test_MpNc.cc b/test/boxmodels/MpNc/test_MpNc.cc index 28be429356..733774ba87 100644 --- a/test/boxmodels/MpNc/test_MpNc.cc +++ b/test/boxmodels/MpNc/test_MpNc.cc @@ -29,40 +29,31 @@ #include "obstacleproblem.hh" #include <dumux/common/start.hh> +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ void usage(const char *progName, const std::string &errorMsg) { if (errorMsg.size() > 0) { - std::cout << errorMsg << "\n" + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial, --grid-file\n" + "(or -tEnd, -dtInitial, -gridFile)\n" + "\n" + "\t--grid-file=FILENAME The file name of the file containing the grid \n" + "\t definition in DGF format\n" ; + + std::cout << errorMessageOut << "\n"; } - std::cout - << "Usage: " << progName << " [options]\n" - << "Mandatory options are:\n" - << "\t--t-end=ENDTIME The time of the end of the simlation [s]\n" - << "\t--dt-initial=STEPSIZE The initial time step size [s]\n" - << "\t--grid-file=FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "Alternativ supported syntax:\n" - << "\t-tEnd ENDTIME The time of the end of the simlation [s]\n" - << "\t-dtInitial STEPSIZE The initial time step size [s]\n" - << "\t-gridFile FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "If --parameter-file is specified parameters can also be defined there. In this case,\n" - << "camel case is used for the parameters (e.g.: --grid-file becomes gridFile). Parameters\n" - << "specified on the command line have priority over those in the parameter file.\n" - << "Important optional options include:\n" - << "\t--help,-h Print this usage message and exit\n" - << "\t--print-parameters[=true|false] Print the run-time modifiable parameters _after_ \n" - << "\t the simulation [default: true]\n" - << "\t--print-properties[=true|false] Print the compile-time parameters _before_ \n" - << "\t the simulation [default: true]\n" - << "\t--parameter-file=FILENAME File with parameter definitions\n" - << "\t--restart=RESTARTTIME Restart simulation from a restart file\n" - << "\n" - << "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" - << "\n"; } int main(int argc, char** argv) diff --git a/test/boxmodels/richards/test_richards.cc b/test/boxmodels/richards/test_richards.cc index ac77ccb034..6b2bcc9a9d 100644 --- a/test/boxmodels/richards/test_richards.cc +++ b/test/boxmodels/richards/test_richards.cc @@ -29,40 +29,31 @@ #include "richardslensproblem.hh" #include <dumux/common/start.hh> +/*! + * \brief Provides an interface for customizing error messages associated with + * reading in parameters. + * + * \param progname The name of the program, that was tried to be started. + * \param errorMsg The error message that was issued by the start function. + * Comprises the thing that went wrong and a general help message. + */ void usage(const char *progName, const std::string &errorMsg) { if (errorMsg.size() > 0) { - std::cout << errorMsg << "\n" + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "--t-end, --dt-initial, --grid-file\n" + "(or -tEnd, -dtInitial, -gridFile)\n" + "\n" + "\t--grid-file=FILENAME The file name of the file containing the grid \n" + "\t definition in DGF format\n" ; + + std::cout << errorMessageOut << "\n"; } - std::cout - << "Usage: " << progName << " [options]\n" - << "Mandatory options are:\n" - << "\t--t-end=ENDTIME The time of the end of the simlation [s]\n" - << "\t--dt-initial=STEPSIZE The initial time step size [s]\n" - << "\t--grid-file=FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "Alternativ supported syntax:\n" - << "\t-tEnd ENDTIME The time of the end of the simlation [s]\n" - << "\t-dtInitial STEPSIZE The initial time step size [s]\n" - << "\t-gridFile FILENAME The file name of the file containing the grid \n" - << "\t definition in DGF format\n" - << "\n" - << "If --parameter-file is specified parameters can also be defined there. In this case,\n" - << "camel case is used for the parameters (e.g.: --grid-file becomes gridFile). Parameters\n" - << "specified on the command line have priority over those in the parameter file.\n" - << "Important optional options include:\n" - << "\t--help,-h Print this usage message and exit\n" - << "\t--print-parameters[=true|false] Print the run-time modifiable parameters _after_ \n" - << "\t the simulation [default: true]\n" - << "\t--print-properties[=true|false] Print the compile-time parameters _before_ \n" - << "\t the simulation [default: true]\n" - << "\t--parameter-file=FILENAME File with parameter definitions\n" - << "\t--restart=RESTARTTIME Restart simulation from a restart file\n" - << "\n" - << "For the case of no arguments given, the input parameter file is expected to be named './parameter.input' \n" - << "\n"; } int main(int argc, char** argv) -- GitLab