OGS
CreateThermoRichardsFlowProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
22#include "ParameterLib/Utils.h"
28
29namespace ProcessLib
30{
31namespace 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 // medium 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 {
64 "Number of components of the process variable '{:s}' is different "
65 "from one: got {:d}.",
66 variable.getName(),
68 }
69}
70
71std::unique_ptr<Process> createThermoRichardsFlowProcess(
72 std::string const& 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
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 {
104 auto per_process_variables = findProcessVariables(
105 variables, pv_config,
106 {
107 "temperature",
109 "pressure"});
110 variable_T = &per_process_variables[0].get();
111 variable_p = &per_process_variables[1].get();
112 process_variables.push_back(std::move(per_process_variables));
113 }
114 else // staggered scheme.
115 {
116 OGS_FATAL(
117 "So far, only the monolithic scheme is implemented for "
118 "THERMO_RICHARDS_FLOW");
119 }
120
123
125 // Specific body force parameter.
126 Eigen::VectorXd specific_body_force;
127 {
128 std::vector<double> const b =
130 config.getConfigParameter<std::vector<double>>(
131 "specific_body_force");
132 if (b.size() != mesh.getDimension())
133 {
134 OGS_FATAL(
135 "specific body force (gravity vector) has {:d} components, "
136 "but mesh dimension is {:d}",
137 b.size(), mesh.getDimension());
138 }
139 specific_body_force.resize(b.size());
140 std::copy_n(b.data(), b.size(), specific_body_force.data());
141 }
142
143 auto media_map =
145 DBUG(
146 "Check the media properties of ThermoRichardsFlow process "
147 "...");
148 checkMPLProperties(media);
149 DBUG("Media properties verified.");
150
151 bool const mass_lumping =
153 config.getConfigParameter<bool>("mass_lumping", false);
154
155 std::unique_ptr<SimplifiedElasticityModel> simplified_elasticity =
156 createElasticityModel(config);
157
159 std::move(media_map), std::move(specific_body_force), mass_lumping,
160 std::move(simplified_elasticity)};
161
162 SecondaryVariableCollection secondary_variables;
163
164 ProcessLib::createSecondaryVariables(config, secondary_variables);
165
166 return std::make_unique<ThermoRichardsFlowProcess>(
167 std::move(name), mesh, std::move(jacobian_assembler), parameters,
168 integration_order, std::move(process_variables),
169 std::move(process_data), std::move(secondary_variables),
170 use_monolithic_scheme);
171}
172} // namespace ThermoRichardsFlow
173} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
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.
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
void checkMPLProperties(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createThermoRichardsFlowProcess(std::string const &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)
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)