Skip to content

Commit fb3380a

Browse files
authored
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.
1 parent 5f2cc15 commit fb3380a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+228
-55
lines changed

src/adjoint/Make/files_Compressible

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ DARegression/DARegression.C
3131
DAStateInfo/DAStateInfo.C
3232
DAStateInfo/DAStateInfoRhoSimpleFoam.C
3333
DAStateInfo/DAStateInfoRhoSimpleCFoam.C
34+
DAStateInfo/DAStateInfoRhoPimpleFoam.C
3435
DAStateInfo/DAStateInfoTurboFoam.C
3536

3637
DAIndex/DAIndex.C
@@ -60,6 +61,7 @@ DAFvSource/DAFvSourceActuatorDisk.C
6061
DAResidual/DAResidual.C
6162
DAResidual/DAResidualDummy.C
6263
DAResidual/DAResidualRhoSimpleFoam.C
64+
DAResidual/DAResidualRhoPimpleFoam.C
6365
DAResidual/DAResidualRhoSimpleCFoam.C
6466
DAResidual/DAResidualTurboFoam.C
6567

@@ -89,6 +91,7 @@ DALinearEqn/DALinearEqn.C
8991
DASolver/DASolver.C
9092
DASolver/DARhoSimpleFoam/DARhoSimpleFoam.C
9193
DASolver/DARhoSimpleCFoam/DARhoSimpleCFoam.C
94+
DASolver/DARhoPimpleFoam/DARhoPimpleFoam.C
9295
DASolver/DATurboFoam/DATurboFoam.C
9396

9497
boundaryConditions/homTemp/homTempFvPatchScalarField.C
@@ -101,7 +104,7 @@ models/SpalartAllmarasFv3/makeSpalartAllmarasFv3Compressible.C
101104
models/SpalartAllmarasFv3FieldInversion/makeSpalartAllmarasFv3FieldInversionCompressible.C
102105
models/kOmegaSSTFieldInversion/makekOmegaSSTFieldInversionCompressible.C
103106
models/kOmegaFieldInversionOmega/makekOmegaFieldInversionOmegaCompressible.C
104-
107+
models/pimpleControlDF/pimpleControlDF.C
105108

106109
models/MRFDF/MRFZoneDF.C
107110
models/MRFDF/MRFZoneListDF.C

tests/Allclean

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ if [ -z "$WM_PROJECT" ]; then
55
exit 1
66
fi
77

8-
rm -rf input __pycache__
8+
rm -rf reg_test_files-main __pycache__

tests/Allrun

+11-9
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ if [ -z "$WM_PROJECT" ]; then
55
exit 1
66
fi
77

8-
# check if we need to download input.tar.gz
9-
if [ -f "input.tar.gz" ]; then
10-
echo "input.tar.gz already exists."
8+
# check if we need to download reg_test_files-main.tar.gz
9+
if [ -f "reg_test_files-main.tar.gz" ]; then
10+
echo "reg_test_files-main.tar.gz already exists."
1111
else
12-
echo "Downloading input.tar.gz"
13-
wget https://github.com/dafoam/files/releases/download/v1.0.0/input.tar.gz --no-check-certificate
12+
echo "Downloading reg_test_files-main.tar.gz"
13+
wget https://github.com/DAFoam/reg_test_files/archive/refs/heads/main.tar.gz -O reg_test_files-main.tar.gz --no-check-certificate
1414
fi
1515

1616
if [ -z "$1" ]; then
@@ -22,8 +22,8 @@ fi
2222

