forked from trelau/SMESH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.py
193 lines (153 loc) · 6.32 KB
/
prepare.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import os
import shutil
import patch
def prepare_netgen():
"""
Prepare sources for Netgen.
"""
# Delete source directories if they exist
if os.path.exists('src/Netgen'):
shutil.rmtree('src/Netgen')
# Copy sources
shutil.copytree('external/Netgen/libsrc', 'src/Netgen/libsrc')
shutil.copytree('external/Netgen/nglib', 'src/Netgen/nglib')
# Patch Netgen sources for SALOME
pset = patch.fromfile('external/NETGENPlugin/src/NETGEN/netgen62ForSalome.patch')
success = pset.apply(strip=1, root='src/Netgen')
if not success:
raise RuntimeError('Failed to apply Netgen patch.')
# Patch occgenmesh for OCCT 7.6
pset = patch.fromfile('patch/occgenmesh_OCCT76.patch')
success = pset.apply(strip=0, root='src/Netgen')
if not success:
raise RuntimeError('Failed to apply occgenmesh for OCCT 7.6 patch.')
# Copy Netgen cmake files into source directory
shutil.copytree('cmake/Netgen', 'src/Netgen', dirs_exist_ok=True)
# Copy netgen_version.hpp
# Obtained from distribution at https://anaconda.org/ngsolve/netgen
shutil.copyfile('extra/Netgen/netgen_version.hpp',
'src/Netgen/libsrc/include/netgen_version.hpp')
def prepare_kernel():
"""
Prepare sources for Kernel.
"""
# Delete source directories if they exist
if os.path.exists('src/Kernel'):
shutil.rmtree('src/Kernel')
# Copy sources
shutil.copytree('external/Kernel/src/Basics',
'src/Kernel/src/Basics')
shutil.copytree('external/Kernel/src/SALOMELocalTrace',
'src/Kernel/src/SALOMELocalTrace')
shutil.copytree('external/Kernel/src/Utils',
'src/Kernel/src/Utils')
# Copy and overwrite the Kernel CMakeLists.txt file
target = os.path.join('src/Kernel', 'CMakeLists.txt')
shutil.copyfile('cmake/Kernel/CMakeLists.txt', target)
# Patch sources
pset = patch.fromfile('patch/Kernel.patch')
success = pset.apply(strip=0, root='src/Kernel')
if not success:
raise RuntimeError('Failed to apply Kernel patch.')
def prepare_geom():
"""
Prepare sources for Geom.
"""
# Delete source directories if they exist
if os.path.exists('src/Geom'):
shutil.rmtree('src/Geom')
# Copy sources
shutil.copytree('external/Geom/src/GEOMUtils',
'src/Geom/src/GEOMUtils')
# Copy and overwrite the Geom CMakeLists.txt file
target = os.path.join('src/Geom', 'CMakeLists.txt')
shutil.copyfile('cmake/Geom/CMakeLists.txt', target)
# Patch sources
pset = patch.fromfile('patch/GEOMUtils.patch')
success = pset.apply(strip=0, root='src/Geom')
if not success:
raise RuntimeError('Failed to apply GEOMUtils patch.')
def prepare_smesh():
"""
Prepare sources for SMESH.
"""
# Delete source directories if they exist
if os.path.exists('src/SMESH'):
shutil.rmtree('src/SMESH')
# Copy sources
shutil.copytree('external/SMESH/src',
'src/SMESH/src')
# Copy and overwrite the SMESH CMakeLists.txt file
target = os.path.join('src/SMESH', 'CMakeLists.txt')
shutil.copyfile('cmake/SMESH/CMakeLists.txt', target)
# Patch sources
pset = patch.fromfile('patch/mefisto.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply mefisto patch.')
pset = patch.fromfile('patch/SMESH_ControlPnt.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply SMESH_ControlPnt patch.')
pset = patch.fromfile('patch/SMESH_Controls.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply SMESH_Controls patch.')
pset = patch.fromfile('patch/SMESH_Mesh.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply SMESH_Mesh patch.')
pset = patch.fromfile('patch/SMESH_MeshAlgos.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply SMESH_MeshAlgos patch.')
pset = patch.fromfile('patch/SMESH_Slot.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply SMESH_Slot patch.')
pset = patch.fromfile('patch/SMESH_SMDS.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply SMESH_SMDS patch.')
pset = patch.fromfile('patch/StdMeshers_Adaptive1D.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply StdMeshers_Adaptive1D patch.')
pset = patch.fromfile('patch/StdMeshers_Projection_2D.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply StdMeshers_Projection_2D patch.')
pset = patch.fromfile('patch/StdMeshers_ViscousLayers.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply StdMeshers_ViscousLayers patch.')
pset = patch.fromfile('patch/SMESH_swap_bool_vector.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply SMESH_swap_bool_vector patch.')
# Copy MeshVSLink sources
shutil.copytree('extra/MeshVSLink',
'src/SMESH/src/MeshVSLink', dirs_exist_ok=True)
# Copy MEFISTO2 trte.c source
shutil.copyfile('extra/MEFISTO2/trte.c', 'src/SMESH/src/MEFISTO2/trte.c')
def prepare_netgen_plugin():
"""
Prepare sources for NETGENPlugin
"""
# Delete source directories if they exist
if os.path.exists('src/SMESH/src/NETGENPlugin'):
shutil.rmtree('src/SMESH/src/NETGENPlugin')
# Copy sources
shutil.copytree('external/NETGENPlugin/src',
'src/SMESH/src/NETGENPlugin/src')
# Patch sources
pset = patch.fromfile('patch/NETGENPlugin_Mesher.patch')
success = pset.apply(strip=0, root='src/SMESH/src/NETGENPlugin')
if not success:
raise RuntimeError('Failed to apply NETGENPlugin_Mesher patch.')
if __name__ == '__main__':
prepare_netgen()
prepare_kernel()
prepare_geom()
prepare_smesh()
prepare_netgen_plugin()