OGS 6.2.0-97-g4a610c866
CreateHTProcess.cpp
Go to the documentation of this file.
1 
10 #include "CreateHTProcess.h"
11 
15 #include "ParameterLib/Utils.h"
19 
20 #include "HTProcess.h"
21 #include "HTMaterialProperties.h"
23 
24 namespace ProcessLib
25 {
26 namespace HT
27 {
28 std::unique_ptr<Process> createHTProcess(
29  MeshLib::Mesh& mesh,
30  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
31  std::vector<ProcessVariable> const& variables,
32  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
33  unsigned const integration_order,
34  BaseLib::ConfigTree const& config,
35  std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
36  std::string const& output_directory,
37  std::map<int, std::unique_ptr<MaterialPropertyLib::Medium>> const& media)
38 {
40  config.checkConfigParameter("type", "HT");
41 
42  DBUG("Create HTProcess.");
43 
44  auto const staggered_scheme =
46  config.getConfigParameterOptional<std::string>("coupling_scheme");
47  const bool use_monolithic_scheme =
48  !(staggered_scheme && (*staggered_scheme == "staggered"));
49 
50  // Process variable.
51 
53  auto const pv_config = config.getConfigSubtree("process_variables");
54 
55  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
56  process_variables;
57  if (use_monolithic_scheme) // monolithic scheme.
58  {
59  auto per_process_variables = findProcessVariables(
60  variables, pv_config,
61  {
62  "temperature",
64  "pressure"});
65  process_variables.push_back(std::move(per_process_variables));
66  }
67  else // staggered scheme.
68  {
69  using namespace std::string_literals;
70  for (auto const& variable_name : {"temperature"s, "pressure"s})
71  {
72  auto per_process_variables =
73  findProcessVariables(variables, pv_config, {variable_name});
74  process_variables.push_back(std::move(per_process_variables));
75  }
76  }
77  // Process IDs, which are set according to the appearance order of the
78  // process variables.
79  const int _heat_transport_process_id = 0;
80  const int _hydraulic_process_id = 1;
81 
82  // Parameter for the density of the solid.
83  auto& density_solid = ParameterLib::findParameter<double>(
84  config,
86  "density_solid", parameters, 1);
87  DBUG("Use '%s' as density_solid parameter.", density_solid.name.c_str());
88 
89  // Parameter for the specific heat capacity of the solid.
90  auto& specific_heat_capacity_solid = ParameterLib::findParameter<double>(
91  config,
93  "specific_heat_capacity_solid", parameters, 1);
94  DBUG("Use '%s' as specific_heat_capacity_solid parameter.",
95  specific_heat_capacity_solid.name.c_str());
96 
97  // Parameter for the thermal conductivity of the solid (only one scalar per
98  // element, i.e., the isotropic case is handled at the moment)
99  auto& thermal_conductivity_solid = ParameterLib::findParameter<double>(
100  config,
102  "thermal_conductivity_solid", parameters, 1);
103  DBUG("Use '%s' as thermal_conductivity_solid parameter.",
104  thermal_conductivity_solid.name.c_str());
105 
106  // Specific body force parameter.
107  Eigen::VectorXd specific_body_force;
108  std::vector<double> const b =
110  config.getConfigParameter<std::vector<double>>("specific_body_force");
111  assert(!b.empty() && b.size() < 4);
112  if (b.size() < mesh.getDimension())
113  {
114  OGS_FATAL(
115  "specific body force (gravity vector) has %d components, mesh "
116  "dimension is %d",
117  b.size(), mesh.getDimension());
118  }
119  bool const has_gravity = MathLib::toVector(b).norm() > 0;
120  if (has_gravity)
121  {
122  specific_body_force.resize(b.size());
123  std::copy_n(b.data(), b.size(), specific_body_force.data());
124  }
125 
126  ParameterLib::ConstantParameter<double> default_solid_thermal_expansion(
127  "default solid thermal expansion", 0.);
128  ParameterLib::ConstantParameter<double> default_biot_constant(
129  "default_biot constant", 0.);
130  ParameterLib::Parameter<double>* solid_thermal_expansion =
131  &default_solid_thermal_expansion;
132  ParameterLib::Parameter<double>* biot_constant = &default_biot_constant;
133 
134  auto const solid_config =
136  config.getConfigSubtreeOptional("solid_thermal_expansion");
137  const bool has_fluid_thermal_expansion = static_cast<bool>(solid_config);
138  if (solid_config)
139  {
140  solid_thermal_expansion = &ParameterLib::findParameter<double>(
142  *solid_config, "thermal_expansion", parameters, 1);
143  DBUG("Use '%s' as solid thermal expansion.",
144  solid_thermal_expansion->name.c_str());
145  biot_constant = &ParameterLib::findParameter<double>(
147  *solid_config, "biot_constant", parameters, 1);
148  DBUG("Use '%s' as Biot's constant.", biot_constant->name.c_str());
149  }
150 
151  std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
152  auto calculatesurfaceflux_config =
154  config.getConfigSubtreeOptional("calculatesurfaceflux");
155  if (calculatesurfaceflux_config)
156  {
157  surfaceflux = ProcessLib::SurfaceFluxData::
158  createSurfaceFluxData(*calculatesurfaceflux_config, meshes,
159  output_directory);
160  }
161 
162  auto media_map =
164 
165  std::unique_ptr<HTMaterialProperties> material_properties =
166  std::make_unique<HTMaterialProperties>(
167  density_solid,
168  std::move(media_map),
169  specific_heat_capacity_solid,
170  thermal_conductivity_solid,
171  has_fluid_thermal_expansion,
172  *solid_thermal_expansion,
173  *biot_constant,
174  specific_body_force,
175  has_gravity);
176 
177  SecondaryVariableCollection secondary_variables;
178 
179  NumLib::NamedFunctionCaller named_function_caller(
180  {"HT_temperature_pressure"});
181 
182  ProcessLib::createSecondaryVariables(config, secondary_variables,
183  named_function_caller);
184 
185  return std::make_unique<HTProcess>(
186  mesh, std::move(jacobian_assembler), parameters, integration_order,
187  std::move(process_variables), std::move(material_properties),
188  std::move(secondary_variables), std::move(named_function_caller),
189  use_monolithic_scheme, std::move(surfaceflux),
190  _heat_transport_process_id, _hydraulic_process_id);
191 }
192 
193 } // namespace HT
194 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
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< ParameterLib::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, std::map< int, std::unique_ptr< MaterialPropertyLib::Medium >> const &media)
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< MaterialSpatialDistributionMap > createMaterialSpatialDistributionMap(std::map< int, std::unique_ptr< Medium >> const &media, MeshLib::Mesh const &mesh)
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.
Single, constant value parameter.
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
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
std::string const name
Definition: Parameter.h:73
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:63