OGS
CreateRichardsMechanicsProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
21#include "ParameterLib/Utils.h"
27
28namespace ProcessLib
29{
30namespace RichardsMechanics
31{
33 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
34{
35 std::array const required_medium_properties = {
42 std::array const required_liquid_properties = {
44 std::array const required_solid_properties = {MaterialPropertyLib::density};
45
46 for (auto const& m : media)
47 {
48 checkRequiredProperties(*m.second, required_medium_properties);
49 checkRequiredProperties(m.second->phase("AqueousLiquid"),
50 required_liquid_properties);
51 checkRequiredProperties(m.second->phase("Solid"),
52 required_solid_properties);
53 }
54}
55
56template <int DisplacementDim>
57std::unique_ptr<Process> createRichardsMechanicsProcess(
58 std::string const& name,
59 MeshLib::Mesh& mesh,
60 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
61 std::vector<ProcessVariable> const& variables,
62 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
63 std::optional<ParameterLib::CoordinateSystem> const&
64 local_coordinate_system,
65 unsigned const integration_order,
66 BaseLib::ConfigTree const& config,
67 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
68{
70 config.checkConfigParameter("type", "RICHARDS_MECHANICS");
71 DBUG("Create RichardsMechanicsProcess.");
72
73 auto const coupling_scheme =
75 config.getConfigParameterOptional<std::string>("coupling_scheme");
76 const bool use_monolithic_scheme =
77 !(coupling_scheme && (*coupling_scheme == "staggered"));
78
80
82 auto const pv_config = config.getConfigSubtree("process_variables");
83
84 ProcessVariable* variable_p;
85 ProcessVariable* variable_u;
86 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
87 process_variables;
88 if (use_monolithic_scheme) // monolithic scheme.
89 {
92 auto per_process_variables = findProcessVariables(
93 variables, pv_config,
94 {
95 "pressure",
97 "displacement"});
98 variable_p = &per_process_variables[0].get();
99 variable_u = &per_process_variables[1].get();
100 process_variables.push_back(std::move(per_process_variables));
101 }
102 else // staggered scheme.
103 {
104 using namespace std::string_literals;
105 for (auto const& variable_name : {"pressure"s, "displacement"s})
106 {
107 auto per_process_variables =
108 findProcessVariables(variables, pv_config, {variable_name});
109 process_variables.push_back(std::move(per_process_variables));
110 }
111 variable_p = &process_variables[0][0].get();
112 variable_u = &process_variables[1][0].get();
113 }
114
115 DBUG("Associate displacement with process variable '{:s}'.",
116 variable_u->getName());
117
118 if (variable_u->getNumberOfGlobalComponents() != DisplacementDim)
119 {
120 OGS_FATAL(
121 "Number of components of the process variable '{:s}' is different "
122 "from the displacement dimension: got {:d}, expected {:d}",
123 variable_u->getName(),
124 variable_u->getNumberOfGlobalComponents(),
125 DisplacementDim);
126 }
127
128 DBUG("Associate pressure with process variable '{:s}'.",
129 variable_p->getName());
130 if (variable_p->getNumberOfGlobalComponents() != 1)
131 {
132 OGS_FATAL(
133 "Pressure process variable '{:s}' is not a scalar variable but has "
134 "{:d} components.",
135 variable_p->getName(),
136 variable_p->getNumberOfGlobalComponents());
137 }
138
139 auto solid_constitutive_relations =
140 MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
141 parameters, local_coordinate_system, materialIDs(mesh), config);
142
144 // Specific body force
145 Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
146 {
147 std::vector<double> const b =
149 config.getConfigParameter<std::vector<double>>(
150 "specific_body_force");
151 if (b.size() != DisplacementDim)
152 {
153 OGS_FATAL(
154 "The size of the specific body force vector does not match the "
155 "displacement dimension. Vector size is {:d}, displacement "
156 "dimension is {:d}",
157 b.size(), DisplacementDim);
158 }
159
160 std::copy_n(b.data(), b.size(), specific_body_force.data());
161 }
162
163 auto media_map =
165 DBUG("Check the media properties of RichardsMechanics process ...");
166 checkMPLProperties(media);
167 DBUG("Media properties verified.");
168
169 // Initial stress conditions
170 auto const initial_stress =
171 ProcessLib::createInitialStress<DisplacementDim>(config, parameters,
172 mesh);
173
174 std::optional<MicroPorosityParameters> micro_porosity_parameters;
175 if (auto const micro_porosity_config =
177 config.getConfigSubtreeOptional("micro_porosity"))
178 {
179 micro_porosity_parameters = MicroPorosityParameters{
182 micro_porosity_config->getConfigSubtree("nonlinear_solver")),
184 micro_porosity_config->getConfigParameter<double>(
185 "mass_exchange_coefficient")};
186 }
187
188 auto const mass_lumping =
190 config.getConfigParameter<bool>("mass_lumping", false);
191
192 auto const explicit_hm_coupling_in_unsaturated_zone =
194 config.getConfigParameter<bool>(
195 "explicit_hm_coupling_in_unsaturated_zone", false);
196
198 materialIDs(mesh),
199 std::move(media_map),
200 std::move(solid_constitutive_relations),
201 initial_stress,
202 specific_body_force,
203 micro_porosity_parameters,
204 mass_lumping,
205 explicit_hm_coupling_in_unsaturated_zone};
206
207 SecondaryVariableCollection secondary_variables;
208
209 ProcessLib::createSecondaryVariables(config, secondary_variables);
210
211 return std::make_unique<RichardsMechanicsProcess<DisplacementDim>>(
212 std::move(name), mesh, std::move(jacobian_assembler), parameters,
213 integration_order, std::move(process_variables),
214 std::move(process_data), std::move(secondary_variables),
215 use_monolithic_scheme);
216}
217
218template std::unique_ptr<Process> createRichardsMechanicsProcess<2>(
219 std::string const& name,
220 MeshLib::Mesh& mesh,
221 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
222 std::vector<ProcessVariable> const& variables,
223 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
224 std::optional<ParameterLib::CoordinateSystem> const&
225 local_coordinate_system,
226 unsigned const integration_order,
227 BaseLib::ConfigTree const& config,
228 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
229
230template std::unique_ptr<Process> createRichardsMechanicsProcess<3>(
231 std::string const& name,
232 MeshLib::Mesh& mesh,
233 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
234 std::vector<ProcessVariable> const& variables,
235 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
236 std::optional<ParameterLib::CoordinateSystem> const&
237 local_coordinate_system,
238 unsigned const integration_order,
239 BaseLib::ConfigTree const& config,
240 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
241
242} // namespace RichardsMechanics
243} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
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
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)
NewtonRaphsonSolverParameters createNewtonRaphsonSolverParameters(BaseLib::ConfigTree const &config)
void checkMPLProperties(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createRichardsMechanicsProcess< 3 >(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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createRichardsMechanicsProcess(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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createRichardsMechanicsProcess< 2 >(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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
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)