25 namespace HeatTransportBHE
30 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
31 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters,
32 unsigned const integration_order,
33 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
37 :
Process(std::move(
name), mesh, std::move(jacobian_assembler), parameters,
38 integration_order, std::move(process_variables),
39 std::move(secondary_variables)),
40 _process_data(std::move(process_data)),
47 "The number of the given BHE properties ({:d}) are not consistent "
48 "with the number of BHE groups in the mesh ({:d}).",
54 if (material_ids ==
nullptr)
56 OGS_FATAL(
"Not able to get material IDs! ");
83 std::vector<std::vector<MeshLib::Element*>
const*> vec_var_elements;
86 std::vector<int> vec_n_components{
98 for (
int i = 0; i < n_BHEs; i++)
100 auto const number_of_unknowns =
101 visit([](
auto const& bhe) {
return bhe.number_of_unknowns; },
108 std::make_unique<MeshLib::MeshSubset const>(
_mesh, bhe_nodes));
110 std::generate_n(std::back_inserter(all_mesh_subsets),
117 vec_n_components.push_back(number_of_unknowns);
118 vec_var_elements.push_back(&bhe_elements);
122 std::make_unique<NumLib::LocalToGlobalIndexMap>(
123 std::move(all_mesh_subsets),
135 unsigned const integration_order)
138 std::unordered_map<std::size_t, BHE::BHETypes*> element_to_bhe_map;
140 for (
int i = 0; i < n_BHEs; i++)
143 for (
auto const& e : bhe_elements)
145 element_to_bhe_map[e->getID()] =
161 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
162 std::vector<GlobalVector*>
const& xdot,
int const process_id,
165 DBUG(
"Assemble HeatTransportBHE process.");
169 std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
179 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
180 std::vector<GlobalVector*>
const& xdot,
const double dxdot_dx,
184 DBUG(
"AssembleWithJacobian HeatTransportBHE process.");
186 std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
194 dxdot_dx, dx_dx, process_id, M, K, b, Jac);
198 double const t,
double const dt, std::vector<GlobalVector*>
const& x,
201 DBUG(
"Compute heat flux for HeatTransportBHE process.");
203 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
204 dof_tables.reserve(x.size());
205 std::generate_n(std::back_inserter(dof_tables), x.size(),
206 [&]() { return _local_to_global_index_map.get(); });
215 #ifdef OGS_USE_PYTHON
225 auto const Tout_nodes_id =
227 const std::size_t n_bc_nodes = Tout_nodes_id.size();
229 for (std::size_t i = 0; i < n_bc_nodes; i++)
242 DBUG(
"Method `tespySolver' not overridden in Python script.");
246 for (std::size_t i = 0; i < n_bc_nodes; i++)
249 std::get<2>(tespy_result)[i];
251 std::get<3>(tespy_result)[i];
253 auto const tespy_has_converged = std::get<1>(tespy_result);
254 if (tespy_has_converged ==
true)
261 std::vector<GlobalVector*>
const& x,
const double t,
const double dt,
262 int const process_id)
270 auto& [time, Tin_value, Tout_value, Tout_nodes_ids, flowrate] =
273 auto const& solution = *x[process_id];
276 const std::size_t n_bc_nodes = Tout_nodes_ids.size();
277 for (std::size_t i = 0; i < n_bc_nodes; i++)
280 Tout_value[i] = solution[Tout_nodes_ids[i]];
286 auto const server_communication_result =
288 Tout_value, flowrate);
291 DBUG(
"Method `serverCommunication' not overridden in Python script.");
294 auto const& [server_communication_Tin_value,
295 server_communication_flowrate] = server_communication_result;
297 std::copy(begin(server_communication_Tin_value),
298 end(server_communication_Tin_value),
300 std::copy(begin(server_communication_flowrate),
301 end(server_communication_flowrate),
307 std::vector<std::vector<MeshLib::Node*>>
const& all_bhe_nodes)
309 const int process_id = 0;
315 for (
int bhe_i = 0; bhe_i < n_BHEs; bhe_i++)
317 auto const& bhe_nodes = all_bhe_nodes[bhe_i];
321 const int variable_id = bhe_i + 1;
323 std::vector<MeshLib::Node*> bhe_boundary_nodes;
327 for (
auto const& bhe_node : bhe_nodes)
330 auto const& connected_elements =
332 const std::size_t n_line_elements = std::count_if(
333 connected_elements.begin(), connected_elements.end(),
335 { return (elem->getDimension() == 1); });
337 if (n_line_elements == 1)
339 bhe_boundary_nodes.push_back(bhe_node);
343 if (bhe_boundary_nodes.size() != 2)
346 "Error!!! The BHE boundary nodes are not correctly found, "
347 "for every single BHE, there should be 2 boundary nodes.");
362 if ((*bhe_boundary_nodes[0])[2] == (*bhe_boundary_nodes[1])[2])
365 "For 1P-type BHE, the BHE inflow and outflow "
366 "nodes are identified according to their mesh node id in "
374 if ((*bhe_boundary_nodes[0])[2] < (*bhe_boundary_nodes[1])[2])
376 std::swap(bhe_boundary_nodes[0], bhe_boundary_nodes[1]);
380 auto get_global_index =
381 [&](std::size_t
const node_id,
int const component)
385 variable_id, component);
388 auto get_global_bhe_bc_indices =
390 std::pair<std::size_t ,
int >, 2>
391 nodes_and_components)
393 return std::make_pair(
394 get_global_index(nodes_and_components[0].first,
395 nodes_and_components[0].second),
396 get_global_index(nodes_and_components[1].first,
397 nodes_and_components[1].second));
401 [&, bc_top_node_id = bhe_boundary_nodes[0]->getID(),
402 bc_bottom_node_id = bhe_boundary_nodes[1]->getID()](
auto& bhe)
404 for (
auto const& in_out_component_id :
405 bhe.inflow_outflow_bc_component_ids)
407 if (bhe.use_python_bcs ||
411 #ifdef OGS_USE_PYTHON
415 bcs.addBoundaryCondition(
417 get_global_bhe_bc_indices(
418 bhe.getBHEInflowDirichletBCNodesAndComponents(
419 bc_top_node_id, bc_bottom_node_id,
420 in_out_component_id.first)),
427 "The Python Boundary Condition was switched on, "
428 "but the data object does not exist! ");
432 "The Python Boundary Condition was switched off! "
433 "Not able to create Boundary Condition for BHE! ");
439 bcs.addBoundaryCondition(
441 get_global_bhe_bc_indices(
442 bhe.getBHEInflowDirichletBCNodesAndComponents(
443 bc_top_node_id, bc_bottom_node_id,
444 in_out_component_id.first)),
445 [&bhe](
double const T,
double const t) {
446 return bhe.updateFlowRateAndTemperature(T, t);
450 auto const bottom_nodes_and_components =
451 bhe.getBHEBottomDirichletBCNodesAndComponents(
453 in_out_component_id.first,
454 in_out_component_id.second);
456 if (bottom_nodes_and_components)
459 bcs.addBoundaryCondition(
461 get_global_bhe_bc_indices(
462 {{{bc_bottom_node_id,
463 in_out_component_id.first},
465 in_out_component_id.second}}})));
void INFO(char const *fmt, Args const &... args)
void DBUG(char const *fmt, Args const &... args)
Global vector based on Eigen vector.
bool isAxiallySymmetric() const
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
std::size_t getID() const
Get id of the mesh.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
std::vector< Element const * > const & getElementsConnectedToNode(std::size_t node_id) const
std::tuple< double, std::vector< double >, std::vector< double >, std::vector< int >, std::vector< double > > dataframe_network
bool isOverriddenTespy() const
bool isOverriddenServerCommunication() const
virtual std::tuple< std::vector< double >, std::vector< double > > serverCommunication(double, double, std::vector< double > const &, std::vector< double > const &, std::vector< double > const &) const
virtual std::tuple< bool, bool, std::vector< double >, std::vector< double > > tespySolver(double, std::vector< double > const &, std::vector< double > const &) const
void computeSecondaryVariableConcrete(double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_dot, int const process_id) override
void createBHEBoundaryConditionTopBottom(std::vector< std::vector< MeshLib::Node * >> const &all_bhe_nodes)
std::unique_ptr< MeshLib::MeshSubset const > _mesh_subset_soil_nodes
const BHEMeshData _bheMeshData
std::vector< std::unique_ptr< MeshLib::MeshSubset const > > _mesh_subset_BHE_nodes
void postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, const double t, const double dt, int const process_id) override
std::vector< std::unique_ptr< HeatTransportBHELocalAssemblerInterface > > _local_assemblers
HeatTransportBHEProcessData _process_data
NumLib::IterationResult postIterationConcreteProcess(GlobalVector const &x) override
void assembleWithJacobianConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, const double dxdot_dx, const double dx_dx, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac) override
void assembleConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
void constructDofTable() override
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
HeatTransportBHEProcess(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const ¶meters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable >>> &&process_variables, HeatTransportBHEProcessData &&process_data, SecondaryVariableCollection &&secondary_variables)
virtual void computeSecondaryVariable(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_dot, int const process_id)
std::vector< std::size_t > const & getActiveElementIDs() const
std::vector< BoundaryConditionCollection > _boundary_conditions
std::unique_ptr< MeshLib::MeshSubset const > _mesh_subset_all_nodes
std::vector< std::reference_wrapper< ProcessVariable > > const & getProcessVariables(const int process_id) const
VectorMatrixAssembler _global_assembler
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _local_to_global_index_map
Handles configuration of several secondary variables from the project file.
void assembleWithJacobian(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< std::reference_wrapper< NumLib::LocalToGlobalIndexMap >> const &dof_tables, const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, const double dxdot_dx, const double dx_dx, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac)
void assemble(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< std::reference_wrapper< NumLib::LocalToGlobalIndexMap >> const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b)
IterationResult
Status flags telling the NonlinearSolver if an iteration succeeded.
void copy(PETScVector const &x, PETScVector &y)
PropertyVector< int > const * materialIDs(Mesh const &mesh)
@ BY_COMPONENT
Ordering data by component type.
std::unique_ptr< BHEBottomDirichletBoundaryCondition > createBHEBottomDirichletBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices)
BHEMeshData getBHEDataInMesh(MeshLib::Mesh const &mesh)
std::unique_ptr< BHEInflowDirichletBoundaryCondition< BHEUpdateCallback > > createBHEInflowDirichletBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices, BHEUpdateCallback bhe_update_callback)
void createLocalAssemblers(std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< std::unique_ptr< LocalAssemblerInterface >> &local_assemblers, ExtraCtorArgs &&... extra_ctor_args)
std::unique_ptr< BHEInflowPythonBoundaryCondition< BHEType > > createBHEInflowPythonBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices, BHEType &bhe, BHEInflowPythonBoundaryConditionPythonSideInterface &py_bc_object)
static void executeSelectedMemberOnDereferenced(Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)
static void executeSelectedMemberDereferenced(Object &object, Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)
std::vector< std::vector< MeshLib::Node * > > BHE_nodes
std::vector< std::vector< MeshLib::Element * > > BHE_elements
std::vector< int > BHE_mat_IDs
MeshLib::PropertyVector< int > const * _mesh_prop_materialIDs
BHEInflowPythonBoundaryConditionPythonSideInterface * py_bc_object
Python object computing BC values.
std::unordered_map< int, int > _map_materialID_to_BHE_ID
std::vector< BHE::BHETypes > _vec_BHE_property
const bool _use_server_communication