OGS 6.2.0-97-g4a610c866
ProjectData.cpp
Go to the documentation of this file.
1 
14 #include "ProjectData.h"
15 
16 #include <algorithm>
17 #include <set>
18 
19 #include <logog/include/logog.hpp>
20 
21 #ifdef OGS_USE_PYTHON
22 #include <pybind11/eval.h>
23 #endif
24 
25 #include "BaseLib/Algorithm.h"
26 #include "BaseLib/ConfigTree.h"
27 #include "BaseLib/FileTools.h"
28 
29 #include "GeoLib/GEOObjects.h"
35 #include "MeshLib/Mesh.h"
36 
40 
41 // FileIO
44 
46 #include "ParameterLib/Utils.h"
48 
49 #ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT
51 #endif
52 #ifdef OGS_BUILD_PROCESS_GROUNDWATERFLOW
54 #endif
55 #ifdef OGS_BUILD_PROCESS_HT
57 #endif
58 #ifdef OGS_BUILD_PROCESS_HEATCONDUCTION
60 #endif
61 #ifdef OGS_BUILD_PROCESS_HEATTRANSPORTBHE
63 #endif
64 #ifdef OGS_BUILD_PROCESS_HYDROMECHANICS
66 #endif
67 #ifdef OGS_BUILD_PROCESS_LIE
70 #endif
71 #ifdef OGS_BUILD_PROCESS_LIQUIDFLOW
73 #endif
74 #ifdef OGS_BUILD_PROCESS_PHASEFIELD
76 #endif
77 #ifdef OGS_BUILD_PROCESS_RICHARDSCOMPONENTTRANSPORT
79 #endif
80 #ifdef OGS_BUILD_PROCESS_RICHARDSFLOW
82 #endif
83 #ifdef OGS_BUILD_PROCESS_RICHARDSMECHANICS
85 #endif
86 #ifdef OGS_BUILD_PROCESS_SMALLDEFORMATION
88 #endif
89 #ifdef OGS_BUILD_PROCESS_SMALLDEFORMATIONNONLOCAL
91 #endif
92 #ifdef OGS_BUILD_PROCESS_TES
94 #endif
95 #ifdef OGS_BUILD_PROCESS_THERMALTWOPHASEFLOWWITHPP
97 #endif
98 #ifdef OGS_BUILD_PROCESS_THERMOHYDROMECHANICS
100 #endif
101 #ifdef OGS_BUILD_PROCESS_THERMOMECHANICALPHASEFIELD
103 #endif
104 #ifdef OGS_BUILD_PROCESS_THERMOMECHANICS
106 #endif
107 #ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPP
109 #endif
110 #ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPRHO
112 #endif
113 
114 namespace
115 {
116 void readGeometry(std::string const& fname, GeoLib::GEOObjects& geo_objects)
117 {
118  DBUG("Reading geometry file '%s'.", fname.c_str());
119  GeoLib::IO::BoostXmlGmlInterface gml_reader(geo_objects);
120  gml_reader.readFile(fname);
121 }
122 
123 std::unique_ptr<MeshLib::Mesh> readSingleMesh(
124  BaseLib::ConfigTree const& mesh_config_parameter,
125  std::string const& project_directory)
126 {
127  std::string const mesh_file = BaseLib::copyPathToFileName(
128  mesh_config_parameter.getValue<std::string>(), project_directory);
129  DBUG("Reading mesh file '%s'.", mesh_file.c_str());
130 
131  auto mesh = std::unique_ptr<MeshLib::Mesh>(
132  MeshLib::IO::readMeshFromFile(mesh_file));
133  if (!mesh)
134  {
135  OGS_FATAL("Could not read mesh from '%s' file. No mesh added.",
136  mesh_file.c_str());
137  }
138 
139 #ifdef DOXYGEN_DOCU_ONLY
140  mesh_config_parameter.getConfigAttributeOptional<bool>("axially_symmetric");
142 #endif // DOXYGEN_DOCU_ONLY
143 
144  if (auto const axially_symmetric =
146  mesh_config_parameter.getConfigAttributeOptional<bool>(
147  "axially_symmetric"))
148  {
149  mesh->setAxiallySymmetric(*axially_symmetric);
150  }
151 
152  return mesh;
153 }
154 
155 std::vector<std::unique_ptr<MeshLib::Mesh>> readMeshes(
156  BaseLib::ConfigTree const& config, std::string const& project_directory)
157 {
158  std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
159 
161  auto optional_meshes = config.getConfigSubtreeOptional("meshes");
162  if (optional_meshes)
163  {
164  DBUG("Reading multiple meshes.");
165  for (auto mesh_config :
167  optional_meshes->getConfigParameterList("mesh"))
168  {
169  meshes.push_back(readSingleMesh(mesh_config, project_directory));
170  }
171  }
172  else
173  { // Read single mesh with geometry.
174  WARN(
175  "Consider switching from mesh and geometry input to multiple "
176  "meshes input. See "
177  "https://www.opengeosys.org/docs/tools/model-preparation/"
178  "constructmeshesfromgeometry/ tool for conversion.");
180  meshes.push_back(readSingleMesh(config.getConfigParameter("mesh"),
182 
183  std::string const geometry_file = BaseLib::copyPathToFileName(
185  config.getConfigParameter<std::string>("geometry"),
186  project_directory);
187  GeoLib::GEOObjects geoObjects;
188  readGeometry(geometry_file, geoObjects);
189 
190  std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_algorithm =
192  auto additional_meshes =
194  geoObjects, *meshes[0], std::move(search_length_algorithm));
195 
196  std::move(begin(additional_meshes), end(additional_meshes),
197  std::back_inserter(meshes));
198  }
199  return meshes;
200 }
201 
202 boost::optional<ParameterLib::CoordinateSystem> parseLocalCoordinateSystem(
203  boost::optional<BaseLib::ConfigTree> const& config,
204  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
205 {
206  if (!config)
207  {
208  return {};
209  }
210 
211  DBUG("Reading coordinate system configuration.");
212 
213  //
214  // Fetch the first basis vector; its length defines the dimension.
215  //
216  auto const& basis_vector_0 = ParameterLib::findParameter<double>(
217  *config,
219  "basis_vector_0", parameters, 0 /* any dimension */);
220  int const dimension = basis_vector_0.getNumberOfComponents();
221 
222  // check dimension
223  if (dimension != 2 && dimension != 3)
224  {
225  OGS_FATAL(
226  "Basis vector parameter '%s' must have two or three components, "
227  "but it has %d.",
228  basis_vector_0.name.c_str(), dimension);
229  }
230 
231  //
232  // Fetch the second basis vector, which must be of the same dimension as the
233  // first one.
234  //
235  auto const& basis_vector_1 = ParameterLib::findParameter<double>(
236  *config,
238  "basis_vector_1", parameters, dimension);
239 
240  //
241  // For two dimensions, we are done; construct coordinate system;
242  //
243  if (dimension == 2)
244  {
245  return ParameterLib::CoordinateSystem{basis_vector_0, basis_vector_1};
246  }
247 
248  //
249  // Parse the third vector, for three dimensions.
250  //
251  auto const& basis_vector_2 = ParameterLib::findParameter<double>(
252  *config,
254  "basis_vector_2", parameters, dimension);
255  return ParameterLib::CoordinateSystem{basis_vector_0, basis_vector_1,
256  basis_vector_2};
257 }
258 } // namespace
259 
260 ProjectData::ProjectData() = default;
261 
263  std::string const& project_directory,
264  std::string const& output_directory)
265 {
266  _mesh_vec = readMeshes(project_config, project_directory);
267 
268  if (auto const python_script =
270  project_config.getConfigParameterOptional<std::string>("python_script"))
271  {
272 #ifdef OGS_USE_PYTHON
273  namespace py = pybind11;
274 
275  // Append project's directory to python's module search path.
276  py::module::import("sys").attr("path").attr("append")(
278 
279  auto const script_path =
280  BaseLib::copyPathToFileName(*python_script, project_directory);
281 
282  // Evaluate in scope of main module
283  py::object scope = py::module::import("__main__").attr("__dict__");
284  py::eval_file(script_path, scope);
285 #else
286  OGS_FATAL("OpenGeoSys has not been built with Python support.");
287 #endif // OGS_USE_PYTHON
288  }
289 
291  parseCurves(project_config.getConfigSubtreeOptional("curves"));
292 
293  auto parameter_names_for_transformation =
295  parseParameters(project_config.getConfigSubtree("parameters"));
296 
299  project_config.getConfigSubtreeOptional("local_coordinate_system"),
300  _parameters);
301 
302  for (auto& parameter : _parameters)
303  {
304  if (std::find(begin(parameter_names_for_transformation),
305  end(parameter_names_for_transformation),
306  parameter->name) !=
307  end(parameter_names_for_transformation))
308  {
309  if (!_local_coordinate_system)
310  {
311  OGS_FATAL(
312  "The parameter '%s' is using the local coordinate system "
313  "but no local coordinate system was provided.",
314  parameter->name.c_str());
315  }
316  parameter->setCoordinateSystem(*_local_coordinate_system);
317  }
318 
319  parameter->initialize(_parameters);
320  }
321 
323  parseProcessVariables(project_config.getConfigSubtree("process_variables"));
324 
326  parseMedia(project_config.getConfigSubtreeOptional("media"));
327 
329  parseProcesses(project_config.getConfigSubtree("processes"),
330  project_directory, output_directory);
331 
333  parseLinearSolvers(project_config.getConfigSubtree("linear_solvers"));
334 
336  parseNonlinearSolvers(project_config.getConfigSubtree("nonlinear_solvers"));
337 
339  parseTimeLoop(project_config.getConfigSubtree("time_loop"),
340  output_directory);
341 }
342 
344  BaseLib::ConfigTree const& process_variables_config)
345 {
346  DBUG("Parse process variables:");
347 
348  std::set<std::string> names;
349 
350  for (auto var_config
352  : process_variables_config.getConfigSubtreeList("process_variable"))
353  {
354  // Either the mesh name is given, or the first mesh's name will be
355  // taken. Taking the first mesh's value is deprecated.
356  auto const mesh_name =
358  var_config.getConfigParameter<std::string>("mesh",
359  _mesh_vec[0]->getName());
360 
361  auto& mesh = *BaseLib::findElementOrError(
362  begin(_mesh_vec), end(_mesh_vec),
363  [&mesh_name](auto const& m) { return m->getName() == mesh_name; },
364  "Expected to find a mesh named " + mesh_name + ".");
365 
366  auto pv = ProcessLib::ProcessVariable{var_config, mesh, _mesh_vec,
367  _parameters};
368  if (!names.insert(pv.getName()).second)
369  {
370  OGS_FATAL("A process variable with name `%s' already exists.",
371  pv.getName().c_str());
372  }
373 
374  _process_variables.push_back(std::move(pv));
375  }
376 }
377 
378 std::vector<std::string> ProjectData::parseParameters(
379  BaseLib::ConfigTree const& parameters_config)
380 {
381  using namespace ProcessLib;
382 
383  std::set<std::string> names;
384  std::vector<std::string> parameter_names_for_transformation;
385 
386  DBUG("Reading parameters:");
387  for (auto parameter_config :
389  parameters_config.getConfigSubtreeList("parameter"))
390  {
391  auto p =
392  ParameterLib::createParameter(parameter_config, _mesh_vec, _curves);
393  if (!names.insert(p->name).second)
394  {
395  OGS_FATAL("A parameter with name `%s' already exists.",
396  p->name.c_str());
397  }
398 
399  auto const use_local_coordinate_system =
401  parameter_config.getConfigParameterOptional<bool>(
402  "use_local_coordinate_system");
403  if (!!use_local_coordinate_system &&
404  *use_local_coordinate_system == true)
405  {
406  parameter_names_for_transformation.push_back(p->name);
407  }
408 
409  _parameters.push_back(std::move(p));
410  }
411 
412  _parameters.push_back(
413  std::make_unique<ParameterLib::ConstantParameter<double>>(
415 
416  return parameter_names_for_transformation;
417 }
418 
420  boost::optional<BaseLib::ConfigTree> const& media_config)
421 {
422  if (!media_config)
423  {
424  return;
425  }
426 
427  DBUG("Reading media:");
428 
429  if (_mesh_vec.empty() || _mesh_vec[0] == nullptr)
430  {
431  ERR("A mesh is required to define medium materials.");
432  return;
433  }
434 
435  for (auto const& medium_config :
437  media_config->getConfigSubtreeList("medium"))
438  {
440  auto const material_id = medium_config.getConfigAttribute<int>("id", 0);
441 
442  if (_media.find(material_id) != _media.end())
443  {
444  OGS_FATAL(
445  "Multiple media were specified for the same material id %d. "
446  "Keep in mind, that if no material id is specified, it is "
447  "assumed to be 0 by default.",
448  material_id);
449  }
450 
451  _media[material_id] = MaterialPropertyLib::createMedium(medium_config);
452  }
453 
454  if (_media.empty())
455  {
456  OGS_FATAL("No entity is found inside <media>.");
457  }
458 }
459 
461  std::string const& project_directory,
462  std::string const& output_directory)
463 {
464  (void)project_directory; // to avoid compilation warning
465  (void)output_directory; // to avoid compilation warning
466 
467  DBUG("Reading processes:");
469  for (auto process_config : processes_config.getConfigSubtreeList("process"))
470  {
471  auto const type =
473  process_config.peekConfigParameter<std::string>("type");
474 
475  auto const name =
477  process_config.getConfigParameter<std::string>("name");
478 
479  auto const integration_order =
481  process_config.getConfigParameter<int>("integration_order");
482 
483  std::unique_ptr<ProcessLib::Process> process;
484 
485  auto jacobian_assembler = ProcessLib::createJacobianAssembler(
487  process_config.getConfigSubtreeOptional("jacobian_assembler"));
488 
489 #ifdef OGS_BUILD_PROCESS_GROUNDWATERFLOW
490  if (type == "GROUNDWATER_FLOW")
491  {
492  // The existence check of the in the configuration referenced
493  // process variables is checked in the physical process.
494  // TODO at the moment we have only one mesh, later there can be
495  // several meshes. Then we have to assign the referenced mesh
496  // here.
498  *_mesh_vec[0], std::move(jacobian_assembler),
499  _process_variables, _parameters, integration_order,
500  process_config, _mesh_vec, output_directory);
501  }
502  else
503 #endif
504 #ifdef OGS_BUILD_PROCESS_LIQUIDFLOW
505  if (type == "LIQUID_FLOW")
506  {
508  *_mesh_vec[0], std::move(jacobian_assembler),
509  _process_variables, _parameters, integration_order,
510  process_config);
511  }
512  else
513 #endif
514 #ifdef OGS_BUILD_PROCESS_TES
515  if (type == "TES")
516  {
518  *_mesh_vec[0], std::move(jacobian_assembler),
519  _process_variables, _parameters, integration_order,
520  process_config);
521  }
522  else
523 #endif
524 #ifdef OGS_BUILD_PROCESS_HEATCONDUCTION
525  if (type == "HEAT_CONDUCTION")
526  {
528  *_mesh_vec[0], std::move(jacobian_assembler),
529  _process_variables, _parameters, integration_order,
530  process_config);
531  }
532  else
533 #endif
534 #ifdef OGS_BUILD_PROCESS_HEATTRANSPORTBHE
535  if (type == "HEAT_TRANSPORT_BHE")
536  {
537  if (_mesh_vec[0]->getDimension() != 3)
538  {
539  OGS_FATAL(
540  "HEAT_TRANSPORT_BHE can only work with a 3-dimentional "
541  "mesh! ");
542  }
543 
544  process =
546  *_mesh_vec[0], std::move(jacobian_assembler),
547  _process_variables, _parameters, integration_order,
548  process_config, _curves);
549  }
550  else
551 #endif
552 #ifdef OGS_BUILD_PROCESS_HYDROMECHANICS
553  if (type == "HYDRO_MECHANICS")
554  {
556  switch (process_config.getConfigParameter<int>("dimension"))
557  {
558  case 2:
559  process =
561  2>(*_mesh_vec[0], std::move(jacobian_assembler),
563  _local_coordinate_system, integration_order,
564  process_config);
565  break;
566  case 3:
567  process =
569  3>(*_mesh_vec[0], std::move(jacobian_assembler),
571  _local_coordinate_system, integration_order,
572  process_config);
573  break;
574  default:
575  OGS_FATAL(
576  "HYDRO_MECHANICS process does not support given "
577  "dimension");
578  }
579  }
580  else
581 #endif
582 #ifdef OGS_BUILD_PROCESS_LIE
583  if (type == "HYDRO_MECHANICS_WITH_LIE")
584  {
586  switch (process_config.getConfigParameter<int>("dimension"))
587  {
588  case 2:
589  process = ProcessLib::LIE::HydroMechanics::
590  createHydroMechanicsProcess<2>(
591  *_mesh_vec[0], std::move(jacobian_assembler),
593  _local_coordinate_system, integration_order,
594  process_config);
595  break;
596  case 3:
597  process = ProcessLib::LIE::HydroMechanics::
598  createHydroMechanicsProcess<3>(
599  *_mesh_vec[0], std::move(jacobian_assembler),
601  _local_coordinate_system, integration_order,
602  process_config);
603  break;
604  default:
605  OGS_FATAL(
606  "HYDRO_MECHANICS_WITH_LIE process does not support "
607  "given dimension");
608  }
609  }
610  else
611 #endif
612 #ifdef OGS_BUILD_PROCESS_HT
613  if (type == "HT")
614  {
616  *_mesh_vec[0], std::move(jacobian_assembler),
617  _process_variables, _parameters, integration_order,
618  process_config, _mesh_vec, output_directory, _media);
619  }
620  else
621 #endif
622 #ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT
623  if (type == "ComponentTransport")
624  {
625  process =
627  *_mesh_vec[0], std::move(jacobian_assembler),
628  _process_variables, _parameters, integration_order,
629  process_config, _mesh_vec, output_directory, _media);
630  }
631  else
632 #endif
633 #ifdef OGS_BUILD_PROCESS_PHASEFIELD
634  if (type == "PHASE_FIELD")
635  {
636  switch (_mesh_vec[0]->getDimension())
637  {
638  case 2:
639  process =
641  *_mesh_vec[0], std::move(jacobian_assembler),
643  _local_coordinate_system, integration_order,
644  process_config);
645  break;
646  case 3:
647  process =
649  *_mesh_vec[0], std::move(jacobian_assembler),
651  _local_coordinate_system, integration_order,
652  process_config);
653  break;
654  }
655  }
656  else
657 #endif
658 #ifdef OGS_BUILD_PROCESS_RICHARDSCOMPONENTTRANSPORT
659  if (type == "RichardsComponentTransport")
660  {
663  *_mesh_vec[0], std::move(jacobian_assembler),
664  _process_variables, _parameters, integration_order,
665  process_config);
666  }
667  else
668 #endif
669 #ifdef OGS_BUILD_PROCESS_SMALLDEFORMATION
670  if (type == "SMALL_DEFORMATION")
671  {
672  switch (_mesh_vec[0]->getDimension())
673  {
674  case 2:
675  process = ProcessLib::SmallDeformation::
676  createSmallDeformationProcess<2>(
677  *_mesh_vec[0], std::move(jacobian_assembler),
679  _local_coordinate_system, integration_order,
680  process_config);
681  break;
682  case 3:
683  process = ProcessLib::SmallDeformation::
684  createSmallDeformationProcess<3>(
685  *_mesh_vec[0], std::move(jacobian_assembler),
687  _local_coordinate_system, integration_order,
688  process_config);
689  break;
690  default:
691  OGS_FATAL(
692  "SMALL_DEFORMATION process does not support "
693  "given dimension");
694  }
695  }
696  else
697 #endif
698 #ifdef OGS_BUILD_PROCESS_SMALLDEFORMATIONNONLOCAL
699  if (type == "SMALL_DEFORMATION_NONLOCAL")
700  {
701  switch (_mesh_vec[0]->getDimension())
702  {
703  case 2:
704  process = ProcessLib::SmallDeformationNonlocal::
705  createSmallDeformationNonlocalProcess<2>(
706  *_mesh_vec[0], std::move(jacobian_assembler),
708  _local_coordinate_system, integration_order,
709  process_config);
710  break;
711  case 3:
712  process = ProcessLib::SmallDeformationNonlocal::
713  createSmallDeformationNonlocalProcess<3>(
714  *_mesh_vec[0], std::move(jacobian_assembler),
716  _local_coordinate_system, integration_order,
717  process_config);
718  break;
719  default:
720  OGS_FATAL(
721  "SMALL_DEFORMATION_NONLOCAL process does not support "
722  "given dimension %d",
723  _mesh_vec[0]->getDimension());
724  }
725  }
726  else
727 #endif
728 #ifdef OGS_BUILD_PROCESS_LIE
729  if (type == "SMALL_DEFORMATION_WITH_LIE")
730  {
732  switch (process_config.getConfigParameter<int>("dimension"))
733  {
734  case 2:
735  process = ProcessLib::LIE::SmallDeformation::
736  createSmallDeformationProcess<2>(
737  *_mesh_vec[0], std::move(jacobian_assembler),
739  _local_coordinate_system, integration_order,
740  process_config);
741  break;
742  case 3:
743  process = ProcessLib::LIE::SmallDeformation::
744  createSmallDeformationProcess<3>(
745  *_mesh_vec[0], std::move(jacobian_assembler),
747  _local_coordinate_system, integration_order,
748  process_config);
749  break;
750  default:
751  OGS_FATAL(
752  "SMALL_DEFORMATION_WITH_LIE process does not support "
753  "given dimension");
754  }
755  }
756  else
757 #endif
758 #ifdef OGS_BUILD_PROCESS_THERMOHYDROMECHANICS
759  if (type == "THERMO_HYDRO_MECHANICS")
760  {
762  switch (process_config.getConfigParameter<int>("dimension"))
763  {
764  case 2:
765  process = ProcessLib::ThermoHydroMechanics::
766  createThermoHydroMechanicsProcess<2>(
767  *_mesh_vec[0], std::move(jacobian_assembler),
769  _local_coordinate_system, integration_order,
770  process_config);
771  break;
772  case 3:
773  process = ProcessLib::ThermoHydroMechanics::
774  createThermoHydroMechanicsProcess<3>(
775  *_mesh_vec[0], std::move(jacobian_assembler),
777  _local_coordinate_system, integration_order,
778  process_config);
779  break;
780  default:
781  OGS_FATAL(
782  "THERMO_HYDRO_MECHANICS process does not support given "
783  "dimension");
784  }
785  }
786  else
787 #endif
788 #ifdef OGS_BUILD_PROCESS_THERMOMECHANICALPHASEFIELD
789  if (type == "THERMO_MECHANICAL_PHASE_FIELD")
790  {
791  switch (_mesh_vec[0]->getDimension())
792  {
793  case 2:
794  process = ProcessLib::ThermoMechanicalPhaseField::
795  createThermoMechanicalPhaseFieldProcess<2>(
796  *_mesh_vec[0], std::move(jacobian_assembler),
798  _local_coordinate_system, integration_order,
799  process_config);
800  break;
801  case 3:
802  process = ProcessLib::ThermoMechanicalPhaseField::
803  createThermoMechanicalPhaseFieldProcess<3>(
804  *_mesh_vec[0], std::move(jacobian_assembler),
806  _local_coordinate_system, integration_order,
807  process_config);
808  break;
809  }
810  }
811  else
812 #endif
813 #ifdef OGS_BUILD_PROCESS_THERMOMECHANICS
814  if (type == "THERMO_MECHANICS")
815  {
816  switch (_mesh_vec[0]->getDimension())
817  {
818  case 2:
819  process = ProcessLib::ThermoMechanics::
820  createThermoMechanicsProcess<2>(
821  *_mesh_vec[0], std::move(jacobian_assembler),
823  _local_coordinate_system, integration_order,
824  process_config);
825  break;
826  case 3:
827  process = ProcessLib::ThermoMechanics::
828  createThermoMechanicsProcess<3>(
829  *_mesh_vec[0], std::move(jacobian_assembler),
831  _local_coordinate_system, integration_order,
832  process_config);
833  break;
834  }
835  }
836  else
837 #endif
838 #ifdef OGS_BUILD_PROCESS_RICHARDSFLOW
839  if (type == "RICHARDS_FLOW")
840  {
842  *_mesh_vec[0], std::move(jacobian_assembler),
843  _process_variables, _parameters, integration_order,
844  process_config, _curves);
845  }
846  else
847 #endif
848 #ifdef OGS_BUILD_PROCESS_RICHARDSMECHANICS
849  if (type == "RICHARDS_MECHANICS")
850  {
852  switch (process_config.getConfigParameter<int>("dimension"))
853  {
854  case 2:
855  process = ProcessLib::RichardsMechanics::
856  createRichardsMechanicsProcess<2>(
857  *_mesh_vec[0], std::move(jacobian_assembler),
859  _local_coordinate_system, integration_order,
860  process_config);
861  break;
862  case 3:
863  process = ProcessLib::RichardsMechanics::
864  createRichardsMechanicsProcess<3>(
865  *_mesh_vec[0], std::move(jacobian_assembler),
867  _local_coordinate_system, integration_order,
868  process_config);
869  break;
870  }
871  }
872  else
873 #endif
874 #ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPP
875  if (type == "TWOPHASE_FLOW_PP")
876  {
877  process =
879  *_mesh_vec[0], std::move(jacobian_assembler),
880  _process_variables, _parameters, integration_order,
881  process_config, _curves);
882  }
883  else
884 #endif
885 #ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPRHO
886  if (type == "TWOPHASE_FLOW_PRHO")
887  {
890  *_mesh_vec[0], std::move(jacobian_assembler),
891  _process_variables, _parameters, integration_order,
892  process_config, _curves);
893  }
894  else
895 #endif
896 #ifdef OGS_BUILD_PROCESS_THERMALTWOPHASEFLOWWITHPP
897  if (type == "THERMAL_TWOPHASE_WITH_PP")
898  {
901  *_mesh_vec[0], std::move(jacobian_assembler),
902  _process_variables, _parameters, integration_order,
903  process_config, _curves);
904  }
905  else
906 #endif
907  {
908  OGS_FATAL("Unknown process type: %s", type.c_str());
909  }
910 
912  name,
913  std::move(process),
914  "The process name is not unique");
915  }
916 }
917 
919  std::string const& output_directory)
920 {
921  DBUG("Reading time loop configuration.");
922 
924  config, output_directory, _processes, _nonlinear_solvers, _mesh_vec);
925 
926  if (!_time_loop)
927  {
928  OGS_FATAL("Initialization of time loop failed.");
929  }
930 }
931 
933 {
934  DBUG("Reading linear solver configuration.");
935 
937  for (auto conf : config.getConfigSubtreeList("linear_solver"))
938  {
940  auto const name = conf.getConfigParameter<std::string>("name");
943  name,
944  std::make_unique<GlobalLinearSolver>("", &conf),
945  "The linear solver name is not unique");
946  }
947 }
948 
950 {
951  DBUG("Reading linear solver configuration.");
952 
954  for (auto conf : config.getConfigSubtreeList("nonlinear_solver"))
955  {
956  auto const ls_name =
958  conf.getConfigParameter<std::string>("linear_solver");
959  auto& linear_solver = BaseLib::getOrError(
960  _linear_solvers, ls_name,
961  "A linear solver with the given name does not exist.");
962 
964  auto const name = conf.getConfigParameter<std::string>("name");
967  name,
968  NumLib::createNonlinearSolver(*linear_solver, conf).first,
969  "The nonlinear solver name is not unique");
970  }
971 }
972 
974  boost::optional<BaseLib::ConfigTree> const& config)
975 {
976  if (!config)
977  {
978  return;
979  }
980 
981  DBUG("Reading curves configuration.");
982 
984  for (auto conf : config->getConfigSubtreeList("curve"))
985  {
987  auto const name = conf.getConfigParameter<std::string>("name");
989  _curves,
990  name,
993  "The curve name is not unique.");
994  }
995 }
std::unique_ptr< Process > createHydroMechanicsProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
void parseProcesses(BaseLib::ConfigTree const &process_config, std::string const &project_directory, std::string const &output_directory)
Container class for geometric objects.
Definition: GEOObjects.h:62
std::vector< std::unique_ptr< ParameterLib::ParameterBase > > _parameters
Buffer for each parameter config passed to the process.
Definition: ProjectData.h:123
std::unique_ptr< Process > createTESProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
std::unique_ptr< Process > createHTProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes, std::string const &output_directory, std::map< int, std::unique_ptr< MaterialPropertyLib::Medium >> const &media)
Definition of the BoostXmlGmlInterface class.
std::unique_ptr< ParameterBase > createParameter(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves)
Definition: Parameter.cpp:23
std::unique_ptr< AbstractJacobianAssembler > createJacobianAssembler(boost::optional< BaseLib::ConfigTree > const &config)
void parseLinearSolvers(BaseLib::ConfigTree const &config)
void parseCurves(boost::optional< BaseLib::ConfigTree > const &config)
std::vector< std::unique_ptr< MeshLib::Mesh > > _mesh_vec
Definition: ProjectData.h:118
std::unique_ptr< Process > createThermalTwoPhaseFlowWithPPProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves)
std::map< std::string, std::unique_ptr< ProcessLib::Process > > _processes
Definition: ProjectData.h:119
std::string copyPathToFileName(const std::string &file_name, const std::string &source)
Definition: FileTools.cpp:155
std::map< std::string, std::unique_ptr< NumLib::NonlinearSolverBase > > _nonlinear_solvers
Definition: ProjectData.h:135
std::unique_ptr< Process > createComponentTransportProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes, std::string const &output_directory, std::map< int, std::unique_ptr< MaterialPropertyLib::Medium >> const &media)
void parseProcessVariables(BaseLib::ConfigTree const &process_variables_config)
std::pair< std::unique_ptr< NonlinearSolverBase >, NonlinearSolverTag > createNonlinearSolver(GlobalLinearSolver &linear_solver, BaseLib::ConfigTree const &config)
boost::optional< ParameterLib::CoordinateSystem > parseLocalCoordinateSystem(boost::optional< BaseLib::ConfigTree > const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
Definition of the Mesh class.
Map::mapped_type & getOrError(Map &map, Key const &key, std::string const &error_message)
Definition: Algorithm.h:147
void parseMedia(boost::optional< BaseLib::ConfigTree > const &media_config)
Parses media configuration and saves them in an object.
std::unique_ptr< Process > createLiquidFlowProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
T getConfigParameter(std::string const &param) const
MeshLib::Mesh * readMeshFromFile(const std::string &file_name)
static const std::string zero_parameter_name
std::map< int, std::unique_ptr< MaterialPropertyLib::Medium > > _media
Definition: ProjectData.h:127
template std::unique_ptr< Process > createPhaseFieldProcess< 2 >(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
template std::unique_ptr< Process > createPhaseFieldProcess< 3 >(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
std::unique_ptr< Process > createGroundwaterFlowProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes, std::string const &output_directory)
std::unique_ptr< Process > createTwoPhaseFlowWithPrhoProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves)
std::unique_ptr< Process > createRichardsComponentTransportProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
std::map< std::string, std::unique_ptr< GlobalLinearSolver > > _linear_solvers
Definition: ProjectData.h:132
boost::optional< ParameterLib::CoordinateSystem > _local_coordinate_system
Definition: ProjectData.h:125
Single, constant value parameter.
std::unique_ptr< Medium > createMedium(BaseLib::ConfigTree const &config)
std::vector< std::unique_ptr< MeshLib::Mesh > > constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const &geo_objects, MeshLib::Mesh const &mesh, std::unique_ptr< SearchLength > search_length_algorithm)
std::unique_ptr< GeoLib::GEOObjects > readGeometry(std::string const &filename)
std::unique_ptr< Process > createTwoPhaseFlowWithPPProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves)
Definition of readMeshFromFile function.
std::vector< std::string > parseParameters(BaseLib::ConfigTree const &parameters_config)
void parseNonlinearSolvers(BaseLib::ConfigTree const &config)
std::unique_ptr< TimeLoop > _time_loop
The time loop used to solve this project&#39;s processes.
Definition: ProjectData.h:130
std::unique_ptr< Process > createHeatConductionProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
void parseTimeLoop(BaseLib::ConfigTree const &config, const std::string &output_directory)
Parses the time loop configuration.
static const double p
std::unique_ptr< UncoupledProcessesTimeLoop > createUncoupledProcessesTimeLoop(BaseLib::ConfigTree const &config, std::string const &output_directory, const std::map< std::string, std::unique_ptr< Process >> &processes, const std::map< std::string, std::unique_ptr< NumLib::NonlinearSolverBase >> &nonlinear_solvers, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes)
Builds an UncoupledProcessesTimeLoop from the given configuration.
void insertIfKeyUniqueElseError(Map &map, Key const &key, Value &&value, std::string const &error_message)
Definition: Algorithm.h:104
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
Definition: ConfigTree.cpp:174
std::unique_ptr< Process > createRichardsFlowProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves)
std::unique_ptr< MeshGeoToolsLib::SearchLength > createSearchLengthAlgorithm(BaseLib::ConfigTree const &external_config, MeshLib::Mesh const &mesh)
unsigned getDimension(MeshLib::MeshElemType eleType)
boost::optional< T > getConfigAttributeOptional(std::string const &attr) const
std::unique_ptr< Process > createHeatTransportBHEProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves)
boost::optional< T > getConfigParameterOptional(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
boost::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
Definition: ConfigTree.cpp:160
Filename manipulation routines.
std::vector< std::unique_ptr< MeshLib::Mesh > > readMeshes(std::vector< std::string > const &filenames)
std::vector< ProcessLib::ProcessVariable > _process_variables
Definition: ProjectData.h:120
std::iterator_traits< InputIt >::reference findElementOrError(InputIt begin, InputIt end, Predicate predicate, std::string const &error="")
Definition: Algorithm.h:67
static std::string project_directory
The directory where the prj file resides.
Definition: FileTools.cpp:25
std::unique_ptr< CurveType > createPiecewiseLinearCurve(BaseLib::ConfigTree const &config)
std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > _curves
Definition: ProjectData.h:138
std::unique_ptr< MeshLib::Mesh > readSingleMesh(BaseLib::ConfigTree const &mesh_config_parameter, std::string const &project_directory)