Skip to content

Commit 057da5b

Browse files
authored
Merge pull request #1382 from su2code/feature_heat_bcperiodic
Add periodic boundary conditions to the heat-equation solver
2 parents 6338bff + 3d52392 commit 057da5b

5 files changed

Lines changed: 155 additions & 4 deletions

File tree

SU2_CFD/include/solvers/CHeatSolver.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,15 @@ class CHeatSolver final : public CSolver {
247247
CConfig *config,
248248
unsigned short val_marker) override;
249249

250+
/*!
251+
* \brief Impose a periodic boundary condition by summing contributions from the complete control volume.
252+
* \param[in] geometry - Geometrical definition of the problem.
253+
* \param[in] solver_container - Container vector with all the solutions.
254+
* \param[in] numerics - Description of the numerical method.
255+
* \param[in] config - Definition of the particular problem.
256+
*/
257+
void BC_Periodic(CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, CConfig* config) final;
258+
250259
/*!
251260
* \brief Set the conjugate heat variables.
252261
* \param[in] val_marker - marker index

SU2_CFD/src/solvers/CHeatSolver.cpp

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ CHeatSolver::CHeatSolver(CGeometry *geometry, CConfig *config, unsigned short iM
159159

160160
SetBaseClassPointerToNodes();
161161

162+
/*--- Communicate and store volume and the number of neighbors for any dual CVs that lie on on periodic markers. ---*/
163+
for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic() / 2; iPeriodic++) {
164+
InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_VOLUME);
165+
CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_VOLUME);
166+
InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_NEIGHBORS);
167+
CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_NEIGHBORS);
168+
}
169+
/*--- Store if implicit scheme is used. This has implications on the Residual and Jacobian handling for periodic
170+
* boundaries ---*/
171+
const bool euler_implicit = (config->GetKind_TimeIntScheme_Heat() == EULER_IMPLICIT);
172+
SetImplicitPeriodic(euler_implicit);
173+
174+
162175
/*--- MPI solution ---*/
163176

164177
InitiateComms(geometry, config, SOLUTION);
@@ -893,6 +906,20 @@ void CHeatSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solv
893906
}
894907
}
895908

909+
void CHeatSolver::BC_Periodic(CGeometry* geometry, CSolver** solver_container, CNumerics* numerics,
910+
CConfig* config) {
911+
/*--- Complete residuals for periodic boundary conditions. We loop over
912+
the periodic BCs in matching pairs so that, in the event that there are
913+
adjacent periodic markers, the repeated points will have their residuals
914+
accumulated corectly during the communications. For implicit calculations
915+
the Jacobians and linear system are also correctly adjusted here. ---*/
916+
917+
for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic() / 2; iPeriodic++) {
918+
InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_RESIDUAL);
919+
CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_RESIDUAL);
920+
}
921+
}
922+
896923
void CHeatSolver::Heat_Fluxes(CGeometry *geometry, CSolver **solver_container, CConfig *config) {
897924

898925
unsigned long iPointNormal;
@@ -1274,11 +1301,12 @@ void CHeatSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_
12741301

12751302
/*--- Modify matrix diagonal to assure diagonal dominance ---*/
12761303

1277-
if (nodes->GetDelta_Time(iPoint) != 0.0) {
1278-
1304+
const su2double dt = nodes->GetDelta_Time(iPoint);
1305+
if (dt != 0.0) {
1306+
/*--- For nodes on periodic boundaries, add the respective partner volume. ---*/
12791307
// Identical for flow and heat
1280-
const su2double Delta = geometry->nodes->GetVolume(iPoint) / nodes->GetDelta_Time(iPoint);
1281-
Jacobian.AddVal2Diag(iPoint, Delta);
1308+
const su2double Vol = geometry->nodes->GetVolume(iPoint) + geometry->nodes->GetPeriodicVolume(iPoint);
1309+
Jacobian.AddVal2Diag(iPoint, Vol / dt);
12821310

12831311
} else {
12841312
Jacobian.SetVal2Diag(iPoint, 1.0);
@@ -1326,6 +1354,12 @@ void CHeatSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_
13261354
}
13271355
}
13281356

1357+
/*--- Synchronize the solution between master and passive periodic nodes after the linear solve. ---*/
1358+
for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic() / 2; iPeriodic++) {
1359+
InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT);
1360+
CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_IMPLICIT);
1361+
}
1362+
13291363
/*--- MPI solution ---*/
13301364

13311365
InitiateComms(geometry, config, SOLUTION);

TestCases/parallel_regression.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,22 @@ def main():
12581258
p1rad.tol = 0.00001
12591259
test_list.append(p1rad)
12601260

