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

New functions in MPhys wrapper #193

Merged
merged 32 commits into from
May 22, 2023
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0baa201
add section dv
hajdik Mar 28, 2023
183a89e
fix childidx
hajdik Mar 28, 2023
8cb8bbe
comment switch
hajdik Mar 28, 2023
a7d57d6
add other DVGeo and DVCon functions
hajdik Apr 3, 2023
d3df0d1
removed old function
hajdik Apr 3, 2023
05c5e1d
Fix shape handling in `nom_addGlobalDV`
A-CGray Apr 4, 2023
e5b7aa5
cleanup docstring
A-CGray Apr 4, 2023
8910a73
Point to original DVGeo method in docstring
A-CGray Apr 10, 2023
92a6e56
Create mphys component docs page
A-CGray Apr 10, 2023
7762396
Add openmdao to docs requirements
A-CGray Apr 10, 2023
2fc70d3
Update conf.py
A-CGray Apr 17, 2023
9ba1947
Update requirements.txt
A-CGray Apr 17, 2023
ccf72d0
Update conf.py
A-CGray Apr 17, 2023
8066abc
`black -l 120 .`
A-CGray Apr 17, 2023
49995d6
minor edit
eirikurj Apr 17, 2023
a4d2c33
Merge branch 'allowScalarDVMPhys' of ssh://github.com/mdolab/pygeo in…
hajdik Apr 21, 2023
5e2827f
Update requirements.txt
hajdik Apr 21, 2023
a44bb7f
Merge branch 'allowScalarDVMPhys' of ssh://github.com/mdolab/pygeo in…
hajdik Apr 21, 2023
3ea6d21
docstrings
hajdik Apr 21, 2023
4561b27
Merge branch 'main' into mphys-localsectiondv
hajdik Apr 21, 2023
f579eae
Merge branch 'main' into mphys-localsectiondv
hajdik May 15, 2023
1e6985e
Merge branch 'main' of ssh://github.com/mdolab/pygeo into mphys-local…
hajdik May 15, 2023
d7f6d4d
add getter for dvgeo
hajdik May 15, 2023
5a577ba
clean up my docstrings
hajdik May 15, 2023
7cb9ff2
extend to return a child DVGeo
hajdik May 15, 2023
b983178
get DVCon
hajdik May 15, 2023
db38b7c
Merge branch 'mphys-localsectiondv' of github.com:hajdik/pygeo into m…
hajdik May 15, 2023
fb964c1
docstrings
hajdik May 15, 2023
a2af073
Merge branch 'main' into mphys-localsectiondv
hajdik May 15, 2023
73a8d41
int
hajdik May 16, 2023
190ba6e
take out addRefAxis
hajdik May 16, 2023
9e7bf7c
return of the refaxis
hajdik May 17, 2023
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
190 changes: 166 additions & 24 deletions pygeo/mphys/mphys_dvgeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,45 @@ def nom_add_point_dict(self, point_dict):
for k, v in point_dict.items():
self.nom_addPointSet(v, k)

def nom_getDVGeo(self, childIdx=None):
"""
Gets the DVGeometry object held in the geometry component so DVGeo methods can be called directly on it

Parameters
----------
childIdx : int, optional
The zero-based index of the child FFD, you want a child DVGeo returned

Returns
-------
self.DVGeo, DVGeometry object
DVGeometry object held by this geometry component

"""

# return the top level DVGeo
if childIdx is None:
return self.DVGeo

# return a child DVGeo
else:
return self.DVGeo.children[childIdx]

def nom_getDVCon(self):
"""
Gets the DVConstraints object held in the geometry component so DVCon methods can be called directly on it

Returns
-------
self.DVCon, DVConstraints object
DVConstraints object held by this geometry component
"""
return self.DVCon

"""
Wrapper for DVGeo functions
"""

