diff --git a/doc/API.rst b/doc/API.rst index 7b3eac54..b1d4a233 100644 --- a/doc/API.rst +++ b/doc/API.rst @@ -9,6 +9,7 @@ This package consists of the following modules: :maxdepth: 1 DVConstraints + mphys_dvgeo DVGeometry DVGeometryMulti DVGeometryESP diff --git a/doc/conf.py b/doc/conf.py index fa25f384..a586c61b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -30,7 +30,18 @@ ) # mock import for autodoc -autodoc_mock_imports = ["numpy", "mpi4py", "scipy", "pyspline", "baseclasses", "pysurf", "prefoil", "pyOCSM", "openvsp"] +autodoc_mock_imports = [ + "numpy", + "mpi4py", + "scipy", + "pyspline", + "baseclasses", + "pysurf", + "prefoil", + "pyOCSM", + "openvsp", + "openmdao", +] # This sets the bibtex bibliography file(s) to reference in the documentation bibtex_bibfiles = ["ref.bib"] diff --git a/doc/mphys_dvgeo.rst b/doc/mphys_dvgeo.rst new file mode 100644 index 00000000..23f8b6f1 --- /dev/null +++ b/doc/mphys_dvgeo.rst @@ -0,0 +1,6 @@ +.. _OM_DVGEOCOMP: + +MPhys DVGeo Component +--------------------- +.. autoclass:: pygeo.mphys.mphys_dvgeo.OM_DVGEOCOMP + :members: diff --git a/pygeo/mphys/mphys_dvgeo.py b/pygeo/mphys/mphys_dvgeo.py index c0f69bcb..cbd53f93 100644 --- a/pygeo/mphys/mphys_dvgeo.py +++ b/pygeo/mphys/mphys_dvgeo.py @@ -136,21 +136,49 @@ def nom_add_point_dict(self, point_dict): self.nom_addPointSet(v, k) 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. + + Parameters + ---------- + dvName : str + See :meth:`addGlobalDV <.DVGeometry.addGlobalDV>` + + value : float, or iterable list of floats + See :meth:`addGlobalDV <.DVGeometry.addGlobalDV>` + + func : python function + See :meth:`addGlobalDV <.DVGeometry.addGlobalDV>` + + 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. + + isComposite : bool, optional + Whether this DV is to be included in the composite DVs, by default False + + Raises + ------ + RuntimeError + Raised if the underlying DVGeo object is not an FFD + """ # global DVs are only added to FFD-based DVGeo objects if self.geo_type != "ffd": raise RuntimeError(f"Only FFD-based DVGeo objects can use global DVs, not type:{self.geo_type}") - # define the input - # When composite DVs are used, input is not required for the default DVs. Now the composite DVs are - # the actual DVs. So OpenMDAO don't need the default DVs as inputs. - if not isComposite: - self.add_input(dvName, distributed=False, shape=len(value)) - # call the dvgeo object and add this dv if childIdx is None: self.DVGeo.addGlobalDV(dvName, value, func) + shape = self.DVGeo.DV_listGlobal[dvName].nVal else: self.DVGeo.children[childIdx].addGlobalDV(dvName, value, func) + shape = self.DVGeo.children[childIdx].DV_listGlobal[dvName].nVal + + # define the input + # When composite DVs are used, input is not required for the default DVs. Now the composite DVs are + # the actual DVs. So OpenMDAO don't need the default DVs as inputs. + if not isComposite: + self.add_input(dvName, val=value, distributed=False, shape=shape) def nom_addLocalDV(self, dvName, axis="y", pointSelect=None, childIdx=None, isComposite=False): # local DVs are only added to FFD-based DVGeo objects