Skip to content

Commit

Permalink
Merge pull request #1563 from su2code/fix_2d_periodic_rotation
Browse files Browse the repository at this point in the history
Fix 2D rotational periodicity
  • Loading branch information
pcarruscag authored Mar 16, 2022
2 parents a288828 + 2a6da92 commit c8ccde5
Show file tree
Hide file tree
Showing 6 changed files with 3,467 additions and 1 deletion.
18 changes: 17 additions & 1 deletion SU2_CFD/src/solvers/CSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry,
ordering is rotation about the x-axis, y-axis, then z-axis. ---*/

if (nDim==2) {
GeometryToolbox::RotationMatrix(Theta, rotMatrix2D);
GeometryToolbox::RotationMatrix(Psi, rotMatrix2D);
} else {
GeometryToolbox::RotationMatrix(Theta, Phi, Psi, rotMatrix3D);
}
Expand Down Expand Up @@ -738,6 +738,22 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry,
Rotate(zeros, jacBlock[iVar], rotBlock[iVar]);
}

/*--- Rotate the vector components of the solution. ---*/

if (rotate_periodic) {
for (iDim = 0; iDim < nDim; iDim++) {
su2double d_diDim[3] = {0.0};
for (iVar = 1; iVar < 1+nDim; ++iVar) {
d_diDim[iVar-1] = rotBlock(iVar, iDim);
}
su2double rotated[3] = {0.0};
Rotate(zeros, d_diDim, rotated);
for (iVar = 1; iVar < 1+nDim; ++iVar) {
rotBlock(iVar, iDim) = rotated[iVar-1];
}
}
}

/*--- Store the partial gradient in the buffer. ---*/

