Skip to content

Commit 8473fb0

Browse files
sabakhshikanekoshmarcomangano
authored
Added mesh shifting in multi-section unification component for maintaining LE coincidence (#454)
* translate mesh in geometry unification * Analytic partials working with fd * Enforce partial checks with fd for shifting. Setup and cleanup tests. shifting on by default * Update docs * black and flake8 * Fix docs * This should fix the docs * Reformulated compute for mesh shifting so that check_partials will pass * Clean up. Add transformations to test. Reports off by default for all tests. * Docs updates * Fixed tests to use real mesh * Fixed transformation application to uni mesh test * Fixed a bug with the connect_mult_spline function for construction --------- Co-authored-by: kanekosh <shugok@umich.edu> Co-authored-by: Marco Mangano <36549388+marcomangano@users.noreply.github.com>
1 parent 84c70a5 commit 8473fb0

12 files changed

Lines changed: 303 additions & 137 deletions

File tree

openaerostruct/docs/advanced_features/multi_section_surfaces.rst

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,94 +14,115 @@ We first start with the induced drag minimization of a simple two-section symmet
1414

1515
Let's start with the necessary imports.
1616

17-
.. literalinclude:: /advanced_features/scripts/basic_2_sec.py
17+
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
1818
:start-after: checkpoint 0
1919
:end-before: checkpoint 1
2020

2121

2222
Then we are ready to discuss the multi-section parameterization and multi-section surface dictionary.
2323

24-
.. literalinclude:: /advanced_features/scripts/basic_2_sec.py
24+
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
2525
:start-after: checkpoint 1
2626
:end-before: checkpoint 2
2727

2828
Next, we setup the flow variables.
2929

30-
.. literalinclude:: /advanced_features/scripts/basic_2_sec.py
30+
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
3131
:start-after: checkpoint 2
3232
:end-before: checkpoint 3
3333

3434

35-
Giving the optimizer control of each wing section without any measure to constrain its motion can lead to undesirable geometries, such as wing sections separating from each other or large kinks appearing along the span, that cause numerical deficiencies in the optimization.
35+
Giving the optimizer control of each wing section without any measure to constrain them can lead to undesirable geometries, such as wing sections separating from each other or large kinks appearing along the span, that cause numerical deficiencies in the optimization.
3636
This concern is addressed by enforcing C0 continuity along the span-wise junctions between the sections.
3737
C0 continuity can be enforced for any geometric parameter OAS controls for a given section.
3838
For example, the tip chord or twist of a given section should match the root chord or twist of the subsequent section.
39-
There are two approaches for enforcing C0 continuity between sections: a constraint-based approach and a construction-based approach.
39+
There are two approaches for enforcing C0 continuity between sections: a construction-based approach and a constraint-based approach.
4040

4141
The constaint-based approach involves explicitly setting a position constraint that joins the surface points at section junctions to a specified tolerance.
42-
This constraint is useful when varying section parameters like span or dihedral, where entire sections could collide or separate if C0 continuity is not strictly enforced.
43-
A fully differentiated implementation that facilitates setting this constraint is incorporated into OAS. This approach is robust but introduces at least two linear constraints per segment junction.
44-
The number of linear constraints can quickly grow for problems with many sections that this study anticipates for morphing applications.
45-
In cases where geometric parameters can be specified as a function of span, however, it is possible to eliminate these additional constraints and maintain C0 continuity using the construction-based approach.
42+
This constraint is useful if the user desires a high degree of customization in how section are attached to each other.
43+
The number of linear constraints can quickly grow for problems with many sections.
44+
By reducing the degree of customization in section attachment, it is possible to eliminate these additional constraints and maintain C0 continuity using the construction-based approach.
45+
The remainder of this section describes the construction-based approach while the constraint-based approach is described in the subsequent section.
4646

47-
.. literalinclude:: /advanced_features/scripts/basic_2_sec.py
47+
48+
Continuity by construction is enforced by assigning the B-spline control points located at section edges to the same independent variable controlled by the optimizer.
49+
Enforcing C0 continuity by construction applies to geometric parameters that employ B-spline parametrization in OAS.
50+
These include chord distribution, twist distribution, shear distribution in all three directions, and thickness and radius distributions for structural spars.
51+
52+
53+
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
4854
:start-after: checkpoint 3
4955
:end-before: checkpoint 4
5056

57+
Geometric transformations parameterized by a single value, such as sweep, span, and dihedral, can still be used in the construction approach.
58+
The multi-section unification component built into the multi-section geometry group automatically shifts sections outboard/inboard to maintain leading edge coincidence between sections.
59+
This shifting is able to keep the sections together during span, sweep, and dihedral changes at the leading edge but enforcing full C0 continuity may still require the construction based approach described above.
5160

52-
The construction-based approach forgoes the constraint entirely.
53-
Continuity by construction is enforced by assigning the B-spline control point located at section edges to the same independent variable controlled by the optimizer.
54-
Enforcing C0 continuity by construction solely applies to geometric parameters that employ B-spline parametrization in OAS.
55-
These include chord distribution, twist distribution, shear distribution in all three directions, and thickness and radius distributions for structural spars.
56-
Geometric transformations parameterized by a single value, such as sweep, taper, and dihedral, cannot be used with C0 continuity enforcement by construction.
61+
.. note::
62+
Mesh shifting cannot compensate for taper transformations.
63+
Instead, the constraint-based approach should be used with the scaler taper variable.
64+
Alternatively, the effect of linear taper can be emulated by using two chord B-spline control points.
5765

66+
.. note::
67+
Mesh shifting could interfere with using the constraint-based approach to maintain C0 continuity during span, sweep, and dihedral transformations.
68+
It is advised to disable mesh shifting by passing the following option into the multi-section geometery group.
5869

59-
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
60-
:start-after: checkpoint 0
61-
:end-before: checkpoint 1
70+
.. code-block:: python
71+
72+
shift_uni_mesh = False
6273
63-
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
64-
:start-after: checkpoint 2
65-
:end-before: checkpoint 3
6674
67-
We can now create the aerodynamic analysis group.
75+
We can now continue by creating the aerodynamic analysis group.
6876

69-
.. literalinclude:: /advanced_features/scripts/basic_2_sec.py
77+
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
7078
:start-after: checkpoint 4
7179
:end-before: checkpoint 5
7280

7381
Connecting the geometry and analysis groups requires care when using the multi-section parameterization.
7482
While the multi-section geometry group is effectively a drop-in replacement for the standard geometery group for multi-section wings, it does require that the unified mesh component be connected to the AeroPoint analysis.
7583

76-
.. literalinclude:: /advanced_features/scripts/basic_2_sec.py
84+
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
7785
:start-after: checkpoint 5
7886
:end-before: checkpoint 6
7987

80-
*The following section applies to user considering cases with thickess to chord B-splines and viscous effects.*
88+
.. note::
89+
When using a thickness to chord ratio B-spline to account for viscous effects the user should be careful to connect the unified thickess to chord ratio B-spline automatically generated by the multi-section geometery group.
8190

82-
When using a thickness to chord ratio B-spline to account for viscous effects the user should be careful to connect the unified thickess to chord ratio B-spline automatically generated by the multi-section geometery group.
83-
84-
.. literalinclude:: /advanced_features/scripts/basic_2_sec_visc.py
85-
:start-after: checkpoint 0
86-
:end-before: checkpoint 1
91+
.. literalinclude:: /advanced_features/scripts/basic_2_sec_visc.py
92+
:start-after: checkpoint 0
93+
:end-before: checkpoint 1
8794

8895
We can now setup our optimization problem and run it.
8996

90-
.. literalinclude:: /advanced_features/scripts/basic_2_sec.py
97+
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
9198
:start-after: checkpoint 6
9299
:end-before: checkpoint 7
93100

94101
We then finish by plotting the result.
95102

96-
.. literalinclude:: /advanced_features/scripts/basic_2_sec.py
103+
.. literalinclude:: /advanced_features/scripts/basic_2_sec_construction.py
97104
:start-after: checkpoint 7
98105
:end-before: checkpoint 8
99106

100107

101-
102-
103-
104108
The following shows the resulting optimized mesh.
105109
The result is identical regardless of if the constraint-based or construction-based joining approahces are used.
106110

107111
.. image:: /advanced_features/figs/multi_section_2_sym.png
112+
113+
114+
Constraint-based Approach
115+
==========================
116+
117+
Setting up the multi-section goemetry group with the constrint-based approach for section joining requires a slightly different inital setup.
118+
The constraint can be enforced at the leading and/or trailing edge of each segment junction in any combination of x, y, or z directions.
119+
A fully differentiated implementation that facilitates setting this constraint is incorporated into OAS. This approach is robust but introduces at least two linear constraints per segment junction.
120+
The steps required to setup the multi-section geometry group by constraint feature differences from the construction-based approach starting at the geometry group setup.
121+
122+
123+
.. literalinclude:: /advanced_features/scripts/basic_2_sec.py
124+
:start-after: checkpoint 3
125+
:end-before: checkpoint 4
126+
127+
128+

openaerostruct/docs/advanced_features/scripts/basic_2_sec.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@
132132
)
133133
prob.model.add_subsystem(surface["name"], multi_geom_group)
134134

