-
Notifications
You must be signed in to change notification settings - Fork 113
Custom pointsets for dvgeo #299
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
Draft
anilyil
wants to merge
20
commits into
mdolab:main
Choose a base branch
from
anilyil:children_dict
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1ab1f6b
first implementation of custom subset of active child FFDs for family…
anilyil b6b294a
Merge branch 'main' into children_dict
anilyil 13b30e1
added reverse mode sensitivities w/ active children check
anilyil 9da19f2
bug fix
anilyil be7d63f
fixed the derivative bug
anilyil a092672
Merge remote-tracking branch 'mdolab/main' into children_dict
anilyil 5beaff3
modified the implementation to be more general
anilyil 04ff66f
Merge branch 'main' into children_dict
anilyil 6e3d586
Merge branch 'main' into children_dict
anilyil d16de96
Merge branch 'main' into children_dict
A-CGray 32d4479
Merge branch 'main' into children_dict
anilyil 9f047f4
add the missing jacvec modifications
anilyil bb2a6cd
fix fwd jacvec product
anilyil fa8821f
Merge remote-tracking branch 'mdolab/main' into children_dict
anilyil 78109c1
Merge branch 'main' into children_dict
eirikurj 6f99214
Merge remote-tracking branch 'mdolab/main' into children_dict
anilyil f217a3a
Merge remote-tracking branch 'mdolab/main' into children_dict
anilyil fc13695
add custom ptset kwargs for the blanking surfaces when they are used …
anilyil d5f1daa
Merge branch 'main' into children_dict
A-CGray 1f6a90b
Merge remote-tracking branch 'mdolab/main' into children_dict
anilyil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3255,8 +3255,6 @@ | |
| Flag to release the adjoint memory when setting a new aeroproblem, by default True | ||
| """ | ||
|
|
||
| ptSetName = "adflow_%s_coords" % aeroProblem.name | ||
|
|
||
| newAP = False | ||
| # Tell the user if we are switching aeroProblems | ||
| if self.curAP != aeroProblem: | ||
|
|
@@ -3270,9 +3268,23 @@ | |
| aeroProblem.adflowData | ||
| except AttributeError: | ||
| aeroProblem.adflowData = adflowFlowCase() | ||
| aeroProblem.ptSetName = ptSetName | ||
| aeroProblem.surfMesh = self.getSurfaceCoordinates(self.designFamilyGroup) | ||
|
|
||
| # dictionary that holds the ptsetname for each family | ||
| ptSetNames = {} | ||
| if self.customPointSetFamilies is None: | ||
| # we dont have a custom child dvgeo mapping. the surface family will be only | ||
| # designFamilyGroup and we will have a single pointset | ||
| ptSetName = f"adflow_{self.designFamilyGroup}_{aeroProblem.name}_coords" | ||
| ptSetNames[self.designFamilyGroup] = ptSetName | ||
| else: | ||
| # we have a custom surface family to child dvgeo mapping. | ||
| for familyName in self.customPointSetFamilies.keys(): | ||
| ptSetName = f"adflow_{familyName}_{aeroProblem.name}_coords" | ||
| ptSetNames[familyName] = ptSetName | ||
|
|
||
| aeroProblem.ptSetNames = ptSetNames | ||
|
|
||
| if self.curAP is not None: | ||
| # If we have already solved something and are now | ||
| # switching, save what we need: | ||
|
|
@@ -3300,10 +3312,31 @@ | |
|
|
||
| # Now check if we have an DVGeo object to deal with: | ||
| if self.DVGeo is not None: | ||
| # DVGeo appeared and we have not embedded points! | ||
| if ptSetName not in self.DVGeo.points: | ||
| coords0 = self.mapVector(self.coords0, self.allFamilies, self.designFamilyGroup, includeZipper=False) | ||
| self.DVGeo.addPointSet(coords0, ptSetName, **self.pointSetKwargs) | ||
| # we have a DVGeo added. check if we have already added the points for this AP | ||
| if self.customPointSetFamilies is None: | ||
| # we have a single pointset | ||
| ptSetName = aeroProblem.ptSetNames[self.designFamilyGroup] | ||
|
|
||
| if ptSetName not in self.DVGeo.points: | ||
| coords0 = self.mapVector( | ||
| self.coords0, self.allFamilies, self.designFamilyGroup, includeZipper=False | ||
| ) | ||
| self.DVGeo.addPointSet(coords0, ptSetName, **self.pointSetKwargs) | ||
| else: | ||
| # we have custom pointsets | ||
| for family, familyKwargs in self.customPointSetFamilies.items(): | ||
| ptSetName = aeroProblem.ptSetNames[family] | ||
|
|
||
| if ptSetName not in self.DVGeo.points: | ||
| # coords0 is now the subset of this family | ||
| coords0 = self.mapVector(self.coords0, self.allFamilies, family, includeZipper=False) | ||
| # this pointset is added with a custom familyKwargs | ||
| self.DVGeo.addPointSet( | ||
| coords0, | ||
| ptSetName, | ||
| **self.pointSetKwargs, | ||
| **familyKwargs, | ||
| ) | ||
|
|
||
| # also check if we need to embed blanking surface points | ||
| if self.getOption("oversetUpdateMode") == "full" and self.getOption("explicitSurfaceCallback") is not None: | ||
|
|
@@ -3313,6 +3346,7 @@ | |
| # used in the explicit hole cutting multiple times in different | ||
| # configurations. | ||
| surfFile = self.blankingSurfDict[surf]["surfFile"] | ||
| surfPointSetKwargs = self.blankingSurfDict[surf]["pointSetKwargs"] | ||
| surfPtSetName = f"points_{surfFile}" | ||
| if surfPtSetName not in self.DVGeo.points: | ||
| # we need to add the pointset to dvgeo. do it in parallel | ||
|
|
@@ -3334,11 +3368,52 @@ | |
| # we already communicated the points when loading the file, | ||
| # so just add them to dvgeo now | ||
| procPts = surfPts[disp[self.comm.rank] : disp[self.comm.rank + 1]] | ||
| self.DVGeo.addPointSet(procPts, surfPtSetName, **self.pointSetKwargs) | ||
| self.DVGeo.addPointSet(procPts, surfPtSetName, **self.pointSetKwargs, **surfPointSetKwargs) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does passing two sets of kwargs to |
||
|
|
||
| # Check if our point-set is up to date: | ||
| if not self.DVGeo.pointSetUpToDate(ptSetName) or aeroProblem.adflowData.disp is not None: | ||
| coords = self.DVGeo.update(ptSetName, config=aeroProblem.name) | ||
| updateSurface = False | ||
|
|
||
| # check for disp first. doing this check here is not the most efficient, | ||
| # but it results in simpler code | ||
| if aeroProblem.adflowData.disp is not None: | ||
| updateSurface = True | ||
|
|
||
| if self.customPointSetFamilies is None: | ||
| # we have a single pointset | ||
| ptSetName = aeroProblem.ptSetNames[self.designFamilyGroup] | ||
|
|
||
| if not self.DVGeo.pointSetUpToDate(ptSetName): | ||
| updateSurface = True | ||
|
|
||
| coords = self.DVGeo.update(ptSetName, config=aeroProblem.name) | ||
|
|
||
| else: | ||
| # we have custom pointsets | ||
| # first figure out if we want to update the pointset; check each family we are tracking | ||
| for family in self.customPointSetFamilies.keys(): | ||
| # return immediately if we are flagged for a surfafce update | ||
| if updateSurface: | ||
| break | ||
|
|
||
| # check if any of the pointsets are out of date | ||
| ptSetName = aeroProblem.ptSetNames[family] | ||
| if not self.DVGeo.pointSetUpToDate(ptSetName): | ||
| updateSurface = True | ||
|
|
||
| # if we have the updateSurface flag True, compute the coords array | ||
| if updateSurface: | ||
| # get the current design surface family. we will overwrite this as we go through the families | ||
| coords = self.mapVector(self.coords0, self.allFamilies, self.designFamilyGroup, includeZipper=False) | ||
|
|
||
| for family in self.customPointSetFamilies.keys(): | ||
| ptSetName = aeroProblem.ptSetNames[family] | ||
| familyCoords = self.DVGeo.update(ptSetName, config=aeroProblem.name) | ||
| # map this to the coords vector | ||
| self.mapVector(familyCoords, family, self.designFamilyGroup, vec2=coords, includeZipper=False) | ||
|
|
||
| if updateSurface: | ||
| # the coords array is computed above. if we have the update surface flag enabled, | ||
| # run the surface update | ||
|
|
||
| # Potentially add a fixed set of displacements to it. | ||
| if aeroProblem.adflowData.disp is not None: | ||
|
|
@@ -4674,9 +4749,22 @@ | |
| # already existing (and possibly nonzero) xsdot and xvdot | ||
| if xDvDot is not None or xSDot is not None: | ||
| if xDvDot is not None and self.DVGeo is not None: | ||
| xsdot += self.DVGeo.totalSensitivityProd(xDvDot, self.curAP.ptSetName, config=self.curAP.name).reshape( | ||
| xsdot.shape | ||
| ) | ||
| if self.customPointSetFamilies is None: | ||
| # no custom pointset families, just process the entire dvdot and add to xsdot | ||
| xsdot += self.DVGeo.totalSensitivityProd( | ||
| xDvDot, self.curAP.ptSetNames[self.designFamilyGroup], config=self.curAP.name | ||
| ).reshape(xsdot.shape) | ||
| else: | ||
| # custom pointsets. accumulate local xsdots in the complete vector | ||
| for family in self.customPointSetFamilies.keys(): | ||
| # process this family's xsdot | ||
| ptSetName = self.curAP.ptSetNames[family] | ||
| xsdot_family = self.DVGeo.totalSensitivityProd( | ||
| xDvDot, ptSetName, self.comm, config=self.curAP.name | ||
| ) | ||
| # map it to an empty surface vector and accumulate | ||
| xsdot += self.mapVector(xsdot_family, family, self.designFamilyGroup) | ||
|
|
||
| if self.mesh is not None: | ||
| xsdot = self.mapVector(xsdot, self.meshFamilyGroup, self.designFamilyGroup, includeZipper=False) | ||
| xvdot += self.mesh.warpDerivFwd(xsdot) | ||
|
|
@@ -4992,12 +5080,38 @@ | |
| if xDvDeriv: | ||
| xdvbar = {} | ||
| if self.mesh is not None: # Include geometric | ||
| # derivatives if mesh is | ||
| # present | ||
| # derivatives if mesh is present | ||
| if self.DVGeo is not None and self.DVGeo.getNDV() > 0: | ||
| xdvbar.update( | ||
| self.DVGeo.totalSensitivity(xsbar, self.curAP.ptSetName, self.comm, config=self.curAP.name) | ||
| ) | ||
| # we have a DVGeo added. check if we have already added the points for this AP | ||
| if self.customPointSetFamilies is None: | ||
| # we have a single pointset | ||
| ptSetName = self.curAP.ptSetNames[self.designFamilyGroup] | ||
|
|
||
| xdvbar.update( | ||
| self.DVGeo.totalSensitivity(xsbar, ptSetName, self.comm, config=self.curAP.name) | ||
| ) | ||
|
|
||
| else: | ||
| # we have custom pointsets | ||
| # start with an empty dict, we set the entries in the first pass, | ||
| # and add in the following passes | ||
| for family in self.customPointSetFamilies.keys(): | ||
| ptSetName = self.curAP.ptSetNames[family] | ||
|
|
||
| # get the mapped xsbar | ||
| xsbarFamily = self.mapVector(xsbar, self.designFamilyGroup, family, includeZipper=False) | ||
|
|
||
| familySens = self.DVGeo.totalSensitivity( | ||
| xsbarFamily, ptSetName, self.comm, config=self.curAP.name | ||
| ) | ||
|
|
||
| for key, val in familySens.items(): | ||
| # not the best way to do this but should work... | ||
| if key in xdvbar: | ||
| xdvbar[key] += val | ||
| else: | ||
| xdvbar[key] = val | ||
|
|
||
| else: | ||
| if self.comm.rank == 0: | ||
| ADFLOWWarning( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the use of
customPointSetFamiliesexclusive to cases where you use child DVGeo's? If not then can you re-word these comments to avoid talking about child dvgeos as it's a bit confusing.