38 [](
auto& config,
auto& parameters,
auto& curves,
auto& bhe_nodes)
41 config, parameters, curves, bhe_nodes));
44 [](
auto& config,
auto& parameters,
auto& curves,
auto& bhe_nodes)
47 config, parameters, curves, bhe_nodes));
50 [](
auto& config,
auto& parameters,
auto& curves,
auto& bhe_nodes)
53 config, parameters, curves, bhe_nodes));
56 [](
auto& config,
auto& parameters,
auto& curves,
auto& bhe_nodes)
59 config, parameters, curves, bhe_nodes));
61 {
"1P", [](
auto& config,
auto& parameters,
auto& curves,
auto& bhe_nodes)
64 config, parameters, curves, bhe_nodes));
68 const std::string& bhe_type,
69 const std::vector<int>& bhe_ids_of_this_bhe,
71 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters,
73 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>>
const&
76 std::map<int, BHE::BHETypes>& bhes_map)
81 OGS_FATAL(
"Unknown BHE type: {:s}", bhe_type);
83 for (
auto const&
id : bhe_ids_of_this_bhe)
85 if (id < 0 || id >=
static_cast<int>(bhe_mesh_data.
BHE_nodes.size()))
88 "BHE id {:d} is out of range. The mesh contains {:d} "
89 "BHE(s) (valid ids: 0 to {:d}).",
91 static_cast<int>(bhe_mesh_data.
BHE_nodes.size()) - 1);
93 std::pair<std::map<int, BHE::BHETypes>::iterator,
bool> result;
94 if (
id == bhe_ids_of_this_bhe[0])
96 auto const& bhe_nodes =
98 result = bhes_map.try_emplace(
99 id, bhe_creator_it->second(bhe_config, parameters, curves,
108 auto const& first_bhe =
109 bhes_map.find(bhe_ids_of_this_bhe[0])->second;
110 auto const& bhe_nodes =
112 result = bhes_map.try_emplace(
117 return bhe.withGeometry(
118 bhe.borehole_geometry.rebuildForNodes(bhe_nodes));
125 "BHE with id '{:d}' is already present in the list! Check for "
126 "duplicate definitions of BHE ids.",
133 std::string
const& name,
135 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
136 std::vector<ProcessVariable>
const& variables,
137 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters,
138 unsigned const integration_order,
140 std::map<std::string,
141 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>>
const&
143 std::map<
int, std::shared_ptr<MaterialPropertyLib::Medium>>
const& media)
148 DBUG(
"Create HeatTransportBHE Process.");
154 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
163 std::vector<std::reference_wrapper<ProcessVariable>> per_process_variables;
165 for (std::string
const& pv_name : range)
167 if (pv_name !=
"temperature_soil" &&
168 pv_name.find(
"temperature_BHE") == std::string::npos)
171 "Found a process variable name '{}'. It should be "
172 "'temperature_soil' or 'temperature_BHE_X'",
175 auto variable = std::find_if(variables.cbegin(), variables.cend(),
177 { return v.getName() == pv_name; });
179 if (variable == variables.end())
182 "Could not find process variable '{:s}' in the provided "
183 "variables list for config tag <{:s}>.",
184 pv_name,
"process_variable");
186 DBUG(
"Found process variable '{:s}' for config tag <{:s}>.",
187 variable->getName(),
"process_variable");
189 per_process_variables.emplace_back(
192 process_variables.push_back(std::move(per_process_variables));
201 auto const& bhe_configs =
205 auto const using_server_communication =
209 auto const mass_lumping =
213 auto const using_algebraic_bc =
217 auto const weighting_factor =
221 auto const is_linear =
226 if (!using_algebraic_bc)
229 "You specified that the process simulated by OGS is linear. "
230 "With that optimization the process will be assembled only "
231 "once and the non-linear solver will only do iterations per "
232 "time step to fulfill the BHE boundary conditions. No other "
233 "non-linearities will be resolved and OGS will not detect if "
234 "there are any non-linearities. It is your responsibility to "
235 "ensure that the assembled equation systems are linear, "
236 "indeed! There is no safety net!");
241 "You specified that the process simulated by OGS is linear. "
242 "With that optimization the process will be assembled only "
243 "once and the non-linear solver will do only one iteration per "
244 "time step. No non-linearities will be resolved and OGS will "
245 "not detect if there are any non-linearities. It is your "
246 "responsibility to ensure that the assembled equation systems "
247 "are linear, indeed! There is no safety net!");
251 std::map<int, BHE::BHETypes> bhes_map;
253 int bhe_iterator = 0;
256 auto const& bhe_config :
258 bhe_configs.getConfigSubtreeList(
"borehole_heat_exchanger"))
260 auto const bhe_id_string =
262 bhe_config.getConfigAttribute<std::string>(
263 "id", std::to_string(bhe_iterator));
265 std::vector<int> bhe_ids_of_this_bhe;
267 if (bhe_id_string ==
"*")
269 int const size =
static_cast<int>(bhe_mesh_data.BHE_mat_IDs.size());
270 bhe_ids_of_this_bhe.resize(size);
271 std::iota(bhe_ids_of_this_bhe.begin(), bhe_ids_of_this_bhe.end(),
276 bhe_ids_of_this_bhe =
281 const std::string bhe_type =
283 bhe_config.getConfigParameter<std::string>(
"type");
286 parameters, curves, bhe_mesh_data, bhes_map);
290 if (
static_cast<int>(bhes_map.size()) - 1 != bhes_map.rbegin()->first)
293 "The maximum given BHE id '{:d}' did not match the number of given "
294 "BHE definitions '{:d}'. The BHE ids needs to be defined starting "
295 "from 0, so the maximum BHE id needs to be number of BHE "
296 "definitions minus 1. After all definitions there are no gaps "
297 "allowed between the given ids.",
298 bhes_map.rbegin()->first, bhes_map.size());
301 std::vector<BHE::BHETypes> bhes;
302 bhes.reserve(bhes_map.size());
303 std::ranges::copy(bhes_map | std::views::values, std::back_inserter(bhes));
304 bhe_mesh_data.updateElementSectionIndices(bhes);
312 auto const using_tespy =
313 visit([](
auto const& bhe) {
return bhe.use_python_bcs; }, bhes[0]);
318 if (using_tespy || using_server_communication)
321 pybind11::object scope =
322 pybind11::module::import(
"__main__").attr(
"__dict__");
324 if (!scope.contains(
"bc_bhe"))
326 "Function 'bc_bhe' is not defined in the python script file, "
327 "or there was no python script file specified.");
333 if (py_object ==
nullptr)
335 "Not able to access the correct bc pointer from python script "
339 py_object->dataframe_network = py_object->initializeDataContainer();
340 if (!py_object->isOverriddenEssential())
343 "Method `initializeDataContainer' not overridden in Python "
347 std::get<3>(py_object->dataframe_network).clear();
373 std::move(media_map), std::move(bhes), py_object, using_tespy,
374 using_server_communication, mass_lumping,
375 {using_algebraic_bc, weighting_factor}, is_linear);
381 return std::make_unique<HeatTransportBHEProcess>(
382 std::move(name), mesh, std::move(jacobian_assembler), parameters,
383 integration_order, std::move(process_variables),
384 std::move(process_data), std::move(secondary_variables),
385 std::move(bhe_mesh_data));
void createAndInsertBHE(const std::string &bhe_type, const std::vector< int > &bhe_ids_of_this_bhe, const BaseLib::ConfigTree &bhe_config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > ¶meters, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves, BHEMeshData const &bhe_mesh_data, std::map< int, BHE::BHETypes > &bhes_map)
std::unique_ptr< Process > createHeatTransportBHEProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > ¶meters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)