24 #include <pybind11/pybind11.h>
29 namespace HeatTransportBHE
34 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
35 std::vector<ProcessVariable>
const& variables,
36 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters,
37 unsigned const integration_order,
40 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>>
const&
42 std::map<
int, std::shared_ptr<MaterialPropertyLib::Medium>>
const& media)
47 DBUG(
"Create HeatTransportBHE Process.");
53 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
61 std::vector<std::reference_wrapper<ProcessVariable>> per_process_variables;
63 for (std::string
const& pv_name : range)
65 if (pv_name !=
"temperature_soil" &&
66 pv_name.find(
"temperature_BHE") == std::string::npos)
69 "Found a process variable name '{:s}'. It should be "
70 "'temperature_soil' or 'temperature_BHE_X'");
72 auto variable = std::find_if(variables.cbegin(), variables.cend(),
74 { return v.getName() == pv_name; });
76 if (variable == variables.end())
79 "Could not find process variable '{:s}' in the provided "
80 "variables list for config tag <{:s}>.",
81 pv_name,
"process_variable");
83 DBUG(
"Found process variable '{:s}' for config tag <{:s}>.",
84 variable->getName(),
"process_variable");
86 per_process_variables.emplace_back(
89 process_variables.push_back(std::move(per_process_variables));
94 std::vector<BHE::BHETypes> bhes;
96 auto const& bhe_configs =
100 auto const using_server_communication =
105 auto const& bhe_config :
107 bhe_configs.getConfigSubtreeList(
"borehole_heat_exchanger"))
110 const std::string bhe_type =
112 bhe_config.getConfigParameter<std::string>(
"type");
114 if (bhe_type ==
"1U")
117 BHE::createBHEUType<BHE::BHE_1U>(bhe_config, curves));
121 if (bhe_type ==
"CXA")
124 BHE::createBHECoaxial<BHE::BHE_CXA>(bhe_config, curves));
128 if (bhe_type ==
"CXC")
131 BHE::createBHECoaxial<BHE::BHE_CXC>(bhe_config, curves));
135 if (bhe_type ==
"2U")
138 BHE::createBHEUType<BHE::BHE_2U>(bhe_config, curves));
142 if (bhe_type ==
"1P")
145 BHE::createBHE1PType<BHE::BHE_1P>(bhe_config, curves));
148 OGS_FATAL(
"Unknown BHE type '{:s}'.", bhe_type);
156 auto const using_tespy =
157 visit([](
auto const& bhe) {
return bhe.use_python_bcs; }, bhes[0]);
162 if (using_tespy || using_server_communication)
164 #ifdef OGS_USE_PYTHON
166 pybind11::object scope =
167 pybind11::module::import(
"__main__").attr(
"__dict__");
169 if (!scope.contains(
"bc_bhe"))
171 "Function 'bc_bhe' is not defined in the python script file, "
172 "or there was no python script file specified.");
178 if (py_object ==
nullptr)
180 "Not able to access the correct bc pointer from python script "
184 py_object->dataframe_network = py_object->initializeDataContainer();
185 if (!py_object->isOverriddenEssential())
188 "Method `initializeDataContainer' not overridden in Python "
192 std::get<3>(py_object->dataframe_network).clear();
217 "Input files suggest the coupling of BHE with pipe network. "
218 "This means the compiling flag OGS_USE_PYTHON must be switched "
224 std::move(media_map), std::move(bhes), py_object, using_tespy,
225 using_server_communication);
231 return std::make_unique<HeatTransportBHEProcess>(
232 std::move(
name), mesh, std::move(jacobian_assembler), parameters,
233 integration_order, std::move(process_variables),
234 std::move(process_data), std::move(secondary_variables));
void DBUG(char const *fmt, Args const &... args)
void checkConfigParameter(std::string const ¶m, T const &value) const
T getConfigParameter(std::string const ¶m) const
ConfigTree getConfigSubtree(std::string const &root) const
Range< ValueIterator< T > > getConfigParameterList(std::string const ¶m) const
Handles configuration of several secondary variables from the project file.
std::unique_ptr< MaterialSpatialDistributionMap > createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium >> const &media, MeshLib::Mesh const &mesh)
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 ¶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)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)