Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions compressible_flow/QuickStart/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
## \file Makefile
# \brief Makefile for the QuickStart tutorial
# \author F. Poli
# \version 7.5.1 "Blackbird"
#
# SU2 Project Website: https://su2code.github.io
#
# The SU2 Project is maintained by the SU2 Foundation
# (http://su2foundation.org)
#
# Copyright 2023, SU2 Contributors (cf. AUTHORS.md)
#
# SU2 is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# SU2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with SU2. If not, see <http://www.gnu.org/licenses/>.

TIME=/usr/bin/time

all: restart_flow.dat NACA0012_coef_pres.pdf NACA0012_pressure_field.png \
adj/restart_adj_cd.dat dadj/restart_adj_cd.dat \
NACA0012_surf_sens.pdf \
NACA0012_coef_pres.png NACA0012_surf_sens.png

restart_flow.dat: inv_NACA0012.cfg mesh_NACA0012_inv.su2
$(TIME) -o su2_cfd_time.out SU2_CFD $< | tee su2_cfd.log

NACA0012_coef_pres.pdf: NACA0012_coef_pres.tex restart_flow.dat surface_flow.csv
texfot -q lualatex $<

NACA0012_pressure_field.png: make_field_shots.py restart_flow.dat flow.vtu
python3 make_field_shots.py

adj/restart_adj_cd.dat: adj/inv_adj_NACA0012.cfg mesh_NACA0012_inv.su2 \
restart_flow.dat
cd adj \
&& ln -sf ../mesh_NACA0012_inv.su2 ./mesh_NACA0012_inv.su2 \
&& ln -sf ../restart_flow.dat ./solution_flow.dat \
&& $(TIME) -o su2_cfd_adj_time.out \
SU2_CFD inv_adj_NACA0012.cfg | tee su2_cfd_adj.log

dadj/restart_adj_cd.dat: dadj/inv_dadj_NACA0012.cfg mesh_NACA0012_inv.su2 \
restart_flow.dat
cd dadj \
&& ln -sf ../mesh_NACA0012_inv.su2 ./mesh_NACA0012_inv.su2 \
&& ln -sf ../restart_flow.dat ./solution_flow.dat \
&& $(TIME) -o su2_cfd_ad_dadj_time.out \
SU2_CFD_AD inv_dadj_NACA0012.cfg | tee su2_cfd_ad_dadj.log

NACA0012_surf_sens.pdf: NACA0012_surf_sens.tex \
adj/restart_adj_cd.dat dadj/restart_adj_cd.dat \
adj/surface_adjoint.csv dadj/surface_adjoint.csv
texfot -q lualatex $<

%.png: %.pdf
convert -density 154x154 $< $@