135-
# docs checkpoint 4
136135

137136
# In this next part, we will setup the aerodynamics group. First we use a utility function called build_sections which takes our multi-section surface dictionary and outputs a
138137
# surface dictionary for each individual section. We then inputs these dictionaries into the mesh unification function unify_mesh to produce a single mesh array for the the entire surface.
@@ -147,7 +146,6 @@
147146
point_name = "aero_point_0"
148147
prob.model.add_subsystem(point_name, aero_group, promotes_inputs=["v", "alpha", "Mach_number", "re", "rho", "cg"])
149148

150-
# docs checkpoint 5
151149

152150
# The following steps are similar to a normal OAS surface script but note the differences in surface naming. Note that
153151
# unified surface created by the multi-section geometry group needs to be connected to AeroPoint(be careful with the naming)
@@ -165,7 +163,6 @@
165163
name + "." + unification_name + "." + name + "_uni_mesh", point_name + ".aero_states." + "surface" + "_def_mesh"
166164
)
167165

168-
# docs checkpoint 6
169166

170167
# Next, we add the DVs to the OpenMDAO problem. Note that each surface's geometeric parameters are under the given section names specified in the multi-surface dictionary earlier.
171168
# Here we use the chord B-spline that we specified earlier for each section and the angle-of-attack as DVs.
@@ -196,16 +193,13 @@
196193
prob.driver.options["tol"] = 1e-3
197194
prob.driver.options["disp"] = True
198195
prob.driver.options["maxiter"] = 1000
199-
prob.driver.options["debug_print"] = ["nl_cons", "objs", "desvars"]
200196

201197
# Set up and run the optimization problem
202198
prob.setup()
203-
204-
# prob.run_model()
205199
prob.run_driver()
206200
# om.n2(prob)
207201

208-
# docs checkpoint 7
202+
# docs checkpoint 4
209203

210204
# Get each section mesh
211205
mesh1 = prob.get_val("surface.sec0.mesh", units="m")
@@ -217,7 +211,7 @@
217211

218212
# Plot the results
219213
def plot_meshes(meshes):
220-
"""this function plots to plot the mesh"""
214+
"""this function plots a list of meshes on the same plot."""
221215
plt.figure(figsize=(8, 4))
222216
for i, mesh in enumerate(meshes):
223217
mesh_x = mesh[:, :, 0]
@@ -235,7 +229,5 @@ def plot_meshes(meshes):
235229
plt.savefig("opt_planform_constraint.png")
236230

237231

238-
# plot_meshes([mesh1,mesh2])
239232
plot_meshes([meshUni])
240-
# plt.show()
241233
# docs checkpoint 8

0 commit comments

Comments
 (0)