2
2
from conda_subprocess import check_output
3
3
import shutil
4
4
5
- source_directory = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "source" )
6
5
7
-
8
- def generate_mesh (domain_size : float = 2.0 ) -> str :
6
+ def generate_mesh (domain_size : float , source_directory : str ) -> str :
9
7
stage_name = "preprocessing"
10
8
gmsh_output_file_name = "square.msh"
11
9
source_file_name = "unit_square.geo"
12
10
os .makedirs (stage_name , exist_ok = True )
13
- _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
11
+ _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name , source_directory = source_directory )
14
12
_ = check_output (
15
13
[
16
14
"gmsh" , "-2" , "-setnumber" , "domain_size" , str (domain_size ),
@@ -40,13 +38,13 @@ def convert_to_xdmf(gmsh_output_file : str) -> dict:
40
38
}
41
39
42
40
43
- def poisson (meshio_output_xdmf : str , meshio_output_h5 : str ) -> dict :
41
+ def poisson (meshio_output_xdmf : str , meshio_output_h5 : str , source_directory : str ) -> dict :
44
42
stage_name = "processing"
45
43
poisson_output_pvd_file_name = "poisson.pvd"
46
44
poisson_output_numdofs_file_name = "numdofs.txt"
47
45
source_file_name = "poisson.py"
48
46
os .makedirs (stage_name , exist_ok = True )
49
- _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
47
+ _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name , source_directory = source_directory )
50
48
_copy_file (stage_name = stage_name , source_file = meshio_output_xdmf )
51
49
_copy_file (stage_name = stage_name , source_file = meshio_output_h5 )
52
50
_ = check_output (
@@ -65,12 +63,12 @@ def poisson(meshio_output_xdmf: str, meshio_output_h5: str) -> dict:
65
63
}
66
64
67
65
68
- def plot_over_line (poisson_output_pvd_file : str , poisson_output_vtu_file : str ) -> str :
66
+ def plot_over_line (poisson_output_pvd_file : str , poisson_output_vtu_file : str , source_directory : str ) -> str :
69
67
stage_name = "postprocessing"
70
68
pvbatch_output_file_name = "plotoverline.csv"
71
69
source_file_name = "postprocessing.py"
72
70
os .makedirs (stage_name , exist_ok = True )
73
- _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
71
+ _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name , source_directory = source_directory )
74
72
_copy_file (stage_name = stage_name , source_file = poisson_output_pvd_file )
75
73
_copy_file (stage_name = stage_name , source_file = poisson_output_vtu_file )
76
74
_ = check_output (
@@ -82,14 +80,14 @@ def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str) -
82
80
return os .path .abspath (os .path .join ("postprocessing" , pvbatch_output_file_name ))
83
81
84
82
85
- def substitute_macros (pvbatch_output_file : str , ndofs : int , domain_size : float = 2.0 ) -> str :
83
+ def substitute_macros (pvbatch_output_file : str , ndofs : int , domain_size : float , source_directory : str ) -> str :
86
84
stage_name = "postprocessing"
87
85
source_file_name = "prepare_paper_macros.py"
88
86
template_file_name = "macros.tex.template"
89
87
macros_output_file_name = "macros.tex"
90
88
os .makedirs (stage_name , exist_ok = True )
91
- _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
92
- _copy_file_from_source (stage_name = stage_name , source_file_name = template_file_name )
89
+ _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name , source_directory = source_directory )
90
+ _copy_file_from_source (stage_name = stage_name , source_file_name = template_file_name , source_directory = source_directory )
93
91
_copy_file (stage_name = stage_name , source_file = pvbatch_output_file )
94
92
_ = check_output (
95
93
[
@@ -104,12 +102,12 @@ def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float =
104
102
return os .path .abspath (os .path .join (stage_name , macros_output_file_name ))
105
103
106
104
107
- def compile_paper (macros_tex : str , plot_file : str ) -> str :
105
+ def compile_paper (macros_tex : str , plot_file : str , source_directory : str ) -> str :
108
106
stage_name = "postprocessing"
109
107
paper_output = "paper.pdf"
110
108
source_file_name = "paper.tex"
111
109
os .makedirs (stage_name , exist_ok = True )
112
- _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name )
110
+ _copy_file_from_source (stage_name = stage_name , source_file_name = source_file_name , source_directory = source_directory )
113
111
_copy_file (stage_name = stage_name , source_file = macros_tex )
114
112
_copy_file (stage_name = stage_name , source_file = plot_file )
115
113
_ = check_output (
@@ -126,12 +124,12 @@ def _poisson_collect_output(numdofs_file: str) -> int:
126
124
return int (f .read ())
127
125
128
126
129
- def _copy_file (stage_name , source_file ):
127
+ def _copy_file (stage_name : str , source_file : str ):
130
128
input_file = os .path .join (os .path .abspath (stage_name ), os .path .basename (source_file ))
131
129
if input_file != source_file :
132
130
shutil .copyfile (source_file , input_file )
133
131
134
132
135
- def _copy_file_from_source (stage_name , source_file_name ):
133
+ def _copy_file_from_source (stage_name : str , source_file_name : str , source_directory : str ):
136
134
source_file = os .path .join (source_directory , source_file_name )
137
- shutil .copyfile (source_file , os .path .join (stage_name , source_file_name ))
135
+ shutil .copyfile (source_file , os .path .join (stage_name , source_file_name ))
0 commit comments