1
1
"""
2
2
Unittest for FUN3D 14.0.2 finite-difference test
3
3
"""
4
+
4
5
import numpy as np , unittest , importlib , os
5
6
from mpi4py import MPI
6
7
import time
39
40
forward_tol = 1e-11
40
41
adjoint_tol = 1e-9
41
42
43
+
42
44
class TestFun3dTacs (unittest .TestCase ):
43
45
FILENAME = "fun3d-tacs-driver.txt"
44
46
FILEPATH = os .path .join (results_folder , FILENAME )
45
47
46
48
def test_alpha_turbulent_aeroelastic (self ):
47
- start_time = time .time ()
49
+ start_time = time .time ()
48
50
49
51
# build the funtofem model with one body and scenario
50
52
model = FUNtoFEMmodel ("plate" )
51
53
plate = Body .aeroelastic ("plate" , boundary = 2 )
52
54
plate .register_to (model )
53
55
54
56
# build the scenario
55
- test_scenario = Scenario .steady ("turbulent_beta" , steps = 500 , coupling_frequency = 20 , uncoupled_steps = 10 )
56
- test_scenario .set_stop_criterion (early_stopping = early_stopping , min_forward_steps = 50 )
57
+ test_scenario = Scenario .steady (
58
+ "turbulent_beta" , steps = 500 , coupling_frequency = 20 , uncoupled_steps = 10
59
+ )
60
+ test_scenario .set_stop_criterion (
61
+ early_stopping = early_stopping , min_forward_steps = 50
62
+ )
57
63
test_scenario .set_temperature (T_ref = 300.0 , T_inf = 300.0 )
58
64
Function .lift ().register_to (test_scenario )
59
65
Function .ksfailure (ks_weight = 10.0 ).register_to (test_scenario )
@@ -65,7 +71,13 @@ def test_alpha_turbulent_aeroelastic(self):
65
71
66
72
# build the solvers and coupled driver
67
73
solvers = SolverManager (comm )
68
- solvers .flow = Fun3d14Interface (comm , model , fun3d_dir = "meshes" , forward_tolerance = forward_tol , adjoint_tolerance = adjoint_tol )
74
+ solvers .flow = Fun3d14Interface (
75
+ comm ,
76
+ model ,
77
+ fun3d_dir = "meshes" ,
78
+ forward_tolerance = forward_tol ,
79
+ adjoint_tolerance = adjoint_tol ,
80
+ )
69
81
70
82
solvers .structural = TacsSteadyInterface .create_from_bdf (
71
83
model , comm , nprocs = 1 , bdf_file = bdf_filename , prefix = output_dir
@@ -102,18 +114,28 @@ def test_thick_turbulent_aeroelastic(self):
102
114
plate .register_to (model )
103
115
104
116
# build the scenario
105
- test_scenario = Scenario .steady ("turbulent_beta" , steps = 500 , coupling_frequency = 20 , uncoupled_steps = 10 )
106
- test_scenario .set_stop_criterion (early_stopping = early_stopping , min_forward_steps = 50 )
117
+ test_scenario = Scenario .steady (
118
+ "turbulent_beta" , steps = 500 , coupling_frequency = 20 , uncoupled_steps = 10
119
+ )
120
+ test_scenario .set_stop_criterion (
121
+ early_stopping = early_stopping , min_forward_steps = 50
122
+ )
107
123
test_scenario .set_temperature (T_ref = 300.0 , T_inf = 300.0 )
108
- Function .lift ().register_to (test_scenario )
124
+ Function .lift ().register_to (test_scenario )
109
125
Function .ksfailure (ks_weight = 10.0 ).register_to (test_scenario )
110
126
Function .drag ().register_to (test_scenario )
111
127
test_scenario .set_flow_ref_vals (qinf = 1.05e5 )
112
128
test_scenario .register_to (model )
113
129
114
130
# build the solvers and coupled driver
115
131
solvers = SolverManager (comm )
116
- solvers .flow = Fun3d14Interface (comm , model , fun3d_dir = "meshes" , forward_tolerance = forward_tol , adjoint_tolerance = adjoint_tol )
132
+ solvers .flow = Fun3d14Interface (
133
+ comm ,
134
+ model ,
135
+ fun3d_dir = "meshes" ,
136
+ forward_tolerance = forward_tol ,
137
+ adjoint_tolerance = adjoint_tol ,
138
+ )
117
139
118
140
solvers .structural = TacsSteadyInterface .create_from_bdf (
119
141
model , comm , nprocs = 1 , bdf_file = bdf_filename , prefix = output_dir
@@ -139,6 +161,7 @@ def test_thick_turbulent_aeroelastic(self):
139
161
)
140
162
self .assertTrue (max_rel_error < 2e-3 )
141
163
164
+
142
165
if __name__ == "__main__" :
143
166
# open and close the file to reset it
144
167
if comm .rank == 0 :
0 commit comments