OGS 6.2.1-97-g73d1aeda3
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 "HTProcessData.h"
23 
24 namespace ProcessLib
25 {
26 namespace HT
27 {
28 std::unique_ptr<Process> createHTProcess(
29  std::string name,
30  MeshLib::Mesh& mesh,
31  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
32  std::vector<ProcessVariable> const& variables,
33  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
34  unsigned const integration_order,
35  BaseLib::ConfigTree const& config,
36  std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
37  std::string const& output_directory,
38  std::map<int, std::unique_ptr<MaterialPropertyLib::Medium>> const& media)
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  // Process IDs, which are set according to the appearance order of the
79  // process variables.
80  const int _heat_transport_process_id = 0;
81  const int _hydraulic_process_id = 1;
82 
83  // Specific body force parameter.
84  Eigen::VectorXd specific_body_force;
85  std::vector<double> const b =
87  config.getConfigParameter<std::vector<double>>("specific_body_force");
88  assert(!b.empty() && b.size() < 4);
89  if (b.size() < mesh.getDimension())
90  {
91  OGS_FATAL(
92  "specific body force (gravity vector) has %d components, mesh "
93  "dimension is %d",
94  b.size(), mesh.getDimension());
95  }
96  bool const has_gravity = MathLib::toVector(b).norm() > 0;
97  if (has_gravity)
98  {
99  specific_body_force.resize(b.size());
100  std::copy_n(b.data(), b.size(), specific_body_force.data());
101  }
102 
103  ParameterLib::ConstantParameter<double> default_solid_thermal_expansion(
104  "default solid thermal expansion", 0.);
105  ParameterLib::ConstantParameter<double> default_biot_constant(
106  "default_biot constant", 0.);
107  ParameterLib::Parameter<double>* solid_thermal_expansion =
108  &default_solid_thermal_expansion;
109  ParameterLib::Parameter<double>* biot_constant = &default_biot_constant;
110 
111  auto const solid_config =
113  config.getConfigSubtreeOptional("solid_thermal_expansion");
114  const bool has_fluid_thermal_expansion = static_cast<bool>(solid_config);
115  if (solid_config)
116  {
117  solid_thermal_expansion = &ParameterLib::findParameter<double>(
119  *solid_config, "thermal_expansion", parameters, 1, &mesh);
120  DBUG("Use '%s' as solid thermal expansion.",
121  solid_thermal_expansion->name.c_str());
122  biot_constant = &ParameterLib::findParameter<double>(
124  *solid_config, "biot_constant", parameters, 1, &mesh);
125  DBUG("Use '%s' as Biot's constant.", biot_constant->name.c_str());
126  }
127 
128  std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
129  auto calculatesurfaceflux_config =
131  config.getConfigSubtreeOptional("calculatesurfaceflux");
132  if (calculatesurfaceflux_config)
133  {
134  surfaceflux = ProcessLib::SurfaceFluxData::
135  createSurfaceFluxData(*calculatesurfaceflux_config, meshes,
136  output_directory);
137  }
138 
139  auto media_map =
141 
142  HTProcessData process_data{
143  std::move(media_map), has_fluid_thermal_expansion,
144  *solid_thermal_expansion, *biot_constant,
145  specific_body_force, has_gravity};
146 
147  SecondaryVariableCollection secondary_variables;
148 
149  NumLib::NamedFunctionCaller named_function_caller(
150  {"HT_temperature_pressure"});
151 
152  ProcessLib::createSecondaryVariables(config, secondary_variables,
153  named_function_caller);
154 
155  return std::make_unique<HTProcess>(
156  std::move(name), mesh, std::move(jacobian_assembler), parameters,
157  integration_order, std::move(process_variables),
158  std::move(process_data), std::move(secondary_variables),
159  std::move(named_function_caller), use_monolithic_scheme,
160  std::move(surfaceflux), _heat_transport_process_id,
161  _hydraulic_process_id);
162 }
163 
164 } // namespace HT
165 } // 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< MaterialSpatialDistributionMap > createMaterialSpatialDistributionMap(std::map< int, std::unique_ptr< Medium >> const &media, MeshLib::Mesh const &mesh)
T getConfigParameter(std::string const &param) const
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
std::unique_ptr< Process > createHTProcess(std::string 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::string const &output_directory, std::map< int, std::unique_ptr< MaterialPropertyLib::Medium >> const &media)
boost::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
Definition: ConfigTree.cpp:160