def nom_addGlobalDV(self, dvName, value, func, childIdx=None, isComposite=False):
"""Add a global design variable to the DVGeo object. This is a wrapper for the DVGeo.addGlobalDV method.

Expand Down Expand Up @@ -197,6 +236,80 @@ def nom_addLocalDV(self, dvName, axis="y", pointSelect=None, childIdx=None, isCo
self.add_input(dvName, distributed=False, shape=nVal)
return nVal

def nom_addLocalSectionDV(
self,
dvName,
secIndex,
childIdx=None,
axis=1,
pointSelect=None,
volList=None,
orient0=None,
orient2="svd",
config=None,
):
"""
Add one or more section local design variables to the DVGeometry object
Wrapper for :meth:`addLocalSectionDV <.DVGeometry.addLocalSectionDV>`
Input parameters are identical to those in wrapped function unless otherwise specified

Parameters
----------
dvName : str
Name to give this design variable
secIndex : char or list of chars
See wrapped
childIdx : int, optional
The zero-based index of the child FFD, if this DV is for a child FFD
The index is defined by the order in which you add the child FFD to the parent
For example, the first child FFD has an index of 0, the second an index of 1, and so on
axis : int, optional
See wrapped
pointSelect : pointSelect object, optional
See wrapped
volList : list, optional
See wrapped
orient0 : orientation, optional
See wrapped
orient2 : str, optional
See wrapped
config : str or list, optional
See wrapped

Returns
-------
nVal, int
number of local section DVs

Raises
------
RuntimeError
Raised if the underlying DVGeo parameterization is not FFD-based
"""
# local DVs are only added to FFD-based DVGeo objects
if self.geo_type != "ffd":
raise RuntimeError(f"Only FFD-based DVGeo objects can use local DVs, not type:{self.geo_type}")

# add the DV to a normal DVGeo
if childIdx is None:
nVal = self.DVGeo.addLocalSectionDV(dvName, secIndex, axis, pointSelect, volList, orient0, orient2, config)
# add the DV to a child DVGeo
else:
nVal = self.DVGeo.children[childIdx].addLocalSectionDV(
dvName,
secIndex,
axis,
pointSelect,
volList,
orient0,
orient2,
config,
)

# define the input
self.add_input(dvName, distributed=False, shape=nVal)
return nVal

def nom_addGeoCompositeDV(self, dvName, ptSetName=None, u=None, scale=None, **kwargs):
# call the dvgeo object and add this dv
self.DVGeo.addCompositeDV(dvName, ptSetName=ptSetName, u=u, scale=scale, **kwargs)
Expand Down Expand Up @@ -242,8 +355,44 @@ def nom_addESPVariable(self, desmptr_name, isComposite=False, **kwargs):
if not isComposite:
self.add_input(desmptr_name, distributed=False, shape=val.shape, val=val)

def nom_addThicknessConstraints2D(self, name, leList, teList, nSpan=10, nChord=10):
self.DVCon.addThicknessConstraints2D(leList, teList, nSpan, nChord, lower=1.0, name=name)
def nom_addRefAxis(self, childIdx=None, **kwargs):
# references axes are only needed in FFD-based DVGeo objects
if self.geo_type != "ffd":
raise RuntimeError(f"Only FFD-based DVGeo objects can use reference axes, not type:{self.geo_type}")

# we just pass this through
if childIdx is None:
return self.DVGeo.addRefAxis(**kwargs)
else:
return self.DVGeo.children[childIdx].addRefAxis(**kwargs)

"""
Wrapper for DVCon functions
"""

def nom_addThicknessConstraints2D(
self,
name,
leList,
teList,
nSpan,
nChord,
scaled=True,
surfaceName="default",
DVGeoName="default",
compNames=None,
):
self.DVCon.addThicknessConstraints2D(
leList,
teList,
nSpan,
nChord,
name=name,
scaled=scaled,
surfaceName=surfaceName,
DVGeoName=DVGeoName,
compNames=compNames,
)
self.add_output(name, distributed=False, val=np.ones((nSpan * nChord,)), shape=nSpan * nChord)

def nom_addThicknessConstraints1D(self, name, ptList, nCon, axis, scaled=True):
Expand All @@ -252,23 +401,25 @@ def nom_addThicknessConstraints1D(self, name, ptList, nCon, axis, scaled=True):

def nom_addVolumeConstraint(self, name, leList, teList, nSpan=10, nChord=10, scaled=True, surfaceName="default"):
"""Add a DVCon volume constraint to the problem
Wrapper for :meth:`addVolumeConstraint <.DVConstraints.addVolumeConstraint>`
Input parameters are identical to those in wrapped function unless otherwise specified

