OGS
CreateHTProcess.cpp
Go to the documentation of this file.
1
11#include "CreateHTProcess.h"
12
14#include "HTProcess.h"
15#include "HTProcessData.h"
23#include "ParameterLib/Utils.h"
27
28namespace ProcessLib
29{
30namespace HT
31{
63
64std::unique_ptr<Process> createHTProcess(
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::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
73 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
74{
76 config.checkConfigParameter("type", "HT");
77
78 DBUG("Create HTProcess.");
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 // Process IDs, which are set according to the appearance order of the
92 // process variables.
93 int const heat_transport_process_id = 0;
94 int hydraulic_process_id = 0;
95
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 process_variables.push_back(std::move(per_process_variables));
109 }
110 else // staggered scheme.
111 {
112 using namespace std::string_literals;
113 for (auto const& variable_name : {"temperature"s, "pressure"s})
114 {
115 auto per_process_variables =
116 findProcessVariables(variables, pv_config, {variable_name});
117 process_variables.push_back(std::move(per_process_variables));
118 }
119 hydraulic_process_id = 1;
120 }
121
123 std::vector<double> const b =
125 config.getConfigParameter<std::vector<double>>("specific_body_force");
126 assert(!b.empty() && b.size() < 4);
127 int const mesh_space_dimension =
129 if (static_cast<int>(b.size()) != mesh_space_dimension)
130 {
131 OGS_FATAL(
132 "specific body force (gravity vector) has {:d} components, mesh "
133 "dimension is {:d}",
134 b.size(), mesh_space_dimension);
135 }
136
137 // Specific body force parameter.
138 Eigen::VectorXd specific_body_force(b.size());
139 bool const has_gravity = MathLib::toVector(b).norm() > 0;
140 if (has_gravity)
141 {
142 std::copy_n(b.data(), b.size(), specific_body_force.data());
143 }
144
145 ParameterLib::ConstantParameter<double> default_solid_thermal_expansion(
146 "default solid thermal expansion", 0.);
147 ParameterLib::ConstantParameter<double> default_biot_constant(
148 "default_biot constant", 0.);
149 ParameterLib::Parameter<double>* solid_thermal_expansion =
150 &default_solid_thermal_expansion;
151 ParameterLib::Parameter<double>* biot_constant = &default_biot_constant;
152
153 auto const solid_config =
155 config.getConfigSubtreeOptional("solid_thermal_expansion");
156 const bool has_fluid_thermal_expansion = static_cast<bool>(solid_config);
157 if (solid_config)
158 {
159 solid_thermal_expansion = &ParameterLib::findParameter<double>(
161 *solid_config, "thermal_expansion", parameters, 1, &mesh);
162 DBUG("Use '{:s}' as solid thermal expansion.",
163 solid_thermal_expansion->name);
164 biot_constant = &ParameterLib::findParameter<double>(
166 *solid_config, "biot_constant", parameters, 1, &mesh);
167 DBUG("Use '{:s}' as Biot's constant.", biot_constant->name);
168 }
169
170 std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
171 auto calculatesurfaceflux_config =
173 config.getConfigSubtreeOptional("calculatesurfaceflux");
174 if (calculatesurfaceflux_config)
175 {
177 *calculatesurfaceflux_config, meshes);
178 }
179
180 auto media_map =
182
183 DBUG("Check the media properties of HT process ...");
184 checkMPLProperties(mesh, media_map);
185 DBUG("Media properties verified.");
186
187 auto stabilizer = NumLib::createNumericalStabilization(mesh, config);
188
189 auto const* aperture_size_parameter = &ParameterLib::findParameter<double>(
191 auto const aperture_config =
193 config.getConfigSubtreeOptional("aperture_size");
194 if (aperture_config)
195 {
196 aperture_size_parameter = &ParameterLib::findParameter<double>(
198 *aperture_config, "parameter", parameters, 1);
199 }
200
201 auto const rotation_matrices = MeshLib::getElementRotationMatrices(
202 mesh_space_dimension, mesh.getDimension(), mesh.getElements());
203 std::vector<Eigen::VectorXd> projected_specific_body_force_vectors;
204 projected_specific_body_force_vectors.reserve(rotation_matrices.size());
205
206 std::transform(rotation_matrices.begin(), rotation_matrices.end(),
207 std::back_inserter(projected_specific_body_force_vectors),
208 [&specific_body_force](const auto& R)
209 { return R * R.transpose() * specific_body_force; });
210
211 HTProcessData process_data{std::move(media_map),
212 has_fluid_thermal_expansion,
213 *solid_thermal_expansion,
214 *biot_constant,
215 has_gravity,
216 heat_transport_process_id,
217 hydraulic_process_id,
218 std::move(stabilizer),
219 projected_specific_body_force_vectors,
220 mesh_space_dimension,
221 *aperture_size_parameter,
222 NumLib::ShapeMatrixCache{integration_order}};
223
224 SecondaryVariableCollection secondary_variables;
225
226 ProcessLib::createSecondaryVariables(config, secondary_variables);
227
228 return std::make_unique<HTProcess>(
229 std::move(name), mesh, std::move(jacobian_assembler), parameters,
230 integration_order, std::move(process_variables),
231 std::move(process_data), std::move(secondary_variables),
232 use_monolithic_scheme, std::move(surfaceflux));
233}
234
235} // namespace HT
236} // 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::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
static PROCESSLIB_EXPORT const std::string constant_one_parameter_name
Definition Process.h:46
Handles configuration of several secondary variables from the project file.
void checkMaterialSpatialDistributionMap(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map, ContainerMedium const &required_properties_medium, ContainerSolid const &required_properties_solid_phase, ContainerLiquid const &required_properties_liquid_phase, ContainerGas const &required_properties_gas_phase)
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
std::vector< Eigen::MatrixXd > getElementRotationMatrices(int const space_dimension, int const mesh_dimension, std::vector< Element * > const &elements)
Element rotation matrix computation.
int getSpaceDimension(std::vector< Node * > const &nodes)
Computes dimension of the embedding space containing the set of given points.
NumericalStabilization createNumericalStabilization(MeshLib::Mesh const &mesh, BaseLib::ConfigTree const &config)
void checkMPLProperties(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
std::unique_ptr< Process > createHTProcess(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::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, 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)
Definition of readMeshFromFile function.
Single, constant value parameter.
std::string const name
Definition Parameter.h:73
static std::unique_ptr< ProcessLib::SurfaceFluxData > createSurfaceFluxData(BaseLib::ConfigTree const &calculatesurfaceflux_config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes)