1
1
import os
2
- import subprocess
2
+ from conda_subprocess import check_output
3
3
import shutil
4
4
5
5
source_directory = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "source" )
@@ -11,24 +11,26 @@ def generate_mesh(domain_size: float = 2.0) -> str:
11
11
source_file_name = "unit_square.geo"
12
12
os .makedirs (stage_name , exist_ok = True )
13
13
_copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
14
- _ = subprocess . check_output (
14
+ _ = check_output (
15
15
[
16
- "conda " , "run " , "-n " , stage_name , "gmsh " , "-2" , "-setnumber" ,
17
- "domain_size" , str ( domain_size ), source_file_name , "-o" , gmsh_output_file_name
16
+ "gmsh " , "-2 " , "-setnumber " , "domain_size " , str ( domain_size ) ,
17
+ source_file_name , "-o" , gmsh_output_file_name
18
18
],
19
+ prefix_name = stage_name ,
19
20
cwd = stage_name ,
20
21
universal_newlines = True ,
21
22
).split ("\n " )
22
23
return os .path .abspath (os .path .join (stage_name , gmsh_output_file_name ))
23
24
24
25
25
- def convert_to_xdmf (gmsh_output_file : str ) -> str :
26
+ def convert_to_xdmf (gmsh_output_file : str ) -> dict :
26
27
stage_name = "preprocessing"
27
28
meshio_output_file_name = "square.xdmf"
28
29
os .makedirs (stage_name , exist_ok = True )
29
30
_copy_file (stage_name = stage_name , source_file = gmsh_output_file )
30
- _ = subprocess .check_output (
31
- ["conda" , "run" , "-n" , stage_name , "meshio" , "convert" , os .path .basename (gmsh_output_file ), meshio_output_file_name ],
31
+ _ = check_output (
32
+ ["meshio" , "convert" , os .path .basename (gmsh_output_file ), meshio_output_file_name ],
33
+ prefix_name = stage_name ,
32
34
cwd = stage_name ,
33
35
universal_newlines = True ,
34
36
).split ("\n " )
@@ -47,12 +49,12 @@ def poisson(meshio_output_xdmf: str, meshio_output_h5: str) -> dict:
47
49
_copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
48
50
_copy_file (stage_name = stage_name , source_file = meshio_output_xdmf )
49
51
_copy_file (stage_name = stage_name , source_file = meshio_output_h5 )
50
- _ = subprocess . check_output (
52
+ _ = check_output (
51
53
[
52
- "conda" , "run" , "-n" , stage_name , "python" , "poisson.py" ,
53
- "--mesh" , os .path .basename (meshio_output_xdmf ), "--degree" , "2" ,
54
+ "python" , "poisson.py" , "--mesh" , os .path .basename (meshio_output_xdmf ), "--degree" , "2" ,
54
55
"--outputfile" , poisson_output_pvd_file_name , "--num-dofs" , poisson_output_numdofs_file_name
55
56
],
57
+ prefix_name = stage_name ,
56
58
cwd = stage_name ,
57
59
universal_newlines = True ,
58
60
).split ("\n " )
@@ -71,8 +73,9 @@ def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str) -
71
73
_copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
72
74
_copy_file (stage_name = stage_name , source_file = poisson_output_pvd_file )
73
75
_copy_file (stage_name = stage_name , source_file = poisson_output_vtu_file )
74
- _ = subprocess .check_output (
75
- ["conda" , "run" , "-n" , stage_name , "pvbatch" , source_file_name , os .path .basename (poisson_output_pvd_file ), pvbatch_output_file_name ],
76
+ _ = check_output (
77
+ ["pvbatch" , source_file_name , os .path .basename (poisson_output_pvd_file ), pvbatch_output_file_name ],
78
+ prefix_name = stage_name ,
76
79
cwd = stage_name ,
77
80
universal_newlines = True ,
78
81
).split ("\n " )
@@ -88,13 +91,13 @@ def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float =
88
91
_copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
89
92
_copy_file_from_source (stage_name = stage_name , source_file_name = template_file_name )
90
93
_copy_file (stage_name = stage_name , source_file = pvbatch_output_file )
91
- _ = subprocess . check_output (
94
+ _ = check_output (
92
95
[
93
- "conda" , "run" , "-n" , stage_name , "python" , "prepare_paper_macros.py" ,
94
- "--macro-template-file" , template_file_name , "--plot-data-path" , os .path .basename (pvbatch_output_file ),
95
- "--domain-size" , str (domain_size ), "--num-dofs" , str (ndofs ),
96
- "--output-macro-file" , macros_output_file_name ,
96
+ "python" , "prepare_paper_macros.py" , "--macro-template-file" , template_file_name ,
97
+ "--plot-data-path" , os .path .basename (pvbatch_output_file ), "--domain-size" , str (domain_size ),
98
+ "--num-dofs" , str (ndofs ), "--output-macro-file" , macros_output_file_name ,
97
99
],
100
+ prefix_name = stage_name ,
98
101
cwd = stage_name ,
99
102
universal_newlines = True ,
100
103
).split ("\n " )
@@ -109,8 +112,9 @@ def compile_paper(macros_tex: str, plot_file: str) -> str:
109
112
_copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
110
113
_copy_file (stage_name = stage_name , source_file = macros_tex )
111
114
_copy_file (stage_name = stage_name , source_file = plot_file )
112
- _ = subprocess .check_output (
113
- ["conda" , "run" , "-n" , stage_name , "tectonic" , source_file_name ],
115
+ _ = check_output (
116
+ ["tectonic" , source_file_name ],
117
+ prefix_name = stage_name ,
114
118
universal_newlines = True ,
115
119
cwd = stage_name ,
116
120
).split ("\n " )
0 commit comments