60 const std::string& bhe_type,
const std::vector<int>& bhe_ids_of_this_bhe,
63 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>>
const&
65 std::map<int, BHE::BHETypes>& bhes_map)
70 OGS_FATAL(
"Unknown BHE type: {:s}", bhe_type);
72 for (
auto const&
id : bhe_ids_of_this_bhe)
74 std::pair<std::map<int, BHE::BHETypes>::iterator,
bool> result;
75 if (
id == bhe_ids_of_this_bhe[0])
77 result = bhes_map.try_emplace(
78 id, bhe_creator_it->second(bhe_config, curves));
82 result = bhes_map.try_emplace(
83 id, bhes_map.find(bhe_ids_of_this_bhe[0])->second);
88 "BHE with id '{:d}' is already present in the list! Check for "
89 "duplicate definitions of BHE ids.",
96 std::string
const& name,
98 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
99 std::vector<ProcessVariable>
const& variables,
100 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters,
101 unsigned const integration_order,
103 std::map<std::string,
104 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>>
const&
106 std::map<
int, std::shared_ptr<MaterialPropertyLib::Medium>>
const& media)
111 DBUG(
"Create HeatTransportBHE Process.");
117 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
126 std::vector<std::reference_wrapper<ProcessVariable>> per_process_variables;
128 for (std::string
const& pv_name : range)
130 if (pv_name !=
"temperature_soil" &&
131 pv_name.find(
"temperature_BHE") == std::string::npos)
134 "Found a process variable name '{}'. It should be "
135 "'temperature_soil' or 'temperature_BHE_X'",
138 auto variable = std::find_if(variables.cbegin(), variables.cend(),
140 { return v.getName() == pv_name; });
142 if (variable == variables.end())
145 "Could not find process variable '{:s}' in the provided "
146 "variables list for config tag <{:s}>.",
147 pv_name,
"process_variable");
149 DBUG(
"Found process variable '{:s}' for config tag <{:s}>.",
150 variable->getName(),
"process_variable");
152 per_process_variables.emplace_back(
155 process_variables.push_back(std::move(per_process_variables));
164 auto const& bhe_configs =
168 auto const using_server_communication =
172 auto const mass_lumping =
176 auto const using_algebraic_bc =
180 auto const weighting_factor =
184 auto const is_linear =
189 if (!using_algebraic_bc)
192 "You specified that the process simulated by OGS is linear. "
193 "With that optimization the process will be assembled only "
194 "once and the non-linear solver will only do iterations per "
195 "time step to fulfill the BHE boundary conditions. No other "
196 "non-linearities will be resolved and OGS will not detect if "
197 "there are any non-linearities. It is your responsibility to "
198 "ensure that the assembled equation systems are linear, "
199 "indeed! There is no safety net!");
204 "You specified that the process simulated by OGS is linear. "
205 "With that optimization the process will be assembled only "
206 "once and the non-linear solver will do only one iteration per "
207 "time step. No non-linearities will be resolved and OGS will "
208 "not detect if there are any non-linearities. It is your "
209 "responsibility to ensure that the assembled equation systems "
210 "are linear, indeed! There is no safety net!");
214 std::map<int, BHE::BHETypes> bhes_map;
216 int bhe_iterator = 0;
219 auto const& bhe_config :
221 bhe_configs.getConfigSubtreeList(
"borehole_heat_exchanger"))
225 bhe_config.getConfigAttribute<std::string>(
226 "id", std::to_string(bhe_iterator));
228 std::vector<int> bhe_ids_of_this_bhe;
230 if (bhe_id_string ==
"*")
232 int size =
static_cast<int>(bhe_mesh_data.BHE_mat_IDs.size());
233 bhe_ids_of_this_bhe.resize(size);
234 std::iota(bhe_ids_of_this_bhe.begin(), bhe_ids_of_this_bhe.end(),
239 bhe_ids_of_this_bhe =
244 const std::string bhe_type =
246 bhe_config.getConfigParameter<std::string>(
"type");
253 if (
static_cast<int>(bhes_map.size()) - 1 != bhes_map.rbegin()->first)
256 "The maximum given BHE id '{:d}' did not match the number of given "
257 "BHE definitions '{:d}'. The BHE ids needs to be defined starting "
258 "from 0, so the maximum BHE id needs to be number of BHE "
259 "definitions minus 1. After all definitions there are no gaps "
260 "allowed between the given ids.",
261 bhes_map.rbegin()->first, bhes_map.size());
264 std::vector<BHE::BHETypes> bhes;
265 bhes.reserve(bhes_map.size());
266 std::ranges::copy(bhes_map | std::views::values, std::back_inserter(bhes));
274 auto const using_tespy =
275 visit([](
auto const& bhe) {
return bhe.use_python_bcs; }, bhes[0]);
280 if (using_tespy || using_server_communication)
283 pybind11::object scope =
284 pybind11::module::import(
"__main__").attr(
"__dict__");
286 if (!scope.contains(
"bc_bhe"))
288 "Function 'bc_bhe' is not defined in the python script file, "
289 "or there was no python script file specified.");
295 if (py_object ==
nullptr)
297 "Not able to access the correct bc pointer from python script "
301 py_object->dataframe_network = py_object->initializeDataContainer();
302 if (!py_object->isOverriddenEssential())
305 "Method `initializeDataContainer' not overridden in Python "
309 std::get<3>(py_object->dataframe_network).clear();
335 std::move(media_map), std::move(bhes), py_object, using_tespy,
336 using_server_communication, mass_lumping,
337 {using_algebraic_bc, weighting_factor}, is_linear);
343 return std::make_unique<HeatTransportBHEProcess>(
344 std::move(name), mesh, std::move(jacobian_assembler), parameters,
345 integration_order, std::move(process_variables),
346 std::move(process_data), std::move(secondary_variables),
347 std::move(bhe_mesh_data));
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 > > const ¶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)