From 8a75d92abed31b8a94dcc769e43c074cb70c3993 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Fri, 15 Mar 2019 22:13:15 +0100 Subject: [PATCH] [PL] Resolve circular dep. HTBHE<->BC. Passing the bhe type to the BCs is not necessary, just a callback. --- .../BHEInflowDirichletBoundaryCondition.h | 23 ++++++++++--------- .../HeatTransportBHEProcess.cpp | 4 +++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ProcessLib/BoundaryCondition/BHEInflowDirichletBoundaryCondition.h b/ProcessLib/BoundaryCondition/BHEInflowDirichletBoundaryCondition.h index 8a2a1bffe4a..dc32752d66a 100644 --- a/ProcessLib/BoundaryCondition/BHEInflowDirichletBoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/BHEInflowDirichletBoundaryCondition.h @@ -11,18 +11,18 @@ #include "BoundaryCondition.h" #include "NumLib/IndexValueVector.h" -#include "ProcessLib/HeatTransportBHE/BHE/BHETypes.h" namespace ProcessLib { -template <typename BHEType> +template <typename BHEUpdateCallback> class BHEInflowDirichletBoundaryCondition final : public BoundaryCondition { public: BHEInflowDirichletBoundaryCondition( std::pair<GlobalIndexType, GlobalIndexType>&& in_out_global_indices, - BHEType& bhe) - : _in_out_global_indices(std::move(in_out_global_indices)), _bhe(bhe) + BHEUpdateCallback bhe_update_callback) + : _in_out_global_indices(std::move(in_out_global_indices)), + _bhe_update_callback(bhe_update_callback) { } @@ -36,19 +36,19 @@ public: bc_values.ids[0] = _in_out_global_indices.first; // here call the corresponding BHE functions auto const T_out = x[_in_out_global_indices.second]; - bc_values.values[0] = _bhe.updateFlowRateAndTemperature(T_out, t); + bc_values.values[0] = _bhe_update_callback(T_out, t); } private: std::pair<GlobalIndexType, GlobalIndexType> const _in_out_global_indices; - BHEType& _bhe; + BHEUpdateCallback _bhe_update_callback; }; -template <typename BHEType> -std::unique_ptr<BHEInflowDirichletBoundaryCondition<BHEType>> +template <typename BHEUpdateCallback> +std::unique_ptr<BHEInflowDirichletBoundaryCondition<BHEUpdateCallback>> createBHEInflowDirichletBoundaryCondition( std::pair<GlobalIndexType, GlobalIndexType>&& in_out_global_indices, - BHEType& bhe) + BHEUpdateCallback bhe_update_callback) { DBUG("Constructing BHEInflowDirichletBoundaryCondition."); @@ -71,7 +71,8 @@ createBHEInflowDirichletBoundaryCondition( } #endif // USE_PETSC - return std::make_unique<BHEInflowDirichletBoundaryCondition<BHEType>>( - std::move(in_out_global_indices), bhe); + return std::make_unique< + BHEInflowDirichletBoundaryCondition<BHEUpdateCallback>>( + std::move(in_out_global_indices), bhe_update_callback); } } // namespace ProcessLib diff --git a/ProcessLib/HeatTransportBHE/HeatTransportBHEProcess.cpp b/ProcessLib/HeatTransportBHE/HeatTransportBHEProcess.cpp index c1269c7d28e..fa34488ae0f 100644 --- a/ProcessLib/HeatTransportBHE/HeatTransportBHEProcess.cpp +++ b/ProcessLib/HeatTransportBHE/HeatTransportBHEProcess.cpp @@ -244,7 +244,9 @@ void HeatTransportBHEProcess::createBHEBoundaryConditionTopBottom( ProcessLib::createBHEInflowDirichletBoundaryCondition( get_global_bhe_bc_indices(bc_top_node_id, in_out_component_id), - bhe)); + [&bhe](double const T, double const t) { + return bhe.updateFlowRateAndTemperature(T, t); + })); // Bottom, outflow. bcs.addBoundaryCondition( -- GitLab