1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2012 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from MEDCouplingRemapper import *
25 class MEDCouplingBasicsTest(unittest.TestCase):
26 def testRemapper1(self):
27 sourceMesh=self.build2DSourceMesh_1();
28 targetMesh=self.build2DTargetMesh_1();
29 remapper=MEDCouplingRemapper()
30 remapper.setPrecision(1e-12);
31 remapper.setIntersectionType(Triangulation);
32 self.failUnless(remapper.prepare(sourceMesh,targetMesh,"P0P0")==1);
33 srcField=MEDCouplingFieldDouble.New(ON_CELLS);
34 srcField.setNature(ConservativeVolumic);
35 srcField.setMesh(sourceMesh);
36 array=DataArrayDouble.New();
37 ptr=sourceMesh.getNumberOfCells()*[None]
38 for i in xrange(sourceMesh.getNumberOfCells()):
41 array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
42 srcField.setArray(array);
43 srcField.setName("abc") ; srcField.setDescription("def")
44 srcField.setTime(7.7,9,10)
45 trgfield=remapper.transferField(srcField,4.57);
46 self.assertEqual("abc",trgfield.getName())
47 self.assertEqual("def",trgfield.getDescription())
48 a,b,c=trgfield.getTime()
49 self.assertAlmostEqual(7.7,a,14)
51 self.assertEqual(c,10)
52 values=trgfield.getArray().getValues();
53 valuesExpected=[7.5 ,7. ,7.,8.,7.5];
54 for i in xrange(targetMesh.getNumberOfCells()):
55 self.failUnless(abs(values[i]-valuesExpected[i])<1e-12);
57 self.failUnless(1==trgfield.getArray().getNumberOfComponents());
60 def testPrepareEx1(self):
61 sourceMesh=self.build2DSourceMesh_1();
62 targetMesh=self.build2DTargetMesh_3();
64 remapper=MEDCouplingRemapper();
65 remapper.setPrecision(1e-12);
66 remapper.setIntersectionType(Triangulation);
67 srcFt=MEDCouplingFieldTemplate.New(ON_CELLS);
68 trgFt=MEDCouplingFieldTemplate.New(ON_CELLS);
69 srcFt.setMesh(sourceMesh);
70 trgFt.setMesh(targetMesh);
71 self.assertEqual(1,remapper.prepareEx(srcFt,trgFt));
72 srcField=MEDCouplingFieldDouble.New(ON_CELLS);
73 srcField.setNature(ConservativeVolumic);
74 srcField.setMesh(sourceMesh);
75 array=DataArrayDouble.New();
76 ptr=sourceMesh.getNumberOfCells()*[None]
77 for i in xrange(sourceMesh.getNumberOfCells()):
80 array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
81 srcField.setArray(array);
82 trgfield=remapper.transferField(srcField,4.220173);
83 values=trgfield.getArray().getValues();
84 valuesExpected=[7.75, 7.0625, 4.220173,8.0]
85 self.assertEqual(4,trgfield.getArray().getNumberOfTuples());
86 self.assertEqual(1,trgfield.getArray().getNumberOfComponents());
88 self.assertAlmostEqual(valuesExpected[i0],values[i0],12);
92 def testPartialTransfer1(self):
93 sourceMesh=self.build2DSourceMesh_1();
94 targetMesh=self.build2DTargetMesh_3();
96 remapper=MEDCouplingRemapper();
97 remapper.setPrecision(1e-12);
98 remapper.setIntersectionType(Triangulation);
99 srcFt=MEDCouplingFieldTemplate.New(ON_CELLS);
100 trgFt=MEDCouplingFieldTemplate.New(ON_CELLS);
101 srcFt.setMesh(sourceMesh);
102 trgFt.setMesh(targetMesh);
103 self.assertEqual(1,remapper.prepareEx(srcFt,trgFt));
104 srcField=MEDCouplingFieldDouble.New(ON_CELLS);
105 srcField.setNature(ConservativeVolumic);
106 srcField.setMesh(sourceMesh);
107 array=DataArrayDouble.New();
108 ptr=sourceMesh.getNumberOfCells()*[None]
109 for i in xrange(sourceMesh.getNumberOfCells()):
112 array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
113 srcField.setArray(array);
114 trgfield=MEDCouplingFieldDouble.New(ON_CELLS);
115 trgfield.setNature(ConservativeVolumic);
116 trgfield.setMesh(targetMesh);
117 array=DataArrayDouble.New();
118 ptr=targetMesh.getNumberOfCells()*[None]
119 for i in xrange(targetMesh.getNumberOfCells()):
122 array.setValues(ptr,targetMesh.getNumberOfCells(),1);
123 trgfield.setArray(array);
124 remapper.partialTransfer(srcField,trgfield);
125 values=trgfield.getArray().getValues();
126 valuesExpected=[7.75, 7.0625, 4.220173,8.0]
127 self.assertEqual(4,trgfield.getArray().getNumberOfTuples());
128 self.assertEqual(1,trgfield.getArray().getNumberOfComponents());
130 self.assertAlmostEqual(valuesExpected[i0],values[i0],12);
134 def testPrepareUC(self):
136 coords=DataArrayDouble([0.,0.5,0.7])
137 src=MEDCouplingUMesh("",1) ; src.setCoords(coords)
138 src.allocateCells(2) ; src.insertNextCell(NORM_SEG2,[0,1]) ; src.insertNextCell(NORM_SEG2,[1,2]) ; src.finishInsertingCells()
139 trg=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.7,-0.1,0.2,0.7,2.,2.3])
140 trg.setCoordsAt(0,arr)
141 fieldSrc=MEDCouplingFieldDouble(ON_CELLS,NO_TIME) ; fieldSrc.setMesh(src) ; arrSrc=DataArrayDouble([10.,30.])
142 fieldSrc.setNature(Integral) ; fieldSrc.setArray(arrSrc)
143 rem=MEDCouplingRemapper()
144 rem.prepare(src,trg,"P0P0")
145 trgField=rem.transferField(fieldSrc,-7.)
146 expected1=[-7.,4.,36.,-7.,-7.]
147 self.assertEqual(5,trgField.getArray().getNumberOfTuples())
148 self.assertEqual(5,len(expected1))
149 for i,val in enumerate(expected1):
150 self.assertAlmostEqual(expected1[i],trgField.getArray().getIJ(i,0),12);
153 coords=DataArrayDouble([0.,0.,0.,1.,1.,1.,1.,0.,0.5,-0.2],5,2)
154 src=MEDCouplingUMesh("",2) ; src.setCoords(coords)
155 src.allocateCells(2) ; src.insertNextCell(NORM_TRI3,[0,1,2]) ; src.insertNextCell(NORM_TRI3,[3,4,0]) ; src.finishInsertingCells()
156 trg=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.7,-0.1,0.2,0.7,2.,2.3])
157 trg.setCoordsAt(0,arr) ; trg.setCoordsAt(1,arr)
158 fieldSrc=MEDCouplingFieldDouble(ON_CELLS,NO_TIME) ; fieldSrc.setMesh(src) ; arrSrc=DataArrayDouble([10.,30.])
159 fieldSrc.setNature(Integral) ; fieldSrc.setArray(arrSrc)
160 rem=MEDCouplingRemapper()
161 rem.prepare(src,trg,"P0P0")
162 trgField=rem.transferField(fieldSrc,-7.)
163 expected2=[-7.,-7.,7.35,0.15,-7.,-7.,2.8,14.85,5.25,-7.,-7.,2.,2.5,-7.,-7.,-7.,1.2,3.,0.9,-7.,-7.,-7.,-7.,-7.,-7.]
164 self.assertEqual(25,trgField.getArray().getNumberOfTuples())
165 self.assertEqual(25,len(expected2))
166 for i,val in enumerate(expected2):
167 self.assertAlmostEqual(expected2[i],trgField.getArray().getIJ(i,0),12);
170 coords=DataArrayDouble([0.,0.,0.,0.,1.,0.,1.,1.,0.,1.,0.,0.,0.5,-0.2,0.,0.1,0.8,1.,0.5,0.,1.],7,3)
171 src=MEDCouplingUMesh("",3) ; src.setCoords(coords)
172 src.allocateCells(2) ; src.insertNextCell(NORM_TETRA4,[0,1,2,5]) ; src.insertNextCell(NORM_TETRA4,[3,4,0,6]) ; src.finishInsertingCells()
173 trg=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.7,-0.1,0.2,0.7,2.,2.3]) ; arr2=DataArrayDouble([-0.7,0.2,0.6,1.2,2.])
174 trg.setCoordsAt(0,arr) ; trg.setCoordsAt(1,arr) ; trg.setCoordsAt(2,arr2)
175 src.checkCoherency2(1e-10)
177 fieldSrc=MEDCouplingFieldDouble(ON_CELLS,NO_TIME) ; fieldSrc.setMesh(src) ; arrSrc=DataArrayDouble([10.,30.])
178 fieldSrc.setNature(Integral) ; fieldSrc.setArray(arrSrc)
179 rem=MEDCouplingRemapper()
180 rem.prepare(src,trg,"P0P0")
181 trgField=rem.transferField(fieldSrc,-7.)
182 expected3=[-7.,-7.,2.925,0.015,-7.,-7.,0.9392,8.595,2.265,-7.,-7.,1.1008,1.1192,-7.,-7.,-7.,0.6392,1.6408,0.2808,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,0.81,-7.,-7.,-7.,0.1208,11.55,0.96,-7.,-7.,1.1752,0.6592,-7.,-7.,-7.,0.8512,1.7744,0.0192,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,1.92,-7.,-7.,-7.,0.12578571428571422,0.007314285714285673,-7.,-7.,-7.,0.3189253968253971,0.1879746031746033,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.,-7.]
183 self.assertEqual(100,trgField.getArray().getNumberOfTuples())
184 self.assertEqual(100,len(expected3))
185 for i,val in enumerate(expected3):
186 self.assertAlmostEqual(expected3[i],trgField.getArray().getIJ(i,0),12);
190 def testPrepareCU(self):
192 coords=DataArrayDouble([0.,0.5,0.7])
193 trg=MEDCouplingUMesh("",1) ; trg.setCoords(coords)
194 trg.allocateCells(2) ; trg.insertNextCell(NORM_SEG2,[0,1]) ; trg.insertNextCell(NORM_SEG2,[1,2]) ; trg.finishInsertingCells()
195 src=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.7,-0.1,0.2,0.7,2.,2.3])
196 src.setCoordsAt(0,arr)
197 fieldSrc=MEDCouplingFieldDouble(ON_CELLS,NO_TIME) ; fieldSrc.setMesh(src) ; arrTrg=DataArrayDouble([10.,30.,40.,70.,80.])
198 fieldSrc.setNature(Integral) ; fieldSrc.setArray(arrTrg)
199 rem=MEDCouplingRemapper()
200 rem.prepare(src,trg,"P0P0")
201 trgField=rem.transferField(fieldSrc,-7.)
203 self.assertEqual(2.,trgField.getArray().getNumberOfTuples())
204 self.assertEqual(2,len(expected1))
205 for i,val in enumerate(expected1):
206 self.assertAlmostEqual(expected1[i],trgField.getArray().getIJ(i,0),12);
209 coords=DataArrayDouble([0.,0.,0.,1.,1.,1.,1.,0.,0.5,-0.2],5,2)
210 trg=MEDCouplingUMesh("",2) ; trg.setCoords(coords)
211 trg.allocateCells(2) ; trg.insertNextCell(NORM_TRI3,[0,1,2]) ; trg.insertNextCell(NORM_TRI3,[3,4,0]) ; trg.finishInsertingCells()
212 src=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.7,-0.1,0.2,0.7,2.,2.3])
213 src.setCoordsAt(0,arr) ; src.setCoordsAt(1,arr)
214 fieldSrc=MEDCouplingFieldDouble(ON_CELLS,NO_TIME) ; fieldSrc.setMesh(src) ; arrSrc=DataArrayDouble([10.,30.,40.,70.,80.,110.,130.,140.,170.,180.,210.,230.,240.,270.,280.,310.,330.,340.,370.,380.,410.,430.,440.,470.,480.])
215 fieldSrc.setNature(Integral) ; fieldSrc.setArray(arrSrc)
216 rem=MEDCouplingRemapper()
217 rem.prepare(src,trg,"P0P0")
218 trgField=rem.transferField(fieldSrc,-7.)
219 expected2=[441.3050624589086,68.69529914529915]
220 self.assertEqual(2,trgField.getArray().getNumberOfTuples())
221 self.assertEqual(2,len(expected2))
222 for i,val in enumerate(expected2):
223 self.assertAlmostEqual(expected2[i],trgField.getArray().getIJ(i,0),12);
226 coords=DataArrayDouble([0.,0.,0.,0.,1.,0.,1.,1.,0.,1.,0.,0.,0.5,-0.2,0.,0.1,0.8,1.,0.5,0.,1.],7,3)
227 trg=MEDCouplingUMesh("",3) ; trg.setCoords(coords)
228 trg.allocateCells(2) ; trg.insertNextCell(NORM_TETRA4,[0,1,2,5]) ; trg.insertNextCell(NORM_TETRA4,[3,4,0,6]) ; trg.finishInsertingCells()
229 src=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.7,-0.1,0.2,0.7,2.,2.3]) ; arr2=DataArrayDouble([-0.7,0.2,0.6,1.2,2.])
230 src.setCoordsAt(0,arr) ; src.setCoordsAt(1,arr) ; src.setCoordsAt(2,arr2)
231 trg.checkCoherency2(1e-10)
233 fieldSrc=MEDCouplingFieldDouble(ON_CELLS,NO_TIME) ; fieldSrc.setMesh(src) ; arrSrc=DataArrayDouble(100) ; arrSrc.iota(7.7)
234 fieldSrc.setNature(Integral) ; fieldSrc.setArray(arrSrc)
235 rem=MEDCouplingRemapper()
236 rem.prepare(src,trg,"P0P0")
237 trgField=rem.transferField(fieldSrc,-7.)
238 expected3=[39.635196634558845,12.13422356758468]
239 self.assertEqual(2,trgField.getArray().getNumberOfTuples())
240 self.assertEqual(2,len(expected3))
241 for i,val in enumerate(expected3):
242 self.assertAlmostEqual(expected3[i],trgField.getArray().getIJ(i,0),12);
246 def testPrepareCC(self):
248 src=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.7,-0.1,0.2,0.7,2.,2.3])
249 src.setCoordsAt(0,arr)
250 trg=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.9,-0.1,0.15])
251 trg.setCoordsAt(0,arr)
252 fieldSrc=MEDCouplingFieldDouble(ON_CELLS,NO_TIME) ; fieldSrc.setMesh(src) ; arrTrg=DataArrayDouble([10.,30.,40.,70.,80.])
253 fieldSrc.setNature(Integral) ; fieldSrc.setArray(arrTrg)
254 rem=MEDCouplingRemapper()
255 rem.prepare(src,trg,"P0P0")
256 trgField=rem.transferField(fieldSrc,-7.)
258 self.assertEqual(2.,trgField.getArray().getNumberOfTuples())
259 self.assertEqual(2,len(expected1))
260 for i,val in enumerate(expected1):
261 self.assertAlmostEqual(expected1[i],trgField.getArray().getIJ(i,0),12);
264 src=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.7,-0.1,0.2,0.7,2.,2.3])
265 src.setCoordsAt(0,arr) ; src.setCoordsAt(1,arr)
266 trg=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.9,-0.1,0.15])
267 trg.setCoordsAt(0,arr) ; trg.setCoordsAt(1,arr)
268 fieldSrc=MEDCouplingFieldDouble(ON_CELLS,NO_TIME) ; fieldSrc.setMesh(src) ; arrSrc=DataArrayDouble([10.,30.,40.,70.,80.,110.,130.,140.,170.,180.,210.,230.,240.,270.,280.,310.,330.,340.,370.,380.,410.,430.,440.,470.,480.])
269 fieldSrc.setNature(Integral) ; fieldSrc.setArray(arrSrc)
270 rem=MEDCouplingRemapper()
271 rem.prepare(src,trg,"P0P0")
272 trgField=rem.transferField(fieldSrc,-7.)
273 expected2=[10.,25.,91.66666666666666,90.27777777777777]
274 self.assertEqual(4,trgField.getArray().getNumberOfTuples())
275 self.assertEqual(4,len(expected2))
276 for i,val in enumerate(expected2):
277 self.assertAlmostEqual(expected2[i],trgField.getArray().getIJ(i,0),12);
280 src=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.7,-0.1,0.2,0.7,2.,2.3])
281 src.setCoordsAt(0,arr) ; src.setCoordsAt(1,arr) ; src.setCoordsAt(2,arr)
282 trg=MEDCouplingCMesh() ; arr=DataArrayDouble([-0.9,-0.1,0.15])
283 trg.setCoordsAt(0,arr) ; trg.setCoordsAt(1,arr) ; trg.setCoordsAt(2,arr)
284 fieldSrc=MEDCouplingFieldDouble(ON_CELLS,NO_TIME) ; fieldSrc.setMesh(src) ; arrSrc=DataArrayDouble(125) ; arrSrc.iota(7.7)
285 fieldSrc.setNature(Integral) ; fieldSrc.setArray(arrSrc) ; fieldSrc.checkCoherency()
286 rem=MEDCouplingRemapper()
287 rem.prepare(src,trg,"P0P0")
288 trgField=rem.transferField(fieldSrc,-7.)
289 expected3=[7.7, 7.249999999999999, 10.583333333333332, 9.513888888888886, 27.25, 23.40277777777777, 26.180555555555546, 22.39583333333333]
290 self.assertEqual(8,trgField.getArray().getNumberOfTuples())
291 self.assertEqual(8,len(expected3))
292 for i,val in enumerate(expected3):
293 self.assertAlmostEqual(expected3[i],trgField.getArray().getIJ(i,0),12);
297 # Bug when source mesh is not homogeneously oriented in source mesh
298 def testNonRegressionNonHomegenousOrriented3DCells(self):
299 csrc=DataArrayDouble([-0.15240000188350677,0,0,-0.1086929515004158,0,0,-0.15240000188350677,0.018142856657505035,0,-0.13054648041725159,0.0090714283287525177,0.019050000235438347,-0.13054648041725159,0.0090714283287525177,0],5,3)
300 src1=MEDCouplingUMesh("src",3) ; src1.allocateCells(0) ; src1.insertNextCell(NORM_TETRA4,[0,1,4,3]) ; src1.insertNextCell(NORM_TETRA4,[2,0,4,3])
301 src2=MEDCouplingUMesh("src",3) ; src2.allocateCells(0) ; src2.insertNextCell(NORM_TETRA4,[0,4,1,3]) ; src2.insertNextCell(NORM_TETRA4,[2,0,4,3])
302 src1.setCoords(csrc) ; src2.setCoords(csrc)
303 ctrg=DataArrayDouble([-0.15240000188350677,-0.038100000470876694,0,0.32379999756813049,-0.038100000470876694,0,-0.15240000188350677,0.076200000941753387,0,0.32379999756813049,0.076200000941753387,0,-0.15240000188350677,-0.038100000470876694,0.076200000941753387,0.32379999756813049,-0.038100000470876694,0.076200000941753387,-0.15240000188350677,0.076200000941753387,0.076200000941753387,0.32379999756813049,0.076200000941753387,0.076200000941753387],8,3)
304 trg=MEDCouplingUMesh("trg",3) ; trg.allocateCells(0) ; trg.insertNextCell(NORM_HEXA8,[0,1,3,2,4,5,7,6])
306 rem1=MEDCouplingRemapper() ; rem1.setSplittingPolicy(PLANAR_FACE_5) ; rem1.prepare(src1,trg,"P0P0")
307 rem2=MEDCouplingRemapper() ; rem2.setSplittingPolicy(PLANAR_FACE_5) ; rem2.prepare(src1,trg,"P0P0")
308 mat1=rem1.getCrudeMatrix() ; mat2=rem2.getCrudeMatrix()
309 self.assertEqual(1,len(mat1)) ; self.assertEqual(1,len(mat2))
310 self.assertEqual(mat1[0].keys(),mat2[0].keys()) ; self.assertEqual([0,1],mat1[0].keys())
311 self.assertAlmostEqual(1.25884108122e-06,mat1[0][0],16) ; self.assertAlmostEqual(1.25884108122e-06,mat2[0][0],16)
312 self.assertAlmostEqual(1.25884086663e-06,mat1[0][1],16) ; self.assertAlmostEqual(1.25884086663e-06,mat2[0][1],16)
314 d=DataArrayDouble([13.45,27.67],2,1)
315 f1=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f1.setMesh(src1) ; f1.setArray(d) ; f1.setNature(RevIntegral)
316 f2=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f2.setMesh(src2) ; f2.setArray(d) ; f2.setNature(RevIntegral)
317 f11=rem1.transferField(f1,1e300) ; f22=rem2.transferField(f2,1e300)
318 expected1=DataArrayDouble([0.012480539537637884])
319 self.assertTrue(f11.getArray().isEqual(expected1,1e-15))
320 self.assertTrue(f22.getArray().isEqual(expected1,1e-15))
322 f1.setNature(Integral) ; f2.setNature(Integral)
323 f11=rem1.transferField(f1,1e300) ; f22=rem2.transferField(f2,1e300)
325 expected2=DataArrayDouble([41.12])
326 self.assertTrue(f11.getArray().isEqual(expected2,1e-13))
327 self.assertTrue(f22.getArray().isEqual(expected2,1e-13))
330 def testCellToNodeReverse3D(self):
331 c=DataArrayDouble([0.,1.,2.5])
332 cc=MEDCouplingCMesh()
334 um=cc.buildUnstructured()
335 f=um.getMeasureField(ON_CELLS)
337 n2o=um.simplexize(PLANAR_FACE_5)
338 f.setArray(f.getArray()[n2o])
340 f.setNature(ConservativeVolumic)
342 f.setName("toto") ; f.setDescription("aDescription")
343 p=MEDCouplingRemapper()
344 p.setP1P0BaryMethod(True)
345 p.prepare(um,um,"P1P0")
346 fNode=p.reverseTransferField(f,1e300)
347 self.assertEqual("toto",fNode.getName())
348 self.assertEqual("aDescription",fNode.getDescription())
349 a,b,c=fNode.getTime()
350 self.assertAlmostEqual(5.6,a,14)
351 self.assertEqual(7,b) ; self.assertEqual(8,c)
353 integExpected=34.328125
354 self.assertAlmostEqual(fNode.integral(False)[0],integExpected,14)
355 self.assertAlmostEqual(f.integral(False)[0],integExpected,14)
358 def build2DSourceMesh_1(self):
359 sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
360 sourceConn=[0,3,1,0,2,3]
361 sourceMesh=MEDCouplingUMesh.New("my name of mesh 2D",2)
362 sourceMesh.allocateCells(2);
363 sourceMesh.insertNextCell(NORM_TRI3,3,sourceConn[0:3]);
364 sourceMesh.insertNextCell(NORM_TRI3,3,sourceConn[3:6]);
365 sourceMesh.finishInsertingCells();
366 myCoords=DataArrayDouble.New();
367 myCoords.setValues(sourceCoords,4,2);
368 sourceMesh.setCoords(myCoords);
371 def build2DTargetMesh_1(self):
372 targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ]
373 targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
374 targetMesh=MEDCouplingUMesh.New();
375 targetMesh.setMeshDimension(2);
376 targetMesh.allocateCells(5);
377 targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]);
378 targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]);
379 targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]);
380 targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]);
381 targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]);
382 targetMesh.finishInsertingCells();
383 myCoords=DataArrayDouble.New();
384 myCoords.setValues(targetCoords,9,2);
385 targetMesh.setCoords(myCoords);
388 def build2DTargetMesh_3(self):
389 targetCoords=[-0.6,-0.4, -0.1,-0.4, 1.1,-0.4, 2.1,-0.4, -0.6,0.1, -0.1,0.1, 1.1,0.1, 2.1,0.1, -0.6,1.1, -0.1,1.1]
390 targetConn=[0,4,5,1, 1,5,6,2, 2,6,7,3, 4,8,9,5]
391 targetMesh=MEDCouplingUMesh.New();
392 targetMesh.setMeshDimension(2);
393 targetMesh.allocateCells(4);
395 targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[4*i:4*(i+1)])
397 targetMesh.finishInsertingCells();
398 myCoords=DataArrayDouble.New();
399 myCoords.setValues(targetCoords,10,2);
400 targetMesh.setCoords(myCoords);