OGS 6.2.1-97-g73d1aeda3
CreateHeatTransportBHEProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <vector>
13 
14 #include "ParameterLib/Utils.h"
16 
17 #include "BHE/BHETypes.h"
18 #include "BHE/CreateBHE1U.h"
19 #include "BHE/CreateBHECoaxial.h"
22 
23 namespace ProcessLib
24 {
25 namespace HeatTransportBHE
26 {
27 std::unique_ptr<Process> createHeatTransportBHEProcess(
28  std::string name,
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::map<std::string,
36  std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
37  curves)
38 {
40  config.checkConfigParameter("type", "HEAT_TRANSPORT_BHE");
41 
42  DBUG("Create HeatTransportBHE Process.");
43 
44  // Process variable.
45 
47  auto const pv_config = config.getConfigSubtree("process_variables");
48  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
49  process_variables;
50 
51  // reading primary variables for each
52  // BHE----------------------------------------------------------
53  auto range =
55  pv_config.getConfigParameterList<std::string>("process_variable");
56  std::vector<std::reference_wrapper<ProcessVariable>> per_process_variables;
57 
58  for (std::string const& pv_name : range)
59  {
60  if (pv_name != "temperature_soil" &&
61  pv_name.find("temperature_BHE") == std::string::npos)
62  {
63  OGS_FATAL(
64  "Found a process variable name '%s'. It should be "
65  "'temperature_soil' or 'temperature_BHE_X'");
66  }
67  auto variable = std::find_if(variables.cbegin(), variables.cend(),
68  [&pv_name](ProcessVariable const& v) {
69  return v.getName() == pv_name;
70  });
71 
72  if (variable == variables.end())
73  {
74  OGS_FATAL(
75  "Could not find process variable '%s' in the provided "
76  "variables "
77  "list for config tag <%s>.",
78  pv_name.c_str(), "process_variable");
79  }
80  DBUG("Found process variable '%s' for config tag <%s>.",
81  variable->getName().c_str(), "process_variable");
82 
83  per_process_variables.emplace_back(
84  const_cast<ProcessVariable&>(*variable));
85  }
86  process_variables.push_back(std::move(per_process_variables));
87  // end of reading primary variables for each
88  // BHE----------------------------------------------------------
89 
90  // solid phase thermal conductivity parameter.
91  auto& thermal_conductivity_solid = ParameterLib::findParameter<double>(
92  config,
94  "thermal_conductivity_solid", parameters, 1, &mesh);
95 
96  DBUG("Use '%s' as solid phase thermal conductivity parameter.",
97  thermal_conductivity_solid.name.c_str());
98 
99  // solid phase thermal conductivity parameter.
100  auto& thermal_conductivity_fluid = ParameterLib::findParameter<double>(
101  config,
103  "thermal_conductivity_fluid", parameters, 1, &mesh);
104 
105  DBUG("Use '%s' as fluid phase thermal conductivity parameter.",
106  thermal_conductivity_fluid.name.c_str());
107 
108  // gas phase thermal conductivity parameter.
109  auto& thermal_conductivity_gas = ParameterLib::findParameter<double>(
110  config,
112  "thermal_conductivity_gas", parameters, 1, &mesh);
113 
114  DBUG("Use '%s' as gas phase thermal conductivity parameter.",
115  thermal_conductivity_gas.name.c_str());
116 
117  // solid phase heat capacity parameter.
118  auto& heat_capacity_solid = ParameterLib::findParameter<double>(
119  config,
121  "heat_capacity_solid", parameters, 1, &mesh);
122 
123  DBUG("Use '%s' as solid phase heat capacity parameter.",
124  heat_capacity_solid.name.c_str());
125 
126  // fluid phase heat capacity parameter.
127  auto& heat_capacity_fluid = ParameterLib::findParameter<double>(
128  config,
130  "heat_capacity_fluid", parameters, 1, &mesh);
131 
132  DBUG("Use '%s' as fluid phase heat capacity parameter.",
133  heat_capacity_fluid.name.c_str());
134 
135  // gas phase heat capacity parameter.
136  auto& heat_capacity_gas = ParameterLib::findParameter<double>(
137  config,
139  "heat_capacity_gas", parameters, 1, &mesh);
140 
141  DBUG("Use '%s' as gas phase heat capacity parameter.",
142  heat_capacity_gas.name.c_str());
143 
144  // solid phase density parameter.
145  auto& density_solid = ParameterLib::findParameter<double>(
146  config,
148  "density_solid", parameters, 1, &mesh);
149 
150  DBUG("Use '%s' as solid phase density parameter.",
151  density_solid.name.c_str());
152 
153  // fluid phase density parameter.
154  auto& density_fluid = ParameterLib::findParameter<double>(
155  config,
157  "density_fluid", parameters, 1, &mesh);
158 
159  DBUG("Use '%s' as fluid phase density parameter.",
160  density_fluid.name.c_str());
161 
162  // gas phase density parameter.
163  auto& density_gas = ParameterLib::findParameter<double>(
164  config,
166  "density_gas", parameters, 1, &mesh);
167 
168  DBUG("Use '%s' as gas phase density parameter.", density_gas.name.c_str());
169 
170  // reading BHE parameters --------------------------------------------------
171  std::vector<BHE::BHETypes> bhes;
172  auto const& bhe_configs =
174  config.getConfigSubtree("borehole_heat_exchangers");
175 
176  for (
177  auto const& bhe_config :
179  bhe_configs.getConfigSubtreeList("borehole_heat_exchanger"))
180  {
181  // read in the parameters
182  const std::string bhe_type =
184  bhe_config.getConfigParameter<std::string>("type");
185 
186  if (bhe_type == "1U")
187  {
188  bhes.emplace_back(BHE::createBHE1U(bhe_config, curves));
189  continue;
190  }
191 
192  if (bhe_type == "CXA")
193  {
194  bhes.emplace_back(
195  BHE::createBHECoaxial<BHE::BHE_CXA>(bhe_config, curves));
196  continue;
197  }
198 
199  if (bhe_type == "CXC")
200  {
201  bhes.emplace_back(
202  BHE::createBHECoaxial<BHE::BHE_CXC>(bhe_config, curves));
203  continue;
204  }
205  OGS_FATAL("Unknown BHE type '%s'.", bhe_type.c_str());
206  }
207  // end of reading BHE parameters -------------------------------------------
208 
209  HeatTransportBHEProcessData process_data{thermal_conductivity_solid,
210  thermal_conductivity_fluid,
211  thermal_conductivity_gas,
212  heat_capacity_solid,
213  heat_capacity_fluid,
214  heat_capacity_gas,
215  density_solid,
216  density_fluid,
217  density_gas,
218  std::move(bhes)};
219 
220  SecondaryVariableCollection secondary_variables;
221 
222  NumLib::NamedFunctionCaller named_function_caller(
223  {"HeatTransportBHE_Temperature"});
224 
225  ProcessLib::createSecondaryVariables(config, secondary_variables,
226  named_function_caller);
227 
228  return std::make_unique<HeatTransportBHEProcess>(
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  std::move(named_function_caller));
233 }
234 } // namespace HeatTransportBHE
235 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
BHE::BHE_1U createBHE1U(BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves)
Definition: CreateBHE1U.cpp:21
Builds expression trees of named functions dynamically at runtime.
void checkConfigParameter(std::string const &param, T const &value) const
std::unique_ptr< Process > createHeatTransportBHEProcess(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::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves)
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
Handles configuration of several secondary variables from the project file.
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
Range< ValueIterator< T > > getConfigParameterList(std::string const &param) const