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

Changed the intermediate opt folder format to 0.0001, 00002, etc. #608

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
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
17 changes: 6 additions & 11 deletions dafoam/pyDAFoam.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,6 @@ def __init__(self):

## The sensitivity map will be saved to disk during optimization for the given design variable
## names in the list. Currently only support design variable type FFD and Field
## The surface sensitivity map is separated from the primal solution because they only have surface mesh.
## They will be saved to folders such as 1e-11, 2e-11, 3e-11, etc,
## When loading in paraview, you need to uncheck the "internalMesh", and check "allWalls" on the left panel
## If your design variable is of field type, the sensitivity map will be saved along with the primal
## solution because they share the same mesh. The sensitivity files read sens_objFuncName_designVarName
## NOTE: this function only supports useAD->mode:reverse
## Example:
## "writeSensMap" : ["shapex", "shapey"]
Expand Down Expand Up @@ -2024,7 +2019,7 @@ def calcTotalDerivsFFD(self, objFuncName, designVarName, dFScaling=1.0, accumula
dFdXsFlatten = dFdXs.flatten()
XsFlatten = Xs.flatten()
size = len(dFdXsFlatten)
timeName = float(self.nSolveAdjoints) / 1e8
timeName = float(self.nSolveAdjoints) / 1e4
name = "sens_" + objFuncName + "_" + designVarName
self.solver.writeSensMapSurface(name, dFdXsFlatten, XsFlatten, size, timeName)
# assign the total derivative to self.adjTotalDeriv
Expand Down Expand Up @@ -2080,7 +2075,7 @@ def calcTotalDerivsField(self, objFuncName, designVarName, fieldType, dFScaling=

# check if we need to save the sensitivity maps
if designVarName in self.getOption("writeSensMap"):
timeName = float(self.nSolveAdjoints) / 1e8
timeName = float(self.nSolveAdjoints) / 1e4
dFdFieldArray = self.vec2Array(totalDeriv)
name = "sens_" + objFuncName + "_" + designVarName
self.solver.writeSensMapField(name, dFdFieldArray, fieldType, timeName)
Expand Down Expand Up @@ -3240,7 +3235,7 @@ def deletePrevPrimalSolTime(self):
def renameSolution(self, solIndex):
"""
Rename the primal solution folder to specific format for post-processing. The renamed time has the
format like 1e-8, 2e-8, etc. One can load these intermediate shapes and fields and
format like 0.0001, 0.0002, etc. One can load these intermediate shapes and fields and
plot them in paraview.
The way it is implemented is that we sort the solution folder and consider the largest time folder
as the solution folder and rename it
Expand All @@ -3259,12 +3254,12 @@ def renameSolution(self, solIndex):

latestTime = self.solver.getLatestTime()

if latestTime < 1e-4:
Info("Latest solution time %g less than 1e-4, not renamed." % latestTime)
if latestTime < 1.0:
Info("Latest solution time %g less than 1, not renamed." % latestTime)
renamed = False
return latestTime, renamed

distTime = "%g" % (solIndex / 1e8)
distTime = "%g" % (solIndex / 1e4)
targetTime = "%g" % latestTime

src = os.path.join(checkPath, targetTime)
Expand Down
Loading