2323
function runTests()
2424
{
25-
rm -rf input DAFoam_Test_${1}.txt
26-
tar -zxf input.tar.gz
25+
rm -rf reg_test_files-main DAFoam_Test_${1}.txt
26+
tar -zxf reg_test_files-main.tar.gz
2727
if [ -z "$DF_CHECK_COVERAGE" ]; then
2828
mpirun --oversubscribe -np 4 python runTests_${1}.py $@ | tee DAFoam_Test_${1}.txt
2929
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
@@ -55,8 +55,8 @@ function runTests()
5555

5656
function runTestsSerial()
5757
{
58-
rm -rf input DAFoam_Test_${1}.txt
59-
tar -zxf input.tar.gz
58+
rm -rf reg_test_files-main DAFoam_Test_${1}.txt
59+
tar -zxf reg_test_files-main.tar.gz
6060
if [ -z "$DF_CHECK_COVERAGE" ]; then
6161
python runTests_${1}.py $@ | tee DAFoam_Test_${1}.txt
6262
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
@@ -119,6 +119,7 @@ case $argm in
119119
runTests DARhoSimpleFoam
120120
runTests DARhoSimpleFoamUBend
121121
runTests DARhoSimpleCFoam
122+
runTests DARhoPimpleFoam
122123
if [ -f "$DAFOAM_ROOT_PATH/OpenFOAM/sharedLibs/libDAFoamCompressibleADR.so" ]; then
123124
runTests DARhoSimpleFoamMRFAD
124125
runTests DARhoSimpleFoamAD
@@ -185,6 +186,7 @@ case $argm in
185186
runTests DARhoSimpleFoam
186187
runTests DARhoSimpleFoamUBend
187188
runTests DARhoSimpleCFoam
189+
runTests DARhoPimpleFoam
188190
if [ -f "$DAFOAM_ROOT_PATH/OpenFOAM/sharedLibs/libDAFoamCompressibleADR.so" ]; then
189191
runTests DARhoSimpleFoamMRFAD
190192
runTests DARhoSimpleFoamAD
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Dictionary Key: CD
2+
@value 0.2304630624535831 1e-08 1e-10
3+
Dictionary Key: CL
4+
@value 6.3056661425586 1e-08 1e-10
5+
Dictionary Key: fail
6+
@value 0 1e-08 1e-10
7+
Dictionary Key: CD
8+
Dictionary Key: twist
9+
@value -0.1045060854662659 0.0001 1e-06
10+
Dictionary Key: CL
11+
Dictionary Key: twist
12+
@value -0.2190748076682245 0.0001 1e-06
13+
Dictionary Key: fail
14+
@value 0 0.0001 1e-06

tests/runTests_DAHeatTransferFoam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
gcomm = MPI.COMM_WORLD
1717

18-
os.chdir("./input/ChannelConjugateHeat/thermal")
18+
os.chdir("./reg_test_files-main/ChannelConjugateHeat/thermal")
1919

2020
aeroOptions = {
2121
"designSurfaces": ["channel_outer", "channel_inner", "channel_sides"],

tests/runTests_DALaplacianFoam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
gcomm = MPI.COMM_WORLD
1717

18-
os.chdir("./input/flange")
18+
os.chdir("./reg_test_files-main/flange")
1919

2020
# test incompressible solvers
2121
aeroOptions = {

tests/runTests_DAPimpleDyMFoam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
from testFuncs import *
1010

11-
os.chdir("./input/NACA0012DynamicMesh")
11+
os.chdir("./reg_test_files-main/NACA0012DynamicMesh")
1212

1313
replace_text_in_file("system/controlDict", "endTime 0.01;", "endTime 0.001;")
1414

tests/runTests_DAPimpleFoam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
gcomm = MPI.COMM_WORLD
2222

23-
os.chdir("./input/NACA0012Unsteady")
23+
os.chdir("./reg_test_files-main/NACA0012Unsteady")
2424

2525
if gcomm.rank == 0:
2626
os.system("rm -rf processor*")

tests/runTests_DAPimpleFoamField.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
gcomm = MPI.COMM_WORLD
2222

23-
os.chdir("./input/NACA0012Unsteady")
23+
os.chdir("./reg_test_files-main/NACA0012Unsteady")
2424

2525
if gcomm.rank == 0:
2626
os.system("rm -rf processor*")

tests/runTests_DAPimpleFoamTurbModels.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
gcomm = MPI.COMM_WORLD
2121

22-
os.chdir("./input/NACA0012Unsteady")
22+
os.chdir("./reg_test_files-main/NACA0012Unsteady")
2323

2424
funcs = {}
2525

tests/runTests_DAPisoFoam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
gcomm = MPI.COMM_WORLD
2323

24-
os.chdir("./input/CurvedCubeHexMesh")
24+
os.chdir("./reg_test_files-main/CurvedCubeHexMesh")
2525

2626
if gcomm.rank == 0:
2727
os.system("rm -rf 0 processor*")

tests/runTests_DAPisoFoamACTL.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
gcomm = MPI.COMM_WORLD
2323

24-
os.chdir("./input/CurvedCubeHexMesh")
24+
os.chdir("./reg_test_files-main/CurvedCubeHexMesh")
2525

2626
if gcomm.rank == 0:
2727
os.system("rm -rf 0 processor*")

tests/runTests_DARhoPimpleFoam.py

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#!/usr/bin/env python
2+
"""
3+
Run Python tests for DARhoPimpleFoam
4+
"""
5+
6+
from mpi4py import MPI
7+
from dafoam import PYDAFOAM, optFuncs
8+
import sys
9+
import os
10+
from pygeo import *
11+
from pyspline import *
12+
from idwarp import *
13+
import numpy as np
14+
from testFuncs import *
15+
16+
calcFDSens = 0
17+
if len(sys.argv) != 1:
18+
if sys.argv[1] == "calcFDSens":
19+
calcFDSens = 1
20+
21+
gcomm = MPI.COMM_WORLD
22+
23+
os.chdir("./reg_test_files-main/NACA0012UnsteadyComp")
24+
25+
if gcomm.rank == 0:
26+
os.system("rm -rf processor*")
27+
28+
twist0 = 0
29+
U0 = 100
30+
T0 = 300.0
31+
p0 = 101325.0
32+
rho0 = p0 / 287.0 / T0
33+
A0 = 0.1
34+
nuTilda0 = 1e-4
35+
36+
# test incompressible solvers
37+
daOptions = {
38+
"designSurfaces": ["wing"],
39+
"solverName": "DARhoPimpleFoam",
40+
"primalBC": {"useWallFunction": True},
41+
"unsteadyAdjoint": {
42+
"mode": "timeAccurate",
43+
"PCMatPrecomputeInterval": 20,
44+
"PCMatUpdateInterval": 1,
45+
"objFuncTimeOperator": "average",
46+
},
47+
"printIntervalUnsteady": 1,
48+
"objFunc": {
49+
"CD": {
50+
"part1": {
51+
"type": "force",
52+
"source": "patchToFace",
53+
"patches": ["wing"],
54+
"directionMode": "fixedDirection",
55+
"direction": [1.0, 0.0, 0.0],
56+
"scale": 1.0 / (0.5 * U0 * U0 * A0 * rho0),
57+
"addToAdjoint": True,
58+
}
59+
},
60+
"CL": {
61+
"part1": {
62+
"type": "force",
63+
"source": "patchToFace",
64+
"patches": ["wing"],
65+
"directionMode": "fixedDirection",
66+
"direction": [0.0, 1.0, 0.0],
67+
"scale": 1.0 / (0.5 * U0 * U0 * A0 * rho0),
68+
"addToAdjoint": True,
69+
}
70+
},
71+
},
72+
"adjStateOrdering": "cell",
73+
"adjEqnOption": {
74+
"gmresRelTol": 1.0e-8,
75+
"pcFillLevel": 1,
76+
"jacMatReOrdering": "natural",
77+
"useNonZeroInitGuess": True,
78+
},
79+
"normalizeStates": {
80+
"U": U0,
81+
"p": p0,
82+
"T": T0,
83+
"nuTilda": 1e-3,
84+
"phi": 1.0,
85+
},
86+
"designVar": {
87+
"twist": {"designVarType": "FFD"},
88+
},
89+
}
90+
91+
# mesh warping parameters, users need to manually specify the symmetry plane
92+
meshOptions = {
93+
"gridFile": os.getcwd(),
94+
"fileType": "OpenFOAM",
95+
# point and normal for the symmetry plane
96+
"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]]],
97+
}
98+
99+
# =============================================================================
100+
# Design variable setup
101+
# =============================================================================
102+
DVGeo = DVGeometry("./FFD/FFD.xyz")
103+
DVGeo.addRefAxis("bodyAxis", xFraction=0.25, alignIndex="k")
104+
105+
106+
def twist(val, geo):
107+
for i in range(2):
108+
geo.rot_z["bodyAxis"].coef[i] = val[0]
109+
110+
111+
DVGeo.addGlobalDV("twist", [twist0], twist, lower=-100.0, upper=100.0, scale=1.0)
112+
113+
114+
# =============================================================================
115+
# DAFoam initialization
116+
# =============================================================================
117+
DASolver = PYDAFOAM(options=daOptions, comm=gcomm)
118+
DASolver.setDVGeo(DVGeo)
119+
mesh = USMesh(options=meshOptions, comm=gcomm)
120+
DASolver.printFamilyList()
121+
DASolver.setMesh(mesh)
122+
evalFuncs = []
123+
DASolver.setEvalFuncs(evalFuncs)
124+
125+
# =============================================================================
126+
# Constraint setup
127+
# =============================================================================
128+
DVCon = DVConstraints()
129+
DVCon.setDVGeo(DVGeo)
130+
DVCon.setSurface(DASolver.getTriangulatedMeshSurface(groupName=DASolver.designSurfacesGroup))
131+
132+
# =============================================================================
133+
# Initialize optFuncs for optimization
134+
# =============================================================================
135+
optFuncs.DASolver = DASolver
136+
optFuncs.DVGeo = DVGeo
137+
optFuncs.DVCon = DVCon
138+
optFuncs.evalFuncs = evalFuncs
139+
optFuncs.gcomm = gcomm
140+
141+
# Run
142+
if calcFDSens == 1:
143+
optFuncs.calcFDSens()
144+
else:
145+
DASolver.runColoring()
146+
xDV = DVGeo.getValues()
147+
funcs = {}
148+
funcs, fail = optFuncs.calcObjFuncValues(xDV)
149+
funcsSens = {}
150+
funcsSens, fail = optFuncs.calcObjFuncSens(xDV, funcs)
151+
152+
if gcomm.rank == 0:
153+
reg_write_dict(funcs, 1e-8, 1e-10)
154+
reg_write_dict(funcsSens, 1e-4, 1e-6)

tests/runTests_DARhoSimpleCFoam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
gcomm = MPI.COMM_WORLD
2323

24-
os.chdir("./input/NACA0012")
24+
os.chdir("./reg_test_files-main/NACA0012")
2525

2626
if gcomm.rank == 0:
2727
os.system("rm -rf 0 processor*")

tests/runTests_DARhoSimpleCFoamAD.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
gcomm = MPI.COMM_WORLD
2323

24-
os.chdir("./input/NACA0012")
24+
os.chdir("./reg_test_files-main/NACA0012")
2525

2626
if gcomm.rank == 0:
2727
os.system("rm -rf 0 processor*")

tests/runTests_DARhoSimpleFoam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
gcomm = MPI.COMM_WORLD
2727

28-
os.chdir("./input/CurvedCubeSnappyHexMesh")
28+
os.chdir("./reg_test_files-main/CurvedCubeSnappyHexMesh")
2929

3030
if gcomm.rank == 0:
3131
os.system("rm -rf 0 processor*")

tests/runTests_DARhoSimpleFoamAD.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
gcomm = MPI.COMM_WORLD
2727

28-
os.chdir("./input/CurvedCubeSnappyHexMesh")
28+
os.chdir("./reg_test_files-main/CurvedCubeSnappyHexMesh")
2929

3030
if gcomm.rank == 0:
3131
os.system("rm -rf 0 processor*")

tests/runTests_DARhoSimpleFoamFIML.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
gcomm = MPI.COMM_WORLD
2727

28-
os.chdir("./input/CurvedCubeSnappyHexMesh")
28+
os.chdir("./reg_test_files-main/CurvedCubeSnappyHexMesh")
2929

3030
if gcomm.rank == 0:
3131
os.system("rm -rf 0 processor*")

tests/runTests_DARhoSimpleFoamMRFAD.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
gcomm = MPI.COMM_WORLD
2323

24-
os.chdir("./input/CompressorFluid")
24+
os.chdir("./reg_test_files-main/CompressorFluid")
2525

2626
if gcomm.rank == 0:
2727
os.system("rm -rf 0 processor*")

0 commit comments

Comments
 (0)