27 #ifndef EWOMS_START_HH 28 #define EWOMS_START_HH 33 #include <opm/material/densead/Evaluation.hpp> 37 #include <ewoms/version.hh> 43 #include <opm/common/Valgrind.hpp> 45 #include <opm/common/ResetLocale.hpp> 47 #include <dune/grid/io/file/dgfparser/dgfparser.hh> 48 #include <dune/common/version.hh> 49 #include <dune/common/parametertreeparser.hh> 50 #include <dune/common/parallel/mpihelper.hh> 53 #include <dune/fem/misc/mpimanager.hh> 74 namespace Properties {
93 template <
class TypeTag>
94 static inline int setupParameters_(
int argc,
char **argv)
97 typedef typename GET_PROP_TYPE(TypeTag, ThreadManager) ThreadManager;
98 typedef typename GET_PROP(TypeTag, ParameterMetaData) ParameterMetaData;
103 MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
110 "An .ini file which contains a set of run-time " 113 "Print the values of the compile time properties at " 114 "the start of the simulation");
116 "Print the values of the run-time parameters at the " 117 "start of the simulation");
127 std::string s = Parameters::parseCommandLineOptions<TypeTag>(argc, argv, myRank == 0);
132 std::string paramFileName = EWOMS_GET_PARAM_(TypeTag, std::string, ParameterFile);
133 if (paramFileName !=
"") {
140 tmp.open(paramFileName.c_str());
141 if (!tmp.is_open()) {
142 std::ostringstream oss;
144 oss <<
"Parameter file \"" << paramFileName
145 <<
"\" does not exist or is not readable.";
146 Parameters::printUsage<TypeTag>(argv[0], oss.str());
152 Dune::ParameterTreeParser::readINITree(paramFileName,
153 ParameterMetaData::tree(),
166 static inline void resetTerminal_(
int signum)
169 signal(signum, SIG_DFL);
170 std::cout <<
"\n\nReceived signal " <<
signum 171 <<
" (\"" << strsignal(signum) <<
"\")." 172 <<
" Trying to reset the terminal.\n";
177 if (system(
"stty sane") != 0)
178 std::cout <<
"Executing the 'stty' command failed." 179 <<
" Terminal might be left in an undefined state!\n";
197 template <
class TypeTag>
198 static inline int start(
int argc,
char **argv)
201 typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
202 typedef typename GET_PROP_TYPE(TypeTag, ThreadManager) ThreadManager;
206 if (isatty(STDIN_FILENO)) {
207 signal(SIGINT, resetTerminal_);
208 signal(SIGHUP, resetTerminal_);
209 signal(SIGABRT, resetTerminal_);
210 signal(SIGFPE, resetTerminal_);
211 signal(SIGSEGV, resetTerminal_);
212 signal(SIGPIPE, resetTerminal_);
213 signal(SIGTERM, resetTerminal_);
220 Dune::Fem::MPIManager::initialize(argc, argv);
221 const int myRank = Dune::Fem::MPIManager::rank();
223 const int myRank = Dune::MPIHelper::instance(argc, argv).rank();
228 int paramStatus = setupParameters_<TypeTag>(argc, argv);
229 if (paramStatus == 1)
231 if (paramStatus == 2)
234 ThreadManager::init();
238 if (endTime < -1e50) {
240 Parameters::printUsage<TypeTag>(argv[0],
241 "Mandatory parameter '--end-time' not specified!");
245 Scalar initialTimeStepSize =
EWOMS_GET_PARAM(TypeTag, Scalar, InitialTimeStepSize);
246 if (initialTimeStepSize < -1e50) {
248 Parameters::printUsage<TypeTag>(argv[0],
249 "Mandatory parameter '--initial-time-step-size' " 256 std::cout <<
"eWoms " << Ewoms::versionString()
257 <<
" will now start the trip. " 258 <<
"Please sit back, relax and enjoy the ride.\n" 264 std::string endParametersSeparator(
"# [end of parameters]\n");
266 bool printSeparator =
false;
267 if (printParams == 1 || !isatty(fileno(stdout))) {
268 Ewoms::Parameters::printValues<TypeTag>();
269 printSeparator =
true;
275 Ewoms::Parameters::printUnused<TypeTag>();
277 std::cout << endParametersSeparator;
281 if (Ewoms::Parameters::printUnused<TypeTag>())
282 std::cout << endParametersSeparator;
287 if (printProps && myRank == 0) {
288 if (printProps == 1 || !isatty(fileno(stdout)))
289 Ewoms::Properties::printValues<TypeTag>();
299 std::cout <<
"eWoms reached the destination. If it is not the one that was intended, " 300 <<
"change the booking and try again.\n" 305 catch (std::exception& e)
308 std::cout << e.what() <<
". Abort!\n" << std::flush;
311 #if ! DUNE_VERSION_NEWER(DUNE_COMMON, 2,5) 312 catch (Dune::Exception& e)
315 std::cout <<
"Dune reported an error: " << e.what() << std::endl << std::flush;
322 std::cout <<
"Unknown exception thrown!\n" << std::flush;
#define EWOMS_END_PARAM_REGISTRATION(TypeTag)
Indicate that all parameters are registered for a given type tag.
Definition: parametersystem.hh:81
Manages the initializing and running of time dependent problems.
Definition: baseauxiliarymodule.hh:37
int signum(Scalar val)
Template function which returns the sign of a floating point value.
Definition: signum.hh:40
static void registerParameters()
Registers all runtime parameters used by the simulation.
Definition: simulator.hh:151
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
This file provides the infrastructure to retrieve run-time parameters.
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
Provides an encapsulation to measure the system time.
Provides the magic behind the eWoms property system.
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
#define GET_PROP(TypeTag, PropTagName)
Retrieve a property for a type tag.
Definition: propertysystem.hh:454
static void registerParameters()
Register all run-time parameters of the thread manager.
Definition: threadmanager.hh:67