Parameters
----------
name :
See :meth:`addVolumeConstraint <.DVConstraints.addVolumeConstraint>`
See wrapped
leList :
See :meth:`addVolumeConstraint <.DVConstraints.addVolumeConstraint>`
See wrapped
teList :
See :meth:`addVolumeConstraint <.DVConstraints.addVolumeConstraint>`
See wrapped
nSpan : int, optional
See :meth:`addVolumeConstraint <.DVConstraints.addVolumeConstraint>`, by default 10
See wrapped
nChord : int, optional
See :meth:`addVolumeConstraint <.DVConstraints.addVolumeConstraint>`, by default 10
See wrapped
scaled : bool, optional
See :meth:`addVolumeConstraint <.DVConstraints.addVolumeConstraint>`, by default True
See wrapped
surfaceName : str, optional
See :meth:`addVolumeConstraint <.DVConstraints.addVolumeConstraint>`, by default "default"
See wrapped
"""
self.DVCon.addVolumeConstraint(
leList, teList, nSpan=nSpan, nChord=nChord, scaled=scaled, name=name, surfaceName=surfaceName
Expand All @@ -277,17 +428,19 @@ def nom_addVolumeConstraint(self, name, leList, teList, nSpan=10, nChord=10, sca

def nom_addProjectedAreaConstraint(self, name, axis, scaled=True, surface_name="default"):
"""Add a DVCon projected area constraint to the problem
Wrapper for :meth:`addProjectedAreaConstraint <.DVConstraints.addProjectedAreaConstraint>`
Input parameters are identical to those in wrapped function unless otherwise specified

Parameters
----------
name :
See :meth:`addProjectedAreaConstraint <.DVConstraints.addProjectedAreaConstraint>`
See wrapped
axis :
See :meth:`addProjectedAreaConstraint <.DVConstraints.addProjectedAreaConstraint>`
See wrapped
scaled : bool, optional
See :meth:`addProjectedAreaConstraint <.DVConstraints.addProjectedAreaConstraint>`, by default True
See wrapped
surface_name : str, optional
See :meth:`addProjectedAreaConstraint <.DVConstraints.addProjectedAreaConstraint>`, by default "default"
See wrapped
"""
self.DVCon.addProjectedAreaConstraint(axis, name=name, scaled=scaled, surfaceName=surface_name)
self.add_output(name, distributed=False, val=1.0)
Expand Down Expand Up @@ -341,17 +494,6 @@ def nom_addTriangulatedSurfaceConstraint(
self.add_output(f"{name}_KS", distributed=False, val=0)
self.add_output(f"{name}_perim", distributed=False, val=0)

def nom_addRefAxis(self, childIdx=None, **kwargs):
# references axes are only needed in FFD-based DVGeo objects
if self.geo_type != "ffd":
raise RuntimeError(f"Only FFD-based DVGeo objects can use reference axes, not type:{self.geo_type}")

# we just pass this through
if childIdx is None:
return self.DVGeo.addRefAxis(**kwargs)
else:
return self.DVGeo.children[childIdx].addRefAxis(**kwargs)

def nom_setConstraintSurface(
self, surface, name="default", addToDVGeo=False, DVGeoName="default", surfFormat="point-vector"
):
Expand Down