Skip to content

Commit 3548413

Browse files
committed
Add files for unsteady CHT adjoint and primal regression test.
1 parent 38afb5e commit 3548413

File tree

8 files changed

+584
-0
lines changed

8 files changed

+584
-0
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
// ----------------------------------------------------------------------------------- //
2+
// Kattmann 20.08.2018, O mesh for CHT vortex shedding behind cylinder
3+
// The O mesh around the cylinder consists out of two half cylinders.
4+
// The inner pin is hollow.
5+
// ----------------------------------------------------------------------------------- //
6+
7+
// Create fluid and solid mesh seperately and merge together e.g. by hand.
8+
9+
// Which domain part should be handled
10+
Which_Mesh_Part= 1;// 0=all, 1=Fluid, 2=Solid
11+
// Evoke Meshing Algorithm?
12+
Do_Meshing= 1; // 0=false, 1=true
13+
// Write Mesh files in .su2 format
14+
Write_mesh= 1; // 0=false, 1=true
15+
16+
//Geometric inputs
17+
cylinder_diameter = 1;
18+
cylinder_radius = cylinder_diameter/2;
19+
mesh_radius = 20 * cylinder_diameter;
20+
inner_pin_d = 0.5;
21+
inner_pin_r = inner_pin_d/2;
22+
23+
// ----------------------------------------------------------------------------------- //
24+
//Mesh inputs
25+
gridsize = 0.1;
26+
Ncylinder = 40;
27+
Nradial = 50;
28+
Rradial = 1.15;
29+
30+
NPinRadial = 10;
31+
RPinRadial = 0.91;
32+
33+
// Each zone is self-sufficient (i.e. has all of its own Points/Lines etc.)
34+
// ----------------------------------------------------------------------------------- //
35+
// Fluid zone
36+
If (Which_Mesh_Part == 0 || Which_Mesh_Part == 1)
37+
38+
// Geometry definition
39+
// Points
40+
Point(1) = {-mesh_radius, 0, 0, gridsize};
41+
Point(2) = {-cylinder_radius, 0, 0, gridsize};
42+
Point(3) = {cylinder_radius, 0, 0, gridsize};
43+
Point(4) = {mesh_radius, 0, 0, gridsize};
44+
Point(5) = {0, 0, 0, gridsize};
45+
46+
//helping point to know height of first layer
47+
//Point(6) = {-cylinder_radius - 0.002, 0, 0, gridsize};
48+
49+
// Lines
50+
Line(1) = {1, 2}; // to the left
51+
Line(2) = {3, 4}; // to the right
52+
53+
Circle(3) = {2, 5, 3}; // lower inner
54+
Circle(4) = {1, 5, 4}; // lower outer
55+
Circle(5) = {3, 5, 2}; // upper inner
56+
Circle(6) = {4, 5, 1}; // upper outer
57+
58+
// Lineloops and surfaces
59+
Line Loop(1) = {1, 3, 2, -4}; Plane Surface(1) = {1}; // lower half cylinder
60+
Line Loop(2) = {1, -5, 2, 6}; Plane Surface(2) = {2}; // upper half cylinder
61+
62+
// ----------------------------------------------------------------------------------- //
63+
// Mesh definition
64+
// make structured mesh with transfinite Lines
65+
66+
// lower
67+
Transfinite Line{3, 4} = Ncylinder;
68+
Transfinite Line{-1, 2} = Nradial Using Progression Rradial;
69+
70+
// upper
71+
Transfinite Line{-5, -6} = Ncylinder;
72+
Transfinite Line{-1, 2} = Nradial Using Progression Rradial;
73+
74+
// Physical Groups
75+
Physical Line("cylinder_fluid") = {3, 5};
76+
Physical Line("farfield") = {4, 6};
77+
Physical Surface("surface_mesh") = {1, 2};
78+
79+
EndIf
80+
81+
// ----------------------------------------------------------------------------------- //
82+
// Pin zone
83+
If (Which_Mesh_Part == 0 || Which_Mesh_Part == 2)
84+
85+
// Geometry definition
86+
// Points
87+
Point(11) = {-cylinder_radius, 0, 0, gridsize};
88+
Point(12) = {-inner_pin_r, 0, 0, gridsize};
89+
Point(13) = {inner_pin_r, 0, 0, gridsize};
90+
Point(14) = {cylinder_radius, 0, 0, gridsize};
91+
Point(15) = {0, 0, 0, gridsize};
92+
93+
// Lines
94+
Line(11) = {11, 12}; // to the left
95+
Line(12) = {13, 14}; // to the right
96+
97+
Circle(13) = {12, 15, 13}; // lower inner
98+
Circle(14) = {11, 15, 14}; // lower outer
99+
Circle(15) = {13, 15, 12}; // upper inner
100+
Circle(16) = {14, 15, 11}; // upper outer
101+
102+
// Lineloops and surfaces
103+
Line Loop(11) = {11, 13, 12, -14}; Plane Surface(11) = {11}; // lower half cylinder
104+
Line Loop(12) = {11, -15, 12, 16}; Plane Surface(12) = {12}; // upper half cylinder
105+
106+
// ----------------------------------------------------------------------------------- //
107+
// Mesh definition
108+
// make structured mesh with transfinite Lines
109+
110+
// lower
111+
Transfinite Line{13, 14} = Ncylinder;
112+
Transfinite Line{-11, 12} = NPinRadial Using Progression RPinRadial;
113+
114+
// upper
115+
Transfinite Line{-15, -16} = Ncylinder;
116+
Transfinite Line{-11, 12} = NPinRadial Using Progression RPinRadial;
117+
118+
// Physical Groups
119+
Physical Line("inner_pin") = {13, 15};
120+
Physical Line("cylinder_solid") = {14, 16};
121+
Physical Surface("surface_mesh") = {11, 12};
122+
123+
EndIf
124+
125+
// ----------------------------------------------------------------------------------- //
126+
Transfinite Surface "*";
127+
Recombine Surface "*";
128+
129+
If (Do_Meshing == 1)
130+
Mesh 1; Mesh 2;
131+
EndIf
132+
133+
// ----------------------------------------------------------------------------------- //
134+
// Write .su2 meshfile
135+
If (Write_mesh == 1)
136+
137+
Mesh.Format = 42; // .su2 mesh format,
138+
If (Which_Mesh_Part == 1)
139+
Save "fluid.su2";
140+
ElseIf (Which_Mesh_Part == 2)
141+
Save "solid.su2";
142+
Else
143+
Printf("Invalid Which_Mesh_Part variable.");
144+
Abort;
145+
EndIf
146+
147+
EndIf
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Unsteady CHT Adjoint Testcase
2+
3+
## Short Description
4+
This is a 2D cylinder in freestream testcase. The flow is incompressible and laminar at Re=200.
5+
A uniform vortex shedding forms behind the cylinder and each shedding cycle is resolved by 54 timesteps.
6+
The pin is heated on the inner surface.
7+
8+
## Mesh
9+
The mesh is for testing purposes only and contains ~4000 elements for the flow and ~1000 for the heat domain.
10+
A gmsh .geo file is added such that the mesh can be recreated and modified.
11+
12+
## Recreating full primal
13+
The primal for a full cycle can be restarted with the `solution_*_00000.dat` and `solution_*_00001.dat`.
14+
The primal solution is necessary for the Discrete Adjoint sweep and for the gradient of the full
15+
shedding cycle the full primal is necessary. The necessary changes to `chtMaster.cfg` are documented
16+
in the config itself
17+
18+
## Discrete Adjoint
19+
In the regression testcase of SU2 only 2 reverse steps are taken.
20+
For that, the solution files 52-55 for the adjoint are added.
21+
The objective Function is the average temperature on the inner pin surface, averaged over the full time.
22+
23+
## Finite Differences using FADO
24+
In order to validate the Discrete Adjoint gradient a Finite Differences python script `findiff.py`
25+
using [FADO](www.github.com/su2code/FADO) is added.
26+
The script starts a baseline simulation and an additional for each of the 18 Design Variables.
27+
Using the `postprocess.py` to print the absolute difference and relative difference in percent to screen.
28+
Make sure to adapt the `chtMaster.cfg` as for the primal.
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
% 2021-03-11 TobiKattmann
2+
%
3+
SOLVER= MULTIPHYSICS
4+
%
5+
% Set RESTART_SOL=YES for primal runs including the FD sweep
6+
RESTART_SOL= NO
7+
RESTART_ITER= 2
8+
READ_BINARY_RESTART= YES
9+
SOLUTION_FILENAME= solution
10+
RESTART_FILENAME= solution
11+
%
12+
CONFIG_LIST = ( fluid.cfg, solid.cfg )
13+
%
14+
MARKER_ZONE_INTERFACE= ( cylinder_fluid, cylinder_solid )
15+
MARKER_CHT_INTERFACE= ( cylinder_fluid, cylinder_solid )
16+
%
17+
% ------------------------- UNSTEADY SIMULATION -------------------------------%
18+
%
19+
TIME_DOMAIN= YES
20+
TIME_MARCHING= DUAL_TIME_STEPPING-2ND_ORDER
21+
%
22+
TIME_STEP= 500
23+
%
24+
MAX_TIME= 1e9
25+
% For a primal restart change TIME_ITER=56 for the correct number of steps. 54 is for the adjoint run.
26+
TIME_ITER= 54
27+
% For the primal (and therefore FD sweep) OUTER_ITER=200 is suitable.
28+
% For an accurate adjont run set OUTER_ITER=500. 100 is for the regression test.
29+
OUTER_ITER= 100
30+
%INNER_ITER= 1
31+
%
32+
UNST_ADJOINT_ITER= 56
33+
%
34+
ITER_AVERAGE_OBJ= 54
35+
%
36+
% ------------------------- INPUT/OUTPUT FILE INFORMATION --------------------------%
37+
%
38+
MESH_FILENAME= MeshCHT.su2
39+
%
40+
SCREEN_OUTPUT= (TIME_ITER, OUTER_ITER, BGS_ADJ_PRESSURE[0], BGS_ADJ_VELOCITY-X[0], BGS_ADJ_VELOCITY-Y[0], BGS_ADJ_TEMPERATURE[0], BGS_ADJ_TEMPERATURE[1] )
41+
% Suitable output for primal simulations
42+
%SCREEN_OUTPUT= (TIME_ITER, OUTER_ITER, WALL_TIME, BGS_PRESSURE[0], BGS_TEMPERATURE[0], BGS_TEMPERATURE[1], DRAG[0], AVG_TEMPERATURE[1] )
43+
SCREEN_WRT_FREQ_OUTER= 50
44+
%
45+
HISTORY_OUTPUT= ( ITER, BGS_RES[0], RMS_RES[0], BGS_RES[1], RMS_RES[1],\
46+
FLOW_COEFF[0], HEAT[0], AERO_COEFF[0], HEAT[1],\
47+
LINSOL[0], LINSOL[1])
48+
%
49+
OUTPUT_FILES= (RESTART, PARAVIEW)
50+
OUTPUT_WRT_FREQ= 1
51+
VOLUME_FILENAME= flow
52+
WRT_PERFORMANCE= YES
53+
%
54+
SOLUTION_ADJ_FILENAME= solution_adj
55+
RESTART_ADJ_FILENAME= solution_adj
56+
VOLUME_ADJ_FILENAME= flow_adj
57+
%
58+
TABULAR_FORMAT= CSV
59+
GRAD_OBJFUNC_FILENAME= of_grad.csv
60+
OUTPUT_PRECISION=16
61+
%
62+
% -------------------- FREE-FORM DEFORMATION PARAMETERS -----------------------%
63+
%
64+
FFD_TOLERANCE= 1E-10
65+
FFD_ITERATIONS= 500
66+
%
67+
% FFD box definition: 2D case (FFD_BoxTag, X1, Y1, 0.0, X2, Y2, 0.0, X3, Y3, 0.0, X4, Y4, 0.0,
68+
% 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
69+
% Counterclockwise definition of FFD cornerpoints
70+
FFD_DEFINITION= (BOX,\
71+
-0.6,-0.6,0.0,\
72+
0.6,-0.6,0.0,\
73+
0.6, 0.6,0.0,\
74+
-0.6, 0.6,0.0,\
75+
0.0,0.0,0.0, 0.0,0.0,0.0 0.0,0.0,0.0, 0.0,0.0,0.0 )
76+
%
77+
% FFD box degree: 2D case (x_degree, y_degree, 0)
78+
FFD_DEGREE= (8, 1, 0)
79+
%
80+
% Surface grid continuity at the intersection with the faces of the FFD boxes.
81+
% To keep a particular level of surface continuity, SU2 automatically freezes the right
82+
% number of control point planes (NO_DERIVATIVE, 1ST_DERIVATIVE, 2ND_DERIVATIVE, USER_INPUT)
83+
FFD_CONTINUITY= NO_DERIVATIVE
84+
%
85+
% ----------------------- DESIGN VARIABLE PARAMETERS --------------------------%
86+
%
87+
%DV_KIND= FFD_SETTING
88+
% First 9 are upper, second 9 are lower DV's
89+
DV_KIND= FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D
90+
%
91+
% Marker of the surface in which we are going apply the shape deformation
92+
DV_MARKER= ( cylinder_fluid, cylinder_solid )
93+
%
94+
% Parameters of the shape deformation
95+
% - FFD_SETTING ( 1.0 )
96+
% - FFD_CONTROL_POINT_2D ( FFD_BoxTag, i_Ind, j_Ind, x_Disp, y_Disp )
97+
%DV_PARAM= ( 1.0 )
98+
DV_PARAM= \
99+
( BOX, 0, 1, 0.0, 1.0);\
100+
( BOX, 1, 1, 0.0, 1.0);\
101+
( BOX, 2, 1, 0.0, 1.0);\
102+
( BOX, 3, 1, 0.0, 1.0);\
103+
( BOX, 4, 1, 0.0, 1.0);\
104+
( BOX, 5, 1, 0.0, 1.0);\
105+
( BOX, 6, 1, 0.0, 1.0);\
106+
( BOX, 7, 1, 0.0, 1.0);\
107+
( BOX, 8, 1, 0.0, 1.0);\
108+
( BOX, 0, 0, 0.0, 1.0);\
109+
( BOX, 1, 0, 0.0, 1.0);\
110+
( BOX, 2, 0, 0.0, 1.0);\
111+
( BOX, 3, 0, 0.0, 1.0);\
112+
( BOX, 4, 0, 0.0, 1.0);\
113+
( BOX, 5, 0, 0.0, 1.0);\
114+
( BOX, 6, 0, 0.0, 1.0);\
115+
( BOX, 7, 0, 0.0, 1.0);\
116+
( BOX, 8, 0, 0.0, 1.0)
117+
%
118+
% Value of the shape deformation
119+
DV_VALUE= 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
120+
%
121+
% ------------------------ GRID DEFORMATION PARAMETERS ------------------------%
122+
%
123+
DEFORM_LINEAR_SOLVER= FGMRES
124+
DEFORM_LINEAR_SOLVER_PREC= ILU
125+
DEFORM_LINEAR_SOLVER_ERROR= 1E-14
126+
DEFORM_NONLINEAR_ITER= 1
127+
DEFORM_LINEAR_SOLVER_ITER= 1000
128+
%
129+
DEFORM_CONSOLE_OUTPUT= YES
130+
DEFORM_STIFFNESS_TYPE= WALL_DISTANCE
131+
%
132+
DEFINITION_DV= \
133+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 0, 1, 0.0, 1.0 ); \
134+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 1, 1, 0.0, 1.0 ); \
135+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 2, 1, 0.0, 1.0 ); \
136+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 3, 1, 0.0, 1.0 ); \
137+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 4, 1, 0.0, 1.0 ); \
138+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 5, 1, 0.0, 1.0 ); \
139+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 6, 1, 0.0, 1.0 ); \
140+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 7, 1, 0.0, 1.0 ); \
141+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 8, 1, 0.0, 1.0 ); \
142+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 0, 0, 0.0, 1.0 ); \
143+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 1, 0, 0.0, 1.0 ); \
144+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 2, 0, 0.0, 1.0 ); \
145+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 3, 0, 0.0, 1.0 ); \
146+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 4, 0, 0.0, 1.0 ); \
147+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 5, 0, 0.0, 1.0 ); \
148+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 6, 0, 0.0, 1.0 ); \
149+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 7, 0, 0.0, 1.0 ); \
150+
( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 8, 0, 0.0, 1.0 )
151+

0 commit comments

Comments
 (0)