OGS
BHE_1U.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <Eigen/Core>
14#include <optional>
15
16#include "BHECommon.h"
17#include "BHECommonUType.h"
18#include "BaseLib/Error.h"
21
22namespace ProcessLib
23{
24namespace HeatTransportBHE
25{
26namespace BHE
27{
41class BHE_1U final : public BHECommonUType
42{
43public:
44 BHE_1U(BoreholeGeometry const& borehole,
48 PipeConfigurationUType const& pipes,
49 bool const use_python_bcs);
50
51 static constexpr int number_of_unknowns = 4;
52 static constexpr int number_of_grout_zones = 2;
53
54 std::array<double, number_of_unknowns> pipeHeatCapacities() const;
55
56 std::array<double, number_of_unknowns> pipeHeatConductions() const;
57
58 std::array<Eigen::Vector3d, number_of_unknowns> pipeAdvectionVectors(
59 Eigen::Vector3d const& /*elem_direction*/) const;
60
61 template <int NPoints,
62 typename SingleUnknownMatrixType,
63 typename RMatrixType,
64 typename RPiSMatrixType,
65 typename RSMatrixType>
66 static void assembleRMatrices(
67 int const idx_bhe_unknowns,
68 Eigen::MatrixBase<SingleUnknownMatrixType> const& matBHE_loc_R,
69 Eigen::MatrixBase<RMatrixType>& R_matrix,
70 Eigen::MatrixBase<RPiSMatrixType>& R_pi_s_matrix,
71 Eigen::MatrixBase<RSMatrixType>& R_s_matrix)
72 {
73 switch (idx_bhe_unknowns)
74 {
75 case 0: // PHI_fig
76 R_matrix.block(0, 2 * NPoints, NPoints, NPoints) +=
77 -1.0 * matBHE_loc_R;
78 R_matrix.block(2 * NPoints, 0, NPoints, NPoints) +=
79 -1.0 * matBHE_loc_R;
80
81 R_matrix.block(0, 0, NPoints, NPoints) +=
82 1.0 * matBHE_loc_R; // K_i1
83 R_matrix.block(2 * NPoints, 2 * NPoints, NPoints, NPoints) +=
84 1.0 * matBHE_loc_R; // K_ig
85 return;
86 case 1: // PHI_fog
87 R_matrix.block(NPoints, 3 * NPoints, NPoints, NPoints) +=
88 -1.0 * matBHE_loc_R;
89 R_matrix.block(3 * NPoints, NPoints, NPoints, NPoints) +=
90 -1.0 * matBHE_loc_R;
91
92 R_matrix.block(NPoints, NPoints, NPoints, NPoints) +=
93 1.0 * matBHE_loc_R; // K_o1
94 R_matrix.block(3 * NPoints, 3 * NPoints, NPoints, NPoints) +=
95 1.0 * matBHE_loc_R; // K_og
96 return;
97 case 2: // PHI_gg
98 R_matrix.block(2 * NPoints, 3 * NPoints, NPoints, NPoints) +=
99 -1.0 * matBHE_loc_R;
100 R_matrix.block(3 * NPoints, 2 * NPoints, NPoints, NPoints) +=
101 -1.0 * matBHE_loc_R;
102
103 R_matrix.block(2 * NPoints, 2 * NPoints, NPoints, NPoints) +=
104 1.0 * matBHE_loc_R; // K_ig // notice we only have
105 // 1 PHI_gg term here.
106 R_matrix.block(3 * NPoints, 3 * NPoints, NPoints, NPoints) +=
107 1.0 * matBHE_loc_R; // K_og // see Diersch 2013 FEFLOW
108 // book page 954 Table M.2
109 return;
110 case 3: // PHI_gs
111 R_s_matrix.template block<NPoints, NPoints>(0, 0).noalias() +=
112 1.0 * matBHE_loc_R;
113
114 R_pi_s_matrix.block(2 * NPoints, 0, NPoints, NPoints) +=
115 -1.0 * matBHE_loc_R;
116 R_pi_s_matrix.block(3 * NPoints, 0, NPoints, NPoints) +=
117 -1.0 * matBHE_loc_R;
118 R_matrix.block(2 * NPoints, 2 * NPoints, NPoints, NPoints) +=
119 1.0 * matBHE_loc_R; // K_ig
120 R_matrix.block(3 * NPoints, 3 * NPoints, NPoints, NPoints) +=
121 1.0 * matBHE_loc_R; // K_og
122 return;
123 default:
124 OGS_FATAL(
125 "Error!!! In the function BHE_1U::assembleRMatrices, "
126 "the index of bhe unknowns is out of range! ");
127 }
128 }
129
131 double updateFlowRateAndTemperature(double T_out, double current_time);
132
133 double thermalResistance(int const unknown_index) const
134 {
135 return _thermal_resistances[unknown_index];
136 }
137
138 static constexpr std::pair<int, int> inflow_outflow_bc_component_ids[] = {
139 {0, 1}};
140
141 static std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>
143 std::size_t const top_node_id,
144 std::size_t const /*bottom_node_id*/,
145 int const in_component_id);
146 static std::optional<
147 std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>>
148 getBHEBottomDirichletBCNodesAndComponents(std::size_t const bottom_node_id,
149 int const in_component_id,
150 int const out_component_id);
151
152public:
153 std::array<double, number_of_unknowns> crossSectionAreas() const;
154
155 void updateHeatTransferCoefficients(double const flow_rate);
156
157private:
158 std::array<double, number_of_unknowns> calcThermalResistances(
159 double const Nu);
160
161private:
168 std::array<double, number_of_unknowns> _thermal_resistances;
169};
170} // namespace BHE
171} // namespace HeatTransportBHE
172} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
static constexpr std::pair< int, int > inflow_outflow_bc_component_ids[]
Definition BHE_1U.h:138
std::array< Eigen::Vector3d, number_of_unknowns > pipeAdvectionVectors(Eigen::Vector3d const &) const
Definition BHE_1U.cpp:88
double updateFlowRateAndTemperature(double T_out, double current_time)
Return the inflow temperature for the boundary condition.
Definition BHE_1U.cpp:262
static constexpr int number_of_unknowns
Definition BHE_1U.h:51
static void assembleRMatrices(int const idx_bhe_unknowns, Eigen::MatrixBase< SingleUnknownMatrixType > const &matBHE_loc_R, Eigen::MatrixBase< RMatrixType > &R_matrix, Eigen::MatrixBase< RPiSMatrixType > &R_pi_s_matrix, Eigen::MatrixBase< RSMatrixType > &R_s_matrix)
Definition BHE_1U.h:66
static std::optional< std::array< std::pair< std::size_t, int >, 2 > > getBHEBottomDirichletBCNodesAndComponents(std::size_t const bottom_node_id, int const in_component_id, int const out_component_id)
Definition BHE_1U.cpp:246
std::array< double, number_of_unknowns > calcThermalResistances(double const Nu)
Nu is the Nusselt number.
Definition BHE_1U.cpp:173
std::array< double, number_of_unknowns > pipeHeatConductions() const
Definition BHE_1U.cpp:61
std::array< double, number_of_unknowns > _thermal_resistances
Definition BHE_1U.h:168
static constexpr int number_of_grout_zones
Definition BHE_1U.h:52
std::array< double, number_of_unknowns > crossSectionAreas() const
Definition BHE_1U.cpp:255
void updateHeatTransferCoefficients(double const flow_rate)
Definition BHE_1U.cpp:161
double thermalResistance(int const unknown_index) const
Definition BHE_1U.h:133
BHE_1U(BoreholeGeometry const &borehole, RefrigerantProperties const &refrigerant, GroutParameters const &grout, FlowAndTemperatureControl const &flowAndTemperatureControl, PipeConfigurationUType const &pipes, bool const use_python_bcs)
Definition BHE_1U.cpp:25
static std::array< std::pair< std::size_t, int >, 2 > getBHEInflowDirichletBCNodesAndComponents(std::size_t const top_node_id, std::size_t const, int const in_component_id)
Definition BHE_1U.cpp:235
std::array< double, number_of_unknowns > pipeHeatCapacities() const
Definition BHE_1U.cpp:46
std::variant< TemperatureCurveConstantFlow, TemperatureCurveFlowCurve, FixedPowerConstantFlow, FixedPowerFlowCurve, PowerCurveConstantFlow, PowerCurveFlowCurve, BuildingPowerCurveConstantFlow > FlowAndTemperatureControl
RefrigerantProperties const refrigerant
Definition BHECommon.h:42
FlowAndTemperatureControl const flowAndTemperatureControl
Definition BHECommon.h:44