OGS 6.2.0-405-gb717f6088
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 // PhreeqcIO
44 
45 // FileIO
48 
50 #include "ParameterLib/Utils.h"
52 #include "ProcessLib/TimeLoop.h"
53 
54 #ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT
56 #endif
57 #ifdef OGS_BUILD_PROCESS_GROUNDWATERFLOW
59 #endif
60 #ifdef OGS_BUILD_PROCESS_HT
62 #endif
63 #ifdef OGS_BUILD_PROCESS_HEATCONDUCTION
65 #endif
66 #ifdef OGS_BUILD_PROCESS_HEATTRANSPORTBHE
68 #endif
69 #ifdef OGS_BUILD_PROCESS_HYDROMECHANICS
71 #endif
72 #ifdef OGS_BUILD_PROCESS_LIE
75 #endif
76 #ifdef OGS_BUILD_PROCESS_LIQUIDFLOW
78 #endif
79 #ifdef OGS_BUILD_PROCESS_PHASEFIELD
81 #endif
82 #ifdef OGS_BUILD_PROCESS_RICHARDSCOMPONENTTRANSPORT
84 #endif
85 #ifdef OGS_BUILD_PROCESS_RICHARDSFLOW
87 #endif
88 #ifdef OGS_BUILD_PROCESS_RICHARDSMECHANICS
90 #endif
91 #ifdef OGS_BUILD_PROCESS_SMALLDEFORMATION
93 #endif
94 #ifdef OGS_BUILD_PROCESS_SMALLDEFORMATIONNONLOCAL
96 #endif
97 #ifdef OGS_BUILD_PROCESS_TES
99 #endif
100 #ifdef OGS_BUILD_PROCESS_THERMALTWOPHASEFLOWWITHPP
102 #endif
103 #ifdef OGS_BUILD_PROCESS_THERMOHYDROMECHANICS
105 #endif
106 #ifdef OGS_BUILD_PROCESS_THERMOMECHANICALPHASEFIELD
108 #endif
109 #ifdef OGS_BUILD_PROCESS_THERMOMECHANICS
111 #endif
112 #ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPP
114 #endif
115 #ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPRHO
117 #endif
118 
119 namespace
120 {
121 void readGeometry(std::string const& fname, GeoLib::GEOObjects& geo_objects)
122 {
123  DBUG("Reading geometry file '%s'.", fname.c_str());
124  GeoLib::IO::BoostXmlGmlInterface gml_reader(geo_objects);
125  gml_reader.readFile(fname);
126 }
127 
128 std::unique_ptr<MeshLib::Mesh> readSingleMesh(
129  BaseLib::ConfigTree const& mesh_config_parameter,
130  std::string const& project_directory)
131 {
132  std::string const mesh_file = BaseLib::copyPathToFileName(
133  mesh_config_parameter.getValue<std::string>(), project_directory);
134  DBUG("Reading mesh file '%s'.", mesh_file.c_str());
135 
136  auto mesh = std::unique_ptr<MeshLib::Mesh>(
137  MeshLib::IO::readMeshFromFile(mesh_file));
138  if (!mesh)
139  {
140  OGS_FATAL("Could not read mesh from '%s' file. No mesh added.",
141  mesh_file.c_str());
142  }
143 
144 #ifdef DOXYGEN_DOCU_ONLY
145  mesh_config_parameter.getConfigAttributeOptional<bool>("axially_symmetric");
147 #endif // DOXYGEN_DOCU_ONLY
148 
149  if (auto const axially_symmetric =
151  mesh_config_parameter.getConfigAttributeOptional<bool>(
152  "axially_symmetric"))
153  {
154  mesh->setAxiallySymmetric(*axially_symmetric);
155  }
156 
157  return mesh;
158 }
159 
160 std::vector<std::unique_ptr<MeshLib::Mesh>> readMeshes(
161  BaseLib::ConfigTree const& config, std::string const& project_directory)
162 {
163  std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
164 
166  auto optional_meshes = config.getConfigSubtreeOptional("meshes");
167  if (optional_meshes)
168  {
169  DBUG("Reading multiple meshes.");
170  for (auto mesh_config :
172  optional_meshes->getConfigParameterList("mesh"))
173  {
174  meshes.push_back(readSingleMesh(mesh_config, project_directory));
175  }
176  }
177  else
178  { // Read single mesh with geometry.
179  WARN(
180  "Consider switching from mesh and geometry input to multiple "
181  "meshes input. See "
182  "https://www.opengeosys.org/docs/tools/model-preparation/"
183  "constructmeshesfromgeometry/ tool for conversion.");
185  meshes.push_back(readSingleMesh(config.getConfigParameter("mesh"),
187 
188  std::string const geometry_file = BaseLib::copyPathToFileName(
190  config.getConfigParameter<std::string>("geometry"),
191  project_directory);
192  GeoLib::GEOObjects geoObjects;
193  readGeometry(geometry_file, geoObjects);
194 
195  std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_algorithm =
197  bool const multiple_nodes_allowed = false;
198  auto additional_meshes =
200  geoObjects, *meshes[0], std::move(search_length_algorithm),
201  multiple_nodes_allowed);
202 
203  std::move(begin(additional_meshes), end(additional_meshes),
204  std::back_inserter(meshes));
205  }
206  return meshes;
207 }
208 
209 boost::optional<ParameterLib::CoordinateSystem> parseLocalCoordinateSystem(
210  boost::optional<BaseLib::ConfigTree> const& config,
211  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
212 {
213  if (!config)
214  {
215  return {};
216  }
217 
218  DBUG("Reading coordinate system configuration.");
219 
220  //
221  // Fetch the first basis vector; its length defines the dimension.
222  //
223  auto const& basis_vector_0 = ParameterLib::findParameter<double>(
224  *config,
226  "basis_vector_0", parameters, 0 /* any dimension */);
227  int const dimension = basis_vector_0.getNumberOfComponents();
228 
229  // check dimension
230  if (dimension != 2 && dimension != 3)
231  {
232  OGS_FATAL(
233  "Basis vector parameter '%s' must have two or three components, "
234  "but it has %d.",
235  basis_vector_0.name.c_str(), dimension);
236  }
237 
238  //
239  // Fetch the second basis vector, which must be of the same dimension as the
240  // first one.
241  //
242  auto const& basis_vector_1 = ParameterLib::findParameter<double>(
243  *config,
245  "basis_vector_1", parameters, dimension);
246 
247  //
248  // For two dimensions, we are done; construct coordinate system;
249  //
250  if (dimension == 2)
251  {
252  return ParameterLib::CoordinateSystem{basis_vector_0, basis_vector_1};
253  }
254 
255  //
256  // Parse the third vector, for three dimensions.
257  //
258  auto const& basis_vector_2 = ParameterLib::findParameter<double>(
259  *config,
261  "basis_vector_2", parameters, dimension);
262  return ParameterLib::CoordinateSystem{basis_vector_0, basis_vector_1,
263  basis_vector_2};
264 }
265 } // namespace
266 
267 ProjectData::ProjectData() = default;
268 
270  std::string const& project_directory,
271  std::string const& output_directory)
272 {
273  _mesh_vec = readMeshes(project_config, project_directory);
274 
275  if (auto const python_script =
277  project_config.getConfigParameterOptional<std::string>("python_script"))
278  {
279 #ifdef OGS_USE_PYTHON
280  namespace py = pybind11;
281 
282  // Append project's directory to python's module search path.
283  py::module::import("sys").attr("path").attr("append")(
285 
286  auto const script_path =
287  BaseLib::copyPathToFileName(*python_script, project_directory);
288 
289  // Evaluate in scope of main module
290  py::object scope = py::module::import("__main__").attr("__dict__");
291  py::eval_file(script_path, scope);
292 #else
293  OGS_FATAL("OpenGeoSys has not been built with Python support.");
294 #endif // OGS_USE_PYTHON
295  }
296 
298  parseCurves(project_config.getConfigSubtreeOptional("curves"));
299 
300  auto parameter_names_for_transformation =
302  parseParameters(project_config.getConfigSubtree("parameters"));
303 
306  project_config.getConfigSubtreeOptional("local_coordinate_system"),
307  _parameters);
308 
309  for (auto& parameter : _parameters)
310  {
311  if (std::find(begin(parameter_names_for_transformation),
312  end(parameter_names_for_transformation),
313  parameter->name) !=
314  end(parameter_names_for_transformation))
315  {
316  if (!_local_coordinate_system)
317  {
318  OGS_FATAL(
319  "The parameter '%s' is using the local coordinate system "
320  "but no local coordinate system was provided.",
321  parameter->name.c_str());
322  }
323  parameter->setCoordinateSystem(*_local_coordinate_system);
324  }
325 
326  parameter->initialize(_parameters);
327  }
328 
330  parseProcessVariables(project_config.getConfigSubtree("process_variables"));
331 
333  parseMedia(project_config.getConfigSubtreeOptional("media"));
334 
336  parseProcesses(project_config.getConfigSubtree("processes"),
337  project_directory, output_directory);
338 
340  parseLinearSolvers(project_config.getConfigSubtree("linear_solvers"));
341 
343  parseNonlinearSolvers(project_config.getConfigSubtree("nonlinear_solvers"));
344 
347  project_config.getConfigSubtreeOptional("chemical_system"),
348  output_directory);
349 
351  parseTimeLoop(project_config.getConfigSubtree("time_loop"),
352  output_directory);
353 }
354 
356  BaseLib::ConfigTree const& process_variables_config)
357 {
358  DBUG("Parse process variables:");
359 
360  std::set<std::string> names;
361 
362  for (auto var_config
364  : process_variables_config.getConfigSubtreeList("process_variable"))
365  {
366  // Either the mesh name is given, or the first mesh's name will be
367  // taken. Taking the first mesh's value is deprecated.
368  auto const mesh_name =
370  var_config.getConfigParameter<std::string>("mesh",
371  _mesh_vec[0]->getName());
372 
373  auto& mesh = *BaseLib::findElementOrError(
374  begin(_mesh_vec), end(_mesh_vec),
375  [&mesh_name](auto const& m) { return m->getName() == mesh_name; },
376  "Expected to find a mesh named " + mesh_name + ".");
377 
378  auto pv = ProcessLib::ProcessVariable{var_config, mesh, _mesh_vec,
379  _parameters};
380  if (!names.insert(pv.getName()).second)
381  {
382  OGS_FATAL("A process variable with name `%s' already exists.",
383  pv.getName().c_str());
384  }
385 
386  _process_variables.push_back(std::move(pv));
387  }
388 }
389 
390 std::vector<std::string> ProjectData::parseParameters(
391  BaseLib::ConfigTree const& parameters_config)
392 {
393  using namespace ProcessLib;
394 
395  std::set<std::string> names;
396  std::vector<std::string> parameter_names_for_transformation;
397 
398  DBUG("Reading parameters:");
399  for (auto parameter_config :
401  parameters_config.getConfigSubtreeList("parameter"))
402  {
403  auto p =
404  ParameterLib::createParameter(parameter_config, _mesh_vec, _curves);
405  if (!names.insert(p->name).second)
406  {
407  OGS_FATAL("A parameter with name `%s' already exists.",
408  p->name.c_str());
409  }
410 
411  auto const use_local_coordinate_system =
413  parameter_config.getConfigParameterOptional<bool>(
414  "use_local_coordinate_system");
415  if (!!use_local_coordinate_system &&
416  *use_local_coordinate_system == true)
417  {
418  parameter_names_for_transformation.push_back(p->name);
419  }
420 
421  _parameters.push_back(std::move(p));
422  }
423 
424  _parameters.push_back(
425  std::make_unique<ParameterLib::ConstantParameter<double>>(
427 
428  return parameter_names_for_transformation;
429 }
430 
432  boost::optional<BaseLib::ConfigTree> const& media_config)
433 {
434  if (!media_config)
435  {
436  return;
437  }
438 
439  DBUG("Reading media:");
440 
441  if (_mesh_vec.empty() || _mesh_vec[0] == nullptr)
442  {
443  ERR("A mesh is required to define medium materials.");
444  return;
445  }
446 
447  for (auto const& medium_config :
449  media_config->getConfigSubtreeList("medium"))
450  {
452  auto const material_id = medium_config.getConfigAttribute<int>("id", 0);
453 
454  if (_media.find(material_id) != _media.end())
455  {
456  OGS_FATAL(
457  "Multiple media were specified for the same material id %d. "
458  "Keep in mind, that if no material id is specified, it is "
459  "assumed to be 0 by default.",
460  material_id);
461  }
462 
463  _media[material_id] = MaterialPropertyLib::createMedium(medium_config);
464  }
465 
466  if (_media.empty())
467  {
468  OGS_FATAL("No entity is found inside <media>.");
469  }
470 }
471 
473  std::string const& project_directory,
474  std::string const& output_directory)
475 {
476  (void)project_directory; // to avoid compilation warning
477  (void)output_directory; // to avoid compilation warning
478 
479  DBUG("Reading processes:");
481  for (auto process_config : processes_config.getConfigSubtreeList("process"))
482  {
483  auto const type =
485  process_config.peekConfigParameter<std::string>("type");
486 
487  auto const name =
489  process_config.getConfigParameter<std::string>("name");
490 
491  auto const integration_order =
493  process_config.getConfigParameter<int>("integration_order");
494 
495  std::unique_ptr<ProcessLib::Process> process;
496 
497  auto jacobian_assembler = ProcessLib::createJacobianAssembler(
499  process_config.getConfigSubtreeOptional("jacobian_assembler"));
500 
501 #ifdef OGS_BUILD_PROCESS_GROUNDWATERFLOW
502  if (type == "GROUNDWATER_FLOW")
503  {
504  // The existence check of the in the configuration referenced
505  // process variables is checked in the physical process.
506  // TODO at the moment we have only one mesh, later there can be
507  // several meshes. Then we have to assign the referenced mesh
508  // here.
510  *_mesh_vec[0], std::move(jacobian_assembler),
511  _process_variables, _parameters, integration_order,
512  process_config, _mesh_vec, output_directory);
513  }
514  else
515 #endif
516 #ifdef OGS_BUILD_PROCESS_LIQUIDFLOW
517  if (type == "LIQUID_FLOW")
518  {
520  *_mesh_vec[0], std::move(jacobian_assembler),
521  _process_variables, _parameters, integration_order,
522  process_config);
523  }
524  else
525 #endif
526 #ifdef OGS_BUILD_PROCESS_TES
527  if (type == "TES")
528  {
530  *_mesh_vec[0], std::move(jacobian_assembler),
531  _process_variables, _parameters, integration_order,
532  process_config);
533  }
534  else
535 #endif
536 #ifdef OGS_BUILD_PROCESS_HEATCONDUCTION
537  if (type == "HEAT_CONDUCTION")
538  {
540  *_mesh_vec[0], std::move(jacobian_assembler),
541  _process_variables, _parameters, integration_order,
542  process_config);
543  }
544  else
545 #endif
546 #ifdef OGS_BUILD_PROCESS_HEATTRANSPORTBHE
547  if (type == "HEAT_TRANSPORT_BHE")
548  {
549  if (_mesh_vec[0]->getDimension() != 3)
550  {
551  OGS_FATAL(
552  "HEAT_TRANSPORT_BHE can only work with a 3-dimentional "
553  "mesh! ");
554  }
555 
556  process =
558  *_mesh_vec[0], std::move(jacobian_assembler),
559  _process_variables, _parameters, integration_order,
560  process_config, _curves);
561  }
562  else
563 #endif
564 #ifdef OGS_BUILD_PROCESS_HYDROMECHANICS
565  if (type == "HYDRO_MECHANICS")
566  {
568  switch (process_config.getConfigParameter<int>("dimension"))
569  {
570  case 2:
571  process =
573  2>(*_mesh_vec[0], std::move(jacobian_assembler),
575  _local_coordinate_system, integration_order,
576  process_config);
577  break;
578  case 3:
579  process =
581  3>(*_mesh_vec[0], std::move(jacobian_assembler),
583  _local_coordinate_system, integration_order,
584  process_config);
585  break;
586  default:
587  OGS_FATAL(
588  "HYDRO_MECHANICS process does not support given "
589  "dimension");
590  }
591  }
592  else
593 #endif
594 #ifdef OGS_BUILD_PROCESS_LIE
595  if (type == "HYDRO_MECHANICS_WITH_LIE")
596  {
598  switch (process_config.getConfigParameter<int>("dimension"))
599  {
600  case 2:
601  process = ProcessLib::LIE::HydroMechanics::
602  createHydroMechanicsProcess<2>(
603  *_mesh_vec[0], std::move(jacobian_assembler),
605  _local_coordinate_system, integration_order,
606  process_config);
607  break;
608  case 3:
609  process = ProcessLib::LIE::HydroMechanics::
610  createHydroMechanicsProcess<3>(
611  *_mesh_vec[0], std::move(jacobian_assembler),
613  _local_coordinate_system, integration_order,
614  process_config);
615  break;
616  default:
617  OGS_FATAL(
618  "HYDRO_MECHANICS_WITH_LIE process does not support "
619  "given dimension");
620  }
621  }
622  else
623 #endif
624 #ifdef OGS_BUILD_PROCESS_HT
625  if (type == "HT")
626  {
628  *_mesh_vec[0], std::move(jacobian_assembler),
629  _process_variables, _parameters, integration_order,
630  process_config, _mesh_vec, output_directory, _media);
631  }
632  else
633 #endif
634 #ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT
635  if (type == "ComponentTransport")
636  {
637  process =
639  *_mesh_vec[0], std::move(jacobian_assembler),
640  _process_variables, _parameters, integration_order,
641  process_config, _mesh_vec, output_directory, _media);
642  }
643  else
644 #endif
645 #ifdef OGS_BUILD_PROCESS_PHASEFIELD
646  if (type == "PHASE_FIELD")
647  {
648  switch (_mesh_vec[0]->getDimension())
649  {
650  case 2:
651  process =
653  *_mesh_vec[0], std::move(jacobian_assembler),
655  _local_coordinate_system, integration_order,
656  process_config);
657  break;
658  case 3:
659  process =
661  *_mesh_vec[0], std::move(jacobian_assembler),
663  _local_coordinate_system, integration_order,
664  process_config);
665  break;
666  }
667  }
668  else
669 #endif
670 #ifdef OGS_BUILD_PROCESS_RICHARDSCOMPONENTTRANSPORT
671  if (type == "RichardsComponentTransport")
672  {
675  *_mesh_vec[0], std::move(jacobian_assembler),
676  _process_variables, _parameters, integration_order,
677  process_config);
678  }
679  else
680 #endif
681 #ifdef OGS_BUILD_PROCESS_SMALLDEFORMATION
682  if (type == "SMALL_DEFORMATION")
683  {
684  switch (_mesh_vec[0]->getDimension())
685  {
686  case 2:
687  process = ProcessLib::SmallDeformation::
688  createSmallDeformationProcess<2>(
689  *_mesh_vec[0], std::move(jacobian_assembler),
691  _local_coordinate_system, integration_order,
692  process_config);
693  break;
694  case 3:
695  process = ProcessLib::SmallDeformation::
696  createSmallDeformationProcess<3>(
697  *_mesh_vec[0], std::move(jacobian_assembler),
699  _local_coordinate_system, integration_order,
700  process_config);
701  break;
702  default:
703  OGS_FATAL(
704  "SMALL_DEFORMATION process does not support "
705  "given dimension");
706  }
707  }
708  else
709 #endif
710 #ifdef OGS_BUILD_PROCESS_SMALLDEFORMATIONNONLOCAL
711  if (type == "SMALL_DEFORMATION_NONLOCAL")
712  {
713  switch (_mesh_vec[0]->getDimension())
714  {
715  case 2:
716  process = ProcessLib::SmallDeformationNonlocal::
717  createSmallDeformationNonlocalProcess<2>(
718  *_mesh_vec[0], std::move(jacobian_assembler),
720  _local_coordinate_system, integration_order,
721  process_config);
722  break;
723  case 3:
724  process = ProcessLib::SmallDeformationNonlocal::
725  createSmallDeformationNonlocalProcess<3>(
726  *_mesh_vec[0], std::move(jacobian_assembler),
728  _local_coordinate_system, integration_order,
729  process_config);
730  break;
731  default:
732  OGS_FATAL(
733  "SMALL_DEFORMATION_NONLOCAL process does not support "
734  "given dimension %d",
735  _mesh_vec[0]->getDimension());
736  }
737  }
738  else
739 #endif
740 #ifdef OGS_BUILD_PROCESS_LIE
741  if (type == "SMALL_DEFORMATION_WITH_LIE")
742  {
744  switch (process_config.getConfigParameter<int>("dimension"))
745  {
746  case 2:
747  process = ProcessLib::LIE::SmallDeformation::
748  createSmallDeformationProcess<2>(
749  *_mesh_vec[0], std::move(jacobian_assembler),
751  _local_coordinate_system, integration_order,
752  process_config);
753  break;
754  case 3:
755  process = ProcessLib::LIE::SmallDeformation::
756  createSmallDeformationProcess<3>(
757  *_mesh_vec[0], std::move(jacobian_assembler),
759  _local_coordinate_system, integration_order,
760  process_config);
761  break;
762  default:
763  OGS_FATAL(
764  "SMALL_DEFORMATION_WITH_LIE process does not support "
765  "given dimension");
766  }
767  }
768  else
769 #endif
770 #ifdef OGS_BUILD_PROCESS_THERMOHYDROMECHANICS
771  if (type == "THERMO_HYDRO_MECHANICS")
772  {
774  switch (process_config.getConfigParameter<int>("dimension"))
775  {
776  case 2:
777  process = ProcessLib::ThermoHydroMechanics::
778  createThermoHydroMechanicsProcess<2>(
779  *_mesh_vec[0], std::move(jacobian_assembler),
781  _local_coordinate_system, integration_order,
782  process_config);
783  break;
784  case 3:
785  process = ProcessLib::ThermoHydroMechanics::
786  createThermoHydroMechanicsProcess<3>(
787  *_mesh_vec[0], std::move(jacobian_assembler),
789  _local_coordinate_system, integration_order,
790  process_config);
791  break;
792  default:
793  OGS_FATAL(
794  "THERMO_HYDRO_MECHANICS process does not support given "
795  "dimension");
796  }
797  }
798  else
799 #endif
800 #ifdef OGS_BUILD_PROCESS_THERMOMECHANICALPHASEFIELD
801  if (type == "THERMO_MECHANICAL_PHASE_FIELD")
802  {
803  switch (_mesh_vec[0]->getDimension())
804  {
805  case 2:
806  process = ProcessLib::ThermoMechanicalPhaseField::
807  createThermoMechanicalPhaseFieldProcess<2>(
808  *_mesh_vec[0], std::move(jacobian_assembler),
810  _local_coordinate_system, integration_order,
811  process_config);
812  break;
813  case 3:
814  process = ProcessLib::ThermoMechanicalPhaseField::
815  createThermoMechanicalPhaseFieldProcess<3>(
816  *_mesh_vec[0], std::move(jacobian_assembler),
818  _local_coordinate_system, integration_order,
819  process_config);
820  break;
821  }
822  }
823  else
824 #endif
825 #ifdef OGS_BUILD_PROCESS_THERMOMECHANICS
826  if (type == "THERMO_MECHANICS")
827  {
828  switch (_mesh_vec[0]->getDimension())
829  {
830  case 2:
831  process = ProcessLib::ThermoMechanics::
832  createThermoMechanicsProcess<2>(
833  *_mesh_vec[0], std::move(jacobian_assembler),
835  _local_coordinate_system, integration_order,
836  process_config);
837  break;
838  case 3:
839  process = ProcessLib::ThermoMechanics::
840  createThermoMechanicsProcess<3>(
841  *_mesh_vec[0], std::move(jacobian_assembler),
843  _local_coordinate_system, integration_order,
844  process_config);
845  break;
846  }
847  }
848  else
849 #endif
850 #ifdef OGS_BUILD_PROCESS_RICHARDSFLOW
851  if (type == "RICHARDS_FLOW")
852  {
854  *_mesh_vec[0], std::move(jacobian_assembler),
855  _process_variables, _parameters, integration_order,
856  process_config, _curves);
857  }
858  else
859 #endif
860 #ifdef OGS_BUILD_PROCESS_RICHARDSMECHANICS
861  if (type == "RICHARDS_MECHANICS")
862  {
864  switch (process_config.getConfigParameter<int>("dimension"))
865  {
866  case 2:
867  process = ProcessLib::RichardsMechanics::
868  createRichardsMechanicsProcess<2>(
869  *_mesh_vec[0], std::move(jacobian_assembler),
871  _local_coordinate_system, integration_order,
872  process_config);
873  break;
874  case 3:
875  process = ProcessLib::RichardsMechanics::
876  createRichardsMechanicsProcess<3>(
877  *_mesh_vec[0], std::move(jacobian_assembler),
879  _local_coordinate_system, integration_order,
880  process_config);
881  break;
882  }
883  }
884  else
885 #endif
886 #ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPP
887  if (type == "TWOPHASE_FLOW_PP")
888  {
889  process =
891  *_mesh_vec[0], std::move(jacobian_assembler),
892  _process_variables, _parameters, integration_order,
893  process_config, _curves);
894  }
895  else
896 #endif
897 #ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPRHO
898  if (type == "TWOPHASE_FLOW_PRHO")
899  {
902  *_mesh_vec[0], std::move(jacobian_assembler),
903  _process_variables, _parameters, integration_order,
904  process_config, _curves);
905  }
906  else
907 #endif
908 #ifdef OGS_BUILD_PROCESS_THERMALTWOPHASEFLOWWITHPP
909  if (type == "THERMAL_TWOPHASE_WITH_PP")
910  {
913  *_mesh_vec[0], std::move(jacobian_assembler),
914  _process_variables, _parameters, integration_order,
915  process_config, _curves);
916  }
917  else
918 #endif
919  {
920  OGS_FATAL("Unknown process type: %s", type.c_str());
921  }
922 
924  name,
925  std::move(process),
926  "The process name is not unique");
927  }
928 }
929 
931  std::string const& output_directory)
932 {
933  DBUG("Reading time loop configuration.");
934 
935  _time_loop = ProcessLib::createTimeLoop(config, output_directory,
938 
939  if (!_time_loop)
940  {
941  OGS_FATAL("Initialization of time loop failed.");
942  }
943 }
944 
946 {
947  DBUG("Reading linear solver configuration.");
948 
950  for (auto conf : config.getConfigSubtreeList("linear_solver"))
951  {
953  auto const name = conf.getConfigParameter<std::string>("name");
956  name,
957  std::make_unique<GlobalLinearSolver>("", &conf),
958  "The linear solver name is not unique");
959  }
960 }
961 
963 {
964  DBUG("Reading linear solver configuration.");
965 
967  for (auto conf : config.getConfigSubtreeList("nonlinear_solver"))
968  {
969  auto const ls_name =
971  conf.getConfigParameter<std::string>("linear_solver");
972  auto& linear_solver = BaseLib::getOrError(
973  _linear_solvers, ls_name,
974  "A linear solver with the given name does not exist.");
975 
977  auto const name = conf.getConfigParameter<std::string>("name");
980  name,
981  NumLib::createNonlinearSolver(*linear_solver, conf).first,
982  "The nonlinear solver name is not unique");
983  }
984 }
985 
987  boost::optional<BaseLib::ConfigTree> const& config)
988 {
989  if (!config)
990  {
991  return;
992  }
993 
994  DBUG("Reading curves configuration.");
995 
997  for (auto conf : config->getConfigSubtreeList("curve"))
998  {
1000  auto const name = conf.getConfigParameter<std::string>("name");
1002  _curves,
1003  name,
1006  "The curve name is not unique.");
1007  }
1008 }
1009 
1011  boost::optional<BaseLib::ConfigTree> const& config,
1012  std::string const& output_directory)
1013 {
1014  if (!config)
1015  return;
1016 
1017 #ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT
1018  INFO(
1019  "Ready for initializing interface to a chemical solver for water "
1020  "chemistry calculation.");
1021 
1022  auto const& process = _processes.begin()->second;
1023  if (auto const* component_transport_process = dynamic_cast<
1025  process.get()))
1026  {
1027  auto const chemical_solver =
1029  config->getConfigAttribute<std::string>("chemical_solver");
1030 
1031  if (boost::iequals(chemical_solver, "Phreeqc"))
1032  {
1033  INFO(
1034  "Configuring phreeqc interface for water chemistry "
1035  "calculation.");
1036 
1037  auto const& process_id_to_component_name_map =
1038  component_transport_process->getProcessIDToComponentNameMap();
1039 
1041  _mesh_vec[0]->getNumberOfBaseNodes(),
1042  process_id_to_component_name_map, *config, output_directory);
1043  }
1044  else
1045  {
1046  OGS_FATAL(
1047  "Unknown chemical solver. Please specify Phreeqc as the solver "
1048  "for water chemistry calculation instead.");
1049  }
1050  }
1051  else
1052 #endif
1053  {
1054  (void)output_directory;
1055 
1056  OGS_FATAL(
1057  "The specified type of the process to be solved is not component "
1058  "transport process so that water chemistry calculation could not "
1059  "be activated.");
1060  }
1061 }
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:125
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)
std::vector< std::unique_ptr< MeshLib::Mesh > > constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const &geo_objects, MeshLib::Mesh const &mesh, std::unique_ptr< SearchLength > search_length_algorithm, bool const multiple_nodes_allowed)
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:120
std::unique_ptr< ChemistryLib::PhreeqcIO > _chemical_system
Definition: ProjectData.h:142
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:121
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:137
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< ProcessLib::TimeLoop > _time_loop
The time loop used to solve this project&#39;s processes.
Definition: ProjectData.h:132
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:129
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:134
boost::optional< ParameterLib::CoordinateSystem > _local_coordinate_system
Definition: ProjectData.h:127
Single, constant value parameter.
std::unique_ptr< Medium > createMedium(BaseLib::ConfigTree const &config)
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)
std::unique_ptr< TimeLoop > createTimeLoop(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, std::unique_ptr< ChemistryLib::PhreeqcIO > &phreeqc_io)
Builds a TimeLoop from the given configuration.
void parseNonlinearSolvers(BaseLib::ConfigTree const &config)
std::unique_ptr< PhreeqcIO > createPhreeqcIO(std::size_t const num_nodes, std::vector< std::pair< int, std::string >> const &process_id_to_component_name_map, BaseLib::ConfigTree const &config, std::string const &output_directory)
void parseChemicalSystem(boost::optional< BaseLib::ConfigTree > const &config, const std::string &output_directory)
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
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:122
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:140
std::unique_ptr< MeshLib::Mesh > readSingleMesh(BaseLib::ConfigTree const &mesh_config_parameter, std::string const &project_directory)