From 05c5e1d9bc2babc5a1e92ddc9aa3637cac57593d Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Tue, 4 Apr 2023 10:29:08 -0400 Subject: [PATCH 01/11] Fix shape handling in `nom_addGlobalDV` --- pygeo/mphys/mphys_dvgeo.py | 47 +++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/pygeo/mphys/mphys_dvgeo.py b/pygeo/mphys/mphys_dvgeo.py index c0f69bcb..944900be 100644 --- a/pygeo/mphys/mphys_dvgeo.py +++ b/pygeo/mphys/mphys_dvgeo.py @@ -136,21 +136,56 @@ 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. + + _extended_summary_ + + Parameters + ---------- + dvName : str + A unique name to be given to this design variable group + + value : float, or iterable list of floats + The starting value(s) for the design variable. This + parameter may be a single variable or a numpy array + (or list) if the function requires more than one + variable. The number of variables is determined by the + rank (and if rank ==1, the length) of this parameter. + + func : python function + The python function handle that will be used to apply the + design variable + + 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 From e5b7aa56fe9d547980575ec9caf1354d1e692af2 Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Tue, 4 Apr 2023 10:30:21 -0400 Subject: [PATCH 02/11] cleanup docstring --- pygeo/mphys/mphys_dvgeo.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pygeo/mphys/mphys_dvgeo.py b/pygeo/mphys/mphys_dvgeo.py index 944900be..69a8ecba 100644 --- a/pygeo/mphys/mphys_dvgeo.py +++ b/pygeo/mphys/mphys_dvgeo.py @@ -138,8 +138,6 @@ def nom_add_point_dict(self, point_dict): 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. - _extended_summary_ - Parameters ---------- dvName : str From 8910a7385f54830b4670f10fd06a9f03eb050e56 Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Mon, 10 Apr 2023 13:34:08 -0400 Subject: [PATCH 03/11] Point to original DVGeo method in docstring --- pygeo/mphys/mphys_dvgeo.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pygeo/mphys/mphys_dvgeo.py b/pygeo/mphys/mphys_dvgeo.py index 69a8ecba..cbd53f93 100644 --- a/pygeo/mphys/mphys_dvgeo.py +++ b/pygeo/mphys/mphys_dvgeo.py @@ -141,18 +141,13 @@ def nom_addGlobalDV(self, dvName, value, func, childIdx=None, isComposite=False) Parameters ---------- dvName : str - A unique name to be given to this design variable group + See :meth:`addGlobalDV <.DVGeometry.addGlobalDV>` value : float, or iterable list of floats - The starting value(s) for the design variable. This - parameter may be a single variable or a numpy array - (or list) if the function requires more than one - variable. The number of variables is determined by the - rank (and if rank ==1, the length) of this parameter. + See :meth:`addGlobalDV <.DVGeometry.addGlobalDV>` func : python function - The python function handle that will be used to apply the - design variable + See :meth:`addGlobalDV <.DVGeometry.addGlobalDV>` childIdx : int, optional The zero-based index of the child FFD, if this DV is for a child FFD. From 92a6e56cb3fa99d6b59b9cec684327865741425c Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Mon, 10 Apr 2023 13:34:23 -0400 Subject: [PATCH 04/11] Create mphys component docs page --- doc/API.rst | 1 + doc/mphys_dvgeo.rst | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 doc/mphys_dvgeo.rst 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/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: From 77623967c76bc2821df4d491c1548c8005621d1d Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Mon, 10 Apr 2023 13:37:37 -0400 Subject: [PATCH 05/11] Add openmdao to docs requirements --- doc/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/requirements.txt b/doc/requirements.txt index b03c9681..58aa0848 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,2 +1,3 @@ numpydoc sphinx_mdolab_theme +openmdao From 2fc70d3939475f12a25bc26501e21f86a0236577 Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Mon, 17 Apr 2023 10:41:23 -0400 Subject: [PATCH 06/11] Update conf.py --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index fa25f384..dd16d46d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -30,7 +30,7 @@ ) # 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"] From 9ba1947eefe55d691e15895750438608675081c8 Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Mon, 17 Apr 2023 10:58:45 -0400 Subject: [PATCH 07/11] Update requirements.txt --- doc/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/requirements.txt b/doc/requirements.txt index 58aa0848..9229b411 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,3 +1,4 @@ numpydoc sphinx_mdolab_theme openmdao +mphys From ccf72d073af8b40560bbb23816fd29b7ad9aab47 Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Mon, 17 Apr 2023 10:59:01 -0400 Subject: [PATCH 08/11] Update conf.py --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index dd16d46d..c4a98ad8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -30,7 +30,7 @@ ) # mock import for autodoc -autodoc_mock_imports = ["numpy", "mpi4py", "scipy", "pyspline", "baseclasses", "pysurf", "prefoil", "pyOCSM", "openvsp", "openMDAO"] +autodoc_mock_imports = ["numpy", "mpi4py", "scipy", "pyspline", "baseclasses", "pysurf", "prefoil", "pyOCSM", "openvsp", "openMDAO", "mphys"] # This sets the bibtex bibliography file(s) to reference in the documentation bibtex_bibfiles = ["ref.bib"] From 8066abc535af3a44b1635f545a2b2a7e84718d37 Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Mon, 17 Apr 2023 11:00:04 -0400 Subject: [PATCH 09/11] `black -l 120 .` --- doc/conf.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index c4a98ad8..3abb5be3 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -30,7 +30,19 @@ ) # mock import for autodoc -autodoc_mock_imports = ["numpy", "mpi4py", "scipy", "pyspline", "baseclasses", "pysurf", "prefoil", "pyOCSM", "openvsp", "openMDAO", "mphys"] +autodoc_mock_imports = [ + "numpy", + "mpi4py", + "scipy", + "pyspline", + "baseclasses", + "pysurf", + "prefoil", + "pyOCSM", + "openvsp", + "openMDAO", + "mphys", +] # This sets the bibtex bibliography file(s) to reference in the documentation bibtex_bibfiles = ["ref.bib"] From 49995d61469ad6ec8ace01f1d3c3196e908887b9 Mon Sep 17 00:00:00 2001 From: Eirikur Jonsson Date: Mon, 17 Apr 2023 16:53:03 +0000 Subject: [PATCH 10/11] minor edit --- doc/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 3abb5be3..a586c61b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -40,8 +40,7 @@ "prefoil", "pyOCSM", "openvsp", - "openMDAO", - "mphys", + "openmdao", ] # This sets the bibtex bibliography file(s) to reference in the documentation From 5e2827f0e77572827c38019346553a7650aa6426 Mon Sep 17 00:00:00 2001 From: Hannah Hajdik Date: Fri, 21 Apr 2023 15:05:51 -0400 Subject: [PATCH 11/11] Update requirements.txt --- doc/requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 9229b411..b03c9681 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,4 +1,2 @@ numpydoc sphinx_mdolab_theme -openmdao -mphys