Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make geometry spline interpolation mesh independent #435

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Changes from 1 commit
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
40 changes: 34 additions & 6 deletions openaerostruct/geometry/geometry_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@
from openaerostruct.utils.check_surface_dict import check_surface_dict_keys


def get_normalized_span_coords(surface, mid_panel=False):
"""Get the normalised coordinates used for interpolating values along the wingspan

These normalized coordinates range from 0 at the tip of the wing to 1 at the root.

Parameters
----------
surface : OpenAeroStruct surface dictionary
Surface to generate coordinates for
mid_panel : bool, optional
Whether the normalized coordinate should be of the panel midpoints rather than the mesh nodes, by default False

Returns
-------
np.array
Normalized coordinate values
"""
spanwise_coord = surface["mesh"][0, :, 1]
span_range = spanwise_coord[-1] - spanwise_coord[0]
span_offset = spanwise_coord[0]
if mid_panel:
x_real = (spanwise_coord[:-1] + spanwise_coord[1:]) / 2
else:
x_real = spanwise_coord
x_norm = (x_real - span_offset) / span_range
return x_norm


class Geometry(om.Group):
"""
Group that contains all components needed for any type of OAS problem.
Expand Down Expand Up @@ -67,7 +95,7 @@ def setup(self):
if "twist_cp" in surface.keys():
n_cp = len(surface["twist_cp"])
# Add bspline components for active bspline geometric variables.
x_interp = np.linspace(0.0, 1.0, int(ny))
x_interp = get_normalized_span_coords(surface)
comp = self.add_subsystem(
"twist_bsp",
om.SplineComp(
Expand All @@ -86,7 +114,7 @@ def setup(self):
if "chord_cp" in surface.keys():
n_cp = len(surface["chord_cp"])
# Add bspline components for active bspline geometric variables.
x_interp = np.linspace(0.0, 1.0, int(ny))
x_interp = get_normalized_span_coords(surface)
comp = self.add_subsystem(
"chord_bsp",
om.SplineComp(
Expand All @@ -103,7 +131,7 @@ def setup(self):
if "t_over_c_cp" in surface.keys():
n_cp = len(surface["t_over_c_cp"])
# Add bspline components for active bspline geometric variables.
x_interp = np.linspace(0.0, 1.0, int(ny - 1))
x_interp = get_normalized_span_coords(surface, mid_panel=True)
comp = self.add_subsystem(
"t_over_c_bsp",
om.SplineComp(
Expand All @@ -119,7 +147,7 @@ def setup(self):
if "xshear_cp" in surface.keys():
n_cp = len(surface["xshear_cp"])
# Add bspline components for active bspline geometric variables.
x_interp = np.linspace(0.0, 1.0, int(ny))
x_interp = get_normalized_span_coords(surface)
comp = self.add_subsystem(
"xshear_bsp",
om.SplineComp(
Expand All @@ -136,7 +164,7 @@ def setup(self):
if "yshear_cp" in surface.keys():
n_cp = len(surface["yshear_cp"])
# Add bspline components for active bspline geometric variables.
x_interp = np.linspace(0.0, 1.0, int(ny))
x_interp = get_normalized_span_coords(surface)
comp = self.add_subsystem(
"yshear_bsp",
om.SplineComp(
Expand All @@ -153,7 +181,7 @@ def setup(self):
if "zshear_cp" in surface.keys():
n_cp = len(surface["zshear_cp"])
# Add bspline components for active bspline geometric variables.
x_interp = np.linspace(0.0, 1.0, int(ny))
x_interp = get_normalized_span_coords(surface)
comp = self.add_subsystem(
"zshear_bsp",
om.SplineComp(
Expand Down
Loading