OGS 6.2.0-97-g4a610c866
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  MeshLib::Mesh& mesh,
29  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
30  std::vector<ProcessVariable> const& variables,
31  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
32  unsigned const integration_order,
33  BaseLib::ConfigTree const& config,
34  std::map<std::string,
35  std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
36  curves)
37 {
39  config.checkConfigParameter("type", "HEAT_TRANSPORT_BHE");
40 
41  DBUG("Create HeatTransportBHE Process.");
42 
43  // Process variable.
44 
46  auto const pv_config = config.getConfigSubtree("process_variables");
47  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
48  process_variables;
49 
50  // reading primary variables for each
51  // BHE----------------------------------------------------------
52  auto range =
54  pv_config.getConfigParameterList<std::string>("process_variable");
55  std::vector<std::reference_wrapper<ProcessVariable>> per_process_variables;
56 
57  for (std::string const& pv_name : range)
58  {
59  if (pv_name != "temperature_soil" &&
60  pv_name.find("temperature_BHE") == std::string::npos)
61  {
62  OGS_FATAL(
63  "Found a process variable name '%s'. It should be "
64  "'temperature_soil' or 'temperature_BHE_X'");
65  }
66  auto variable = std::find_if(variables.cbegin(), variables.cend(),
67  [&pv_name](ProcessVariable const& v) {
68  return v.getName() == pv_name;
69  });
70 
71  if (variable == variables.end())
72  {
73  OGS_FATAL(
74  "Could not find process variable '%s' in the provided "
75  "variables "
76  "list for config tag <%s>.",
77  pv_name.c_str(), "process_variable");
78  }
79  DBUG("Found process variable '%s' for config tag <%s>.",
80  variable->getName().c_str(), "process_variable");
81 
82  per_process_variables.emplace_back(
83  const_cast<ProcessVariable&>(*variable));
84  }
85  process_variables.push_back(std::move(per_process_variables));
86  // end of reading primary variables for each
87  // BHE----------------------------------------------------------
88 
89  // solid phase thermal conductivity parameter.
90  auto& thermal_conductivity_solid = ParameterLib::findParameter<double>(
91  config,
93  "thermal_conductivity_solid", parameters, 1);
94 
95  DBUG("Use '%s' as solid phase thermal conductivity parameter.",
96  thermal_conductivity_solid.name.c_str());
97 
98  // solid phase thermal conductivity parameter.
99  auto& thermal_conductivity_fluid = ParameterLib::findParameter<double>(
100  config,
102  "thermal_conductivity_fluid", parameters, 1);
103 
104  DBUG("Use '%s' as fluid phase thermal conductivity parameter.",
105  thermal_conductivity_fluid.name.c_str());
106 
107  // gas phase thermal conductivity parameter.
108  auto& thermal_conductivity_gas = ParameterLib::findParameter<double>(
109  config,
111  "thermal_conductivity_gas", parameters, 1);
112 
113  DBUG("Use '%s' as gas phase thermal conductivity parameter.",
114  thermal_conductivity_gas.name.c_str());
115 
116  // solid phase heat capacity parameter.
117  auto& heat_capacity_solid = ParameterLib::findParameter<double>(
118  config,
120  "heat_capacity_solid", parameters, 1);
121 
122  DBUG("Use '%s' as solid phase heat capacity parameter.",
123  heat_capacity_solid.name.c_str());
124 
125  // fluid phase heat capacity parameter.
126  auto& heat_capacity_fluid = ParameterLib::findParameter<double>(
127  config,
129  "heat_capacity_fluid", parameters, 1);
130 
131  DBUG("Use '%s' as fluid phase heat capacity parameter.",
132  heat_capacity_fluid.name.c_str());
133 
134  // gas phase heat capacity parameter.
135  auto& heat_capacity_gas = ParameterLib::findParameter<double>(
136  config,
138  "heat_capacity_gas", parameters, 1);
139 
140  DBUG("Use '%s' as gas phase heat capacity parameter.",
141  heat_capacity_gas.name.c_str());
142 
143  // solid phase density parameter.
144  auto& density_solid = ParameterLib::findParameter<double>(
145  config,
147  "density_solid", parameters, 1);
148 
149  DBUG("Use '%s' as solid phase density parameter.",
150  density_solid.name.c_str());
151 
152  // fluid phase density parameter.
153  auto& density_fluid = ParameterLib::findParameter<double>(
154  config,
156  "density_fluid", parameters, 1);
157 
158  DBUG("Use '%s' as fluid phase density parameter.",
159  density_fluid.name.c_str());
160 
161  // gas phase density parameter.
162  auto& density_gas = ParameterLib::findParameter<double>(
163  config,
165  "density_gas", parameters, 1);
166 
167  DBUG("Use '%s' as gas phase density parameter.", density_gas.name.c_str());
168 
169  // reading BHE parameters --------------------------------------------------
170  std::vector<BHE::BHETypes> bhes;
171  auto const& bhe_configs =
173  config.getConfigSubtree("borehole_heat_exchangers");
174 
175  for (
176  auto const& bhe_config :
178  bhe_configs.getConfigSubtreeList("borehole_heat_exchanger"))
179  {
180  // read in the parameters
181  const std::string bhe_type =
183  bhe_config.getConfigParameter<std::string>("type");
184 
185  if (bhe_type == "1U")
186  {
187  bhes.emplace_back(BHE::createBHE1U(bhe_config, curves));
188  continue;
189  }
190 
191  if (bhe_type == "CXA")
192  {
193  bhes.emplace_back(
194  BHE::createBHECoaxial<BHE::BHE_CXA>(bhe_config, curves));
195  continue;
196  }
197 
198  if (bhe_type == "CXC")
199  {
200  bhes.emplace_back(
201  BHE::createBHECoaxial<BHE::BHE_CXC>(bhe_config, curves));
202  continue;
203  }
204  OGS_FATAL("Unknown BHE type '%s'.", bhe_type.c_str());
205  }
206  // end of reading BHE parameters -------------------------------------------
207 
208  HeatTransportBHEProcessData process_data{thermal_conductivity_solid,
209  thermal_conductivity_fluid,
210  thermal_conductivity_gas,
211  heat_capacity_solid,
212  heat_capacity_fluid,
213  heat_capacity_gas,
214  density_solid,
215  density_fluid,
216  density_gas,
217  std::move(bhes)};
218 
219  SecondaryVariableCollection secondary_variables;
220 
221  NumLib::NamedFunctionCaller named_function_caller(
222  {"HeatTransportBHE_Temperature"});
223 
224  ProcessLib::createSecondaryVariables(config, secondary_variables,
225  named_function_caller);
226 
227  return std::make_unique<HeatTransportBHEProcess>(
228  mesh, std::move(jacobian_assembler), parameters, integration_order,
229  std::move(process_variables), std::move(process_data),
230  std::move(secondary_variables), std::move(named_function_caller));
231 }
232 } // namespace HeatTransportBHE
233 } // 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
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
Handles configuration of several secondary variables from the project file.
std::unique_ptr< Process > createHeatTransportBHEProcess(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)
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
Range< ValueIterator< T > > getConfigParameterList(std::string const &param) const