1261+
1262+
# #############################
1263+
# ### Solid Heat Conduction ###
1264+
# #############################
1265+
1266+
# 2D pins, periodically connected
1267+
solid_periodic_pins = TestCase('solid_periodic_pins')
1268+
solid_periodic_pins.cfg_dir = "solid_heat_conduction/periodic_pins"
1269+
solid_periodic_pins.cfg_file = "configSolid.cfg"
1270+
solid_periodic_pins.test_iter = 750
1271+
solid_periodic_pins.test_vals = [-15.739745, -14.448665, 300.900000, 425.320000, 0.000000, 5.000000, -1.448445] #last 7 lines
1272+
solid_periodic_pins.su2_exec = "mpirun -n 2 SU2_CFD"
1273+
solid_periodic_pins.timeout = 1600
1274+
solid_periodic_pins.tol = 0.00001
1275+
test_list.append(solid_periodic_pins)
1276+
12611277
# ###############################
12621278
# ### Conjugate heat transfer ###
12631279
# ###############################
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Periodic Pins
2+
3+
This a solid heat conduction testcase in which the `HEAT_EQUATION` solver runs standalone (i.e. not as CHT).
4+
The simulation domain is the solid domain of the `incomp_navierstokes/streamwise_periodic/chtPinArray_2d`-Testcase.
5+
Therefore the provided gmsh `.geo` file contains the full CHT mesh but only writes out the solid zone when called.
6+
7+
Note that using periodic boundary conditions for the solid zone made the solution take ~10x more iterations to converge , compared to the same setup using adiabatic walls.
8+
This was found for solid only as well as CHT cases.
9+
10+
Expected results are perfectly matched Temperatures at the periodic interface. Compare e.g. using Paraview's `Transform`-Filter with domain length 0.0111544m.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2+
% %
3+
% SU2 configuration file %
4+
% Case description: Solid-only Heated Pins, periodically connected %
5+
% Author: T. Kattmann %
6+
% Institution: Bosch Thermotechniek B.V. %
7+
% Date: 2021.09.27 %
8+
% File Version 7.2.0 "Blackbird" %
9+
% %
10+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11+
%
12+
% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------%
13+
%
14+
SOLVER= HEAT_EQUATION
15+
%
16+
OBJECTIVE_FUNCTION= AVG_TEMPERATURE
17+
OBJECTIVE_WEIGHT= 1.0
18+
%
19+
OPT_OBJECTIVE= AVG_TOTALTEMP
20+
%
21+
% ---------------- (SOLIDS) CONDUCTION CONDITION DEFINITION -------------------%
22+
%
23+
INC_NONDIM= DIMENSIONAL
24+
FREESTREAM_TEMPERATURE= 345.0
25+
MATERIAL_DENSITY= 2719
26+
SPECIFIC_HEAT_CP = 871.0
27+
THERMAL_CONDUCTIVITY_CONSTANT= 200
28+
%
29+
% -------------------- BOUNDARY CONDITION DEFINITION --------------------------%
30+
%
31+
MARKER_HEATFLUX= (solid_pin1_inner, 5e5, \
32+
solid_pin2_inner, 5e5, \
33+
solid_pin3_inner, 0.0, \
34+
solid_pin1_walls, 0.0, \
35+
solid_pin2_walls, 0.0, \
36+
solid_pin3_walls, 0.0)
37+
%
38+
MARKER_PERIODIC= ( solid_pin1_periodic, solid_pin3_periodic, 0.0,0.0,0.0, 0.0,0.0,0.0, 0.0111544,0.0,0.0 )
39+
%
40+
MARKER_ISOTHERMAL= ( solid_pin1_interface, 300, solid_pin2_interface, 300, solid_pin3_interface, 300 )
41+
%
42+
% ------------------------ SURFACES IDENTIFICATION ----------------------------%
43+
%
44+
MARKER_MONITORING = ( solid_pin1_inner, solid_pin3_inner )
45+
%
46+
% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------%
47+
%
48+
%NUM_METHOD_GRAD= GREEN_GAUSS
49+
NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES
50+
CFL_NUMBER= 1e8
51+
%
52+
% ------------------------ LINEAR SOLVER DEFINITION ---------------------------%
53+
%
54+
LINEAR_SOLVER= FGMRES
55+
LINEAR_SOLVER_PREC= ILU
56+
LINEAR_SOLVER_ERROR= 1E-15
57+
LINEAR_SOLVER_ITER= 5
58+
%
59+
% --------------------------- CONVERGENCE PARAMETERS --------------------------%
60+
%
61+
ITER= 1000
62+
%
63+
CONV_FIELD= RMS_TEMPERATURE
64+
CONV_RESIDUAL_MINVAL= -16
65+
CONV_STARTITER= 10
66+
%
67+
% -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------%
68+
%
69+
TIME_DISCRE_HEAT= EULER_IMPLICIT
70+
%
71+
% ------------------------- INPUT/OUTPUT INFORMATION --------------------------%
72+
%
73+
MESH_FILENAME= solid.su2
74+
%
75+
SCREEN_OUTPUT= INNER_ITER, RMS_TEMPERATURE, MAX_TEMPERATURE, AVG_TEMPERATURE, TOTAL_HEATFLUX, MAXIMUM_HEATFLUX, LINSOL_ITER, LINSOL_RESIDUAL
76+
SCREEN_WRT_FREQ_INNER= 50
77+
%
78+
HISTORY_OUTPUT= (ITER, RMS_RES, HEAT, LINSOL)
79+
%
80+
OUTPUT_FILES= RESTART, PARAVIEW_MULTIBLOCK
81+
VOLUME_OUTPUT= RESIDUAL
82+
OUTPUT_WRT_FREQ= 1000

0 commit comments

Comments
 (0)