44 #include <boost/program_options/parsers.hpp>
45 #include <boost/program_options/variables_map.hpp>
46 #include <boost/program_options/options_description.hpp>
54 #define _PROGRAM_VERSION_ "1.8.0"
56 #ifndef _PROGRAM_REVISION_
57 #define _PROGRAM_REVISION_ "(unknown revision)"
60 #ifndef _PROGRAM_BRANCH_
61 #define _PROGRAM_BRANCH_ "(unknown branch)"
64 #ifndef _COMPILER_FLAGS_
65 #define _COMPILER_FLAGS_ "(unknown compiler flags)"
71 namespace it = Input::Type;
77 =
it::Record(
"Root",
"Root record of JSON input for Flow123d.")
80 "Simulation problem to be solved.")
82 "If true, the program will wait for key press before it terminates.");
91 main_input_filename_(
""),
103 string revision(_GIT_REVISION_);
104 string branch(_GIT_BRANCH_);
105 string url(_GIT_URL_);
106 string build = string(__DATE__) +
", " + string(__TIME__) +
" flags: " + string(
_COMPILER_FLAGS_);
109 xprintf(
Msg,
"This is Flow123d, version %s revision: %s\n", version.c_str(), revision.c_str());
114 branch.c_str(), build.c_str() , url.c_str() );
122 cout <<
"Usage error: The main input file has to be specified through -s parameter.\n\n";
129 std::ifstream in_stream(fname.c_str());
131 xprintf(
UsrErr,
"Can not open main input file: '%s'.\n", fname.c_str());
136 }
catch (Input::JSONToStorage::ExcInputError &e ) {
137 e << Input::JSONToStorage::EI_File(fname);
throw;
138 }
catch (Input::JSONToStorage::ExcNotJSONFormat &e) {
139 e << Input::JSONToStorage::EI_File(fname);
throw;
149 namespace po = boost::program_options;
153 po::options_description desc(
"Allowed options");
155 (
"help",
"produce help message")
156 (
"solve,s", po::value< string >(),
"Main input file to solve.")
157 (
"input_dir,i", po::value< string >()->default_value(
"input"),
"Directory for the ${INPUT} placeholder in the main input file.")
158 (
"output_dir,o", po::value< string >()->default_value(
"output"),
"Directory for all produced output files.")
159 (
"log,l", po::value< string >()->default_value(
"flow123"),
"Set base name for log files.")
160 (
"version",
"Display version and build information and exit.")
161 (
"no_log",
"Turn off logging.")
162 (
"no_profiler",
"Turn off profiler output.")
163 (
"full_doc",
"Prints full structure of the main input file.")
164 (
"JSON_template",
"Prints description of the main input file as a valid CON file.")
165 (
"latex_doc",
"Prints description of the main input file in Latex format using particular macros.")
166 (
"JSON_machine",
"Prints full structure of the main input file as a valid CON file.");
170 po::variables_map vm;
171 po::parsed_options parsed = po::basic_command_line_parser<char>(argc, argv).options(desc).allow_unregistered().run();
172 po::store(parsed, vm);
176 vector<string> to_pass_further = po::collect_unrecognized(parsed.options, po::include_positional);
187 passed_argc_ = arg_i;
190 if (vm.count(
"help")) {
191 cout << desc <<
"\n";
195 if (vm.count(
"version")) {
201 if (vm.count(
"full_doc")) {
209 if (vm.count(
"JSON_template")) {
215 if (vm.count(
"latex_doc")) {
223 if (vm.count(
"JSON_machine")) {
230 if (vm.count(
"solve")) {
231 string input_filename = vm[
"solve"].as<
string>();
236 if (delim_pos < input_filename.npos) {
252 if (vm.count(
"input_dir")) {
253 input_dir = vm[
"input_dir"].as<
string>();
255 if (vm.count(
"output_dir")) {
256 output_dir = vm[
"output_dir"].as<
string>();
262 if (vm.count(
"log")) {
266 if (vm.count(
"no_log")) {
289 using namespace Input;
319 printf(
"\nPress <ENTER> for closing the window\n");
340 int main(
int argc,
char **argv) {
341 using namespace Input;
342 std::string ini_fname;
347 app.
init(argc, argv);
393 xprintf(
Err,
"Not implemented yet in this version\n");
399 void main_compute_mh(
struct Problem *problem) {
400 int type=
OptGetInt(
"Global",
"Problem_type", NULL);
402 case STEADY_SATURATED:
403 main_compute_mh_steady_saturated(problem);
405 case UNSTEADY_SATURATED:
406 main_compute_mh_unsteady_saturated(problem);
408 case PROBLEM_DENSITY:
419 void main_compute_mh_unsteady_saturated(
struct Problem *problem)
422 const string& mesh_file_name = IONameHandler::get_instance()->get_input_file_name(
OptGetStr(
"Input",
"Mesh", NULL));
426 meshReader->
read(mesh_file_name, mesh);
428 mesh->setup_materials(* problem->material_database);
435 string output_file = IONameHandler::get_instance()->get_output_file_name(
OptGetFileName(
"Output",
"Output_file",
"\\"));
436 output_time =
new OutputTime(mesh, output_file);
443 TimeMark::Type output_mark_type = main_time_marks->new_strict_mark_type();
446 while (! water_time.
is_end()) {
447 water->compute_one_step();
448 water_output->postprocess();
450 if ( main_time_marks->
is_current(water_time, output_mark_type) ) {
451 output_time->get_data_from_mesh();
455 output_time->free_data_from_mesh();
463 void main_compute_mh_steady_saturated(
struct Problem *problem)
465 const string& mesh_file_name = IONameHandler::get_instance()->get_input_file_name(
OptGetStr(
"Input",
"Mesh", NULL));
469 meshReader->
read(mesh_file_name, mesh);
471 mesh->setup_materials(* problem->material_database);
485 problem->water=
new DarcyFlowMH_Steady(main_time_marks, mesh, problem->material_database);
489 problem->water->compute_one_step();
491 if (
OptGetBool(
"Transport",
"Transport_on",
"no") ==
true) {
497 water_output->postprocess();
500 string out_fname = IONameHandler::get_instance()->get_output_file_name(
OptGetFileName(
"Output",
"Output_file", NULL));
501 Output *output =
new Output(mesh, out_fname);
502 output->get_data_from_mesh();
505 output->write_data();
506 output->free_data_from_mesh();
571 if (
OptGetBool(
"Transport",
"Transport_on",
"no") ==
true) {
572 problem->otransport->convection();
610 void main_compute_mh_density(
struct Problem *problem)
612 Mesh* mesh = (
Mesh*) ConstantDB::getInstance()->getObject(MESH::MAIN_INSTANCE);
613 int i, j, dens_step, n_step, frame = 0, rank;
614 double save_step, stop_time;
627 output_time =
new OutputTime(mesh, problem->otransport->transport_out_fname);