OGS 6.1.0-1699-ge946d4c5f
CreateHTProcess.cpp
Go to the documentation of this file.
1 
10 #include "CreateHTProcess.h"
11 
14 
16 
21 
22 #include "HTProcess.h"
23 #include "HTMaterialProperties.h"
25 
26 namespace ProcessLib
27 {
28 namespace HT
29 {
30 std::unique_ptr<Process> createHTProcess(
31  MeshLib::Mesh& mesh,
32  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
33  std::vector<ProcessVariable> const& variables,
34  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
35  unsigned const integration_order,
36  BaseLib::ConfigTree const& config,
37  std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
38  std::string const& output_directory)
39 {
41  config.checkConfigParameter("type", "HT");
42 
43  DBUG("Create HTProcess.");
44 
45  auto const staggered_scheme =
47  config.getConfigParameterOptional<std::string>("coupling_scheme");
48  const bool use_monolithic_scheme =
49  !(staggered_scheme && (*staggered_scheme == "staggered"));
50 
51  // Process variable.
52 
54  auto const pv_config = config.getConfigSubtree("process_variables");
55 
56  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
57  process_variables;
58  if (use_monolithic_scheme) // monolithic scheme.
59  {
60  auto per_process_variables = findProcessVariables(
61  variables, pv_config,
62  {
63  "temperature",
65  "pressure"});
66  process_variables.push_back(std::move(per_process_variables));
67  }
68  else // staggered scheme.
69  {
70  using namespace std::string_literals;
71  for (auto const& variable_name : {"temperature"s, "pressure"s})
72  {
73  auto per_process_variables =
74  findProcessVariables(variables, pv_config, {variable_name});
75  process_variables.push_back(std::move(per_process_variables));
76  }
77  }
78 
81  parameters)};
82 
84  auto const& fluid_config = config.getConfigSubtree("fluid");
85  auto fluid_properties =
87 
88  // Parameter for the density of the solid.
89  auto& density_solid = findParameter<double>(
90  config,
92  "density_solid", parameters, 1);
93  DBUG("Use '%s' as density_solid parameter.", density_solid.name.c_str());
94 
95  // Parameter for the specific heat capacity of the solid.
96  auto& specific_heat_capacity_solid = findParameter<double>(
97  config,
99  "specific_heat_capacity_solid", parameters, 1);
100  DBUG("Use '%s' as specific_heat_capacity_solid parameter.",
101  specific_heat_capacity_solid.name.c_str());
102 
103  // Parameter for the thermal conductivity of the solid (only one scalar per
104  // element, i.e., the isotropic case is handled at the moment)
105 
106  ConstantParameter<double> default_thermal_dispersivity_longitudinal(
107  "default thermal dispersivity longitudinal", 0.);
108  ConstantParameter<double> default_thermal_dispersivity_transversal(
109  "default thermal dispersivity transversal", 0.);
110 
111  Parameter<double>* thermal_dispersivity_longitudinal =
112  &default_thermal_dispersivity_longitudinal;
113  Parameter<double>* thermal_dispersivity_transversal =
114  &default_thermal_dispersivity_transversal;
115  auto const dispersion_config =
117  config.getConfigSubtreeOptional("thermal_dispersivity");
118  bool const has_fluid_thermal_dispersivity =
119  static_cast<bool>(dispersion_config);
120  if (dispersion_config)
121  {
122  thermal_dispersivity_longitudinal = &findParameter<double>(
123  *dispersion_config,
125  "longitudinal", parameters, 1);
126  DBUG("Use '%s' as thermal_dispersivity_longitudinal parameter.",
127  thermal_dispersivity_longitudinal->name.c_str());
128 
129  // Parameter for the thermal conductivity of the solid (only one scalar
130  // per
131  // element, i.e., the isotropic case is handled at the moment)
132  thermal_dispersivity_transversal = &findParameter<double>(
133  *dispersion_config,
135  "transversal", parameters, 1);
136  DBUG("Use '%s' as thermal_dispersivity_transversal parameter.",
137  thermal_dispersivity_transversal->name.c_str());
138  }
139 
140  // Parameter for the thermal conductivity of the solid (only one scalar per
141  // element, i.e., the isotropic case is handled at the moment)
142  auto& thermal_conductivity_solid = findParameter<double>(
143  config,
145  "thermal_conductivity_solid", parameters, 1);
146  DBUG("Use '%s' as thermal_conductivity_solid parameter.",
147  thermal_conductivity_solid.name.c_str());
148 
149  // Parameter for the thermal conductivity of the fluid.
150  auto& thermal_conductivity_fluid = findParameter<double>(
151  config,
153  "thermal_conductivity_fluid", parameters, 1);
154  DBUG("Use '%s' as thermal_conductivity_fluid parameter.",
155  thermal_conductivity_fluid.name.c_str());
156 
157  // Specific body force parameter.
158  Eigen::VectorXd specific_body_force;
159  std::vector<double> const b =
161  config.getConfigParameter<std::vector<double>>("specific_body_force");
162  assert(!b.empty() && b.size() < 4);
163  if (b.size() < mesh.getDimension())
164  {
165  OGS_FATAL(
166  "specific body force (gravity vector) has %d components, mesh "
167  "dimension is %d",
168  b.size(), mesh.getDimension());
169  }
170  bool const has_gravity = MathLib::toVector(b).norm() > 0;
171  if (has_gravity)
172  {
173  specific_body_force.resize(b.size());
174  std::copy_n(b.data(), b.size(), specific_body_force.data());
175  }
176 
177  ConstantParameter<double> default_solid_thermal_expansion(
178  "default solid thermal expansion", 0.);
179  ConstantParameter<double> default_biot_constant("default_biot constant",
180  0.);
181  Parameter<double>* solid_thermal_expansion =
182  &default_solid_thermal_expansion;
183  Parameter<double>* biot_constant = &default_biot_constant;
184 
185  auto const solid_config =
187  config.getConfigSubtreeOptional("solid_thermal_expansion");
188  const bool has_fluid_thermal_expansion = static_cast<bool>(solid_config);
189  if (solid_config)
190  {
191  solid_thermal_expansion = &findParameter<double>(
193  *solid_config, "thermal_expansion", parameters, 1);
194  DBUG("Use '%s' as solid thermal expansion.",
195  solid_thermal_expansion->name.c_str());
196  biot_constant = &findParameter<double>(
198  *solid_config, "biot_constant", parameters, 1);
199  DBUG("Use '%s' as Biot's constant.", biot_constant->name.c_str());
200  }
201 
202  std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
203  auto calculatesurfaceflux_config =
205  config.getConfigSubtreeOptional("calculatesurfaceflux");
206  if (calculatesurfaceflux_config)
207  {
208  surfaceflux = ProcessLib::SurfaceFluxData::
209  createSurfaceFluxData(*calculatesurfaceflux_config, meshes,
210  output_directory);
211  }
212 
213  std::unique_ptr<HTMaterialProperties> material_properties =
214  std::make_unique<HTMaterialProperties>(
215  std::move(porous_media_properties),
216  density_solid,
217  std::move(fluid_properties),
218  has_fluid_thermal_dispersivity,
219  *thermal_dispersivity_longitudinal,
220  *thermal_dispersivity_transversal,
221  specific_heat_capacity_solid,
222  thermal_conductivity_solid,
223  thermal_conductivity_fluid,
224  has_fluid_thermal_expansion,
225  *solid_thermal_expansion,
226  *biot_constant,
227  specific_body_force,
228  has_gravity);
229 
230  SecondaryVariableCollection secondary_variables;
231 
232  NumLib::NamedFunctionCaller named_function_caller(
233  {"HT_temperature_pressure"});
234 
235  ProcessLib::createSecondaryVariables(config, secondary_variables,
236  named_function_caller);
237 
238  return std::make_unique<HTProcess>(
239  mesh, std::move(jacobian_assembler), parameters, integration_order,
240  std::move(process_variables), std::move(material_properties),
241  std::move(secondary_variables), std::move(named_function_caller),
242  use_monolithic_scheme, std::move(surfaceflux));
243 }
244 
245 } // namespace HT
246 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
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::unique_ptr< Process > createHTProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes, std::string const &output_directory)
PorousMediaProperties createPorousMediaProperties(MeshLib::Mesh &mesh, BaseLib::ConfigTree const &configs, std::vector< std::unique_ptr< ProcessLib::ParameterBase >> const &parameters)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
Builds expression trees of named functions dynamically at runtime.
std::unique_ptr< FluidProperties > createFluidProperties(BaseLib::ConfigTree const &config)
static std::unique_ptr< ProcessLib::SurfaceFluxData > createSurfaceFluxData(BaseLib::ConfigTree const &calculatesurfaceflux_config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes, std::string const &output_directory)
Definition of readMeshFromFile function.
void checkConfigParameter(std::string const &param, T const &value) const
std::string const name
Definition: Parameter.h:60
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
Single, constant value parameter.
Handles configuration of several secondary variables from the project file.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:81
boost::optional< T > getConfigParameterOptional(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:71