|
5 | 5 | import os |
6 | 6 | import subprocess |
7 | 7 |
|
8 | | -def test_lidDrivenCanvity(working_dir, print_output): |
9 | | - subprocess.run( |
10 | | - "make -j8 && ./amr2d.gnu.ex inputs.2d.lid_driven_cavity", |
11 | | - shell=True, |
12 | | - check=True, |
13 | | - cwd=working_dir, |
14 | | - stdout=None if print_output else subprocess.DEVNULL, |
15 | | - stderr=None if print_output else subprocess.DEVNULL |
16 | | - ) |
17 | | - print("Test_lidDrivenCanvity succeed") |
18 | | - |
19 | | -def test_LidDrivenCavitySphere(working_dir, print_output): |
20 | | - subprocess.run( |
21 | | - "make -j8 && ./amr3d.gnu.MPI.ex inputs.3d.lid_driven_cavity_particle", |
22 | | - shell=True, |
23 | | - check=True, |
24 | | - cwd=working_dir, |
25 | | - stdout=None if print_output else subprocess.DEVNULL, |
26 | | - stderr=None if print_output else subprocess.DEVNULL |
27 | | - ) |
28 | | - print("Test LidDrivenCavitySphere succeed") |
29 | | - |
30 | | -def test_RSV(working_dir, print_output): |
31 | | - subprocess.run( |
32 | | - "make -j8 && ./amr2d.gnu.MPI.ex inputs.2d.rsv", |
33 | | - shell=True, |
34 | | - check=True, |
35 | | - cwd=working_dir, |
36 | | - stdout=None if print_output else subprocess.DEVNULL, |
37 | | - stderr=None if print_output else subprocess.DEVNULL |
38 | | - ) |
39 | | - print("Test RSV succeed") |
40 | | - |
41 | | -def test_DraftingKissingTumbling(working_dir, print_output): |
42 | | - subprocess.run( |
43 | | - "make -j8 USE_CUDA=FALSE USE_MPI=TRUE DEBUG=FALSE;" |
44 | | - "mpiexec -np 2 ./amr3d.gnu.MPI.ex inputs.3d.DKT max_step=1 amr.n_cell=16 8 8", |
45 | | - shell=True, |
46 | | - check=True, |
47 | | - cwd=working_dir, |
48 | | - stdout=None if print_output else subprocess.DEVNULL, |
49 | | - stderr=None if print_output else subprocess.DEVNULL |
50 | | - ) |
51 | | - print("test_DraftingKissingTumbling succeed") |
| 8 | +# Common overrides for fast CI runs: minimal steps, small grids, no file output |
| 9 | +CI_OVERRIDES = "max_step=2 amr.plot_int=-1 amr.check_int=-1" |
52 | 10 |
|
53 | | -def test_FallingSphere(working_dir, print_output): |
| 11 | +def run_test (name, working_dir, build_cmd, run_cmd, print_output): |
| 12 | + """Build and run a single test case.""" |
| 13 | + full_cmd = f"{build_cmd} && {run_cmd}" |
54 | 14 | subprocess.run( |
55 | | - "make -j8 USE_CUDA=FALSE USE_MPI=TRUE DEBUG=FALSE;" |
56 | | - "mpiexec -np 2 ./amr3d.gnu.MPI.ex inputs.3d.FallingSphere max_step=1 amr.n_cell=16 8 8", |
57 | | - shell=True, |
58 | | - check=True, |
59 | | - cwd=working_dir, |
60 | | - stdout=None if print_output else subprocess.DEVNULL, |
61 | | - stderr=None if print_output else subprocess.DEVNULL |
| 15 | + full_cmd, |
| 16 | + shell=True, |
| 17 | + check=True, |
| 18 | + cwd=working_dir, |
| 19 | + stdout=None if print_output else subprocess.DEVNULL, |
| 20 | + stderr=None if print_output else subprocess.DEVNULL |
62 | 21 | ) |
63 | | - print("test_FallingSphere succeed") |
64 | | - |
65 | | -def test_FlowPastCylinder(working_dir, print_output): |
66 | | - subprocess.run( |
67 | | - "make -j8 USE_CUDA=FALSE USE_MPI=TRUE DEBUG=FALSE;" |
68 | | - "mpiexec -np 2 ./amr3d.gnu.MPI.ex inputs.3d.flow_past_cylinder-x max_step=1", |
69 | | - shell=True, |
70 | | - check=True, |
71 | | - cwd=working_dir, |
72 | | - stdout=None if print_output else subprocess.DEVNULL, |
73 | | - stderr=None if print_output else subprocess.DEVNULL |
74 | | - ) |
75 | | - print("test_FlowPastCylinder succeed") |
76 | | - |
77 | | -def test_FlowPastSphere(working_dir, print_output): |
78 | | - subprocess.run( |
79 | | - "make -j8 USE_CUDA=FALSE USE_MPI=TRUE DEBUG=FALSE;" |
80 | | - "mpiexec -np 2 ./amr3d.gnu.MPI.ex inputs.3d.flow_past_sphere max_step=1 amr.n_cell=16 8 8", |
81 | | - shell=True, |
82 | | - check=True, |
83 | | - cwd=working_dir, |
84 | | - stdout=None if print_output else subprocess.DEVNULL, |
85 | | - stderr=None if print_output else subprocess.DEVNULL |
86 | | - ) |
87 | | - print("test_FlowPastSphere succeed") |
88 | | - |
89 | | -def test_RayleighTaylor(working_dir, print_output): |
90 | | - subprocess.run( |
91 | | - "make -j8 USE_CUDA=FALSE USE_MPI=TRUE DEBUG=FALSE && mpiexec -np 2 ./amr2d.gnu.MPI.ex inputs.2d.rayleightaylor", |
92 | | - shell=True, |
93 | | - check=True, |
94 | | - cwd=working_dir, |
95 | | - stdout=None if print_output else subprocess.DEVNULL, |
96 | | - stderr=None if print_output else subprocess.DEVNULL |
97 | | - ) |
98 | | - print("test_RayleighTaylor succeed") |
99 | | - |
100 | | -def test_RayleighTaylor_LS(working_dir, print_output): |
101 | | - subprocess.run( |
102 | | - "make -j8 USE_CUDA=FALSE USE_MPI=TRUE DEBUG=FALSE;" |
103 | | - "mpiexec -np 2 ./amr2d.gnu.MPI.ex inputs.2d.rayleightaylor_rt ", |
104 | | - shell=True, |
105 | | - check=True, |
106 | | - cwd=working_dir, |
107 | | - stdout=None if print_output else subprocess.DEVNULL, |
108 | | - stderr=None if print_output else subprocess.DEVNULL |
109 | | - ) |
110 | | - print("test_RayleighTaylor_LS succeed") |
111 | | - |
112 | | - |
| 22 | + print(f"Test {name} succeed") |
113 | 23 |
|
114 | 24 | def main(): |
115 | | - # if print_output = false,the information of compile and running doesn't display in terminal |
116 | | - print_output =False |
| 25 | + # if print_output = false, the information of compile and running doesn't display in terminal |
| 26 | + print_output = False |
117 | 27 |
|
118 | 28 | script_dir = os.path.dirname(os.path.abspath(__file__)) |
119 | 29 | print("Script Directory:", script_dir) |
120 | 30 |
|
121 | | - # LidDrivenCavity |
| 31 | + # LidDrivenCavity (2D, no MPI — basic compilation and run test) |
122 | 32 | working_dir = os.path.join(script_dir, "../Tutorials/LidDrivenCavity") |
123 | 33 | print("Test Working Directory:", os.path.abspath(working_dir)) |
124 | | - test_lidDrivenCanvity(working_dir, print_output) |
125 | | - |
126 | | - # LidDrivenCavitySphere |
127 | | - working_dir = os.path.join(script_dir, "../Tutorials/LidDrivenCavitySphere") |
128 | | - print("Test Working Directory:", os.path.abspath(working_dir)) |
129 | | - test_LidDrivenCavitySphere(working_dir, print_output) |
| 34 | + run_test( |
| 35 | + "LidDrivenCavity", |
| 36 | + working_dir, |
| 37 | + "make -j8", |
| 38 | + f"./amr2d.gnu.ex inputs.2d.lid_driven_cavity {CI_OVERRIDES}", |
| 39 | + print_output |
| 40 | + ) |
130 | 41 |
|
131 | | - # RSV |
| 42 | + # RSV (2D, MPI, level set) |
132 | 43 | working_dir = os.path.join(script_dir, "../Tutorials/RSV") |
133 | 44 | print("Test Working Directory:", os.path.abspath(working_dir)) |
134 | | - test_RSV(working_dir, False) |
135 | | - |
| 45 | + run_test( |
| 46 | + "RSV", |
| 47 | + working_dir, |
| 48 | + "make -j8", |
| 49 | + f"./amr2d.gnu.MPI.ex inputs.2d.rsv {CI_OVERRIDES}", |
| 50 | + print_output |
| 51 | + ) |
136 | 52 |
|
137 | | - # DraftingKissingTumbling |
| 53 | + # DraftingKissingTumbling (3D, MPI, particles/IBM) |
138 | 54 | working_dir = os.path.join(script_dir, "../Tutorials/DraftingKissingTumbling") |
139 | 55 | print("Test Working Directory:", os.path.abspath(working_dir)) |
140 | | - test_DraftingKissingTumbling(working_dir, print_output) |
141 | | - |
142 | | - # FallingSphere |
143 | | - working_dir = os.path.join(script_dir, "../Tutorials/FallingSphere") |
144 | | - print("Test Working Directory:", os.path.abspath(working_dir)) |
145 | | - test_FallingSphere(working_dir, print_output) |
146 | | - |
147 | | - # FlowPastCylinder |
148 | | - working_dir = os.path.join(script_dir, "../Tutorials/FlowPastCylinder") |
149 | | - print("Test Working Directory:", os.path.abspath(working_dir)) |
150 | | - test_FlowPastCylinder(working_dir, print_output) |
151 | | - |
152 | | - # FlowPastSphere |
153 | | - working_dir = os.path.join(script_dir, "../Tutorials/FlowPastSphere") |
154 | | - print("Test Working Directory:", os.path.abspath(working_dir)) |
155 | | - test_FlowPastSphere(working_dir, print_output) |
156 | | - |
157 | | - # RayleighTaylor |
158 | | - working_dir = os.path.join(script_dir, "../Tutorials/RayleighTaylor") |
159 | | - print("Test Working Directory:", os.path.abspath(working_dir)) |
160 | | - test_RayleighTaylor(working_dir, print_output) |
161 | | - |
162 | | - # RayleighTaylor_LS |
163 | | - working_dir = os.path.join(script_dir, "../Tutorials/RayleighTaylor_LS") |
164 | | - print("Test Working Directory:", os.path.abspath(working_dir)) |
165 | | - test_RayleighTaylor_LS(working_dir, print_output) |
166 | | - |
| 56 | + run_test( |
| 57 | + "DraftingKissingTumbling", |
| 58 | + working_dir, |
| 59 | + "make -j8 USE_CUDA=FALSE USE_MPI=TRUE DEBUG=FALSE", |
| 60 | + f"mpiexec -np 2 ./amr3d.gnu.MPI.ex inputs.3d.DKT max_step=1 amr.n_cell=16 8 8 amr.plot_int=-1 amr.check_int=-1", |
| 61 | + print_output |
| 62 | + ) |
167 | 63 |
|
168 | 64 |
|
169 | | -if __name__== "__main__" : |
| 65 | +if __name__ == "__main__": |
170 | 66 | main() |
171 | | - |
0 commit comments