OGS
CreateThermoRichardsFlowProcess.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <cassert>
7
15#include "ParameterLib/Utils.h"
21
22namespace ProcessLib
23{
24namespace ThermoRichardsFlow
25{
27 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
28{
29 std::array const required_medium_properties = {
34 std::array const required_liquid_properties = {
37 };
38 std::array const required_solid_properties = {MaterialPropertyLib::density};
39
40 // Thermal properties are not checked because they can be phase property or
41 // medium property (will be enabled later).
42 for (auto const& m : media)
43 {
44 checkRequiredProperties(*m.second, required_medium_properties);
45 checkRequiredProperties(m.second->phase("AqueousLiquid"),
46 required_liquid_properties);
47 checkRequiredProperties(m.second->phase("Solid"),
48 required_solid_properties);
49 }
50}
51
53{
54 if (variable.getNumberOfGlobalComponents() != 1)
55 {
57 "Number of components of the process variable '{:s}' is different "
58 "from one: got {:d}.",
59 variable.getName(),
61 }
62}
63
64std::unique_ptr<Process> createThermoRichardsFlowProcess(
65 std::string const& name,
66 MeshLib::Mesh& mesh,
67 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
68 std::vector<ProcessVariable> const& variables,
69 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
70 unsigned const integration_order,
71 BaseLib::ConfigTree const& config,
72 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
73{
75 config.checkConfigParameter("type", "THERMO_RICHARDS_FLOW");
76 DBUG("Create ThermoRichardsFlowProcess.");
77
78 auto const coupling_scheme =
80 config.getConfigParameterOptional<std::string>("coupling_scheme");
81 const bool use_monolithic_scheme =
82 !(coupling_scheme && (*coupling_scheme == "staggered"));
83
85
87 auto const pv_config = config.getConfigSubtree("process_variables");
88
89 ProcessVariable* variable_T;
90 ProcessVariable* variable_p;
91 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
92 process_variables;
93 if (use_monolithic_scheme) // monolithic scheme.
94 {
97 auto per_process_variables = findProcessVariables(
98 variables, pv_config,
99 {
100 "temperature",
102 "pressure"});
103 variable_T = &per_process_variables[0].get();
104 variable_p = &per_process_variables[1].get();
105 process_variables.push_back(std::move(per_process_variables));
106 }
107 else // staggered scheme.
108 {
109 OGS_FATAL(
110 "So far, only the monolithic scheme is implemented for "
111 "THERMO_RICHARDS_FLOW");
112 }
113
116
118 // Specific body force parameter.
119 Eigen::VectorXd specific_body_force;
120 {
121 std::vector<double> const b =
123 config.getConfigParameter<std::vector<double>>(
124 "specific_body_force");
125 if (b.size() != mesh.getDimension())
126 {
127 OGS_FATAL(
128 "specific body force (gravity vector) has {:d} components, "
129 "but mesh dimension is {:d}",
130 b.size(), mesh.getDimension());
131 }
132 specific_body_force.resize(b.size());
133 std::copy_n(b.data(), b.size(), specific_body_force.data());
134 }
135
136 auto const is_linear =
138 config.getConfigParameter("linear", false);
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
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, is_linear);
168}
169} // namespace ThermoRichardsFlow
170} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
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:79
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)