.PHONY: clean
clean:
-rm -f *.log *.aux *.out *adj/*.log *adj/*.out
-rm -f *adj/solution_flow.dat *adj/mesh_NACA0012_inv.su2

.PHONY: distclean
distclean: clean
-rm -f *.vtu *.csv *.dat *adj/*.csv *adj/*.dat *.png *.pdf
72 changes: 72 additions & 0 deletions compressible_flow/QuickStart/NACA0012_coef_pres.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
\documentclass[tikz,margin=1pt]{standalone}

%% \file NACA0012_coef_pres.tex
% \brief LaTeX code for the C_p plot in the QuickStart tutorial
% \author F. Poli
% \version 7.5.1 "Blackbird"
%
% SU2 Project Website: https://su2code.github.io
%
% The SU2 Project is maintained by the SU2 Foundation
% (http://su2foundation.org)
%
% Copyright 2023, SU2 Contributors (cf. AUTHORS.md)
%
% SU2 is free software; you can redistribute it and/or
% modify it under the terms of the GNU Lesser General Public
% License as published by the Free Software Foundation; either
% version 2.1 of the License, or (at your option) any later version.
%
% SU2 is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with SU2. If not, see <http://www.gnu.org/licenses/>.

\usepackage{pgfplots}
\pgfplotsset{compat=1.17,trig format plots=rad,tick scale binop=\times,
/pgf/number format/sci generic={mantissa sep=\times,exponent={10^{#1}}},
/pgf/number format/1000 sep={\,}}
%\usepgfplotslibrary{groupplots}
%\usepgfplotslibrary{patchplots}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\pagecolor{white}
\begin{axis}
[
title={Coefficient of pressure for the NACA 0012 airfoil},
width=108mm,
height=88mm,
xlabel={$x/c$},
ylabel={$C_p$},
enlarge x limits=false,
%enlarge y limits=true,
ymin=-1.5,ymax=1.5,
y dir=reverse,
%ymajorgrids=true,
legend cell align=left,
legend pos=south east,
table/col sep=comma,
]
\addplot%+
[
blue!50!black,
thick,
mark=*,
mark size=0.7,
]
table
[
x="x",
y="Pressure_Coefficient",
]
{surface_flow.csv};
\addlegendentry{SU2}
\end{axis}
\end{tikzpicture}
\end{document}


85 changes: 85 additions & 0 deletions compressible_flow/QuickStart/NACA0012_surf_sens.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
\documentclass[tikz,margin=1pt]{standalone}

%% \file NACA0012_surf_sens.tex
% \brief LaTeX code for the sensitivity plot in the QuickStart tutorial
% \author F. Poli
% \version 7.5.1 "Blackbird"
%
% SU2 Project Website: https://su2code.github.io
%
% The SU2 Project is maintained by the SU2 Foundation
% (http://su2foundation.org)
%
% Copyright 2023, SU2 Contributors (cf. AUTHORS.md)
%
% SU2 is free software; you can redistribute it and/or
% modify it under the terms of the GNU Lesser General Public
% License as published by the Free Software Foundation; either
% version 2.1 of the License, or (at your option) any later version.
%
% SU2 is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with SU2. If not, see <http://www.gnu.org/licenses/>.

\usepackage{pgfplots}
\pgfplotsset{compat=1.17,trig format plots=rad,tick scale binop=\times,
/pgf/number format/sci generic={mantissa sep=\times,exponent={10^{#1}}},
/pgf/number format/1000 sep={\,}}
%\usepgfplotslibrary{groupplots}
%\usepgfplotslibrary{patchplots}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\pagecolor{white}
\begin{axis}
[
title={Surface sensitivities for the NACA 0012 airfoil},
width=108mm,
height=88mm,
xlabel={$x/c$},
ylabel={surface sensitivity},
enlarge x limits=false,
%enlarge y limits=true,
ymin=-2,ymax=2,
%ymajorgrids=true,
legend cell align=left,
legend pos=south west,
table/col sep=comma,
]
\addplot%+
[
blue!50!black,
thick,
mark=*,
mark size=0.7,
]
table
[
x="x",
y="Surface_Sensitivity",
]
{adj/surface_adjoint.csv};
\addlegendentry{SU2 continuous adjoint}
\addplot%+
[
blue!40!white,
thick,
mark=*,
mark size=0.7,
]
table
[
x="x",
y="Surface_Sensitivity",
]
{dadj/surface_adjoint.csv};
\addlegendentry{SU2 discrete adjoint}
\end{axis}
\end{tikzpicture}
\end{document}


135 changes: 135 additions & 0 deletions compressible_flow/QuickStart/adj/inv_adj_NACA0012.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% SU2 configuration file %
% Case description: Transonic inviscid flow around a NACA0012 airfoil %
% Author: Thomas D. Economon %
% Institution: Stanford University %
% Date: 2014.06.11 %
% File Version 7.5.1 "Blackbird" %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------%

SOLVER= EULER
MATH_PROBLEM= CONTINUOUS_ADJOINT
RESTART_SOL= NO

% ----------- COMPRESSIBLE AND INCOMPRESSIBLE FREE-STREAM DEFINITION ----------%

MACH_NUMBER= 0.8
AOA= 1.25
FREESTREAM_PRESSURE= 101325.0
FREESTREAM_TEMPERATURE= 273.15

% -------------- COMPRESSIBLE AND INCOMPRESSIBLE FLUID CONSTANTS --------------%

GAMMA_VALUE= 1.4
GAS_CONSTANT= 287.87

% ---------------------- REFERENCE VALUE DEFINITION ---------------------------%

REF_ORIGIN_MOMENT_X = 0.25
REF_ORIGIN_MOMENT_Y = 0.00
REF_ORIGIN_MOMENT_Z = 0.00
REF_LENGTH= 1.0
REF_AREA= 1.0
REF_DIMENSIONALIZATION= DIMENSIONAL

% ----------------------- BOUNDARY CONDITION DEFINITION -----------------------%

MARKER_EULER= ( airfoil )
MARKER_FAR= ( farfield )

% ------------------------ SURFACES IDENTIFICATION ----------------------------%

MARKER_PLOTTING = ( airfoil )
MARKER_MONITORING = ( airfoil )
MARKER_DESIGNING = ( airfoil )

% ------------- COMMON PARAMETERS TO DEFINE THE NUMERICAL METHOD --------------%

NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES
OBJECTIVE_FUNCTION= DRAG
CFL_NUMBER= 1e3
CFL_ADAPT= NO
CFL_ADAPT_PARAM= ( 0.1, 2.0, 10.0, 1e10 )
ITER= 250

% ------------------------ LINEAR SOLVER DEFINITION ---------------------------%

LINEAR_SOLVER= FGMRES
LINEAR_SOLVER_PREC= ILU
LINEAR_SOLVER_ERROR= 1E-10
LINEAR_SOLVER_ITER= 10

% -------------------------- MULTIGRID PARAMETERS -----------------------------%

MGLEVEL= 3
MGCYCLE= W_CYCLE
MG_PRE_SMOOTH= ( 1, 2, 3, 3 )
MG_POST_SMOOTH= ( 0, 0, 0, 0 )
MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 )
MG_DAMP_RESTRICTION= 1.0
MG_DAMP_PROLONGATION= 1.0

% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------%

CONV_NUM_METHOD_FLOW= JST
JST_SENSOR_COEFF= ( 0.5, 0.02 )
TIME_DISCRE_FLOW= EULER_IMPLICIT

% ---------------- ADJOINT-FLOW NUMERICAL METHOD DEFINITION -------------------%

CONV_NUM_METHOD_ADJFLOW= JST
CFL_REDUCTION_ADJFLOW= 0.01
TIME_DISCRE_ADJFLOW= EULER_IMPLICIT

% ----------------------- DESIGN VARIABLE PARAMETERS --------------------------%

DV_KIND= HICKS_HENNE
DV_MARKER= ( airfoil )
DV_PARAM= ( 1, 0.5 )
DV_VALUE= 0.01

% ------------------------ GRID DEFORMATION PARAMETERS ------------------------%

DEFORM_LINEAR_SOLVER_ITER= 500
DEFORM_NONLINEAR_ITER= 1
DEFORM_LINEAR_SOLVER_ERROR= 1E-14
DEFORM_CONSOLE_OUTPUT= YES
DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME

% --------------------------- CONVERGENCE PARAMETERS --------------------------%

CONV_FIELD= RMS_DENSITY
CONV_RESIDUAL_MINVAL= -8
CONV_STARTITER= 10
CONV_CAUCHY_ELEMS= 100
CONV_CAUCHY_EPS= 1E-6
SCREEN_OUTPUT=(INNER_ITER, WALL_TIME, RMS_RES, LIFT, DRAG, CAUCHY_SENS_PRESS, CAUCHY_DRAG RMS_ADJ_DENSITY RMS_ADJ_ENERGY)

% ------------------------- INPUT/OUTPUT INFORMATION --------------------------%

MESH_FILENAME= mesh_NACA0012_inv.su2
MESH_FORMAT= SU2
MESH_OUT_FILENAME= mesh_out.su2
SOLUTION_FILENAME= solution_flow.dat
SOLUTION_ADJ_FILENAME= solution_adj.dat
TABULAR_FORMAT= CSV
CONV_FILENAME= history
RESTART_FILENAME= restart_flow.dat
RESTART_ADJ_FILENAME= restart_adj.dat
VOLUME_FILENAME= flow
VOLUME_ADJ_FILENAME= adjoint
GRAD_OBJFUNC_FILENAME= of_grad.dat
SURFACE_FILENAME= surface_flow
SURFACE_ADJ_FILENAME= surface_adjoint
OUTPUT_WRT_FREQ= 250
OUTPUT_FILES= (RESTART, SURFACE_CSV)

% --------------------- OPTIMAL SHAPE DESIGN DEFINITION -----------------------%

OPT_OBJECTIVE= DRAG * 0.001
OPT_CONSTRAINT= ( LIFT > 0.328188 ) * 0.001; ( MOMENT_Z > 0.034068 ) * 0.001; ( AIRFOIL_THICKNESS > 0.11 ) * 0.001
DEFINITION_DV= ( 30, 1.0 | airfoil | 0, 0.05 ); ( 30, 1.0 | airfoil | 0, 0.10 ); ( 30, 1.0 | airfoil | 0, 0.15 ); ( 30, 1.0 | airfoil | 0, 0.20 ); ( 30, 1.0 | airfoil | 0, 0.25 ); ( 30, 1.0 | airfoil | 0, 0.30 ); ( 30, 1.0 | airfoil | 0, 0.35 ); ( 30, 1.0 | airfoil | 0, 0.40 ); ( 30, 1.0 | airfoil | 0, 0.45 ); ( 30, 1.0 | airfoil | 0, 0.50 ); ( 30, 1.0 | airfoil | 0, 0.55 ); ( 30, 1.0 | airfoil | 0, 0.60 ); ( 30, 1.0 | airfoil | 0, 0.65 ); ( 30, 1.0 | airfoil | 0, 0.70 ); ( 30, 1.0 | airfoil | 0, 0.75 ); ( 30, 1.0 | airfoil | 0, 0.80 ); ( 30, 1.0 | airfoil | 0, 0.85 ); ( 30, 1.0 | airfoil | 0, 0.90 ); ( 30, 1.0 | airfoil | 0, 0.95 ); ( 30, 1.0 | airfoil | 1, 0.05 ); ( 30, 1.0 | airfoil | 1, 0.10 ); ( 30, 1.0 | airfoil | 1, 0.15 ); ( 30, 1.0 | airfoil | 1, 0.20 ); ( 30, 1.0 | airfoil | 1, 0.25 ); ( 30, 1.0 | airfoil | 1, 0.30 ); ( 30, 1.0 | airfoil | 1, 0.35 ); ( 30, 1.0 | airfoil | 1, 0.40 ); ( 30, 1.0 | airfoil | 1, 0.45 ); ( 30, 1.0 | airfoil | 1, 0.50 ); ( 30, 1.0 | airfoil | 1, 0.55 ); ( 30, 1.0 | airfoil | 1, 0.60 ); ( 30, 1.0 | airfoil | 1, 0.65 ); ( 30, 1.0 | airfoil | 1, 0.70 ); ( 30, 1.0 | airfoil | 1, 0.75 ); ( 30, 1.0 | airfoil | 1, 0.80 ); ( 30, 1.0 | airfoil | 1, 0.85 ); ( 30, 1.0 | airfoil | 1, 0.90 ); ( 30, 1.0 | airfoil | 1, 0.95 )
Loading