2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from libMEDMEM_Swig import *
29 srcdir = os.getenv("srcdir")
30 med_root = os.getenv("MED_ROOT_DIR")
32 # make check is being performed
33 dir_renumber="./renumber"
34 dir_mesh = os.path.join( srcdir, "../../resources")
36 # hope renumber has been already installed
37 dir_renumber=os.path.join( med_root, "bin/salome/renumber")
38 dir_mesh = os.path.join( med_root, "share/salome/resources/med")
41 dir_renumber="../../../MED_INSTALL/bin/salome/renumber"
42 dir_mesh="../../resources"
49 string_to_execute="'"+dir_renumber+" "+dir_mesh+"/"+filename+" "+meshname+" "+method+" "+dir_mesh+"/out_"+filename+"'"
50 eval("os.system("+string_to_execute+")")
51 m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
53 field_ini=[2,3,12,13,14,15,4,5,6,7,8,9,16,17,0,1,10,11]
54 s = m.getSupportOnAll(MED_CELL)
56 id=f.addDriver(MED_DRIVER,dir_mesh+"/out_"+filename,"Test field")
60 field=field&(f.getValueIJ(i+1,1)==field_ini[i*2])
61 field=field&(f.getValueIJ(i+1,2)==field_ini[i*2+1])
64 nbcell2dboost=m.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
65 connectivite=[2,6,13,11,11,13,14,12,6,5,15,13,12,14,10,4,13,15,16,14,5,1,7,15,14,16,9,10,15,7,8,16,16,8,3,9]
66 connectivite_index=[1,5,9,13,17,21,25,29,33,37]
67 conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_QUAD4)
68 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
69 conn2dboost=(list(conn)==connectivite) # convert numpy.ndarray to list
70 conn_index2dboost=(list(conn_index)==connectivite_index)
71 Boost2D=conn2dboost and conn_index2dboost and (nbcell2dboost==9) and field
72 os.remove(dir_mesh+"/out_"+filename)
77 string_to_execute="'"+dir_renumber+" "+dir_mesh+"/"+filename+" "+meshname+" "+method+" "+dir_mesh+"/out_"+filename+"'"
78 eval("os.system("+string_to_execute+")")
79 m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
80 nbcell2dmetis=m.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
81 connectivite=[12,14,10,4,2,6,13,11,11,13,14,12,16,8,3,9,5,1,7,15,15,7,8,16,14,16,9,10,6,5,15,13,13,15,16,14]
82 connectivite_index=[1,5,9,13,17,21,25,29,33,37]
83 conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_QUAD4)
84 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
85 conn2dmetis=(list(conn)==connectivite)
86 conn_index2dmetis=(list(conn_index)==connectivite_index)
87 Metis2D=conn2dmetis and conn_index2dmetis and (nbcell2dmetis==9)
88 os.remove(dir_mesh+"/out_"+filename)
90 ## *** Avec polygone ***
92 filename="Test2Dpoly.med"
96 print "TEST 2D Boost with polygons"
98 string_to_execute="'"+dir_renumber+" "+dir_mesh+"/"+filename+" "+meshname+" "+method+" "+dir_mesh+"/out_"+filename+"'"
99 eval("os.system("+string_to_execute+")")
100 m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
101 nbcell2dpolyboost=m.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
102 connectivite=[2,5,9,10,11,10,9,12,5,6,8,9,4,11,12,16,12,9,8,13,6,1,7,8,16,12,13,15,13,8,7,14,15,13,14,3]
103 connectivite_index=[1,5,9,13,17,21,25,29,33,37]
104 conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_POLYGON)
105 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL)
106 conn2dpolyboost=(list(conn)==connectivite)
107 conn_index2dpolyboost=(list(conn_index)==connectivite_index)
108 PolyBoost2D=conn2dpolyboost and conn_index2dpolyboost and (nbcell2dpolyboost==9)
109 os.remove(dir_mesh+"/out_"+filename)
111 print "TEST 2D Metis with polygons"
113 string_to_execute="'"+dir_renumber+" "+dir_mesh+"/"+filename+" "+meshname+" "+method+" "+dir_mesh+"/out_"+filename+"'"
114 eval("os.system("+string_to_execute+")")
115 m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
116 nbcell2dpolymetis=m.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
117 connectivite=[6,1,7,8,2,5,9,10,5,6,8,9,15,13,14,3,4,11,12,16,16,12,13,15,11,10,9,12,12,9,8,13,13,8,7,14]
118 connectivite_index=[1,5,9,13,17,21,25,29,33,37]
119 conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_POLYGON)
120 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL)
121 conn2dpolymetis=(list(conn)==connectivite)
122 conn_index2dpolymetis=(list(conn_index)==connectivite_index)
123 PolyMetis2D=conn2dpolymetis and conn_index2dpolymetis and (nbcell2dpolymetis==9)
124 os.remove(dir_mesh+"/out_"+filename)
132 filename="Test3D.med"
136 print "TEST 3D Boost"
138 string_to_execute="'"+dir_renumber+" "+dir_mesh+"/"+filename+" "+meshname+" "+method+" "+dir_mesh+"/out_"+filename+"'"
139 eval("os.system("+string_to_execute+")")
140 m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
141 nbcell3dboost=m.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
142 connectivite=[23,13,5,18,27,22,14,26,17,6,13,23,25,16,22,27,27,22,14,26,24,15,7,20,9,23,18,1,21,27,26,10,25,16,22,27,19,8,15,24,2,17,23,9,12,25,27,21,21,27,26,10,11,24,20,3,12,25,27,21,4,19,24,11]
143 connectivite_index=[1,9,17,25,33,41,49,57,65]
144 conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_HEXA8)
145 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
146 conn3dboost=(list(conn)==connectivite)
147 conn_index3dboost=(list(conn_index)==connectivite_index)
148 Boost3D=conn3dboost and conn_index3dboost and (nbcell3dboost==8)
149 os.remove(dir_mesh+"/out_"+filename)
152 print "TEST 3D Metis"
154 string_to_execute="'"+dir_renumber+" "+dir_mesh+"/"+filename+" "+meshname+" "+method+" "+dir_mesh+"/out_"+filename+"'"
155 eval("os.system("+string_to_execute+")")
156 m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
157 nbcell3dmetis=m.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
158 connectivite=[12,25,27,21,4,19,24,11,27,22,14,26,24,15,7,20,17,6,13,23,25,16,22,27,9,23,18,1,21,27,26,10,23,13,5,18,27,22,14,26,25,16,22,27,19,8,15,24,2,17,23,9,12,25,27,21,21,27,26,10,11,24,20,3]
159 connectivite_index=[1,9,17,25,33,41,49,57,65]
160 conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_HEXA8)
161 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
162 conn3dmetis=(list(conn)==connectivite)
163 conn_index3dmetis=(list(conn_index)==connectivite_index)
164 Metis3D=conn3dmetis&conn_index3dmetis&(nbcell3dmetis==8)
165 os.remove(dir_mesh+"/out_"+filename)
168 ## *** Avec polyedres ***
170 ## 23,13,5,18,27,26,14,22,23,27,22,13,13,22,14,5,5,14,26,18,18,26,27,23,
171 ## 21,27,26,10,11,3,20,24,21,11,24,27,27,24,20,26,26,20,3,10,10,3,11,21,
172 ## 12,25,27,21,4,11,24,19,12,4,19,25,25,19,24,27,27,24,11,21,21,11,4,12,
173 ## 9,23,18,1,21,10,26,27,9,21,27,23,23,27,26,18,18,26,10,1,1,10,21,9,
174 ## 2,17,23,9,12,21,27,25,2,12,25,17,17,25,27,23,23,27,21,9,9,21,12,2,
175 ## 25,16,22,27,19,24,15,8,25,19,8,16,16,8,15,22,22,15,24,27,27,24,19,25,
176 ## 17,6,13,23,25,27,22,16,17,25,16,6,6,16,22,13,13,22,27,23,23,27,25,17,
177 ## 27,22,14,26,24,20,7,15,27,24,15,22,22,15,7,14,14,7,20,26,26,20,24,27,
180 filename="Test3Dpoly.med"
184 print "TEST 3D Boost with polyhedra"
186 string_to_execute="'"+dir_renumber+" "+dir_mesh+"/"+filename+" "+meshname+" "+method+" "+dir_mesh+"/out_"+filename+"'"
187 eval("os.system("+string_to_execute+")")
188 m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
189 nbcell3dpolyboost=m.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
190 connectivite=[23,13,5,18,-1,27,26,14,22,-1,23,27,22,13,-1,13,22,14,5,-1,5,14,26,18,-1,18,26,27,23,
191 17,6,13,23,-1,25,27,22,16,-1,17,25,16,6,-1,6,16,22,13,-1,13,22,27,23,-1,23,27,25,17,
192 27,22,14,26,-1,24,20,7,15,-1,27,24,15,22,-1,22,15,7,14,-1,14,7,20,26,-1,26,20,24,27,
193 9,23,18,1,-1,21,10,26,27,-1,9,21,27,23,-1,23,27,26,18,-1,18,26,10,1,-1,1,10,21,9,
194 25,16,22,27,-1,19,24,15,8,-1,25,19,8,16,-1,16,8,15,22,-1,22,15,24,27,-1,27,24,19,25,
195 2,17,23,9,-1,12,21,27,25,-1,2,12,25,17,-1,17,25,27,23,-1,23,27,21,9,-1,9,21,12,2,
196 21,27,26,10,-1,11,3,20,24,-1,21,11,24,27,-1,27,24,20,26,-1,26,20,3,10,-1,10,3,11,21,
197 12,25,27,21,-1,4,11,24,19,-1,12,4,19,25,-1,25,19,24,27,-1,27,24,11,21,-1,21,11,4,12]
198 connectivite_index=[1, 30, 59, 88, 117, 146, 175, 204, 233]
199 conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_POLYHEDRA)
200 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
201 conn3dpolyboost=(connectivite==list(conn))
202 conn_index3dpolyboost=(connectivite_index==list(conn_index))
203 PolyBoost3D=(conn3dpolyboost and conn_index3dpolyboost and (nbcell3dpolyboost==8))
204 os.remove(dir_mesh+"/out_"+filename)
207 print "TEST 3D Metis with polyhedra"
209 string_to_execute="'"+dir_renumber+" "+dir_mesh+"/"+filename+" "+meshname+" "+method+" "+dir_mesh+"/out_"+filename+"'"
210 eval("os.system("+string_to_execute+")")
211 m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
212 nbcell3dpolymetis=m.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
213 connectivite=[12,25,27,21,-1,4,11,24,19,-1,12,4,19,25,-1,25,19,24,27,-1,27,24,11,21,-1,21,11,4,12,
214 27,22,14,26,-1,24,20,7,15,-1,27,24,15,22,-1,22,15,7,14,-1,14,7,20,26,-1,26,20,24,27,
215 17,6,13,23,-1,25,27,22,16,-1,17,25,16,6,-1,6,16,22,13,-1,13,22,27,23,-1,23,27,25,17,
216 9,23,18,1,-1,21,10,26,27,-1,9,21,27,23,-1,23,27,26,18,-1,18,26,10,1,-1,1,10,21,9,
217 23,13,5,18,-1,27,26,14,22,-1,23,27,22,13,-1,13,22,14,5,-1,5,14,26,18,-1,18,26,27,23,
218 25,16,22,27,-1,19,24,15,8,-1,25,19,8,16,-1,16,8,15,22,-1,22,15,24,27,-1,27,24,19,25,
219 2,17,23,9,-1,12,21,27,25,-1,2,12,25,17,-1,17,25,27,23,-1,23,27,21,9,-1,9,21,12,2,
220 21,27,26,10,-1,11,3,20,24,-1,21,11,24,27,-1,27,24,20,26,-1,26,20,3,10,-1,10,3,11,21]
221 connectivite_index=[1, 30, 59, 88, 117, 146, 175, 204, 233]
222 conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_POLYHEDRA)
223 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
224 conn3dpolymetis=(list(conn)==connectivite)
225 conn_index3dpolymetis=(list(conn_index)==connectivite_index)
226 PolyMetis3D=(conn3dpolymetis and conn_index3dpolymetis and (nbcell3dpolymetis==8))
227 os.remove(dir_mesh+"/out_"+filename)
236 print "ERROR Boost 2D"
240 print "ERROR Metis 2D"
242 print "Poly Boost 2D ok"
244 print "ERROR Poly Boost 2D"
246 print "Poly Metis 2D ok"
248 print "ERROR Poly Metis 2D"
252 print "ERROR Boost 3D"
256 print "ERROR Metis 3D"
258 print "Poly Boost 3D ok"
260 print "ERROR Poly Boost 3D"
262 print "Poly Metis 3D ok"
264 print "ERROR Poly Metis 3D"
268 if Boost2D&Metis2D&PolyBoost2D&PolyMetis2D&Boost3D&Metis3D&PolyBoost3D&PolyMetis3D:
269 print "Every mesh correctly renumbered"
273 sys.exit("Error in the renumbering test")