for (iVar = 0; iVar < ICOUNT; iVar++) {
Expand Down
8 changes: 8 additions & 0 deletions TestCases/hybrid_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ def main():
poiseuille_profile.test_vals = [-12.494752, -7.712204, -0.000000, 2.085796]
test_list.append(poiseuille_profile)

# 2D Rotational Periodic
periodic2d = TestCase('periodic2d')
periodic2d.cfg_dir = "navierstokes/periodic2D"
periodic2d.cfg_file = "config.cfg"
periodic2d.test_iter = 1400
periodic2d.test_vals = [-10.818511, -8.363385, -8.287482, -5.334813, -1.087926, -2945.2]
test_list.append(periodic2d)

##########################
### Compressible RANS ###
##########################
Expand Down
76 changes: 76 additions & 0 deletions TestCases/navierstokes/periodic2D/config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
SOLVER= NAVIER_STOKES
KIND_TURB_MODEL= NONE
RESTART_SOL= NO

% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------%
%
MACH_NUMBER= 0.1
AOA= 22.5
INIT_OPTION= TD_CONDITIONS
FREESTREAM_OPTION= TEMPERATURE_FS
FREESTREAM_TEMPERATURE= 300
FREESTREAM_PRESSURE= 99000

% ---------------------- REFERENCE VALUE DEFINITION ---------------------------%
%
REF_ORIGIN_MOMENT_X = 0.00
REF_ORIGIN_MOMENT_Y = 0.00
REF_ORIGIN_MOMENT_Z = 0.00
REF_LENGTH= 1
REF_AREA= 1
%
FLUID_MODEL= IDEAL_GAS
GAMMA_VALUE= 1.4
GAS_CONSTANT= 287.87
VISCOSITY_MODEL= CONSTANT_VISCOSITY
MU_CONSTANT= 0.001

% -------------------- BOUNDARY CONDITION DEFINITION --------------------------%
%
MARKER_PERIODIC= ( per1, per2, 0,0,0, 0,0,45, 0,0,0 )
MARKER_OUTLET= ( outlet, 99000.0 )
INLET_TYPE= TOTAL_CONDITIONS
MARKER_INLET= ( inlet, 300, 100000, 1, 0, 0 )
SPECIFIED_INLET_PROFILE= YES
INLET_FILENAME= inlet.dat
%
MARKER_ANALYZE= ( outlet, inlet )

% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------%
%
NUM_METHOD_GRAD= GREEN_GAUSS
CFL_NUMBER= 100
CFL_ADAPT= NO
TIME_DISCRE_FLOW= EULER_IMPLICIT

% ------------------------ LINEAR SOLVER DEFINITION ---------------------------%
%
LINEAR_SOLVER= FGMRES
LINEAR_SOLVER_PREC= LU_SGS
LINEAR_SOLVER_ERROR= 0.1
LINEAR_SOLVER_ITER= 4

% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------%
%
CONV_NUM_METHOD_FLOW= ROE
USE_VECTORIZATION= YES
MUSCL_FLOW= YES
SLOPE_LIMITER_FLOW= VENKATAKRISHNAN_WANG
VENKAT_LIMITER_COEFF= 0.05

% --------------------------- CONVERGENCE PARAMETERS --------------------------%
%
CONV_RESIDUAL_MINVAL= -11
CONV_STARTITER= 0
INNER_ITER= 5000

% ------------------------- INPUT/OUTPUT INFORMATION --------------------------%
%
MESH_FORMAT= SU2
MESH_FILENAME= sector.su2
OUTPUT_WRT_FREQ= 9999
%
SCREEN_OUTPUT= ( INNER_ITER, RMS_DENSITY, RMS_MOMENTUM-X, RMS_MOMENTUM-Y,\
RMS_ENERGY, LINSOL_RESIDUAL, SURFACE_PRESSURE_DROP )
46 changes: 46 additions & 0 deletions TestCases/navierstokes/periodic2D/inlet.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
NMARK= 1
MARKER_TAG= inlet
NROW=40
NCOL=6
# COORD-X COORD-Y TEMPERATURE PRESSURE NORMAL-X NORMAL-Y
2.5000000E-01 0.0000000E+00 3.00E+02 1.00E+05 0.25881905 0.96592583
2.4994931E-01 5.0342633E-03 3.00E+02 1.00E+05 0.23931566 0.97094182
2.4979725E-01 1.0066485E-02 3.00E+02 1.00E+05 0.21971523 0.97556405
2.4954389E-01 1.5094624E-02 3.00E+02 1.00E+05 0.20002569 0.97979065
2.4918933E-01 2.0116642E-02 3.00E+02 1.00E+05 0.18025504 0.98361991
2.4873371E-01 2.5130502E-02 3.00E+02 1.00E+05 0.16041128 0.98705026
2.4817722E-01 3.0134170E-02 3.00E+02 1.00E+05 0.14050247 0.99008033
2.4752008E-01 3.5125618E-02 3.00E+02 1.00E+05 0.12053668 0.99270887
2.4676257E-01 4.0102820E-02 3.00E+02 1.00E+05 0.10052201 0.99493484
2.4590498E-01 4.5063760E-02 3.00E+02 1.00E+05 0.08046657 0.99675731
2.4494766E-01 5.0006424E-02 3.00E+02 1.00E+05 0.06037850 0.99817555
2.4389101E-01 5.4928808E-02 3.00E+02 1.00E+05 0.04026594 0.99918900
2.4273545E-01 5.9828916E-02 3.00E+02 1.00E+05 0.02013705 0.99979723
2.4148146E-01 6.4704761E-02 3.00E+02 1.00E+05 0.00000000 1.00000000
2.4012953E-01 6.9554366E-02 3.00E+02 1.00E+05 -0.02013705 0.99979723
2.3868022E-01 7.4375764E-02 3.00E+02 1.00E+05 -0.04026594 0.99918900
2.3713411E-01 7.9166999E-02 3.00E+02 1.00E+05 -0.06037850 0.99817555
2.3549184E-01 8.3926128E-02 3.00E+02 1.00E+05 -0.08046657 0.99675731
2.3375406E-01 8.8651222E-02 3.00E+02 1.00E+05 -0.10052201 0.99493484
2.3192149E-01 9.3340364E-02 3.00E+02 1.00E+05 -0.12053668 0.99270887
2.2999486E-01 9.7991653E-02 3.00E+02 1.00E+05 -0.14050247 0.99008033
2.2797496E-01 1.0260320E-01 3.00E+02 1.00E+05 -0.16041128 0.98705026
2.2586261E-01 1.0717314E-01 3.00E+02 1.00E+05 -0.18025504 0.98361991
2.2365866E-01 1.1169962E-01 3.00E+02 1.00E+05 -0.20002569 0.97979065
2.2136401E-01 1.1618079E-01 3.00E+02 1.00E+05 -0.21971523 0.97556405
2.1897958E-01 1.2061485E-01 3.00E+02 1.00E+05 -0.23931566 0.97094182
2.1650635E-01 1.2500000E-01 3.00E+02 1.00E+05 -0.25881905 0.96592583
2.1394532E-01 1.2933445E-01 3.00E+02 1.00E+05 -0.27821746 0.96051811
2.1129752E-01 1.3361646E-01 3.00E+02 1.00E+05 -0.29750305 0.95472087
2.0856403E-01 1.3784427E-01 3.00E+02 1.00E+05 -0.31666799 0.94853644
2.0574597E-01 1.4201619E-01 3.00E+02 1.00E+05 -0.33570451 0.94196735
2.0284446E-01 1.4613051E-01 3.00E+02 1.00E+05 -0.35460489 0.93501624
1.9986069E-01 1.5018557E-01 3.00E+02 1.00E+05 -0.37336146 0.92768595
1.9679587E-01 1.5417972E-01 3.00E+02 1.00E+05 -0.39196661 0.91997944
1.9365124E-01 1.5811134E-01 3.00E+02 1.00E+05 -0.41041281 0.91189985
1.9042808E-01 1.6197885E-01 3.00E+02 1.00E+05 -0.42869256 0.90345043
1.8712769E-01 1.6578066E-01 3.00E+02 1.00E+05 -0.44679846 0.89463464
1.8375141E-01 1.6951525E-01 3.00E+02 1.00E+05 -0.46472317 0.88545603
1.8030061E-01 1.7318109E-01 3.00E+02 1.00E+05 -0.48245941 0.87591833
1.7677670E-01 1.7677670E-01 3.00E+02 1.00E+05 -0.50000000 0.86602540

31 changes: 31 additions & 0 deletions TestCases/navierstokes/periodic2D/sector.geo
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Gmsh .geo script
ri = 0.25;
ro = 0.5;
N = 40;

Point(1) = {0.0, 0.0, 0.0, 1.0};
Point(2) = {ri, 0.0, 0.0, 1.0};
Point(3) = {ro, 0.0, 0.0, 1.0};
Point(4) = {ro/Sqrt(2), ro/Sqrt(2), 0.0, 1.0};
Point(5) = {ri/Sqrt(2), ri/Sqrt(2), 0.0, 1.0};

Circle(1) = {2, 1, 5};
Circle(2) = {3, 1, 4};
Line(3) = {2, 3};
Line(4) = {5, 4};

Curve Loop(1) = {4, -2, -3, 1};
Surface(1) = {1};

Physical Curve("inlet", 5) = {1};
Physical Curve("outlet", 6) = {2};
Physical Curve("per1", 7) = {3};
Physical Curve("per2", 8) = {4};
Physical Surface("fluid", 9) = {1};

Transfinite Curve {1, 2} = N Using Progression 1;
Transfinite Curve {3, 4} = N Using Progression 1;
Transfinite Surface {1};
Recombine Surface {1};

Mesh 2;
Loading

0 comments on commit c8ccde5

Please sign in to comment.