OGS
BHE_2U.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_2U final : public BHECommonUType
42{
43public:
44 BHE_2U(BoreholeGeometry const& borehole,
48 PipeConfigurationUType const& pipes,
49 bool const use_python_bcs);
50
51 static constexpr int number_of_unknowns = 8;
52 static constexpr int number_of_grout_zones = 4;
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, 4 * NPoints, NPoints, NPoints) +=
77 -1.0 * matBHE_loc_R;
78 R_matrix.block(4 * NPoints, 0, NPoints, NPoints) +=
79 -1.0 * matBHE_loc_R; // R_i1
80
81 R_matrix.block(2, 5 * NPoints, NPoints, NPoints) +=
82 -1.0 * matBHE_loc_R;
83 R_matrix.block(5 * NPoints, 2, NPoints, NPoints) +=
84 -1.0 * matBHE_loc_R; // R_i2
85
86 R_matrix.block(0, 0, NPoints, NPoints) +=
87 1.0 * matBHE_loc_R; // K_i1
88 R_matrix.block(NPoints, NPoints, NPoints, NPoints) +=
89 1.0 * matBHE_loc_R; // K_i2
90 R_matrix.block(4 * NPoints, 4 * NPoints, NPoints, NPoints) +=
91 1.0 * matBHE_loc_R;
92 R_matrix.block(5 * NPoints, 5 * NPoints, NPoints, NPoints) +=
93 1.0 * matBHE_loc_R; // K_ig
94 return;
95 case 1: // PHI_fog
96 R_matrix.block(2 * NPoints, 6 * NPoints, NPoints, NPoints) +=
97 -1.0 * matBHE_loc_R;
98 R_matrix.block(6 * NPoints, 2 * NPoints, NPoints, NPoints) +=
99 -1.0 * matBHE_loc_R; // R_o1
100 R_matrix.block(3 * NPoints, 7 * NPoints, NPoints, NPoints) +=
101 -1.0 * matBHE_loc_R;
102 R_matrix.block(7 * NPoints, 3 * NPoints, NPoints, NPoints) +=
103 -1.0 * matBHE_loc_R; // R_o2
104
105 R_matrix.block(2 * NPoints, 2 * NPoints, NPoints, NPoints) +=
106 1.0 * matBHE_loc_R; // K_o1
107 R_matrix.block(3 * NPoints, 3 * NPoints, NPoints, NPoints) +=
108 1.0 * matBHE_loc_R; // K_o2
109 R_matrix.block(6 * NPoints, 6 * NPoints, NPoints, NPoints) +=
110 1.0 * matBHE_loc_R;
111 R_matrix.block(7 * NPoints, 7 * NPoints, NPoints, NPoints) +=
112 1.0 * matBHE_loc_R; // K_og
113 return;
114 case 2: // PHI_gg_1
115 R_matrix.block(4 * NPoints, 6 * NPoints, NPoints, NPoints) +=
116 -1.0 * matBHE_loc_R;
117 R_matrix.block(6 * NPoints, 4 * NPoints, NPoints, NPoints) +=
118 -1.0 * matBHE_loc_R;
119 R_matrix.block(4 * NPoints, 7 * NPoints, NPoints, NPoints) +=
120 -1.0 * matBHE_loc_R;
121 R_matrix.block(7 * NPoints, 4 * NPoints, NPoints, NPoints) +=
122 -1.0 * matBHE_loc_R;
123 R_matrix.block(5 * NPoints, 6 * NPoints, NPoints, NPoints) +=
124 -1.0 * matBHE_loc_R;
125 R_matrix.block(6 * NPoints, 5 * NPoints, NPoints, NPoints) +=
126 -1.0 * matBHE_loc_R;
127 R_matrix.block(5 * NPoints, 7 * NPoints, NPoints, NPoints) +=
128 -1.0 * matBHE_loc_R;
129 R_matrix.block(7 * NPoints, 5 * NPoints, NPoints, NPoints) +=
130 -1.0 * matBHE_loc_R; // R_g1
131
132 R_matrix.block(4 * NPoints, 4 * NPoints, NPoints, NPoints) +=
133 2.0 * matBHE_loc_R;
134 R_matrix.block(5 * NPoints, 5 * NPoints, NPoints, NPoints) +=
135 2.0 * matBHE_loc_R; // K_ig // notice we have two
136 // PHI_gg_1 term here.
137 R_matrix.block(6 * NPoints, 6 * NPoints, NPoints, NPoints) +=
138 2.0 * matBHE_loc_R;
139 R_matrix.block(7 * NPoints, 7 * NPoints, NPoints, NPoints) +=
140 2.0 * matBHE_loc_R; // K_og // see Diersch 2013 FEFLOW
141 // book page 954 Table M.2
142 return;
143 case 3: // PHI_gg_2
144 R_matrix.block(4 * NPoints, 5 * NPoints, NPoints, NPoints) +=
145 -1.0 * matBHE_loc_R;
146 R_matrix.block(5 * NPoints, 4 * NPoints, NPoints, NPoints) +=
147 -1.0 * matBHE_loc_R;
148 R_matrix.block(6 * NPoints, 7 * NPoints, NPoints, NPoints) +=
149 -1.0 * matBHE_loc_R;
150 R_matrix.block(7 * NPoints, 6 * NPoints, NPoints, NPoints) +=
151 -1.0 * matBHE_loc_R; // R_g2
152
153 R_matrix.block(4 * NPoints, 4 * NPoints, NPoints, NPoints) +=
154 1.0 * matBHE_loc_R;
155 R_matrix.block(5 * NPoints, 5 * NPoints, NPoints, NPoints) +=
156 1.0 * matBHE_loc_R; // K_ig // notice we only have
157 // 1 PHI_gg term here.
158 R_matrix.block(6 * NPoints, 6 * NPoints, NPoints, NPoints) +=
159 1.0 * matBHE_loc_R;
160 R_matrix.block(7 * NPoints, 7 * NPoints, NPoints, NPoints) +=
161 1.0 * matBHE_loc_R; // K_og // see Diersch 2013 FEFLOW
162 // book page 954 Table M.2
163 return;
164 case 4: // PHI_gs
165 R_s_matrix.template block<NPoints, NPoints>(0, 0).noalias() +=
166 1.0 * matBHE_loc_R;
167
168 R_pi_s_matrix.block(4 * NPoints, 0, NPoints, NPoints) +=
169 -1.0 * matBHE_loc_R;
170 R_pi_s_matrix.block(5 * NPoints, 0, NPoints, NPoints) +=
171 -1.0 * matBHE_loc_R;
172 R_pi_s_matrix.block(6 * NPoints, 0, NPoints, NPoints) +=
173 -1.0 * matBHE_loc_R;
174 R_pi_s_matrix.block(7 * NPoints, 0, NPoints, NPoints) +=
175 -1.0 * matBHE_loc_R;
176 R_matrix.block(4 * NPoints, 4 * NPoints, NPoints, NPoints) +=
177 1.0 * matBHE_loc_R;
178 R_matrix.block(5 * NPoints, 5 * NPoints, NPoints, NPoints) +=
179 1.0 * matBHE_loc_R; // K_ig
180 R_matrix.block(6 * NPoints, 6 * NPoints, NPoints, NPoints) +=
181 1.0 * matBHE_loc_R;
182 R_matrix.block(7 * NPoints, 7 * NPoints, NPoints, NPoints) +=
183 1.0 * matBHE_loc_R; // K_og
184 return;
185 default:
186 OGS_FATAL(
187 "Error!!! In the function BHE_2U::assembleRMatrices, "
188 "the index of bhe unknowns is out of range! ");
189 }
190 }
191
193 double updateFlowRateAndTemperature(double T_out, double current_time);
194
195 double thermalResistance(int const unknown_index) const
196 {
197 return _thermal_resistances[unknown_index];
198 }
199
200 static constexpr std::pair<int, int> inflow_outflow_bc_component_ids[] = {
201 {0, 2}, {1, 3}};
202
203 static std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>
205 std::size_t const top_node_id,
206 std::size_t const /*bottom_node_id*/,
207 int const in_component_id);
208
209 static std::optional<
210 std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>>
211 getBHEBottomDirichletBCNodesAndComponents(std::size_t const bottom_node_id,
212 int const in_component_id,
213 int const out_component_id);
214
215public:
216 std::array<double, number_of_unknowns> crossSectionAreas() const;
217
218 void updateHeatTransferCoefficients(double const flow_rate);
219
220private:
221 std::array<double, number_of_unknowns> calcThermalResistances(
222 double const Nu);
223
224private:
231 std::array<double, number_of_unknowns> _thermal_resistances;
232};
233} // namespace BHE
234} // namespace HeatTransportBHE
235} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
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_2U.cpp:264
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_2U.h:66
std::array< double, number_of_unknowns > calcThermalResistances(double const Nu)
Nu is the Nusselt number.
Definition BHE_2U.cpp:193
static constexpr int number_of_unknowns
Definition BHE_2U.h:51
static constexpr std::pair< int, int > inflow_outflow_bc_component_ids[]
Definition BHE_2U.h:200
void updateHeatTransferCoefficients(double const flow_rate)
Definition BHE_2U.cpp:181
std::array< double, number_of_unknowns > _thermal_resistances
Definition BHE_2U.h:231
std::array< double, number_of_unknowns > pipeHeatConductions() const
Definition BHE_2U.cpp:65
std::array< Eigen::Vector3d, number_of_unknowns > pipeAdvectionVectors(Eigen::Vector3d const &) const
Definition BHE_2U.cpp:98
double updateFlowRateAndTemperature(double T_out, double current_time)
Return the inflow temperature for the boundary condition.
Definition BHE_2U.cpp:298
std::array< double, number_of_unknowns > pipeHeatCapacities() const
Definition BHE_2U.cpp:46
BHE_2U(BoreholeGeometry const &borehole, RefrigerantProperties const &refrigerant, GroutParameters const &grout, FlowAndTemperatureControl const &flowAndTemperatureControl, PipeConfigurationUType const &pipes, bool const use_python_bcs)
Definition BHE_2U.cpp:25
std::array< double, number_of_unknowns > crossSectionAreas() const
Definition BHE_2U.cpp:284
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_2U.cpp:275
static constexpr int number_of_grout_zones
Definition BHE_2U.h:52
double thermalResistance(int const unknown_index) const
Definition BHE_2U.h:195
std::variant< TemperatureCurveConstantFlow, TemperatureCurveFlowCurve, FixedPowerConstantFlow, FixedPowerFlowCurve, PowerCurveConstantFlow, PowerCurveFlowCurve, BuildingPowerCurveConstantFlow > FlowAndTemperatureControl
RefrigerantProperties const refrigerant
Definition BHECommon.h:42
FlowAndTemperatureControl const flowAndTemperatureControl
Definition BHECommon.h:44