From 343fee2922aae899b799adaf6a99cec68e0d18fd Mon Sep 17 00:00:00 2001 From: Anil Yildirim Date: Fri, 8 Apr 2022 14:57:32 +0200 Subject: [PATCH 1/4] updates to aero only cases --- .../mach_tutorial_wing/adflow/ffd.xyz | 50 ------------------- .../adflow/mphys_aero_analysis.py | 12 +++-- .../adflow/mphys_aero_opt.py | 27 ++++++---- .../adflow/mphys_aero_opt_2pt.py | 11 ++-- .../adflow/mphys_aero_opt_2pt_parallel.py | 10 ++-- 5 files changed, 35 insertions(+), 75 deletions(-) delete mode 100644 examples/aero_only/mach_tutorial_wing/adflow/ffd.xyz diff --git a/examples/aero_only/mach_tutorial_wing/adflow/ffd.xyz b/examples/aero_only/mach_tutorial_wing/adflow/ffd.xyz deleted file mode 100644 index 97f427fe..00000000 --- a/examples/aero_only/mach_tutorial_wing/adflow/ffd.xyz +++ /dev/null @@ -1,50 +0,0 @@ - 1 - 6 2 8 - -0.10000000 0.94000000 1.98000000 3.02000000 4.06000000 5.10000000 - -0.10000000 0.94000000 1.98000000 3.02000000 4.06000000 5.10000000 - 1.48118553 2.37782471 3.27446389 4.17110307 5.06774224 5.96438142 - 1.48118553 2.37782471 3.27446389 4.17110307 5.06774224 5.96438142 - 2.65300391 3.44339822 4.23379253 5.02418685 5.81458116 6.60497547 - 2.65300391 3.44339822 4.23379253 5.02418685 5.81458116 6.60497547 - 3.70785003 4.40260496 5.09735989 5.79211482 6.48686975 7.18162468 - 3.70785003 4.40260496 5.09735989 5.79211482 6.48686975 7.18162468 - 4.69325821 5.29866946 5.90408072 6.50949197 7.11490323 7.72031449 - 4.69325821 5.29866946 5.90408072 6.50949197 7.11490323 7.72031449 - 5.63005558 6.15053054 6.67100550 7.19148047 7.71195543 8.23243039 - 5.63005558 6.15053054 6.67100550 7.19148047 7.71195543 8.23243039 - 6.52985197 6.96874539 7.40763881 7.84653223 8.28542566 8.72431908 - 6.52985197 6.96874539 7.40763881 7.84653223 8.28542566 8.72431908 - 7.40000000 7.76000000 8.12000000 8.48000000 8.84000000 9.20000000 - 7.40000000 7.76000000 8.12000000 8.48000000 8.84000000 9.20000000 - -0.50000000 -0.50000000 -0.50000000 -0.50000000 -0.50000000 -0.50000000 - 0.50000000 0.50000000 0.50000000 0.50000000 0.50000000 0.50000000 - -0.44729382 -0.44729382 -0.44729382 -0.44729382 -0.44729382 -0.44729382 - 0.44729382 0.44729382 0.44729382 0.44729382 0.44729382 0.44729382 - -0.40823320 -0.40823320 -0.40823320 -0.40823320 -0.40823320 -0.40823320 - 0.40823320 0.40823320 0.40823320 0.40823320 0.40823320 0.40823320 - -0.37307167 -0.37307167 -0.37307167 -0.37307167 -0.37307167 -0.37307167 - 0.37307167 0.37307167 0.37307167 0.37307167 0.37307167 0.37307167 - -0.34022473 -0.34022473 -0.34022473 -0.34022473 -0.34022473 -0.34022473 - 0.34022473 0.34022473 0.34022473 0.34022473 0.34022473 0.34022473 - -0.30899815 -0.30899815 -0.30899815 -0.30899815 -0.30899815 -0.30899815 - 0.30899815 0.30899815 0.30899815 0.30899815 0.30899815 0.30899815 - -0.27900493 -0.27900493 -0.27900493 -0.27900493 -0.27900493 -0.27900493 - 0.27900493 0.27900493 0.27900493 0.27900493 0.27900493 0.27900493 - -0.25000000 -0.25000000 -0.25000000 -0.25000000 -0.25000000 -0.25000000 - 0.25000000 0.25000000 0.25000000 0.25000000 0.25000000 0.25000000 - -0.01000000 -0.01000000 -0.01000000 -0.01000000 -0.01000000 -0.01000000 - -0.01000000 -0.01000000 -0.01000000 -0.01000000 -0.01000000 -0.01000000 - 2.99636075 2.99636075 2.99636075 2.99636075 2.99636075 2.99636075 - 2.99636075 2.99636075 2.99636075 2.99636075 2.99636075 2.99636075 - 5.22437810 5.22437810 5.22437810 5.22437810 5.22437810 5.22437810 - 5.22437810 5.22437810 5.22437810 5.22437810 5.22437810 5.22437810 - 7.22999218 7.22999218 7.22999218 7.22999218 7.22999218 7.22999218 - 7.22999218 7.22999218 7.22999218 7.22999218 7.22999218 7.22999218 - 9.10358160 9.10358160 9.10358160 9.10358160 9.10358160 9.10358160 - 9.10358160 9.10358160 9.10358160 9.10358160 9.10358160 9.10358160 - 10.88474568 10.88474568 10.88474568 10.88474568 10.88474568 10.88474568 - 10.88474568 10.88474568 10.88474568 10.88474568 10.88474568 10.88474568 - 12.59555855 12.59555855 12.59555855 12.59555855 12.59555855 12.59555855 - 12.59555855 12.59555855 12.59555855 12.59555855 12.59555855 12.59555855 - 14.25000000 14.25000000 14.25000000 14.25000000 14.25000000 14.25000000 - 14.25000000 14.25000000 14.25000000 14.25000000 14.25000000 14.25000000 diff --git a/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_analysis.py b/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_analysis.py index b477330c..705477c0 100644 --- a/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_analysis.py +++ b/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_analysis.py @@ -1,23 +1,27 @@ -from mpi4py import MPI +import argparse import openmdao.api as om from mphys.multipoint import Multipoint +from mphys.scenario_aerodynamic import ScenarioAerodynamic from adflow.mphys import ADflowBuilder from baseclasses import AeroProblem -from mphys.scenario_aerodynamic import ScenarioAerodynamic +parser = argparse.ArgumentParser() +parser.add_argument("--level", type=str, default="L1") +args = parser.parse_args() class Top(Multipoint): def setup(self): aero_options = { # I/O Parameters - "gridFile": "wing_vol.cgns", + "gridFile": f"wing_vol_{args.level}.cgns", "outputDirectory": ".", "monitorvariables": ["resrho", "cl", "cd"], "writeTecplotSurfaceSolution": True, # Physics Parameters "equationType": "RANS", + "liftindex": 3, # z is the lift direction # Solver Parameters "smoother": "DADI", "CFL": 0.5, @@ -90,7 +94,7 @@ def configure(self): prob.model.list_outputs(units=True) # prob.model.list_outputs() -if MPI.COMM_WORLD.rank == 0: +if prob.model.comm.rank == 0: print("Scenario 0") print("cl =", prob["cruise.aero_post.cl"]) print("cd =", prob["cruise.aero_post.cd"]) diff --git a/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt.py b/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt.py index 3d2ef19f..0feb7274 100644 --- a/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt.py +++ b/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt.py @@ -1,5 +1,5 @@ +import argparse import numpy as np -from mpi4py import MPI import openmdao.api as om from mphys.multipoint import Multipoint @@ -8,10 +8,9 @@ from baseclasses import AeroProblem from pygeo.mphys import OM_DVGEOCOMP -import argparse - parser = argparse.ArgumentParser() parser.add_argument("--task", default="run") +parser.add_argument("--level", type=str, default="L1") args = parser.parse_args() @@ -23,7 +22,7 @@ def setup(self): ################################################################################ aero_options = { # I/O Parameters - "gridFile": "wing_vol.cgns", + "gridFile": f"wing_vol_{args.level}.cgns", "outputDirectory": ".", "monitorvariables": ["resrho", "resturb", "cl", "cd"], "writeTecplotSurfaceSolution": False, @@ -31,6 +30,7 @@ def setup(self): # 'writesurfacesolution':False, # Physics Parameters "equationType": "RANS", + "liftindex": 3, # z is the lift direction # Solver Parameters "smoother": "DADI", "CFL": 1.5, @@ -118,13 +118,19 @@ def configure(self): # Set up global design variables def twist(val, geo): for i in range(1, nRefAxPts): - geo.rot_z["wing"].coef[i] = val[i - 1] + geo.rot_y["wing"].coef[i] = val[i - 1] self.geometry.nom_addGeoDVGlobal(dvName="twist", value=np.array([0] * nTwist), func=twist) - nLocal = self.geometry.nom_addGeoDVLocal(dvName="thickness") - - leList = [[0.01, 0, 0.001], [7.51, 0, 13.99]] - teList = [[4.99, 0, 0.001], [8.99, 0, 13.99]] + nLocal = self.geometry.nom_addGeoDVLocal(dvName="thickness", axis="z") + + if args.level == "L3": + # we need to offset the projected points a bit further in the wing because this mesh is too coarse + leList = [[0.1, 0.001, 0.0], [7.6, 13.8, 0.0]] + teList = [[4.8, 0.001, 0.0], [8.8, 13.8, 0.0]] + else: + # L1 and L2 meshes can work with the more accurate coordinates + leList = [[0.01, 0.001, 0.0], [7.51, 13.99, 0.0]] + teList = [[4.99, 0.001, 0.0], [8.99, 13.99, 0.0]] self.geometry.nom_addThicknessConstraints2D("thickcon", leList, teList, nSpan=10, nChord=10) self.geometry.nom_addVolumeConstraint("volcon", leList, teList, nSpan=20, nChord=20) self.geometry.nom_add_LETEConstraint( @@ -201,8 +207,7 @@ def twist(val, geo): prob.model.list_inputs(units=True) prob.model.list_outputs(units=True) -# prob.model.list_outputs() -if MPI.COMM_WORLD.rank == 0: +if prob.model.comm.rank == 0: print("Scenario 0") print("cl =", prob["cruise.aero_post.cl"]) print("cd =", prob["cruise.aero_post.cd"]) diff --git a/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt_2pt.py b/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt_2pt.py index 45c0a919..fcafc38e 100644 --- a/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt_2pt.py +++ b/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt_2pt.py @@ -1,5 +1,5 @@ +import argparse import numpy as np -from mpi4py import MPI import openmdao.api as om from mphys.multipoint import Multipoint @@ -8,10 +8,10 @@ from baseclasses import AeroProblem from pygeo.mphys import OM_DVGEOCOMP -import argparse parser = argparse.ArgumentParser() parser.add_argument("--task", default="run") +parser.add_argument("--level", type=str, default="L1") args = parser.parse_args() @@ -23,7 +23,7 @@ def setup(self): ################################################################################ aero_options = { # I/O Parameters - "gridFile": "wing_vol.cgns", + "gridFile": f"wing_vol_{args.level}.cgns", "outputDirectory": ".", "monitorvariables": ["resrho", "resturb", "cl", "cd"], "writeTecplotSurfaceSolution": False, @@ -31,6 +31,7 @@ def setup(self): # 'writesurfacesolution':False, # Physics Parameters "equationType": "RANS", + "liftindex": 3, # z is the lift direction # Solver Parameters "smoother": "DADI", "CFL": 1.5, @@ -129,7 +130,7 @@ def configure(self): # Set up global design variables def twist(val, geo): for i in range(1, nRefAxPts): - geo.rot_z["wing"].coef[i] = val[i - 1] + geo.rot_y["wing"].coef[i] = val[i - 1] self.geometry.nom_addGeoDVGlobal(dvName="twist", value=np.array([0] * nTwist), func=twist) @@ -200,7 +201,7 @@ def twist(val, geo): prob.model.list_outputs(units=True) # prob.model.list_outputs() -if MPI.COMM_WORLD.rank == 0: +if prob.model.comm.rank == 0: print("Cruise 0") print("cl =", prob["cruise0.aero_post.cl"]) print("cd =", prob["cruise0.aero_post.cd"]) diff --git a/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt_2pt_parallel.py b/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt_2pt_parallel.py index 34ec15ff..b74fa975 100644 --- a/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt_2pt_parallel.py +++ b/examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt_2pt_parallel.py @@ -1,4 +1,4 @@ -from mpi4py import MPI +import argparse import openmdao.api as om from mphys.multipoint import MultipointParallel @@ -6,10 +6,10 @@ from adflow.mphys import ADflowBuilder from baseclasses import AeroProblem -import argparse parser = argparse.ArgumentParser() parser.add_argument("--task", default="run") +parser.add_argument("--level", type=str, default="L1") args = parser.parse_args() @@ -21,8 +21,7 @@ def setup(self): ################################################################################ aero_options = { # I/O Parameters - # "gridFile": "wing_vol_coarse.cgns", - "gridFile": "wing_vol.cgns", + "gridFile": f"wing_vol_{args.level}.cgns", "outputDirectory": ".", "monitorvariables": ["resrho", "resturb", "cl", "cd"], "writeTecplotSurfaceSolution": False, @@ -30,6 +29,7 @@ def setup(self): # 'writesurfacesolution':False, # Physics Parameters "equationType": "RANS", + "liftindex": 3, # z is the lift direction # Solver Parameters "smoother": "DADI", "CFL": 1.5, @@ -220,7 +220,7 @@ def configure(self): cl1 = prob.get_val("mp.cruise1.aero_post.cl", get_remote=True) cd1 = prob.get_val("mp.cruise1.aero_post.cd", get_remote=True) -if MPI.COMM_WORLD.rank == 0: +if prob.model.comm.rank == 0: print("Cruise 0") print("cl =", cl0) print("cd =", cd1) From dc935753317a7527c2528b5eaf7f1b2ddb1c5ed4 Mon Sep 17 00:00:00 2001 From: Anil Yildirim Date: Fri, 8 Apr 2022 17:52:33 +0200 Subject: [PATCH 2/4] updated aerostructural test. updated gitignore. added readmes to mach example directories --- .gitignore | 7 +++++++ .../mach_tutorial_wing/adflow/readme.md | 5 +++++ .../adflow_meld_tacs/mphys_as_2scenario.py | 18 ++++++------------ .../adflow_meld_tacs/readme.md | 5 +++++ 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 examples/aero_only/mach_tutorial_wing/adflow/readme.md create mode 100644 examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/readme.md diff --git a/.gitignore b/.gitignore index 779ffefd..7e1ae3c2 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,10 @@ tests/input_files/*.xyz # n2s that might be generated under examples examples/**/*.html + +# FFD files for adflow examples +examples/aero_only/mach_tutorial_wing/adflow/*.xyz +examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/*.xyz + +# DAFoam input files +tests/input_files/dafoam* \ No newline at end of file diff --git a/examples/aero_only/mach_tutorial_wing/adflow/readme.md b/examples/aero_only/mach_tutorial_wing/adflow/readme.md new file mode 100644 index 00000000..c96d4d3f --- /dev/null +++ b/examples/aero_only/mach_tutorial_wing/adflow/readme.md @@ -0,0 +1,5 @@ +To obtain the CFD grids and the FFD box required for these examples: + +1. Go to mphys/tests/input_files +2. Run the get-input-files.sh script. This will download and extract the input file archive provided by the University of Michigan. +3. Copy the wing_vol_L*.cgns and ffd.xyz files to this directory. \ No newline at end of file diff --git a/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/mphys_as_2scenario.py b/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/mphys_as_2scenario.py index f83ddf05..285776d9 100644 --- a/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/mphys_as_2scenario.py +++ b/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/mphys_as_2scenario.py @@ -1,30 +1,23 @@ import numpy as np import argparse -from mpi4py import MPI import openmdao.api as om - from mphys import Multipoint from mphys.scenario_aerostructural import ScenarioAeroStructural - from adflow.mphys import ADflowBuilder +from baseclasses import AeroProblem from tacs.mphys import TacsBuilder from mphys.solver_builders.mphys_meld import MeldBuilder - # TODO RLT needs to be updated with the new tacs wrapper # from rlt.mphys import RltBuilder -from baseclasses import AeroProblem - import tacs_setup -# set these for convenience -comm = MPI.COMM_WORLD -rank = comm.rank parser = argparse.ArgumentParser() parser.add_argument("--xfer", default="meld", choices=["meld", "rlt"]) +parser.add_argument("--level", type=str, default="L1") args = parser.parse_args() if args.xfer == "meld": @@ -41,7 +34,7 @@ def setup(self): ################################################################################ aero_options = { # I/O Parameters - "gridFile": "wing_vol.cgns", + "gridFile": f"wing_vol_{args.level}.cgns", "outputDirectory": ".", "monitorvariables": ["resrho", "resturb", "cl", "cd"], "writeTecplotSurfaceSolution": False, @@ -49,6 +42,7 @@ def setup(self): # 'writesurfacesolution':False, # Physics Parameters "equationType": "RANS", + "liftindex": 3, # z is the lift direction # Solver Parameters "smoother": "DADI", "CFL": 1.5, @@ -97,7 +91,7 @@ def setup(self): ################################################################################ if args.xfer == "meld": - isym = 1 + isym = 1 # y-symmetry ldxfer_builder = MeldBuilder(aero_builder, struct_builder, isym=isym) ldxfer_builder.initialize(self.comm) else: @@ -193,7 +187,7 @@ def configure(self): prob.model.list_outputs() -if MPI.COMM_WORLD.rank == 0: +if prob.model.comm.rank == 0: print("Cruise") print("cl =", prob["cruise.aero_post.cl"]) print("cd =", prob["cruise.aero_post.cd"]) diff --git a/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/readme.md b/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/readme.md new file mode 100644 index 00000000..dbc1be1f --- /dev/null +++ b/examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/readme.md @@ -0,0 +1,5 @@ +To obtain the CFD grids and the FFD box required for these examples: + +1. Go to mphys/tests/input_files +2. Run the get-input-files.sh script. This will download and extract the input file archive provided by the University of Michigan. +3. Copy the wing_vol_L*.cgns and wingbox.bdf files to this directory. \ No newline at end of file From b057588fc875a30f61ac12311763a2fb599727df Mon Sep 17 00:00:00 2001 From: Anil Yildirim Date: Fri, 8 Apr 2022 18:34:32 +0200 Subject: [PATCH 3/4] updated the aerostruct test, gitignore, and readme --- .gitignore | 5 ++++- README.md | 2 ++ tests/regression_tests/test_aerostruct.py | 11 ++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 7e1ae3c2..326385a4 100644 --- a/.gitignore +++ b/.gitignore @@ -33,9 +33,12 @@ tests/input_files/*.xyz # n2s that might be generated under examples examples/**/*.html +# n2s that are generated under tests for the documentation +tests/**/*.html + # FFD files for adflow examples examples/aero_only/mach_tutorial_wing/adflow/*.xyz examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/*.xyz # DAFoam input files -tests/input_files/dafoam* \ No newline at end of file +tests/input_files/dafoam* diff --git a/README.md b/README.md index 443e5b09..b21482d4 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ paramerized and these input files. They can be obtained by running `get-input-files.sh` ``` wingbox.bdf +wing_vol_L1.cgns +wing_vol_L2.cgns wing_vol_L3.cgns ffd.xyz ``` diff --git a/tests/regression_tests/test_aerostruct.py b/tests/regression_tests/test_aerostruct.py index 93011c15..d8f606ed 100644 --- a/tests/regression_tests/test_aerostruct.py +++ b/tests/regression_tests/test_aerostruct.py @@ -90,7 +90,7 @@ def setup(self): ################################################################################ aero_options = { # I/O Parameters - "gridFile": os.path.join(baseDir, "../input_files/wing_vol.cgns"), + "gridFile": os.path.join(baseDir, "../input_files/wing_vol_L3.cgns"), "outputDirectory": ".", "monitorvariables": ["resrho", "resturb", "cl", "cd"], "writeTecplotSurfaceSolution": False, @@ -98,6 +98,7 @@ def setup(self): # 'writesurfacesolution':False, # Physics Parameters "equationType": "RANS", + "liftindex": 3, # Solver Parameters "smoother": "DADI", "CFL": 1.5, @@ -219,10 +220,10 @@ def configure(self): "xfer_builder_class": MeldBuilder, "xfer_options": {"isym": 1, "n": 200, "beta": 0.5}, "ref_vals": { - "xa": 5.44356782419053, - "cl": 0.3384087364751269, - "func_struct": 0.25177455023767636, - "cd": 0.029881839034169452, + "xa": 5.633698956781166, + "cl": 0.209180113189859, + "func_struct": 0.6808193125485819, + "cd": 0.025108879963099927, }, }, # { From 9a8bd52b782954f6545d875749efe7f7ffc6c484 Mon Sep 17 00:00:00 2001 From: Anil Yildirim Date: Fri, 8 Apr 2022 18:37:34 +0200 Subject: [PATCH 4/4] more gitignore --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 326385a4..1f4eaa94 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,18 @@ examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/*.xyz # DAFoam input files tests/input_files/dafoam* + +# DAFoam test outputs +tests/regression_tests/0 +tests/regression_tests/constant +tests/regression_tests/FFD +tests/regression_tests/system +tests/integration_tests/0 +tests/integration_tests/constant +tests/integration_tests/FFD +tests/integration_tests/system +tests/0 +tests/constant +tests/FFD +tests/system +