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(
47 required_liquid_properties);
48 checkRequiredProperties(
50 required_solid_properties);
51 }
52}
53
55{
56 if (variable.getNumberOfGlobalComponents() != 1)
57 {
59 "Number of components of the process variable '{:s}' is different "
60 "from one: got {:d}.",
61 variable.getName(),
63 }
64}
65
66std::unique_ptr<Process> createThermoRichardsFlowProcess(
67 std::string const& name,
68 MeshLib::Mesh& mesh,
69 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
70 std::vector<ProcessVariable> const& variables,
71 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
72 unsigned const integration_order,
73 BaseLib::ConfigTree const& config,
74 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
75{
77 config.checkConfigParameter("type", "THERMO_RICHARDS_FLOW");
78 DBUG("Create ThermoRichardsFlowProcess.");
79
80 auto const coupling_scheme =
82 config.getConfigParameterOptional<std::string>("coupling_scheme");
83 const bool use_monolithic_scheme =
84 !(coupling_scheme && (*coupling_scheme == "staggered"));
85
87
89 auto const pv_config = config.getConfigSubtree("process_variables");
90
91 ProcessVariable* variable_T;
92 ProcessVariable* variable_p;
93 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
94 process_variables;
95 if (use_monolithic_scheme) // monolithic scheme.
96 {
99 auto per_process_variables = findProcessVariables(
100 variables, pv_config,
101 {
102 "temperature",
104 "pressure"});
105 variable_T = &per_process_variables[0].get();
106 variable_p = &per_process_variables[1].get();
107 process_variables.push_back(std::move(per_process_variables));
108 }
109 else // staggered scheme.
110 {
111 OGS_FATAL(
112 "So far, only the monolithic scheme is implemented for "
113 "THERMO_RICHARDS_FLOW");
114 }
115
118
120 // Specific body force parameter.
121 Eigen::VectorXd specific_body_force;
122 {
123 std::vector<double> const b =
125 config.getConfigParameter<std::vector<double>>(
126 "specific_body_force");
127 if (b.size() != mesh.getDimension())
128 {
129 OGS_FATAL(
130 "specific body force (gravity vector) has {:d} components, "
131 "but mesh dimension is {:d}",
132 b.size(), mesh.getDimension());
133 }
134 specific_body_force.resize(b.size());
135 std::copy_n(b.data(), b.size(), specific_body_force.data());
136 }
137
138 auto const is_linear =
140 config.getConfigParameter("linear", false);
141
142 auto media_map =
144 DBUG(
145 "Check the media properties of ThermoRichardsFlow process "
146 "...");
147 checkMPLProperties(media);
148 DBUG("Media properties verified.");
149
150 bool const mass_lumping =
152 config.getConfigParameter<bool>("mass_lumping", false);
153
154 std::unique_ptr<SimplifiedElasticityModel> simplified_elasticity =
155 createElasticityModel(config);
156
158 std::move(media_map), std::move(specific_body_force), mass_lumping,
159 std::move(simplified_elasticity)};
160
161 SecondaryVariableCollection secondary_variables;
162
163 ProcessLib::createSecondaryVariables(config, secondary_variables);
164
165 return std::make_unique<ThermoRichardsFlowProcess>(
166 std::move(name), mesh, std::move(jacobian_assembler), parameters,
167 integration_order, std::move(process_variables),
168 std::move(process_data), std::move(secondary_variables),
169 use_monolithic_scheme, is_linear);
170}
171} // namespace ThermoRichardsFlow
172} // 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
Definition Mesh.h:80
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)