OGS
CreateThermoRichardsFlowProcess.cpp
Go to the documentation of this file.
1 
12 
13 #include <cassert>
14 
19 #include "MaterialLib/MPL/Medium.h"
22 #include "ParameterLib/Utils.h"
28 
29 namespace ProcessLib
30 {
31 namespace ThermoRichardsFlow
32 {
34  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
35 {
36  std::array const required_medium_properties = {
41  std::array const required_liquid_properties = {
44  };
45  std::array const required_solid_properties = {MaterialPropertyLib::density};
46 
47  // Thermal properties are not checked because they can be phase property or
48  // meduim property (will be enabled later).
49  for (auto const& m : media)
50  {
51  checkRequiredProperties(*m.second, required_medium_properties);
52  checkRequiredProperties(m.second->phase("AqueousLiquid"),
53  required_liquid_properties);
54  checkRequiredProperties(m.second->phase("Solid"),
55  required_solid_properties);
56  }
57 }
58 
60 {
61  if (variable.getNumberOfGlobalComponents() != 1)
62  {
63  OGS_FATAL(
64  "Number of components of the process variable '{:s}' is different "
65  "from one: got {:d}.",
66  variable.getName(),
67  variable.getNumberOfGlobalComponents());
68  }
69 }
70 
71 std::unique_ptr<Process> createThermoRichardsFlowProcess(
72  std::string name,
73  MeshLib::Mesh& mesh,
74  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
75  std::vector<ProcessVariable> const& variables,
76  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
77  unsigned const integration_order,
78  BaseLib::ConfigTree const& config,
79  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
80 {
82  config.checkConfigParameter("type", "THERMO_RICHARDS_FLOW");
83  DBUG("Create ThermoRichardsFlowProcess.");
84 
85  auto const coupling_scheme =
87  config.getConfigParameterOptional<std::string>("coupling_scheme");
88  const bool use_monolithic_scheme =
89  !(coupling_scheme && (*coupling_scheme == "staggered"));
90 
91  // Process variable.
92 
94  auto const pv_config = config.getConfigSubtree("process_variables");
95 
96  ProcessVariable* variable_T;
97  ProcessVariable* variable_p;
98  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
99  process_variables;
100  if (use_monolithic_scheme) // monolithic scheme.
101  {
102  auto per_process_variables = findProcessVariables(
103  variables, pv_config,
104  {
105  "temperature",
107  "pressure"});
108  variable_T = &per_process_variables[0].get();
109  variable_p = &per_process_variables[1].get();
110  process_variables.push_back(std::move(per_process_variables));
111  }
112  else // staggered scheme.
113  {
114  OGS_FATAL(
115  "So far, only the monolithic scheme is implemented for "
116  "THERMO_RICHARDS_FLOW");
117  }
118 
119  checkProcessVariableComponents(*variable_T);
120  checkProcessVariableComponents(*variable_p);
121 
122  // Specific body force parameter.
123  Eigen::VectorXd specific_body_force;
124  {
125  std::vector<double> const b =
127  config.getConfigParameter<std::vector<double>>(
128  "specific_body_force");
129  if (b.size() != mesh.getDimension())
130  {
131  OGS_FATAL(
132  "specific body force (gravity vector) has {:d} components, "
133  "but mesh dimension is {:d}",
134  b.size(), mesh.getDimension());
135  }
136  specific_body_force.resize(b.size());
137  std::copy_n(b.data(), b.size(), specific_body_force.data());
138  }
139 
140  auto media_map =
142  DBUG(
143  "Check the media properties of ThermoRichardsFlow process "
144  "...");
145  checkMPLProperties(media);
146  DBUG("Media properties verified.");
147 
148  bool const mass_lumping =
150  config.getConfigParameter<bool>("mass_lumping", false);
151 
152  std::unique_ptr<SimplifiedElasticityModel> simplified_elasticity =
153  createElasticityModel(config);
154 
155  ThermoRichardsFlowProcessData process_data{
156  std::move(media_map), std::move(specific_body_force), mass_lumping,
157  std::move(simplified_elasticity)};
158 
159  SecondaryVariableCollection secondary_variables;
160 
161  ProcessLib::createSecondaryVariables(config, secondary_variables);
162 
163  return std::make_unique<ThermoRichardsFlowProcess>(
164  std::move(name), mesh, std::move(jacobian_assembler), parameters,
165  integration_order, std::move(process_variables),
166  std::move(process_data), std::move(secondary_variables),
167  use_monolithic_scheme);
168 }
169 } // namespace ThermoRichardsFlow
170 } // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
void checkConfigParameter(std::string const &param, T const &value) const
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:71
std::string const & getName() const
int getNumberOfGlobalComponents() const
Returns the number of components of the process variable.
Handles configuration of several secondary variables from the project file.
std::unique_ptr< MaterialSpatialDistributionMap > createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium >> const &media, MeshLib::Mesh const &mesh)
void checkRequiredProperties(Component const &c, Container const &required_properties)
Definition: Component.h:96
std::unique_ptr< Process > createThermoRichardsFlowProcess(std::string name, 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< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
void checkProcessVariableComponents(ProcessVariable const &variable)
void checkMPLProperties(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
std::unique_ptr< SimplifiedElasticityModel > createElasticityModel(BaseLib::ConfigTree const &config)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)