1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDCouplingBasicsTest.hxx"
22 #include "MEDCouplingUMesh.hxx"
23 #include "MEDCouplingExtrudedMesh.hxx"
24 #include "MEDCouplingFieldDouble.hxx"
25 #include "MEDCouplingMemArray.hxx"
26 #include "MEDCouplingMultiFields.hxx"
28 #include "MEDCouplingBasicsTestData1.hxx"
30 #include "Interpolation2D.txx"
31 #include "Interpolation3D2D.txx"
32 #include "Interpolation2D1D.txx"
33 #include "MEDCouplingNormalizedUnstructuredMesh.txx"
34 #include "MEDCouplingNormalizedCartesianMesh.txx"
36 using namespace ParaMEDMEM;
38 typedef std::vector<std::map<int,double> > IntersectionMatrix;
40 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSourceMesh_2()
42 double sourceCoords[84]={100.0, 100.0, 0.0, 100.0, 100.0, 100.0, 100.0, 0.0, 100.0, 100.0, 0.0, 0.0, 0.0, 100.0, 0.0, 0.0, 100.0, 100.0, 0.0,
43 0.0, 100.0, 0.0, 0.0, 0.0, 100.0, 100.0, 200.0, 100.0, 0.0, 200.0, 0.0, 100.0, 200.0, 0.0, 0.0, 200.0, 100.0, 200.0,
44 0.0, 100.0, 200.0, 100.0, 0.0, 200.0, 0.0, 0.0, 200.0, 100.0, 100.0, 200.0, 200.0, 0.0, 200.0, 200.0, 200.0, 100.0,
45 0.0, 200.0, 100.00000000833332, 100.00000000833332, 200.0, 0.0, 100.0, 200.0, 0.0, 0.0, 200.0, 100.0, 200.0, 200.0,
46 0.0, 200.0, 200.0, 200.0, 0.0, 200.0, 200.0, 100.0, 200.0, 200.0, 200.0, 149.999999970343, 149.9999999874621, 49.999999881628682};
49 int sourceConn[212]={25, 27, 13, 19, 18, 3, 20, 21, 5, 10, 17, 1, 1, 3, 0, 7, 18, 1, 0, 27, 12, 27, 13, 24, 25, 19, 16, 26, 1, 2, 6, 8, 15, 13,
50 12, 5, 24, 13, 25, 27, 10, 11, 9, 6, 19, 8, 23, 1, 22, 8, 23, 19, 16, 13, 17, 1, 6, 9, 10, 8, 13, 17, 5, 15, 5, 4, 1, 12, 18,
51 0, 24, 27, 19, 20, 18, 1, 7, 6, 5, 1, 4, 12, 15, 14, 25, 27, 19, 18, 1, 19, 16, 13, 20, 19, 23, 1, 27, 12, 1, 0, 6, 5, 1, 10,
52 4, 5, 1, 7, 12, 27, 1, 13, 5, 15, 4, 12, 19, 16, 26, 22, 13, 5, 17, 1, 1, 3, 7, 2, 13, 5, 1, 12, 18, 1, 3, 0, 8, 23, 2, 9, 3,
53 1, 18, 20, 1, 27, 19, 13, 24, 25, 18, 27, 25, 16, 19, 13, 7, 1, 2, 6, 3, 1, 20, 2, 8, 16, 17, 1, 7, 4, 0, 1, 18, 19, 1, 27,
54 27, 12, 0, 24, 9, 6, 2, 8, 1, 4, 0, 12, 19, 16, 22, 8, 8, 2, 23, 1, 1, 16, 19, 8, 20, 2, 1, 23, 10, 1, 6, 8, 10, 8, 17, 1};
56 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
57 sourceMesh->setMeshDimension(3);
58 sourceMesh->allocateCells(53);
60 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+4*i);
61 sourceMesh->finishInsertingCells();
62 DataArrayDouble *myCoords=DataArrayDouble::New();
63 myCoords->alloc(28,3);
64 std::copy(sourceCoords,sourceCoords+84,myCoords->getPointer());
65 sourceMesh->setCoords(myCoords);
70 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_2()
72 double targetCoords[24]={200.0, 200.0, 0.0, 200.0, 200.0, 200.0, 200.0, 0.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 0.0, 200.0, 200.0, 0.0, 0.0, 0.0, 0.0, 0.0, 200.0};
73 int targetConn[20]={5, 6, 3, 0, 1, 3, 0, 5, 3, 6, 5, 7, 6, 4, 0, 5, 6, 3, 0, 2};
74 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
75 targetMesh->setMeshDimension(3);
76 targetMesh->allocateCells(5);
78 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn+4*i);
79 targetMesh->finishInsertingCells();
80 DataArrayDouble *myCoords=DataArrayDouble::New();
82 std::copy(targetCoords,targetCoords+24,myCoords->getPointer());
83 targetMesh->setCoords(myCoords);
88 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_1()
90 double targetCoords[36]={
91 25.,25.,0., 25.,25.,50., 25.,25.,200., 75.,25.,0., 75.,25.,50., 75.,25.,200.,
92 25.,125.,0., 25.,125.,50., 25.,125.,200., 125.,125.,0., 125.,125.,50., 125.,125.,200.
94 int targetConn[16]={0,1, 1,2, 3,4, 4,5, 6,7, 7,8, 9,10, 10,11};
96 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("my name of mesh 1D",1);
97 targetMesh->allocateCells(8);
99 targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
100 targetMesh->finishInsertingCells();
101 DataArrayDouble *myCoords=DataArrayDouble::New();
102 myCoords->alloc(12,3);
103 std::copy(targetCoords,targetCoords+36,myCoords->getPointer());
104 targetMesh->setCoords(myCoords);
109 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DSourceMesh_1()
111 double sourceCoords[8]={-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7};
112 int sourceConn[6]={0,3,1,0,2,3};
113 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New("my name of mesh 2D",2);
114 sourceMesh->allocateCells(2);
115 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
116 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
117 sourceMesh->finishInsertingCells();
118 DataArrayDouble *myCoords=DataArrayDouble::New();
119 myCoords->alloc(4,2);
120 std::copy(sourceCoords,sourceCoords+8,myCoords->getPointer());
121 sourceMesh->setCoords(myCoords);
126 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_1()
128 double targetCoords[18]={-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 };
129 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
130 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
131 targetMesh->setMeshDimension(2);
132 targetMesh->allocateCells(5);
133 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
134 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
135 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
136 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
137 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
138 targetMesh->finishInsertingCells();
139 DataArrayDouble *myCoords=DataArrayDouble::New();
140 myCoords->alloc(9,2);
141 std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
142 targetMesh->setCoords(myCoords);
147 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshPerm_1()
149 double targetCoords[18]={-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 };
150 int targetConn[18]={0,3,4,1, 1,2,4, 4,5,2, 6,7,4,3, 7,8,5,4};
151 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
152 targetMesh->setMeshDimension(2);
153 targetMesh->allocateCells(5);
154 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
155 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
156 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
157 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
158 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
159 targetMesh->finishInsertingCells();
160 DataArrayDouble *myCoords=DataArrayDouble::New();
161 myCoords->alloc(9,2);
162 std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
163 targetMesh->setCoords(myCoords);
168 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_2()
170 double targetCoords[18]={-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 };
171 int targetConn[24]={0,3,4, 0,4,1, 1,4,2, 4,5,2, 3,6,4, 6,7,4, 4,7,5, 7,8,5 };
172 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
173 targetMesh->setMeshDimension(2);
174 targetMesh->allocateCells(8);
175 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
176 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
177 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+6);
178 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+9);
179 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+12);
180 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+15);
181 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18);
182 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21);
183 targetMesh->finishInsertingCells();
184 DataArrayDouble *myCoords=DataArrayDouble::New();
185 myCoords->alloc(9,2);
186 std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
187 targetMesh->setCoords(myCoords);
192 MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU1DMesh_U()
194 double coords[4]={ 0.0, 0.3, 0.75, 1.0 };
195 int conn[2*3]={ 0,1, 1,2, 2,3 };
196 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
197 mesh->setMeshDimension(1);
198 mesh->allocateCells(3);
199 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
200 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
201 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4);
202 mesh->finishInsertingCells();
203 DataArrayDouble *myCoords=DataArrayDouble::New();
204 myCoords->alloc(4,1);
205 std::copy(coords,coords+4,myCoords->getPointer());
206 mesh->setCoords(myCoords);
210 MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU2DMesh_U()
212 double coords[18]={0.0,0.0, 0.5,0.0, 1.0,0.0, 0.0,0.5, 0.5,0.5, 1.0,0.5, 0.0,1.0, 0.5,1.0, 1.0,1.0 };
213 int conn[18]={0,1,4,3, 3,4,7,6, 4,5,8,7, 1,5,4, 1,2,5 };
214 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
215 mesh->setMeshDimension(2);
216 mesh->allocateCells(5);
217 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
218 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+4);
219 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+8);
220 mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+12);
221 mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+15);
222 mesh->finishInsertingCells();
223 DataArrayDouble *myCoords=DataArrayDouble::New();
224 myCoords->alloc(9,2);
225 std::copy(coords,coords+18,myCoords->getPointer());
226 mesh->setCoords(myCoords);
230 MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU3DMesh_U()
234 // 0.0,1.0,0.0 ,0.0,0.3,0.0 ,0.0,0.3,0.3 ,0.3,0.0,0.0 ,0.3,0.3,1.0 ,1.0,0.0,1.0 ,1.0,0.0,0.3 ,0.3,0.0,0.3 ,0.3,1.0,0.3 ,0.0,0.3,1.0 ,0.3,0.0,1.0 ,0.3,0.3,0.3 ,1.0,0.3,1.0 ,1.0,0.0,0.0 ,0.0,0.0,0.0 ,1.0,0.3,0.3 ,0.3,1.0,0.0 ,1.0,1.0,0.3 ,1.0,1.0,1.0 ,0.0,1.0,1.0 ,0.3,0.3,0.0 ,0.0,1.0,0.3 ,0.0,0.0,1.0 ,0.3,1.0,1.0 ,1.0,0.3,0.0 ,0.0,0.0,0.3 ,1.0,1.0,0.0
235 0.0,0.0,0.0, 0.3,0.0,0.0, 1.0,0.0,0.0, 0.0,0.3,0.0, 0.3,0.3,0.0, 1.0,0.3,0.0, 0.0,1.0,0.0, 0.3,1.0,0.0, 1.0,1.0,0.0, 0.0,0.0,0.3, 0.3,0.0,0.3, 1.0,0.0,0.3, 0.0,0.3,0.3, 0.3,0.3,0.3, 1.0,0.3,0.3, 0.0,1.0,0.3, 0.3,1.0,0.3, 1.0,1.0,0.3, 0.0,0.0,1.0, 0.3,0.0,1.0, 1.0,0.0,1.0, 0.0,0.3,1.0, 0.3,0.3,1.0, 1.0,0.3,1.0, 0.0,1.0,1.0, 0.3,1.0,1.0, 1.0,1.0,1.0,
239 // 11,15,12,4,8,17,18,23,3,13,6,7,20,24,15,11,14,3,7,25,1,20,11,2,1,20,11,2,0,16,8,21,20,24,15,11,16,26,17,8,25,7,10,22,2,11,4,9,2,11,4,9,21,8,23,19,7,6,5,10,11,15,12,4
240 0,3,4,1,9,12,13,10, 1,4,5,2,10,13,14,11, 3,6,7,4,12,15,16,13, 4,7,8,5,13,16,17,14, 9,12,13,10,18,21,22,19, 10,13,14,11,19,22,23,20, 12,15,16,13,21,24,25,22, 13,16,17,14,22,25,26,23
242 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
243 mesh->setMeshDimension(3);
244 mesh->allocateCells(8);
246 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i);
247 mesh->finishInsertingCells();
248 DataArrayDouble *myCoords=DataArrayDouble::New();
249 myCoords->alloc(27,3);
250 std::copy(coords,coords+27*3,myCoords->getPointer());
251 mesh->setCoords(myCoords);
256 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfSourceMesh_1()
258 double sourceCoords[12]={-0.3,-0.3,0.5, 0.7,-0.3,1.5, -0.3,0.7,0.5, 0.7,0.7,1.5};
259 int sourceConn[6]={0,3,1,0,2,3};
260 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
261 sourceMesh->setMeshDimension(2);
262 sourceMesh->allocateCells(2);
263 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
264 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
265 sourceMesh->finishInsertingCells();
266 DataArrayDouble *myCoords=DataArrayDouble::New();
267 myCoords->alloc(4,3);
268 std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer());
269 sourceMesh->setCoords(myCoords);
274 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfSourceMesh_2()
276 double sourceCoords[12]={-0.3,-0.3,0., 0.7,-0.3,0., -0.3,0.7,0., 0.7,0.7,0.};
277 int sourceConn[6]={0,3,1,0,2,3};
278 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
279 sourceMesh->setMeshDimension(2);
280 sourceMesh->allocateCells(2);
281 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
282 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
283 sourceMesh->finishInsertingCells();
284 DataArrayDouble *myCoords=DataArrayDouble::New();
285 myCoords->alloc(4,3);
286 std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer());
287 sourceMesh->setCoords(myCoords);
292 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMesh_1()
294 double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
295 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
296 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
297 targetMesh->setMeshDimension(2);
298 targetMesh->allocateCells(5);
299 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
300 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
301 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
302 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
303 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
304 targetMesh->finishInsertingCells();
305 DataArrayDouble *myCoords=DataArrayDouble::New();
306 myCoords->alloc(9,3);
307 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
308 targetMesh->setCoords(myCoords);
314 * Idem build3DSurfTargetMesh_1 except that cell id 2 is not correctly numbered.
316 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMeshPerm_1()
318 double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
319 int targetConn[18]={0,3,4,1, 1,4,2, 4,2,5, 6,7,4,3, 7,8,5,4};
320 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
321 targetMesh->setMeshDimension(2);
322 targetMesh->allocateCells(5);
323 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
324 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
325 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
326 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
327 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
328 targetMesh->finishInsertingCells();
329 DataArrayDouble *myCoords=DataArrayDouble::New();
330 myCoords->alloc(9,3);
331 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
332 targetMesh->setCoords(myCoords);
337 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMesh_2()
339 double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
340 int targetConn[24]={0,3,4, 0,4,1, 1,4,2, 4,5,2, 3,6,4, 6,7,4, 4,7,5, 7,8,5 };
341 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
342 targetMesh->setMeshDimension(2);
343 targetMesh->allocateCells(8);
344 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
345 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
346 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+6);
347 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+9);
348 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+12);
349 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+15);
350 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18);
351 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21);
352 targetMesh->finishInsertingCells();
353 DataArrayDouble *myCoords=DataArrayDouble::New();
354 myCoords->alloc(9,3);
355 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
356 targetMesh->setCoords(myCoords);
361 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSourceMesh_1()
363 double sourceCoords[27]={ 0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 200.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0,
364 200.0, 0.0, 0.0, 200.0, 200.0, 200.0, 200.0, 200.0, 0.0, 100.0, 100.0, 100.0 };
365 int sourceConn[48]={8,1,7,3, 6,0,8,2, 7,4,5,8, 6,8,4,7, 6,8,0,4, 6,8,7,3, 8,1,3,0, 4,1,5,8, 1,7,5,8, 0,3,8,2, 8,1,0,4, 3,6,8,2};
366 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
367 sourceMesh->setMeshDimension(3);
368 sourceMesh->allocateCells(12);
369 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn);
370 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+4);
371 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+8);
372 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+12);
373 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+16);
374 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+20);
375 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+24);
376 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+28);
377 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+32);
378 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+36);
379 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+40);
380 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+44);
381 sourceMesh->finishInsertingCells();
382 DataArrayDouble *myCoords=DataArrayDouble::New();
383 myCoords->alloc(9,3);
384 std::copy(sourceCoords,sourceCoords+27,myCoords->getPointer());
385 sourceMesh->setCoords(myCoords);
390 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_1()
392 double targetCoords[81]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. ,
393 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. ,
394 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200. };
395 int targetConn[64]={0,1,4,3,9,10,13,12, 1,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16,
396 9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,23,26,25};
397 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
398 targetMesh->setMeshDimension(3);
399 targetMesh->allocateCells(12);
401 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
402 targetMesh->finishInsertingCells();
403 DataArrayDouble *myCoords=DataArrayDouble::New();
404 myCoords->alloc(27,3);
405 std::copy(targetCoords,targetCoords+81,myCoords->getPointer());
406 targetMesh->setCoords(myCoords);
411 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshMergeNode_1()
413 double targetCoords[36]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,-0.3, 0.2,-0.3, 0.2,-0.3, 0.2,0.2, 0.2,0.2, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, 0.2,0.7 };
414 int targetConn[18]={0,9,7,5, 4,6,2, 10,11,8, 9,14,15,7, 17,16,13,6};
415 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
416 targetMesh->setMeshDimension(2);
417 targetMesh->allocateCells(5);
418 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
419 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
420 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
421 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
422 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
423 targetMesh->finishInsertingCells();
424 DataArrayDouble *myCoords=DataArrayDouble::New();
425 myCoords->alloc(18,2);
426 std::copy(targetCoords,targetCoords+36,myCoords->getPointer());
427 targetMesh->setCoords(myCoords);
432 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMeshMergeNode_1()
434 double targetCoords[93]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. ,
435 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. ,
436 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200., 50.,0.,0., 50.,0.,0., 50.,0.,0., 200., 50., 200.};
437 int targetConn[64]={0,29,4,3,9,10,13,12, 28,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16,
438 9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,30,26,25};
439 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
440 targetMesh->setMeshDimension(3);
441 targetMesh->allocateCells(12);
443 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
444 targetMesh->finishInsertingCells();
445 DataArrayDouble *myCoords=DataArrayDouble::New();
446 myCoords->alloc(31,3);
447 std::copy(targetCoords,targetCoords+93,myCoords->getPointer());
448 targetMesh->setCoords(myCoords);
453 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DExtrudedUMesh_1(MEDCouplingUMesh *&mesh2D)
456 0.,0.,0., 1.,1.,0., 1.,1.25,0., 1.,0.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0.,
457 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0.,
458 0.,0.,1., 1.,1.,1., 1.,1.25,1., 1.,0.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1.,
459 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1.,
460 0.,0.,2., 1.,1.,2., 1.,1.25,2., 1.,0.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2.,
461 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2.,
462 0.,0.,3., 1.,1.,3., 1.,1.25,3., 1.,0.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3.,
463 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.};
467 0,11,1,3,15,26,16,18, 1,2,4,7,13,6,-1,1,16,21,6,-1,6,21,28,13,-1,13,7,22,28,-1,7,4,19,22,-1,4,2,17,19,-1,2,1,16,17,-1,16,21,28,22,19,17,
468 1,6,5,3,16,21,20,18, 13,10,9,6,28,25,24,21,
469 11,8,7,4,2,1,-1,11,26,16,1,-1,1,16,17,2,-1,2,17,19,4,-1,4,19,22,7,-1,7,8,23,22,-1,8,11,26,23,-1,26,16,17,19,22,23,
470 7,12,14,13,22,27,29,28,
472 15,26,16,18,30,41,31,33, 16,17,19,22,28,21,-1,16,31,36,21,-1,21,36,43,28,-1,28,22,37,43,-1,22,19,34,37,-1,19,17,32,34,-1,17,16,31,32,-1,31,36,43,37,34,32,
473 16,21,20,18,31,36,35,33, 28,25,24,21,43,40,39,36,
474 26,23,22,19,17,16,-1,26,41,31,16,-1,16,31,32,17,-1,17,32,34,19,-1,19,34,37,22,-1,22,23,38,37,-1,23,26,41,38,-1,41,31,32,34,37,38,
475 22,27,29,28,37,42,44,43,
477 30,41,31,33,45,56,46,48, 31,32,34,37,43,36,-1,31,46,51,36,-1,36,51,58,43,-1,43,37,52,58,-1,37,34,49,52,-1,34,32,47,49,-1,32,31,46,47,-1,46,51,58,52,49,47,
478 31,36,35,33,46,51,50,48, 43,40,39,36,58,55,54,51,
479 41,38,37,34,32,31,-1,41,56,46,31,-1,31,46,47,32,-1,32,47,49,34,-1,34,49,52,37,-1,37,38,53,52,-1,38,41,56,53,-1,56,46,47,49,52,53,
480 37,42,44,43,52,57,59,58
482 int conn2[28]={7,12,14,13, 11,8,7,4,2,1, 13,10,9,6, 1,6,5,3, 1,2,4,7,13,6, 0,11,1,3};
484 MEDCouplingUMesh *ret=MEDCouplingUMesh::New();
485 ret->setMeshDimension(3);
486 ret->allocateCells(18);
488 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn);
489 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+8);
490 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+51);
491 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+59);
492 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+67);
493 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+110);
495 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+118);
496 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+126);
497 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+169);
498 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+177);
499 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+185);
500 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+228);
502 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+236);
503 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+244);
504 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+287);
505 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+295);
506 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+303);
507 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+346);
509 ret->finishInsertingCells();
510 DataArrayDouble *myCoords=DataArrayDouble::New();
511 myCoords->alloc(60,3);
512 std::copy(coords,coords+180,myCoords->getPointer());
513 ret->setCoords(myCoords);
515 mesh2D=MEDCouplingUMesh::New();
516 mesh2D->setMeshDimension(2);
517 mesh2D->allocateCells(6);
518 mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2);
519 mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+4);
520 mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+10);
521 mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+14);
522 mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+18);
523 mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+24);
524 mesh2D->setCoords(myCoords);
529 void MEDCouplingBasicsTest::build3DExtrudedUMesh_2(MEDCouplingUMesh *&meshN, MEDCouplingUMesh *&meshTT, MEDCouplingUMesh *&meshTF)
531 const double coordsN[270]={
532 0, 0, 0, 0.10803000450134277, 0, 0, 0.21606000900268554, 0, 0, 0.28808000564575198, 0, 0, 0.36010002136230468, 0, 0, 0.43212001800537109, 0, 0, 0,
533 0.072020001411437995, 0, 0.10803000450134277, 0.072020001411437995, 0, 0.21606000900268554, 0.072020001411437995, 0, 0.28808000564575198, 0.072020001411437995,
534 0, 0.36010002136230468, 0.072020001411437995, 0, 0.43212001800537109, 0.072020001411437995, 0, 0, 0.10803000450134277, 0, 0.10803000450134277,
535 0.10803000450134277, 0, 0.21606000900268554, 0.10803000450134277, 0, 0.28808000564575198, 0.10803000450134277, 0, 0.36010002136230468, 0.10803000450134277, 0,
536 0.43212001800537109, 0.10803000450134277, 0, 0, 0.14404000282287599, 0, 0.10803000450134277, 0.14404000282287599, 0, 0.21606000900268554, 0.14404000282287599, 0,
537 0.28808000564575198, 0.14404000282287599, 0, 0.36010002136230468, 0.14404000282287599, 0, 0.43212001800537109, 0.14404000282287599, 0, 0, 0.21606000900268554, 0,
538 0.10803000450134277, 0.21606000900268554, 0, 0.21606000900268554, 0.21606000900268554, 0, 0.28808000564575198, 0.21606000900268554, 0, 0.36010002136230468,
539 0.21606000900268554, 0, 0.43212001800537109, 0.21606000900268554, 0, 0, 0, 2.1364999389648438, 0.10803000450134277, 0, 2.1364999389648438, 0.21606000900268554,
540 0, 2.1364999389648438, 0.28808000564575198, 0, 2.1364999389648438, 0.36010002136230468, 0, 2.1364999389648438, 0.43212001800537109, 0, 2.1364999389648438, 0,
541 0.072020001411437995, 2.1364999389648438, 0.10803000450134277, 0.072020001411437995, 2.1364999389648438, 0.21606000900268554, 0.072020001411437995,
542 2.1364999389648438, 0.28808000564575198, 0.072020001411437995, 2.1364999389648438, 0.36010002136230468, 0.072020001411437995, 2.1364999389648438,
543 0.43212001800537109, 0.072020001411437995, 2.1364999389648438, 0, 0.10803000450134277, 2.1364999389648438, 0.10803000450134277, 0.10803000450134277,
544 2.1364999389648438, 0.21606000900268554, 0.10803000450134277, 2.1364999389648438, 0.28808000564575198, 0.10803000450134277, 2.1364999389648438,
545 0.36010002136230468, 0.10803000450134277, 2.1364999389648438, 0.43212001800537109, 0.10803000450134277, 2.1364999389648438, 0, 0.14404000282287599,
546 2.1364999389648438, 0.10803000450134277, 0.14404000282287599, 2.1364999389648438, 0.21606000900268554, 0.14404000282287599, 2.1364999389648438,
547 0.28808000564575198, 0.14404000282287599, 2.1364999389648438, 0.36010002136230468, 0.14404000282287599, 2.1364999389648438, 0.43212001800537109,
548 0.14404000282287599, 2.1364999389648438, 0, 0.21606000900268554, 2.1364999389648438, 0.10803000450134277, 0.21606000900268554, 2.1364999389648438,
549 0.21606000900268554, 0.21606000900268554, 2.1364999389648438, 0.28808000564575198, 0.21606000900268554, 2.1364999389648438, 0.36010002136230468,
550 0.21606000900268554, 2.1364999389648438, 0.43212001800537109, 0.21606000900268554, 2.1364999389648438, 0, 0, 4.2729998779296876, 0.10803000450134277, 0,
551 4.2729998779296876, 0.21606000900268554, 0, 4.2729998779296876, 0.28808000564575198, 0, 4.2729998779296876, 0.36010002136230468, 0, 4.2729998779296876,
552 0.43212001800537109, 0, 4.2729998779296876, 0, 0.072020001411437995, 4.2729998779296876, 0.10803000450134277, 0.072020001411437995, 4.2729998779296876,
553 0.21606000900268554, 0.072020001411437995, 4.2729998779296876, 0.28808000564575198, 0.072020001411437995, 4.2729998779296876, 0.36010002136230468,
554 0.072020001411437995, 4.2729998779296876, 0.43212001800537109, 0.072020001411437995, 4.2729998779296876, 0, 0.10803000450134277, 4.2729998779296876,
555 0.10803000450134277, 0.10803000450134277, 4.2729998779296876, 0.21606000900268554, 0.10803000450134277, 4.2729998779296876, 0.28808000564575198,
556 0.10803000450134277, 4.2729998779296876, 0.36010002136230468, 0.10803000450134277, 4.2729998779296876, 0.43212001800537109, 0.10803000450134277,
557 4.2729998779296876, 0, 0.14404000282287599, 4.2729998779296876, 0.10803000450134277, 0.14404000282287599, 4.2729998779296876, 0.21606000900268554,
558 0.14404000282287599, 4.2729998779296876, 0.28808000564575198, 0.14404000282287599, 4.2729998779296876, 0.36010002136230468, 0.14404000282287599,
559 4.2729998779296876, 0.43212001800537109, 0.14404000282287599, 4.2729998779296876, 0, 0.21606000900268554, 4.2729998779296876, 0.10803000450134277,
560 0.21606000900268554, 4.2729998779296876, 0.21606000900268554, 0.21606000900268554, 4.2729998779296876, 0.28808000564575198, 0.21606000900268554,
561 4.2729998779296876, 0.36010002136230468, 0.21606000900268554, 4.2729998779296876, 0.43212001800537109, 0.21606000900268554, 4.2729998779296876};
562 const int connN[320]={
563 0, 1, 7, 6, 30, 31, 37, 36, 1, 2, 8, 7, 31, 32, 38, 37, 2, 3, 9, 8, 32, 33, 39, 38, 3, 4, 10, 9, 33, 34, 40, 39, 4, 5, 11, 10, 34, 35, 41, 40, 6,
564 7, 13, 12, 36, 37, 43, 42, 7, 8, 14, 13, 37, 38, 44, 43, 8, 9, 15, 14, 38, 39, 45, 44, 9, 10, 16, 15, 39, 40, 46, 45, 10, 11, 17, 16, 40, 41, 47,
565 46, 12, 13, 19, 18, 42, 43, 49, 48, 13, 14, 20, 19, 43, 44, 50, 49, 14, 15, 21, 20, 44, 45, 51, 50, 15, 16, 22, 21, 45, 46, 52, 51, 16, 17, 23,
566 22, 46, 47, 53, 52, 18, 19, 25, 24, 48, 49, 55, 54, 19, 20, 26, 25, 49, 50, 56, 55, 20, 21, 27, 26, 50, 51, 57, 56, 21, 22, 28, 27, 51, 52, 58,
567 57, 22, 23, 29, 28, 52, 53, 59, 58, 30, 31, 37, 36, 60, 61, 67, 66, 31, 32, 38, 37, 61, 62, 68, 67, 32, 33, 39, 38, 62, 63, 69, 68, 33, 34, 40,
568 39, 63, 64, 70, 69, 34, 35, 41, 40, 64, 65, 71, 70, 36, 37, 43, 42, 66, 67, 73, 72, 37, 38, 44, 43, 67, 68, 74, 73, 38, 39, 45, 44, 68, 69, 75,
569 74, 39, 40, 46, 45, 69, 70, 76, 75, 40, 41, 47, 46, 70, 71, 77, 76, 42, 43, 49, 48, 72, 73, 79, 78, 43, 44, 50, 49, 73, 74, 80, 79, 44, 45, 51,
570 50, 74, 75, 81, 80, 45, 46, 52, 51, 75, 76, 82, 81, 46, 47, 53, 52, 76, 77, 83, 82, 48, 49, 55, 54, 78, 79, 85, 84, 49, 50, 56, 55, 79, 80, 86,
571 85, 50, 51, 57, 56, 80, 81, 87, 86, 51, 52, 58, 57, 81, 82, 88, 87, 52, 53, 59, 58, 82, 83, 89, 88};
572 meshN=MEDCouplingUMesh::New();
573 meshN->setName("meshExtrudedN");
574 meshN->setMeshDimension(3);
575 meshN->allocateCells(40);
576 for(int i=0;i<40;i++)
577 meshN->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,connN+8*i);
578 meshN->finishInsertingCells();
579 DataArrayDouble *myCoords=DataArrayDouble::New();
580 myCoords->alloc(90,3);
581 std::copy(coordsN,coordsN+270,myCoords->getPointer());
582 meshN->setCoords(myCoords);
585 meshTT=MEDCouplingUMesh::New();
586 meshTT->setName("meshExtrudedTT");
587 meshTT->setMeshDimension(3);
588 meshTT->allocateCells(200);
589 for(int i=0;i<200;i++)
590 meshTT->insertNextCell(INTERP_KERNEL::NORM_POLYHED,connITT[i+1]-connITT[i],connTT+connITT[i]);
591 meshTT->finishInsertingCells();
592 myCoords=DataArrayDouble::New();
593 myCoords->alloc(1720,3);
594 std::copy(coordsTT,coordsTT+5160,myCoords->getPointer());
595 meshTT->setCoords(myCoords);
598 meshTF=MEDCouplingUMesh::New();
599 meshTF->setName("meshExtrudedTF");
600 meshTF->setMeshDimension(3);
601 meshTF->allocateCells(340);
602 for(int i=0;i<320;i++)
603 meshTF->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,connTFH8+8*i);
604 for(int i=0;i<20;i++)
605 meshTF->insertNextCell(INTERP_KERNEL::NORM_POLYHED,connTFPOLH_I[i+1]-connTFPOLH_I[i],connTFPOLH+connTFPOLH_I[i]);
606 meshTF->finishInsertingCells();
607 myCoords=DataArrayDouble::New();
608 myCoords->alloc(567,3);
609 std::copy(coordsTF,coordsTF+1701,myCoords->getPointer());
610 meshTF->setCoords(myCoords);
614 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshMerged_1()
616 double targetCoords[26]={
617 -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,
618 0.7,-0.3, 1.7,-0.3, 0.7,0.7, 1.7,0.7
621 0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4,
624 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
625 targetMesh->setName("merge");
626 targetMesh->setMeshDimension(2);
627 targetMesh->allocateCells(10);
628 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
629 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
630 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
631 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
632 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
633 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18);
634 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21);
635 targetMesh->finishInsertingCells();
636 DataArrayDouble *myCoords=DataArrayDouble::New();
637 myCoords->alloc(13,2);
638 std::copy(targetCoords,targetCoords+26,myCoords->getPointer());
639 targetMesh->setCoords(myCoords);
644 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveMesh(double dx, double dy)
651 double targetCoords[3*2]=
653 0.+dx,0.+dy, 1.+dx,0.+dy, 2.+dx,1.+dy
655 int targetConn[2*2]={1,2, 0,1};
657 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("2Dcurve 1D mesh",1);
658 targetMesh->allocateCells(2);
660 targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
661 targetMesh->finishInsertingCells();
662 DataArrayDouble *myCoords=DataArrayDouble::New();
663 myCoords->alloc(3,2);
664 std::copy(targetCoords,targetCoords+3*2,myCoords->getPointer());
665 targetMesh->setCoords(myCoords);
670 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMesh(double dx)
672 double targetCoords[4]=
674 0.+dx, 1.+dx, 3.+dx, 4.+dx
676 int targetConn[2*3]={1,2, 0,1, 2,3};
678 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("1D mesh",1);
679 targetMesh->allocateCells(3);
681 targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
682 targetMesh->finishInsertingCells();
683 DataArrayDouble *myCoords=DataArrayDouble::New();
684 myCoords->alloc(4,1);
685 std::copy(targetCoords,targetCoords+4,myCoords->getPointer());
686 targetMesh->setCoords(myCoords);
691 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DSourceMesh_2()
693 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DSourceMesh",1);
694 ret->allocateCells(4);
695 int conn[8]={0,1,2,3,1,2,3,4};
697 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
698 ret->finishInsertingCells();
699 double coords[5]={0.3,0.7,0.9,1.0,1.12};
700 DataArrayDouble *myCoords=DataArrayDouble::New();
701 myCoords->alloc(5,1);
702 std::copy(coords,coords+5,myCoords->getPointer());
703 ret->setCoords(myCoords);
708 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_2()
710 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DTargetMesh",1);
711 ret->allocateCells(2);
712 int conn[4]={1,2,0,1};
714 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
715 ret->finishInsertingCells();
716 double coords[3]={0.5,0.75,1.2};
717 DataArrayDouble *myCoords=DataArrayDouble::New();
718 myCoords->alloc(3,1);
719 std::copy(coords,coords+3,myCoords->getPointer());
720 ret->setCoords(myCoords);
725 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveSourceMesh_2()
727 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DSourceMesh",1);
728 ret->allocateCells(4);
729 int conn[8]={0,1,2,3,1,2,3,4};
731 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
732 ret->finishInsertingCells();
733 double coords[10]={0.3,0.3,0.7,0.7,0.9,0.9,1.0,1.0,1.12,1.12};
734 DataArrayDouble *myCoords=DataArrayDouble::New();
735 myCoords->alloc(5,2);
736 std::copy(coords,coords+10,myCoords->getPointer());
737 ret->setCoords(myCoords);
742 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveTargetMesh_2()
744 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DTargetMesh",1);
745 ret->allocateCells(2);
746 int conn[4]={1,2,0,1};
748 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
749 ret->finishInsertingCells();
750 double coords[6]={0.5,0.5,0.75,0.75,1.2,1.2};
751 DataArrayDouble *myCoords=DataArrayDouble::New();
752 myCoords->alloc(3,2);
753 std::copy(coords,coords+6,myCoords->getPointer());
754 ret->setCoords(myCoords);
759 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_3()
761 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DMesh_3",1);
762 ret->allocateCells(4);
763 int conn[10]={0,1,2, 3,4, 6,5,7 ,9,8};
764 ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn);
765 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+3);
766 ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+5);
767 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+8);
768 ret->finishInsertingCells();
769 double coords[10]={0.5,1.,0.8,5.,5.21,0.5,1.1,0.7,5.,5.31};
770 DataArrayDouble *myCoords=DataArrayDouble::New();
771 myCoords->alloc(10,1);
772 std::copy(coords,coords+10,myCoords->getPointer());
773 ret->setCoords(myCoords);
778 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveTargetMesh_3()
780 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("2DCurveMesh_3",1);
781 ret->allocateCells(4);
782 int conn[10]={0,1,2, 3,4, 6,5,7 ,9,8};
783 ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn);
784 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+3);
785 ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+5);
786 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+8);
787 ret->finishInsertingCells();
788 double coords[20]={0.5,0.5,1.,1.,0.8,0.8,5.,5.,5.21,5.21,0.5,0.5,1.1,1.1,0.7,0.7,5.,5.,5.31,5.31};
789 DataArrayDouble *myCoords=DataArrayDouble::New();
790 myCoords->alloc(10,2);
791 std::copy(coords,coords+20,myCoords->getPointer());
792 ret->setCoords(myCoords);
797 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_3()
799 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("2DMesh_3",2);
800 ret->allocateCells(10);
802 0,1,2, 0,1,3,4, 0,1,3,5,4, 0,1,2,6,7,8, 0,1,3,4,6,9,2,10,
803 0,2,1, 0,4,3,1, 0,4,5,3,1, 0,2,1,8,7,6, 0,4,3,1,10,2,9,6
805 ret->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
806 ret->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+3);
807 ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,5,conn+7);
808 ret->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+12);
809 ret->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+18);
810 ret->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+26);
811 ret->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+29);
812 ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,5,conn+33);
813 ret->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+38);
814 ret->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+44);
815 ret->finishInsertingCells();
816 double coords[22]={0.,0.,1.,0.,0.5,1.,1.,1.,0.,1.,0.5,2.,0.5,0.,0.75,0.5,0.25,0.5,1.,0.5,0.,0.5};
817 DataArrayDouble *myCoords=DataArrayDouble::New();
818 myCoords->alloc(11,2);
819 std::copy(coords,coords+22,myCoords->getPointer());
820 ret->setCoords(myCoords);
822 ret->checkCoherency();
827 * Same as build2DTargetMesh_1 but with more nodes than needed. To check tryToShareSameCoordsPermute method.
829 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_4()
831 double targetCoords[20]={-0.3,-0.3, 0.2,-0.3, 0.7,-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 };
832 int targetConn[18]={0,4,5,1, 1,5,3, 5,6,2, 7,8,5,4, 8,9,6,5};
833 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
834 targetMesh->setMeshDimension(2);
835 targetMesh->allocateCells(5);
836 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
837 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
838 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
839 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
840 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
841 targetMesh->finishInsertingCells();
842 DataArrayDouble *myCoords=DataArrayDouble::New();
843 myCoords->alloc(10,2);
844 std::copy(targetCoords,targetCoords+20,myCoords->getPointer());
845 targetMesh->setCoords(myCoords);
850 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_3()
855 MEDCouplingMultiFields *MEDCouplingBasicsTest::buildMultiFields_1()
857 ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1();
859 ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1();
861 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
862 const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4};
863 const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4};
864 const double vals2[]={5.,6.,7.,8.,9.};
865 const double vals4[]={15.,16.,17.,18.,19.};
867 ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
868 ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer());
869 ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer());
870 ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
871 ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
873 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
874 d0->setInfoOnComponent(0,"c1");
875 d1->setInfoOnComponent(0,"c6");
876 d1_1->setInfoOnComponent(0,"c9");
877 d2->setInfoOnComponent(0,"c5");
878 d4->setInfoOnComponent(0,"c7");
880 ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
883 f0->setTime(0.2,5,6);
885 ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::LINEAR_TIME);
887 std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
889 f1->setStartTime(0.7,7,8);
890 f1->setEndTime(1.2,9,10);
892 ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
895 f2->setTime(1.2,11,12);
896 f2->setEndTime(1.5,13,14);
898 ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
901 f3->setTime(1.7,15,16);
903 ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
908 std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
909 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
910 ParaMEDMEM::MEDCouplingMultiFields *ret=ParaMEDMEM::MEDCouplingMultiFields::New(fs);
928 std::vector<MEDCouplingFieldDouble *> MEDCouplingBasicsTest::buildMultiFields_2()
930 ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1();
932 ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1();
934 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
935 const double vals1[]={0.,1.,2.,3.,4.};
936 const double vals1_1[]={170.,171.,172.,173.,174.};
937 const double vals2[]={5.,6.,7.,8.,9.};
938 const double vals4[]={15.,16.,17.,18.,19.};
940 ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
941 ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer());
942 ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer());
943 ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
944 ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
946 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
947 d0->setInfoOnComponent(0,"c1");
948 d1->setInfoOnComponent(0,"c6");
949 d1_1->setInfoOnComponent(0,"c9");
950 d2->setInfoOnComponent(0,"c5");
951 d4->setInfoOnComponent(0,"c7");
953 ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
956 f0->setTime(0.2,5,6);
958 ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
960 std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
962 f1->setStartTime(0.7,7,8);
963 f1->setEndTime(1.2,9,10);
965 ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
968 f2->setTime(1.2,11,12);
969 f2->setEndTime(1.5,13,14);
971 ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
974 f3->setTime(1.7,15,16);
976 ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
981 std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
982 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
994 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMultiTypes_1()
996 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi1DMesh",1);
997 DataArrayDouble *coo=buildCoordsForMultiTypes_1();
998 const int conn[5]={0,2, 0,2,1};
999 mesh->allocateCells(2);
1000 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
1001 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+2);
1002 mesh->finishInsertingCells();
1003 mesh->setCoords(coo);
1008 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DMultiTypes_1()
1010 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi2DMesh",2);
1011 DataArrayDouble *coo=buildCoordsForMultiTypes_1();
1012 const int conn[21]={3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15};
1013 mesh->allocateCells(4);
1014 mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
1015 mesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+3);
1016 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+9);
1017 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+13);
1018 mesh->finishInsertingCells();
1019 mesh->setCoords(coo);
1024 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DMultiTypes_1()
1026 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi3DMesh",3);
1027 DataArrayDouble *coo=buildCoordsForMultiTypes_1();
1028 const int conn[81]={0,16,17,18,
1029 0,16,17,18,19,20,21,22,23,24,
1031 0,11,10,9,25,15,14,13,12,26,27,28,29,
1033 0,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
1034 0,9,10,11,44,45,46,47,
1035 0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 };
1036 mesh->allocateCells(8);
1037 mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
1038 mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn+4);
1039 mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+14);
1040 mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA13,13,conn+19);
1041 mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+32);
1042 mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA15,15,conn+38);
1043 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+53);
1044 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA20,20,conn+61);
1045 mesh->finishInsertingCells();
1046 mesh->setCoords(coo);
1051 DataArrayDouble *MEDCouplingBasicsTest::buildCoordsForMultiTypes_1()
1053 DataArrayDouble *coords=DataArrayDouble::New();
1054 coords->alloc(56,3);
1055 coords->setInfoOnComponent(0,"X (cm)");
1056 coords->setInfoOnComponent(1,"Y (cm)");
1057 coords->setInfoOnComponent(2,"Z (cm)");
1058 const double data[168]={
1069 4.0, 4.0, 0.0, //#10
1070 4.0, 0.0, 0.0, //#11
1071 0.0, 2.0, 0.0, //#12
1072 2.0, 4.0, 0.0, //#13
1073 4.0, 2.0, 0.0, //#14
1074 2.0, 0.0, 0.0, //#15
1075 0.0, 6.0, 0.0, //#16
1076 3.0, 3.0, 0.0, //#17
1077 1.3, 3.0, 3.0, //#18
1078 0.0, 3.0, 0.0, //#19
1079 1.5, 4.5, 0.0, //#20
1080 1.5, 1.5, 0.0, //#21
1081 0.65, 1.5, 1.5, //#22
1082 0.65, 4.5, 1.5, //#23
1083 2.15, 3.0, 1.5, //#24
1084 2.0, 2.0, 2.0, //#25
1085 3.0, 1.0, 1.0, //#26
1086 3.0, 3.0, 1.0, //#27
1087 1.0, 3.0, 1.0, //#28
1088 1.0, 1.0, 1.0, //#29
1089 0.0, 3.0, 0.0, //#30
1090 2.0, 0.0, 0.0, //#31
1091 0.0, 0.0, 6.0, //#32
1092 0.0, 3.0, 6.0, //#33
1093 3.0, 0.0, 6.0, //#34
1094 0.0, 1.5, 0.0, //#35
1095 1.5, 1.5, 0.0, //#36
1096 1.5, 0.0, 0.0, //#37
1097 0.0, 1.5, 6.0, //#38
1098 1.5, 1.5, 6.0, //#39
1099 1.5, 0.0, 6.0, //#40
1100 0.0, 0.0, 3.0, //#41
1101 0.0, 3.0, 3.0, //#42
1102 3.0, 0.0, 3.0, //#43
1103 0.0, 0.0, 4.0, //#44
1104 0.0, 4.0, 4.0, //#45
1105 4.0, 4.0, 4.0, //#46
1106 4.0, 0.0, 4.0, //#47
1107 0.0, 2.0, 4.0, //#48
1108 2.0, 4.0, 4.0, //#49
1109 4.0, 2.0, 4.0, //#50
1110 2.0, 0.0, 4.0, //#51
1111 0.0, 0.0, 2.0, //#52
1112 0.0, 4.0, 2.0, //#53
1113 4.0, 4.0, 2.0, //#54
1116 std::copy(data,data+168,coords->getPointer());
1120 MEDCouplingUMesh *MEDCouplingBasicsTest::buildHexa8Mesh_1()
1122 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Hexa8Only",3);
1123 DataArrayDouble *coo=DataArrayDouble::New();
1124 const double coords[81]={0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0};
1126 std::copy(coords,coords+81,coo->getPointer());
1127 const int conn[64]={3,12,13,4,0,9,10,1,
1128 4,13,14,5,1,10,11,2,
1129 6,15,16,7,3,12,13,4,
1130 7,16,17,8,4,13,14,5,
1131 12,21,22,13,9,18,19,10,
1132 13,22,23,14,10,19,20,11,
1133 15,24,25,16,12,21,22,13,
1134 16,25,26,17,13,22,23,14};
1135 mesh->allocateCells(8);
1136 for(int i=0;i<8;i++)
1137 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i);
1138 mesh->finishInsertingCells();
1139 mesh->setCoords(coo);
1144 MEDCouplingUMesh *MEDCouplingBasicsTest::buildPointe_1(MEDCouplingUMesh *& m1)
1146 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Pointe.med",3);
1147 MEDCouplingUMesh *mesh2=MEDCouplingUMesh::New("Pointe.med",2);
1148 const double coords[57]={0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 0.0, 2.0, 1.0, -2.0, 0.0, 1.0, 0.0, -2.0, 1.0, 1.0, 1.0, 2.0, -1.0, 1.0, 2.0, -1.0, -1.0, 2.0, 1.0, -1.0, 2.0, 1.0, 1.0, 3.0, -1.0, 1.0, 3.0, -1.0, -1.0, 3.0, 1.0, -1.0, 3.0, 1.0, 1.0, 4.0, -1.0, 1.0, 4.0, -1.0, -1.0, 4.0, 1.0, -1.0, 4.0, 0.0, 0.0, 5.0};
1149 const int conn[74]={0,1,2,5,0,1,3,2,0,1,4,3,0,1,5,4,1,6,3,2,1,7,4,3,1,8,5,4,1,9,2,5,1,6,2,9,1,7,3,6,1,8,4,7,1,9,5,8, 6,7,8,9,1,14,17,16,15,18, 10,11,12,13,6,7,8,9,14,15,16,17,10,11,12,13};
1150 DataArrayDouble *coo=DataArrayDouble::New();
1152 std::copy(coords,coords+57,coo->getPointer());
1153 mesh->setCoords(coo);
1154 mesh2->setCoords(coo);
1156 mesh->allocateCells(16);
1157 for(int i=0;i<12;i++)
1158 mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+4*i);
1159 mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+48);
1160 mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+53);
1161 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+58);
1162 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+66);
1163 mesh->finishInsertingCells();
1164 //[1,34,29,23,41,32]
1165 const int conn2[20]={0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9};
1166 mesh2->allocateCells(6);
1167 for(int i=0;i<4;i++)
1168 mesh2->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn2+3*i);
1169 mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+12);
1170 mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+16);
1171 mesh2->finishInsertingCells();
1177 double MEDCouplingBasicsTest::sumAll(const std::vector< std::map<int,double> >& matrix)
1180 for(std::vector< std::map<int,double> >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++)
1181 for(std::map<int,double>::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++)
1182 ret+=(*iter2).second;
1186 MEDCouplingUMesh *MEDCouplingBasicsTest::build2D1DSourceMesh()
1188 double sourceCoords[18]={-17., 3., -17., 8., -5., 8.,
1189 -5., 3., -9., 0., -13., 3.,
1190 -9., 8., -7., 0., -7., 8.
1192 int sourceConn[16]={0,1, 1,2, 2,3, 3,0, 3,4, 4,5, 4,6, 7,8};
1193 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1194 sourceMesh->setMeshDimension(1);
1195 sourceMesh->allocateCells(8);
1196 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn);
1197 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+2);
1198 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+4);
1199 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+6);
1200 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+8);
1201 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+10);
1202 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+12);
1203 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+14);
1204 sourceMesh->finishInsertingCells();
1205 DataArrayDouble *myCoords=DataArrayDouble::New();
1206 myCoords->alloc(9,2);
1207 std::copy(sourceCoords,sourceCoords+18,myCoords->getPointer());
1208 sourceMesh->setCoords(myCoords);
1209 myCoords->decrRef();
1213 MEDCouplingUMesh *MEDCouplingBasicsTest::build2D1DTargetMesh()
1215 double targetCoords[10]={-17., 0., -17.,6., -9.,6., -9.,0., -5., 3.};
1216 int targetConn[7]={0,1,2,3, 2,3,4};
1217 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1218 targetMesh->setMeshDimension(2);
1219 targetMesh->allocateCells(2);
1220 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
1221 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,targetConn + 4);
1222 targetMesh->finishInsertingCells();
1223 DataArrayDouble *myCoords=DataArrayDouble::New();
1224 myCoords->alloc(5,2);
1225 std::copy(targetCoords,targetCoords+10,myCoords->getPointer());
1226 targetMesh->setCoords(myCoords);
1227 myCoords->decrRef();
1231 MEDCouplingUMesh* MEDCouplingBasicsTest::build2D1DSegSourceMesh(const double shiftX,
1232 const double inclinationX)
1234 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1235 sourceMesh->setMeshDimension(1);
1238 const int nbYP1 = nbY + 1;
1239 sourceMesh->allocateCells(nbY);
1242 for (int iY = 0; iY < nbY; ++iY)
1244 sourceConn[0] = iY ;
1245 sourceConn[1] = iY + 1;
1246 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn);
1248 sourceMesh->finishInsertingCells();
1250 std::vector<double> sourceCoords;
1251 for (int iY = 0; iY < nbYP1; ++iY)
1253 sourceCoords.push_back(iY * inclinationX + shiftX);
1254 sourceCoords.push_back(iY * 4.);
1256 DataArrayDouble *myCoords=DataArrayDouble::New();
1257 myCoords->alloc(nbYP1,2);
1258 std::copy(sourceCoords.begin(),sourceCoords.end(),myCoords->getPointer());
1259 sourceMesh->setCoords(myCoords);
1260 myCoords->decrRef();
1265 MEDCouplingUMesh* MEDCouplingBasicsTest::build2D1DQuadTargetMesh(const double inclinationX)
1267 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1268 targetMesh->setMeshDimension(2);
1272 const int nbXP1 = nbX + 1;
1273 const int nbYP1 = nbY + 1;
1274 targetMesh->allocateCells(nbX * nbY);
1277 for (int iX = 0; iX < nbX; ++iX)
1279 for (int iY = 0; iY < nbY; ++iY)
1281 targetConn[0] = iY + iX * nbYP1;
1282 targetConn[1] = iY + 1 + iX * nbYP1;
1283 targetConn[2] = iY + 1 + (iX + 1) * nbYP1;
1284 targetConn[3] = iY + (iX + 1) * nbYP1;
1285 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
1288 targetMesh->finishInsertingCells();
1290 std::vector<double> targetCoords;
1291 for (int iX = 0; iX < nbXP1; ++iX)
1293 for (int iY = 0; iY < nbYP1; ++iY)
1295 targetCoords.push_back(iX * 3. + iY * inclinationX);
1296 targetCoords.push_back(iY * 4.);
1299 DataArrayDouble *myCoords=DataArrayDouble::New();
1300 myCoords->alloc(nbXP1 * nbYP1, 2);
1301 std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
1302 targetMesh->setCoords(myCoords);
1303 myCoords->decrRef();
1308 MEDCouplingUMesh* MEDCouplingBasicsTest::build2D1DTriTargetMesh(const double inclinationX)
1310 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1311 targetMesh->setMeshDimension(2);
1315 const int nbXP1 = nbX + 1;
1316 const int nbYP1 = nbY + 1;
1317 targetMesh->allocateCells(nbX * nbY * 2);
1320 for (int iX = 0; iX < nbX; ++iX)
1322 for (int iY = 0; iY < nbY; ++iY)
1324 targetConn[0] = iY + iX * nbYP1;
1325 targetConn[1] = iY + 1 + iX * nbYP1;
1326 targetConn[2] = iY + 1 + (iX + 1) * nbYP1;
1327 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
1328 targetConn[0] = iY + iX * nbYP1;
1329 targetConn[1] = iY + 1 + (iX + 1) * nbYP1;
1330 targetConn[2] = iY + (iX + 1) * nbYP1;
1331 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
1334 targetMesh->finishInsertingCells();
1336 std::vector<double> targetCoords;
1337 for (int iX = 0; iX < nbXP1; ++iX)
1339 for (int iY = 0; iY < nbYP1; ++iY)
1341 targetCoords.push_back(iX * 3. + iY * inclinationX);
1342 targetCoords.push_back(iY * 4.);
1345 DataArrayDouble *myCoords=DataArrayDouble::New();
1346 myCoords->alloc(nbXP1 * nbYP1, 2);
1347 std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
1348 targetMesh->setCoords(myCoords);
1349 myCoords->decrRef();
1354 MEDCouplingUMesh *MEDCouplingBasicsTest::build3D2DSourceMesh()
1356 double sourceCoords[63]={-12., 6., 10., -12.,10., 6., -16.,10. , 10.,
1357 -20., 0., 0., -12., 0., 0., -12., 0. , -4., -20.,0.,-4.,
1358 -20., 0., 10., -12., 0., 10., -20.,10. , 10.,
1359 -25., 5., -5., 5., 5., -5., 5., 5. , 25., -25.,5.,25.,
1360 -20., 0., 16., -18., 0., 16., -20., 2.5, 16.,
1361 -25., 0., -5., 5., 0., -5., 5., 0. , 25., -25.,0.,25.
1363 int sourceConn[25]={0,1,2, 3,4,5,6, 7,8,9, 10,11,12,13, 14,15,16, 3,4,8,7, 17,18,19,20};
1364 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1365 sourceMesh->setMeshDimension(2);
1366 sourceMesh->allocateCells(7);
1367 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,sourceConn);
1368 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+3);
1369 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,sourceConn+7);
1370 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+10);
1371 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,sourceConn+14);
1372 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+17);
1373 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+21);
1374 sourceMesh->finishInsertingCells();
1375 DataArrayDouble *myCoords=DataArrayDouble::New();
1376 myCoords->alloc(21,3);
1377 std::copy(sourceCoords,sourceCoords+63,myCoords->getPointer());
1378 sourceMesh->setCoords(myCoords);
1379 myCoords->decrRef();
1383 MEDCouplingUMesh *MEDCouplingBasicsTest::build3D2DTargetMesh()
1385 double targetCoords[45]={-20., 0., 0., -20.,10., 0., -12.,10., 0.,
1386 -12., 0., 0., -20., 0.,10., -20.,10.,10.,
1387 -12.,10.,10., -12., 0.,10., -20., 0.,18.,
1388 -20.,-5.,10., -20.,-5.,-4., -12.,-5.,-4.,
1389 -12.,-5.,10., -20., 0.,-4., -12., 0.,-4.
1391 int targetConn[20]={4,5,7,8, 0,3,2,1,4,7,6,5, 4,13,14,7,9,10,11,12};
1392 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1393 targetMesh->setMeshDimension(3);
1394 targetMesh->allocateCells(3);
1395 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1396 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn + 4);
1397 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn + 12);
1398 targetMesh->finishInsertingCells();
1399 DataArrayDouble *myCoords=DataArrayDouble::New();
1400 myCoords->alloc(15,3);
1401 std::copy(targetCoords,targetCoords+45,myCoords->getPointer());
1402 targetMesh->setCoords(myCoords);
1403 myCoords->decrRef();
1407 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DQuadSourceMesh(const double shiftX,
1408 const double inclinationX)
1410 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1411 sourceMesh->setMeshDimension(2);
1415 const int nbYP1 = nbY + 1;
1416 const int nbZP1 = nbZ + 1;
1417 sourceMesh->allocateCells(nbY * nbZ);
1420 for (int iY = 0; iY < nbY; ++iY)
1422 for (int iZ = 0; iZ < nbZ; ++iZ)
1424 sourceConn[0] = iZ + iY * nbZP1;
1425 sourceConn[1] = iZ + 1 + iY * nbZP1;
1426 sourceConn[2] = iZ + 1 + (iY + 1) * nbZP1;
1427 sourceConn[3] = iZ + (iY + 1) * nbZP1;
1428 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn);
1431 sourceMesh->finishInsertingCells();
1433 std::vector<double> sourceCoords;
1434 for (int iY = 0; iY < nbYP1; ++iY)
1436 for (int iZ = 0; iZ < nbZP1; ++iZ)
1438 sourceCoords.push_back(iY * inclinationX + shiftX);
1439 sourceCoords.push_back(iY * 4.);
1440 sourceCoords.push_back(iZ * 3.);
1444 DataArrayDouble *myCoords=DataArrayDouble::New();
1445 myCoords->alloc(nbYP1 * nbZP1,3);
1446 std::copy(sourceCoords.begin(),sourceCoords.end(),myCoords->getPointer());
1447 sourceMesh->setCoords(myCoords);
1448 myCoords->decrRef();
1453 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DTriSourceMesh(const double shiftX,
1454 const double inclinationX)
1456 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1457 sourceMesh->setMeshDimension(2);
1461 const int nbYP1 = nbY + 1;
1462 const int nbZP1 = nbZ + 1;
1463 sourceMesh->allocateCells(nbY * nbZ * 2);
1466 for (int iY = 0; iY < nbY; ++iY)
1468 for (int iZ = 0; iZ < nbZ; ++iZ)
1470 sourceConn[0] = iZ + iY * nbZP1;
1471 sourceConn[1] = iZ + 1 + iY * nbZP1;
1472 sourceConn[2] = iZ + 1 + (iY + 1) * nbZP1;
1473 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
1474 sourceConn[0] = iZ + iY * nbZP1;
1475 sourceConn[1] = iZ + (iY + 1) * nbZP1;
1476 sourceConn[2] = iZ + 1 + (iY + 1) * nbZP1;
1477 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
1480 sourceMesh->finishInsertingCells();
1482 std::vector<double> sourceCoords;
1483 for (int iY = 0; iY < nbYP1; ++iY)
1485 for (int iZ = 0; iZ < nbZP1; ++iZ)
1487 sourceCoords.push_back(iY * inclinationX + shiftX);
1488 sourceCoords.push_back(iY * 4.);
1489 sourceCoords.push_back(iZ * 3.);
1493 DataArrayDouble *myCoords=DataArrayDouble::New();
1494 myCoords->alloc(nbYP1 * nbZP1,3);
1495 std::copy(sourceCoords.begin(),sourceCoords.end(),myCoords->getPointer());
1496 sourceMesh->setCoords(myCoords);
1497 myCoords->decrRef();
1502 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DHexaTargetMesh(const double inclinationX)
1504 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1505 targetMesh->setMeshDimension(3);
1510 const int nbXP1 = nbX + 1;
1511 const int nbYP1 = nbY + 1;
1512 const int nbZP1 = nbZ + 1;
1513 targetMesh->allocateCells(nbX * nbY * nbZ);
1516 for (int iX = 0; iX < nbX; ++iX)
1518 for (int iY = 0; iY < nbY; ++iY)
1520 for (int iZ = 0; iZ < nbZ; ++iZ)
1522 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1523 targetConn[1] = iZ + 1 + ( iY + iX * nbYP1) * nbZP1;
1524 targetConn[2] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1525 targetConn[3] = iZ + ((iY + 1) + iX * nbYP1) * nbZP1;
1526 targetConn[4] = iZ + ( iY + (iX + 1) * nbYP1) * nbZP1;
1527 targetConn[5] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1528 targetConn[6] = iZ + 1 + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1529 targetConn[7] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1530 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn);
1534 targetMesh->finishInsertingCells();
1536 std::vector<double> targetCoords;
1537 for (int iX = 0; iX < nbXP1; ++iX)
1539 for (int iY = 0; iY < nbYP1; ++iY)
1541 for (int iZ = 0; iZ < nbZP1; ++iZ)
1543 targetCoords.push_back(iX * 3. + iY * inclinationX);
1544 targetCoords.push_back(iY * 4.);
1545 targetCoords.push_back(iZ * 3.);
1549 DataArrayDouble *myCoords=DataArrayDouble::New();
1550 myCoords->alloc(nbXP1 * nbYP1 * nbZP1, 3);
1551 std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
1552 targetMesh->setCoords(myCoords);
1553 myCoords->decrRef();
1558 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DTetraTargetMesh(const double inclinationX)
1560 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1561 targetMesh->setMeshDimension(3);
1566 const int nbXP1 = nbX + 1;
1567 const int nbYP1 = nbY + 1;
1568 const int nbZP1 = nbZ + 1;
1569 targetMesh->allocateCells(nbX * nbY * nbZ * 5);
1572 for (int iX = 0; iX < nbX; ++iX)
1574 for (int iY = 0; iY < nbY; ++iY)
1576 for (int iZ = 0; iZ < nbZ; ++iZ)
1578 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1579 targetConn[1] = iZ + 1 + ( iY + iX * nbYP1) * nbZP1;
1580 targetConn[2] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1581 targetConn[3] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1582 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1583 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1584 targetConn[1] = iZ + ( iY + (iX + 1) * nbYP1) * nbZP1;
1585 targetConn[2] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1586 targetConn[3] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1587 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1588 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1589 targetConn[1] = iZ + ((iY + 1) + iX * nbYP1) * nbZP1;
1590 targetConn[2] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1591 targetConn[3] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1592 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1593 targetConn[0] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1594 targetConn[1] = iZ + 1 + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1595 targetConn[2] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1596 targetConn[3] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1597 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1598 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1599 targetConn[1] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1600 targetConn[2] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1601 targetConn[3] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1602 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1606 targetMesh->finishInsertingCells();
1608 std::vector<double> targetCoords;
1609 for (int iX = 0; iX < nbXP1; ++iX)
1611 for (int iY = 0; iY < nbYP1; ++iY)
1613 for (int iZ = 0; iZ < nbZP1; ++iZ)
1615 targetCoords.push_back(iX * 3. + iY * inclinationX);
1616 targetCoords.push_back(iY * 4.);
1617 targetCoords.push_back(iZ * 3.);
1621 DataArrayDouble *myCoords=DataArrayDouble::New();
1622 myCoords->alloc(nbXP1 * nbYP1 * nbZP1, 3);
1623 std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
1624 targetMesh->setCoords(myCoords);
1625 myCoords->decrRef();
1630 int MEDCouplingBasicsTest::countNonZero(const std::vector< std::map<int,double> >& matrix)
1633 for(std::vector< std::map<int,double> >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++)
1634 for(std::map<int,double>::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++)
1635 if (!INTERP_KERNEL::epsilonEqual((*iter2).second, 0.)) ret +=1;
1639 void MEDCouplingBasicsTest::test2D1DMeshesIntersection(MEDCouplingUMesh *sourceMesh,
1640 MEDCouplingUMesh *targetMesh,
1641 const double correctLength,
1642 const int correctDuplicateFacesNbr,
1643 const int correctTotalIntersectFacesNbr)
1645 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
1646 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1647 INTERP_KERNEL::Interpolation2D1D myInterpolator;
1648 myInterpolator.setPrecision(1e-12);
1649 const double prec = 1.0e-5;
1650 IntersectionMatrix matrix;
1651 myInterpolator.setIntersectionType(INTERP_KERNEL::Geometric2D);
1652 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
1654 std::cout.precision(16);
1656 const double length = sumAll(matrix);
1657 LOG(1, "length = " << surf <<" correctLength = " << correctLength );
1658 CPPUNIT_ASSERT_DOUBLES_EQUAL(correctLength, length, prec * std::max(correctLength, length));
1660 INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
1661 int duplicateFacesNbr = duplicateFaces.size();
1662 LOG(1, "duplicateFacesNbr = " << duplicateFacesNbr <<" correctDuplicateFacesNbr = " << correctDuplicateFacesNbr);
1663 CPPUNIT_ASSERT_EQUAL(correctDuplicateFacesNbr, duplicateFacesNbr);
1665 if (correctTotalIntersectFacesNbr >= 0)
1667 int totalIntersectFacesNbr = countNonZero(matrix);
1668 LOG(1, "totalIntersectFacesNbr = " << totalIntersectFacesNbr <<" correctTotalIntersectFacesNbr = " << correctTotalIntersectFacesNbr );
1669 CPPUNIT_ASSERT_EQUAL(correctTotalIntersectFacesNbr, totalIntersectFacesNbr);
1672 sourceMesh->decrRef();
1673 targetMesh->decrRef();
1676 void MEDCouplingBasicsTest::test3D2DMeshesIntersection(MEDCouplingUMesh *sourceMesh,
1677 MEDCouplingUMesh *targetMesh,
1678 const double correctSurf,
1679 const int correctDuplicateFacesNbr,
1680 const int correctTotalIntersectFacesNbr)
1682 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1683 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1684 INTERP_KERNEL::Interpolation3D2D myInterpolator;
1685 myInterpolator.setPrecision(1e-12);
1686 const double prec = 1.0e-5;
1687 IntersectionMatrix matrix;
1688 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1689 for ( size_t i = 0; i < sizeof(sp)/sizeof(sp[0]); ++i )
1691 myInterpolator.setSplittingPolicy( sp[i] );
1693 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
1695 std::cout.precision(16);
1697 const double surf = sumAll(matrix);
1698 LOG(1, "surf = " << surf <<" correctSurf = " << correctSurf );
1699 CPPUNIT_ASSERT_DOUBLES_EQUAL(correctSurf, surf, prec * std::max(correctSurf, surf));
1701 INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
1702 int duplicateFacesNbr = duplicateFaces.size();
1703 LOG(1, "duplicateFacesNbr = " << duplicateFacesNbr <<" correctDuplicateFacesNbr = " << correctDuplicateFacesNbr);
1704 CPPUNIT_ASSERT_EQUAL(correctDuplicateFacesNbr, duplicateFacesNbr);
1706 if (correctTotalIntersectFacesNbr >= 0)
1708 int totalIntersectFacesNbr = countNonZero(matrix);
1709 LOG(1, "totalIntersectFacesNbr = " << totalIntersectFacesNbr <<" correctTotalIntersectFacesNbr = " << correctTotalIntersectFacesNbr );
1710 CPPUNIT_ASSERT_EQUAL(correctTotalIntersectFacesNbr, totalIntersectFacesNbr);
1714 sourceMesh->decrRef();
1715 targetMesh->decrRef();