-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used new reg_test_files and added rhoPimple test. (#609)
* Switched the reg_test input to a repo. * Added the DARhoPimple test. * Fixed an issue in the make file for rhopimple. * Added the missing make file for rhopimple.
- Loading branch information
Showing
49 changed files
with
228 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -5,4 +5,4 @@ if [ -z "$WM_PROJECT" ]; then | |
exit 1 | ||
fi | ||
|
||
rm -rf input __pycache__ | ||
rm -rf reg_test_files-main __pycache__ |
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Dictionary Key: CD | ||
@value 0.2304630624535831 1e-08 1e-10 | ||
Dictionary Key: CL | ||
@value 6.3056661425586 1e-08 1e-10 | ||
Dictionary Key: fail | ||
@value 0 1e-08 1e-10 | ||
Dictionary Key: CD | ||
Dictionary Key: twist | ||
@value -0.1045060854662659 0.0001 1e-06 | ||
Dictionary Key: CL | ||
Dictionary Key: twist | ||
@value -0.2190748076682245 0.0001 1e-06 | ||
Dictionary Key: fail | ||
@value 0 0.0001 1e-06 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,154 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Run Python tests for DARhoPimpleFoam | ||
""" | ||
|
||
from mpi4py import MPI | ||
from dafoam import PYDAFOAM, optFuncs | ||
import sys | ||
import os | ||
from pygeo import * | ||
from pyspline import * | ||
from idwarp import * | ||
import numpy as np | ||
from testFuncs import * | ||
|
||
calcFDSens = 0 | ||
if len(sys.argv) != 1: | ||
if sys.argv[1] == "calcFDSens": | ||
calcFDSens = 1 | ||
|
||
gcomm = MPI.COMM_WORLD | ||
|
||
os.chdir("./reg_test_files-main/NACA0012UnsteadyComp") | ||
|
||
if gcomm.rank == 0: | ||
os.system("rm -rf processor*") | ||
|
||
twist0 = 0 | ||
U0 = 100 | ||
T0 = 300.0 | ||
p0 = 101325.0 | ||
rho0 = p0 / 287.0 / T0 | ||
A0 = 0.1 | ||
nuTilda0 = 1e-4 | ||
|
||
# test incompressible solvers | ||
daOptions = { | ||
"designSurfaces": ["wing"], | ||
"solverName": "DARhoPimpleFoam", | ||
"primalBC": {"useWallFunction": True}, | ||
"unsteadyAdjoint": { | ||
"mode": "timeAccurate", | ||
"PCMatPrecomputeInterval": 20, | ||
"PCMatUpdateInterval": 1, | ||
"objFuncTimeOperator": "average", | ||
}, | ||
"printIntervalUnsteady": 1, | ||
"objFunc": { | ||
"CD": { | ||
"part1": { | ||
"type": "force", | ||
"source": "patchToFace", | ||
"patches": ["wing"], | ||
"directionMode": "fixedDirection", | ||
"direction": [1.0, 0.0, 0.0], | ||
"scale": 1.0 / (0.5 * U0 * U0 * A0 * rho0), | ||
"addToAdjoint": True, | ||
} | ||
}, | ||
"CL": { | ||
"part1": { | ||
"type": "force", | ||
"source": "patchToFace", | ||
"patches": ["wing"], | ||
"directionMode": "fixedDirection", | ||
"direction": [0.0, 1.0, 0.0], | ||
"scale": 1.0 / (0.5 * U0 * U0 * A0 * rho0), | ||
"addToAdjoint": True, | ||
} | ||
}, | ||
}, | ||
"adjStateOrdering": "cell", | ||
"adjEqnOption": { | ||
"gmresRelTol": 1.0e-8, | ||
"pcFillLevel": 1, | ||
"jacMatReOrdering": "natural", | ||
"useNonZeroInitGuess": True, | ||
}, | ||
"normalizeStates": { | ||
"U": U0, | ||
"p": p0, | ||
"T": T0, | ||
"nuTilda": 1e-3, | ||
"phi": 1.0, | ||
}, | ||
"designVar": { | ||
"twist": {"designVarType": "FFD"}, | ||
}, | ||
} | ||
|
||
# mesh warping parameters, users need to manually specify the symmetry plane | ||
meshOptions = { | ||
"gridFile": os.getcwd(), | ||
"fileType": "OpenFOAM", | ||
# point and normal for the symmetry plane | ||
"symmetryPlanes": [[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]], [[0.0, 0.0, 0.1], [0.0, 0.0, 1.0]]], | ||
} | ||
|
||
# ============================================================================= | ||
# Design variable setup | ||
# ============================================================================= | ||
DVGeo = DVGeometry("./FFD/FFD.xyz") | ||
DVGeo.addRefAxis("bodyAxis", xFraction=0.25, alignIndex="k") | ||
|
||
|
||
def twist(val, geo): | ||
for i in range(2): | ||
geo.rot_z["bodyAxis"].coef[i] = val[0] | ||
|
||
|
||
DVGeo.addGlobalDV("twist", [twist0], twist, lower=-100.0, upper=100.0, scale=1.0) | ||
|
||
|
||
# ============================================================================= | ||
# DAFoam initialization | ||
# ============================================================================= | ||
DASolver = PYDAFOAM(options=daOptions, comm=gcomm) | ||
DASolver.setDVGeo(DVGeo) | ||
mesh = USMesh(options=meshOptions, comm=gcomm) | ||
DASolver.printFamilyList() | ||
DASolver.setMesh(mesh) | ||
evalFuncs = [] | ||
DASolver.setEvalFuncs(evalFuncs) | ||
|
||
# ============================================================================= | ||
# Constraint setup | ||
# ============================================================================= | ||
DVCon = DVConstraints() | ||
DVCon.setDVGeo(DVGeo) | ||
DVCon.setSurface(DASolver.getTriangulatedMeshSurface(groupName=DASolver.designSurfacesGroup)) | ||
|
||
# ============================================================================= | ||
# Initialize optFuncs for optimization | ||
# ============================================================================= | ||
optFuncs.DASolver = DASolver | ||
optFuncs.DVGeo = DVGeo | ||
optFuncs.DVCon = DVCon | ||
optFuncs.evalFuncs = evalFuncs | ||
optFuncs.gcomm = gcomm | ||
|
||
# Run | ||
if calcFDSens == 1: | ||
optFuncs.calcFDSens() | ||
else: | ||
DASolver.runColoring() | ||
xDV = DVGeo.getValues() | ||
funcs = {} | ||
funcs, fail = optFuncs.calcObjFuncValues(xDV) | ||
funcsSens = {} | ||
funcsSens, fail = optFuncs.calcObjFuncSens(xDV, funcs) | ||
|
||
if gcomm.rank == 0: | ||
reg_write_dict(funcs, 1e-8, 1e-10) | ||
reg_write_dict(funcsSens, 1e-4, 1e-6) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.