Skip to content

Commit 2c4ca42

Browse files
authored
Some more clean up and fix boundary numbering (#303)
* CFD boundaries are reordered * Formatting * Formatting 2 * Formatting 3 * Create _plot_sizing.py
1 parent c8d8910 commit 2c4ca42

File tree

14 files changed

+58
-18
lines changed

14 files changed

+58
-18
lines changed

examples/fun3d_examples/_ssw-testing/1_panel_thickness.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@
145145
# <----------------------------------------------------
146146

147147
# make a funtofem scenario
148-
cruise = Scenario.steady("cruise_inviscid", steps=300, coupling_frequency=30, uncoupled_steps=0)
148+
cruise = Scenario.steady(
149+
"cruise_inviscid", steps=300, coupling_frequency=30, uncoupled_steps=0
150+
)
149151
cruise.adjoint_steps = (
150152
100 # outer coupling iterations, total 5000 flow adjoints, 100 grid adjoints
151153
)
@@ -286,7 +288,13 @@
286288
manager.register_to_problem(opt_problem)
287289

288290
# run an SNOPT optimization
289-
snoptimizer = SNOPT(options={"Verify level": 0, "Function precision": 1e-4, "Major Optimality tol" : 1e-4})
291+
snoptimizer = SNOPT(
292+
options={
293+
"Verify level": 0,
294+
"Function precision": 1e-4,
295+
"Major Optimality tol": 1e-4,
296+
}
297+
)
290298

291299
sol = snoptimizer(
292300
opt_problem,

examples/fun3d_examples/_ssw-testing/_oneway_sizing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Local machine optimization for the panel thicknesses using nribs-1 OML panels and nribs-1 LE panels
1414
"""
1515

16-
#from pyoptsparse import SLSQP, Optimization
16+
# from pyoptsparse import SLSQP, Optimization
1717
from pyoptsparse import SNOPT, Optimization
1818

1919
# script inputs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from funtofem import *
2+
3+
# 1 : plot 1_sizing_opt_local.py results
4+
# ---------------------------------------------------------------------------
5+
plotter = PlotManager.from_hist_file(
6+
"ssw-sizing1_design.txt",
7+
accepted_names=["cruise_inviscid-mass", "cruise_inviscid-ksfailure"],
8+
plot_names=["mass", "ks-stress"],
9+
ignore_other_names=True,
10+
)
11+
12+
# MAKE EACH PLOT FOR A DIFFERENT MODE
13+
functions = []
14+
Function.plot("ks-stress").optimize(scale=1.0, plot_name="ks-stress").register_to(
15+
plotter
16+
)
17+
plotter.add_constraint(value=1.0, name="ks-constr")
18+
Function.plot("mass").optimize(scale=0.01, plot_name="mass").register_to(plotter)
19+
20+
plotter(
21+
plot_name="sizing-hist.png",
22+
legend_frac=0.9,
23+
yaxis_name="function values",
24+
color_offset=0,
25+
niceplots_style="doumont-light",
26+
yscale_log=True,
27+
)

examples/fun3d_examples/_ssw-testing/geometry/_mesh_fun3d_egads.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Set whether to build an inviscid or viscous mesh
99
# ------------------------------------------------
1010
case = "inviscid"
11-
#case = "turbulent"
11+
# case = "turbulent"
1212

1313
if case == "inviscid":
1414
project_name = "ssw-inviscid"

examples/fun3d_examples/ssw_meshdef_optimization/1_panel_thickness.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
# theta_init=0.6, theta_max=0.95, history_file=aitken_file, debug=True
8181
# )
8282
# )
83-
wing = Body.aeroelastic("wing", boundary=3)
83+
wing = Body.aeroelastic("wing", boundary=2)
8484

8585
# setup the material and shell properties
8686
aluminum = caps2tacs.Isotropic.aluminum().register_to(tacs_model)

examples/fun3d_examples/ssw_meshdef_optimization/2_aero_aoa.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
# BODIES AND STRUCT DVs
8080
# <----------------------------------------------------
8181

82-
wing = Body.aeroelastic("wing", boundary=3)
82+
wing = Body.aeroelastic("wing", boundary=2)
8383

8484
# setup the material and shell properties
8585
aluminum = caps2tacs.Isotropic.aluminum().register_to(tacs_model)

examples/fun3d_examples/ssw_meshdef_optimization/3_geom_twist.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
# BODIES AND STRUCT DVs
129129
# <----------------------------------------------------
130130

131-
wing = Body.aeroelastic("wing", boundary=3)
131+
wing = Body.aeroelastic("wing", boundary=2)
132132

133133
# setup the material and shell properties
134134
aluminum = caps2tacs.Isotropic.aluminum().register_to(tacs_model)

examples/fun3d_examples/ssw_meshdef_optimization/4_oml_shape.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
# BODIES AND STRUCT DVs
129129
# <----------------------------------------------------
130130

131-
wing = Body.aeroelastic("wing", boundary=3)
131+
wing = Body.aeroelastic("wing", boundary=2)
132132

133133
# setup the material and shell properties
134134
aluminum = caps2tacs.Isotropic.aluminum().register_to(tacs_model)

examples/fun3d_examples/ssw_meshdef_optimization/_2_cfd_only.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# BODIES AND STRUCT DVs
3535
# <----------------------------------------------------
3636

37-
wing = Body.aeroelastic("wing", boundary=3)
37+
wing = Body.aeroelastic("wing", boundary=2)
3838

3939
# register the wing body to the model
4040
wing.register_to(f2f_model)

examples/fun3d_examples/ssw_meshdef_optimization/_oneway_sizing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
# BODIES AND STRUCT DVs
7676
# -------------------------------------------------
7777

78-
wing = Body.aeroelastic("wing", boundary=3)
78+
wing = Body.aeroelastic("wing", boundary=2)
7979

8080
# setup the material and shell properties
8181
aluminum = caps2tacs.Isotropic.aluminum().register_to(tacs_model)

examples/fun3d_examples/ssw_meshdef_optimization/_run_flow.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# Construct the FUNtoFEM model
2222
f2f_model = FUNtoFEMmodel("ssw_flow")
23-
wing = Body.aeroelastic("wing", boundary=3)
23+
wing = Body.aeroelastic("wing", boundary=2)
2424
wing.register_to(f2f_model)
2525

2626
# Make a FUNtoFEM scenario
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
3
2-
1 5000 Farfield
3-
2 6662 SymmetryY
4-
3 4000 wing
2+
1 5000 farfield
3+
2 4000 wing
4+
3 6662 symmetry
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
3
2-
1 5000 Farfield
3-
2 6662 SymmetryY
4-
3 3000 wing
2+
1 5000 farfield
3+
2 3000 wing
4+
3 6662 symmetry
5+

funtofem/interface/test_solver.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,11 @@ def finite_difference(
10831083
f_functions = [func.value.real for func in model.get_functions(all=True)]
10841084

10851085
finite_diff_TD = [
1086-
(f_functions[ifunc] - i_functions[ifunc]) / 2 / epsilon if central_diff else (f_functions[ifunc] - m_functions[ifunc])/epsilon
1086+
(
1087+
(f_functions[ifunc] - i_functions[ifunc]) / 2 / epsilon
1088+
if central_diff
1089+
else (f_functions[ifunc] - m_functions[ifunc]) / epsilon
1090+
)
10871091
for ifunc in range(nfunctions)
10881092
]
10891093

0 commit comments

Comments
 (0)