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"
22
23namespace ProcessLib
24{
25namespace ThermoRichardsFlow
26{
28 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
29{
30 std::array const required_medium_properties = {
35 std::array const required_liquid_properties = {
38 };
39 std::array const required_solid_properties = {MaterialPropertyLib::density};
40
41 // Thermal properties are not checked because they can be phase property or
42 // medium property (will be enabled later).
43 for (auto const& m : media)
44 {
45 checkRequiredProperties(*m.second, required_medium_properties);
46 checkRequiredProperties(
48 required_liquid_properties);
49 checkRequiredProperties(
51 required_solid_properties);
52 }
53
55}
56
58{
59 if (variable.getNumberOfGlobalComponents() != 1)
60 {
62 "Number of components of the process variable '{:s}' is different "
63 "from one: got {:d}.",
64 variable.getName(),
66 }
67}
68
69std::unique_ptr<Process> createThermoRichardsFlowProcess(
70 std::string const& name,
71 MeshLib::Mesh& mesh,
72 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
73 std::vector<ProcessVariable> const& variables,
74 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
75 unsigned const integration_order,
76 BaseLib::ConfigTree const& config,
77 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
78{
80 config.checkConfigParameter("type", "THERMO_RICHARDS_FLOW");
81 DBUG("Create ThermoRichardsFlowProcess.");
82
83 auto const coupling_scheme =
85 config.getConfigParameterOptional<std::string>("coupling_scheme");
86 const bool use_monolithic_scheme =
87 !(coupling_scheme && (*coupling_scheme == "staggered"));
88
90
92 auto const pv_config = config.getConfigSubtree("process_variables");
93
94 ProcessVariable* variable_T;
95 ProcessVariable* variable_p;
96 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
97 process_variables;
98 if (use_monolithic_scheme) // monolithic scheme.
99 {
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
121
123 // Specific body force parameter.
124 Eigen::VectorXd specific_body_force;
125 {
126 std::vector<double> const b =
128 config.getConfigParameter<std::vector<double>>(
129 "specific_body_force");
130 if (b.size() != mesh.getDimension())
131 {
132 OGS_FATAL(
133 "specific body force (gravity vector) has {:d} components, "
134 "but mesh dimension is {:d}",
135 b.size(), mesh.getDimension());
136 }
137 specific_body_force.resize(b.size());
138 std::copy_n(b.data(), b.size(), specific_body_force.data());
139 }
140
141 auto const is_linear =
143 config.getConfigParameter("linear", false);
144
145 auto media_map =
147 DBUG(
148 "Check the media properties of ThermoRichardsFlow process "
149 "...");
150 checkMPLProperties(media);
151 DBUG("Media properties verified.");
152
153 bool const mass_lumping =
155 config.getConfigParameter<bool>("mass_lumping", false);
156
157 std::unique_ptr<SimplifiedElasticityModel> simplified_elasticity =
158 createElasticityModel(config);
159
161 std::move(media_map), std::move(specific_body_force), mass_lumping,
162 std::move(simplified_elasticity)};
163
164 SecondaryVariableCollection secondary_variables;
165
166 ProcessLib::createSecondaryVariables(config, secondary_variables);
167
168 return std::make_unique<ThermoRichardsFlowProcess>(
169 std::move(name), mesh, std::move(jacobian_assembler), parameters,
170 integration_order, std::move(process_variables),
171 std::move(process_data), std::move(secondary_variables),
172 use_monolithic_scheme, is_linear);
173}
174} // namespace ThermoRichardsFlow
175} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:10
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 checkThermoOsmosisProperties(MaterialPropertyLib::Medium const &medium)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)