1 // Copyright (C) 2007-2012 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.
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
20 #include "MEDCouplingBasicsTest.hxx"
21 #include "MEDCouplingUMesh.hxx"
22 #include "MEDCouplingExtrudedMesh.hxx"
23 #include "MEDCouplingFieldDouble.hxx"
24 #include "MEDCouplingMemArray.hxx"
25 #include "MEDCouplingMultiFields.hxx"
27 #include "MEDCouplingBasicsTestData1.hxx"
29 #include "Interpolation2D.txx"
30 #include "Interpolation3D2D.txx"
31 #include "Interpolation2D1D.txx"
32 #include "MEDCouplingNormalizedUnstructuredMesh.txx"
33 #include "MEDCouplingNormalizedCartesianMesh.txx"
35 using namespace ParaMEDMEM;
37 typedef std::vector<std::map<int,double> > IntersectionMatrix;
39 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSourceMesh_2()
41 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,
42 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,
43 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,
44 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,
45 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};
48 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,
49 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,
50 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,
51 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,
52 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,
53 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};
55 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
56 sourceMesh->setMeshDimension(3);
57 sourceMesh->allocateCells(53);
59 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+4*i);
60 sourceMesh->finishInsertingCells();
61 DataArrayDouble *myCoords=DataArrayDouble::New();
62 myCoords->alloc(28,3);
63 std::copy(sourceCoords,sourceCoords+84,myCoords->getPointer());
64 sourceMesh->setCoords(myCoords);
69 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_2()
71 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};
72 int targetConn[20]={5, 6, 3, 0, 1, 3, 0, 5, 3, 6, 5, 7, 6, 4, 0, 5, 6, 3, 0, 2};
73 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
74 targetMesh->setMeshDimension(3);
75 targetMesh->allocateCells(5);
77 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn+4*i);
78 targetMesh->finishInsertingCells();
79 DataArrayDouble *myCoords=DataArrayDouble::New();
81 std::copy(targetCoords,targetCoords+24,myCoords->getPointer());
82 targetMesh->setCoords(myCoords);
87 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_1()
89 double targetCoords[36]={
90 25.,25.,0., 25.,25.,50., 25.,25.,200., 75.,25.,0., 75.,25.,50., 75.,25.,200.,
91 25.,125.,0., 25.,125.,50., 25.,125.,200., 125.,125.,0., 125.,125.,50., 125.,125.,200.
93 int targetConn[16]={0,1, 1,2, 3,4, 4,5, 6,7, 7,8, 9,10, 10,11};
95 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("my name of mesh 1D",1);
96 targetMesh->allocateCells(8);
98 targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
99 targetMesh->finishInsertingCells();
100 DataArrayDouble *myCoords=DataArrayDouble::New();
101 myCoords->alloc(12,3);
102 std::copy(targetCoords,targetCoords+36,myCoords->getPointer());
103 targetMesh->setCoords(myCoords);
108 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DSourceMesh_1()
110 double sourceCoords[8]={-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7};
111 int sourceConn[6]={0,3,1,0,2,3};
112 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New("my name of mesh 2D",2);
113 sourceMesh->allocateCells(2);
114 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
115 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
116 sourceMesh->finishInsertingCells();
117 DataArrayDouble *myCoords=DataArrayDouble::New();
118 myCoords->alloc(4,2);
119 std::copy(sourceCoords,sourceCoords+8,myCoords->getPointer());
120 sourceMesh->setCoords(myCoords);
125 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_1()
127 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 };
128 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
129 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
130 targetMesh->setMeshDimension(2);
131 targetMesh->allocateCells(5);
132 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
133 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
134 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
135 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
136 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
137 targetMesh->finishInsertingCells();
138 DataArrayDouble *myCoords=DataArrayDouble::New();
139 myCoords->alloc(9,2);
140 std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
141 targetMesh->setCoords(myCoords);
146 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshPerm_1()
148 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 };
149 int targetConn[18]={0,3,4,1, 1,2,4, 4,5,2, 6,7,4,3, 7,8,5,4};
150 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
151 targetMesh->setMeshDimension(2);
152 targetMesh->allocateCells(5);
153 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
154 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
155 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
156 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
157 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
158 targetMesh->finishInsertingCells();
159 DataArrayDouble *myCoords=DataArrayDouble::New();
160 myCoords->alloc(9,2);
161 std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
162 targetMesh->setCoords(myCoords);
167 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_2()
169 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 };
170 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 };
171 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
172 targetMesh->setMeshDimension(2);
173 targetMesh->allocateCells(8);
174 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
175 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
176 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+6);
177 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+9);
178 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+12);
179 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+15);
180 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18);
181 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21);
182 targetMesh->finishInsertingCells();
183 DataArrayDouble *myCoords=DataArrayDouble::New();
184 myCoords->alloc(9,2);
185 std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
186 targetMesh->setCoords(myCoords);
191 MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU1DMesh_U()
193 double coords[4]={ 0.0, 0.3, 0.75, 1.0 };
194 int conn[2*3]={ 0,1, 1,2, 2,3 };
195 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
196 mesh->setMeshDimension(1);
197 mesh->allocateCells(3);
198 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
199 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
200 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4);
201 mesh->finishInsertingCells();
202 DataArrayDouble *myCoords=DataArrayDouble::New();
203 myCoords->alloc(4,1);
204 std::copy(coords,coords+4,myCoords->getPointer());
205 mesh->setCoords(myCoords);
209 MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU2DMesh_U()
211 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 };
212 int conn[18]={0,1,4,3, 3,4,7,6, 4,5,8,7, 1,5,4, 1,2,5 };
213 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
214 mesh->setMeshDimension(2);
215 mesh->allocateCells(5);
216 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
217 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+4);
218 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+8);
219 mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+12);
220 mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+15);
221 mesh->finishInsertingCells();
222 DataArrayDouble *myCoords=DataArrayDouble::New();
223 myCoords->alloc(9,2);
224 std::copy(coords,coords+18,myCoords->getPointer());
225 mesh->setCoords(myCoords);
229 MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU3DMesh_U()
233 // 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
234 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,
238 // 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
239 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
241 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
242 mesh->setMeshDimension(3);
243 mesh->allocateCells(8);
245 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i);
246 mesh->finishInsertingCells();
247 DataArrayDouble *myCoords=DataArrayDouble::New();
248 myCoords->alloc(27,3);
249 std::copy(coords,coords+27*3,myCoords->getPointer());
250 mesh->setCoords(myCoords);
255 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfSourceMesh_1()
257 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};
258 int sourceConn[6]={0,3,1,0,2,3};
259 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
260 sourceMesh->setMeshDimension(2);
261 sourceMesh->allocateCells(2);
262 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
263 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
264 sourceMesh->finishInsertingCells();
265 DataArrayDouble *myCoords=DataArrayDouble::New();
266 myCoords->alloc(4,3);
267 std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer());
268 sourceMesh->setCoords(myCoords);
273 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfSourceMesh_2()
275 double sourceCoords[12]={-0.3,-0.3,0., 0.7,-0.3,0., -0.3,0.7,0., 0.7,0.7,0.};
276 int sourceConn[6]={0,3,1,0,2,3};
277 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
278 sourceMesh->setMeshDimension(2);
279 sourceMesh->allocateCells(2);
280 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
281 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
282 sourceMesh->finishInsertingCells();
283 DataArrayDouble *myCoords=DataArrayDouble::New();
284 myCoords->alloc(4,3);
285 std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer());
286 sourceMesh->setCoords(myCoords);
291 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMesh_1()
293 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};
294 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
295 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
296 targetMesh->setMeshDimension(2);
297 targetMesh->allocateCells(5);
298 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
299 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
300 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
301 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
302 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
303 targetMesh->finishInsertingCells();
304 DataArrayDouble *myCoords=DataArrayDouble::New();
305 myCoords->alloc(9,3);
306 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
307 targetMesh->setCoords(myCoords);
313 * Idem build3DSurfTargetMesh_1 except that cell id 2 is not correctly numbered.
315 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMeshPerm_1()
317 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};
318 int targetConn[18]={0,3,4,1, 1,4,2, 4,2,5, 6,7,4,3, 7,8,5,4};
319 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
320 targetMesh->setMeshDimension(2);
321 targetMesh->allocateCells(5);
322 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
323 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
324 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
325 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
326 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
327 targetMesh->finishInsertingCells();
328 DataArrayDouble *myCoords=DataArrayDouble::New();
329 myCoords->alloc(9,3);
330 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
331 targetMesh->setCoords(myCoords);
336 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMesh_2()
338 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};
339 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 };
340 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
341 targetMesh->setMeshDimension(2);
342 targetMesh->allocateCells(8);
343 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
344 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
345 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+6);
346 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+9);
347 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+12);
348 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+15);
349 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18);
350 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21);
351 targetMesh->finishInsertingCells();
352 DataArrayDouble *myCoords=DataArrayDouble::New();
353 myCoords->alloc(9,3);
354 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
355 targetMesh->setCoords(myCoords);
360 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSourceMesh_1()
362 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,
363 200.0, 0.0, 0.0, 200.0, 200.0, 200.0, 200.0, 200.0, 0.0, 100.0, 100.0, 100.0 };
364 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};
365 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
366 sourceMesh->setMeshDimension(3);
367 sourceMesh->allocateCells(12);
368 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn);
369 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+4);
370 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+8);
371 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+12);
372 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+16);
373 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+20);
374 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+24);
375 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+28);
376 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+32);
377 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+36);
378 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+40);
379 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+44);
380 sourceMesh->finishInsertingCells();
381 DataArrayDouble *myCoords=DataArrayDouble::New();
382 myCoords->alloc(9,3);
383 std::copy(sourceCoords,sourceCoords+27,myCoords->getPointer());
384 sourceMesh->setCoords(myCoords);
389 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_1()
391 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. ,
392 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. ,
393 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. };
394 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,
395 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};
396 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
397 targetMesh->setMeshDimension(3);
398 targetMesh->allocateCells(12);
400 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
401 targetMesh->finishInsertingCells();
402 DataArrayDouble *myCoords=DataArrayDouble::New();
403 myCoords->alloc(27,3);
404 std::copy(targetCoords,targetCoords+81,myCoords->getPointer());
405 targetMesh->setCoords(myCoords);
410 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshMergeNode_1()
412 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 };
413 int targetConn[18]={0,9,7,5, 4,6,2, 10,11,8, 9,14,15,7, 17,16,13,6};
414 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
415 targetMesh->setMeshDimension(2);
416 targetMesh->allocateCells(5);
417 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
418 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
419 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
420 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
421 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
422 targetMesh->finishInsertingCells();
423 DataArrayDouble *myCoords=DataArrayDouble::New();
424 myCoords->alloc(18,2);
425 std::copy(targetCoords,targetCoords+36,myCoords->getPointer());
426 targetMesh->setCoords(myCoords);
431 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMeshMergeNode_1()
433 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. ,
434 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. ,
435 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.};
436 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,
437 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};
438 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
439 targetMesh->setMeshDimension(3);
440 targetMesh->allocateCells(12);
442 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
443 targetMesh->finishInsertingCells();
444 DataArrayDouble *myCoords=DataArrayDouble::New();
445 myCoords->alloc(31,3);
446 std::copy(targetCoords,targetCoords+93,myCoords->getPointer());
447 targetMesh->setCoords(myCoords);
452 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DExtrudedUMesh_1(MEDCouplingUMesh *&mesh2D)
455 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.,
456 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0.,
457 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.,
458 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1.,
459 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.,
460 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2.,
461 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.,
462 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.};
466 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,
467 1,6,5,3,16,21,20,18, 13,10,9,6,28,25,24,21,
468 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,
469 7,12,14,13,22,27,29,28,
471 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,
472 16,21,20,18,31,36,35,33, 28,25,24,21,43,40,39,36,
473 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,
474 22,27,29,28,37,42,44,43,
476 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,
477 31,36,35,33,46,51,50,48, 43,40,39,36,58,55,54,51,
478 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,
479 37,42,44,43,52,57,59,58
481 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};
483 MEDCouplingUMesh *ret=MEDCouplingUMesh::New();
484 ret->setMeshDimension(3);
485 ret->allocateCells(18);
487 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn);
488 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+8);
489 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+51);
490 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+59);
491 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+67);
492 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+110);
494 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+118);
495 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+126);
496 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+169);
497 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+177);
498 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+185);
499 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+228);
501 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+236);
502 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+244);
503 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+287);
504 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+295);
505 ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+303);
506 ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+346);
508 ret->finishInsertingCells();
509 DataArrayDouble *myCoords=DataArrayDouble::New();
510 myCoords->alloc(60,3);
511 std::copy(coords,coords+180,myCoords->getPointer());
512 ret->setCoords(myCoords);
514 mesh2D=MEDCouplingUMesh::New();
515 mesh2D->setMeshDimension(2);
516 mesh2D->allocateCells(6);
517 mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2);
518 mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+4);
519 mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+10);
520 mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+14);
521 mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+18);
522 mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+24);
523 mesh2D->setCoords(myCoords);
528 void MEDCouplingBasicsTest::build3DExtrudedUMesh_2(MEDCouplingUMesh *&meshN, MEDCouplingUMesh *&meshTT, MEDCouplingUMesh *&meshTF)
530 const double coordsN[270]={
531 0, 0, 0, 0.10803000450134277, 0, 0, 0.21606000900268554, 0, 0, 0.28808000564575198, 0, 0, 0.36010002136230468, 0, 0, 0.43212001800537109, 0, 0, 0,
532 0.072020001411437995, 0, 0.10803000450134277, 0.072020001411437995, 0, 0.21606000900268554, 0.072020001411437995, 0, 0.28808000564575198, 0.072020001411437995,
533 0, 0.36010002136230468, 0.072020001411437995, 0, 0.43212001800537109, 0.072020001411437995, 0, 0, 0.10803000450134277, 0, 0.10803000450134277,
534 0.10803000450134277, 0, 0.21606000900268554, 0.10803000450134277, 0, 0.28808000564575198, 0.10803000450134277, 0, 0.36010002136230468, 0.10803000450134277, 0,
535 0.43212001800537109, 0.10803000450134277, 0, 0, 0.14404000282287599, 0, 0.10803000450134277, 0.14404000282287599, 0, 0.21606000900268554, 0.14404000282287599, 0,
536 0.28808000564575198, 0.14404000282287599, 0, 0.36010002136230468, 0.14404000282287599, 0, 0.43212001800537109, 0.14404000282287599, 0, 0, 0.21606000900268554, 0,
537 0.10803000450134277, 0.21606000900268554, 0, 0.21606000900268554, 0.21606000900268554, 0, 0.28808000564575198, 0.21606000900268554, 0, 0.36010002136230468,
538 0.21606000900268554, 0, 0.43212001800537109, 0.21606000900268554, 0, 0, 0, 2.1364999389648438, 0.10803000450134277, 0, 2.1364999389648438, 0.21606000900268554,
539 0, 2.1364999389648438, 0.28808000564575198, 0, 2.1364999389648438, 0.36010002136230468, 0, 2.1364999389648438, 0.43212001800537109, 0, 2.1364999389648438, 0,
540 0.072020001411437995, 2.1364999389648438, 0.10803000450134277, 0.072020001411437995, 2.1364999389648438, 0.21606000900268554, 0.072020001411437995,
541 2.1364999389648438, 0.28808000564575198, 0.072020001411437995, 2.1364999389648438, 0.36010002136230468, 0.072020001411437995, 2.1364999389648438,
542 0.43212001800537109, 0.072020001411437995, 2.1364999389648438, 0, 0.10803000450134277, 2.1364999389648438, 0.10803000450134277, 0.10803000450134277,
543 2.1364999389648438, 0.21606000900268554, 0.10803000450134277, 2.1364999389648438, 0.28808000564575198, 0.10803000450134277, 2.1364999389648438,
544 0.36010002136230468, 0.10803000450134277, 2.1364999389648438, 0.43212001800537109, 0.10803000450134277, 2.1364999389648438, 0, 0.14404000282287599,
545 2.1364999389648438, 0.10803000450134277, 0.14404000282287599, 2.1364999389648438, 0.21606000900268554, 0.14404000282287599, 2.1364999389648438,
546 0.28808000564575198, 0.14404000282287599, 2.1364999389648438, 0.36010002136230468, 0.14404000282287599, 2.1364999389648438, 0.43212001800537109,
547 0.14404000282287599, 2.1364999389648438, 0, 0.21606000900268554, 2.1364999389648438, 0.10803000450134277, 0.21606000900268554, 2.1364999389648438,
548 0.21606000900268554, 0.21606000900268554, 2.1364999389648438, 0.28808000564575198, 0.21606000900268554, 2.1364999389648438, 0.36010002136230468,
549 0.21606000900268554, 2.1364999389648438, 0.43212001800537109, 0.21606000900268554, 2.1364999389648438, 0, 0, 4.2729998779296876, 0.10803000450134277, 0,
550 4.2729998779296876, 0.21606000900268554, 0, 4.2729998779296876, 0.28808000564575198, 0, 4.2729998779296876, 0.36010002136230468, 0, 4.2729998779296876,
551 0.43212001800537109, 0, 4.2729998779296876, 0, 0.072020001411437995, 4.2729998779296876, 0.10803000450134277, 0.072020001411437995, 4.2729998779296876,
552 0.21606000900268554, 0.072020001411437995, 4.2729998779296876, 0.28808000564575198, 0.072020001411437995, 4.2729998779296876, 0.36010002136230468,
553 0.072020001411437995, 4.2729998779296876, 0.43212001800537109, 0.072020001411437995, 4.2729998779296876, 0, 0.10803000450134277, 4.2729998779296876,
554 0.10803000450134277, 0.10803000450134277, 4.2729998779296876, 0.21606000900268554, 0.10803000450134277, 4.2729998779296876, 0.28808000564575198,
555 0.10803000450134277, 4.2729998779296876, 0.36010002136230468, 0.10803000450134277, 4.2729998779296876, 0.43212001800537109, 0.10803000450134277,
556 4.2729998779296876, 0, 0.14404000282287599, 4.2729998779296876, 0.10803000450134277, 0.14404000282287599, 4.2729998779296876, 0.21606000900268554,
557 0.14404000282287599, 4.2729998779296876, 0.28808000564575198, 0.14404000282287599, 4.2729998779296876, 0.36010002136230468, 0.14404000282287599,
558 4.2729998779296876, 0.43212001800537109, 0.14404000282287599, 4.2729998779296876, 0, 0.21606000900268554, 4.2729998779296876, 0.10803000450134277,
559 0.21606000900268554, 4.2729998779296876, 0.21606000900268554, 0.21606000900268554, 4.2729998779296876, 0.28808000564575198, 0.21606000900268554,
560 4.2729998779296876, 0.36010002136230468, 0.21606000900268554, 4.2729998779296876, 0.43212001800537109, 0.21606000900268554, 4.2729998779296876};
561 const int connN[320]={
562 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,
563 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,
564 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,
565 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,
566 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,
567 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,
568 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,
569 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,
570 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};
571 meshN=MEDCouplingUMesh::New();
572 meshN->setName("meshExtrudedN");
573 meshN->setMeshDimension(3);
574 meshN->allocateCells(40);
575 for(int i=0;i<40;i++)
576 meshN->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,connN+8*i);
577 meshN->finishInsertingCells();
578 DataArrayDouble *myCoords=DataArrayDouble::New();
579 myCoords->alloc(90,3);
580 std::copy(coordsN,coordsN+270,myCoords->getPointer());
581 meshN->setCoords(myCoords);
584 meshTT=MEDCouplingUMesh::New();
585 meshTT->setName("meshExtrudedTT");
586 meshTT->setMeshDimension(3);
587 meshTT->allocateCells(200);
588 for(int i=0;i<200;i++)
589 meshTT->insertNextCell(INTERP_KERNEL::NORM_POLYHED,connITT[i+1]-connITT[i],connTT+connITT[i]);
590 meshTT->finishInsertingCells();
591 myCoords=DataArrayDouble::New();
592 myCoords->alloc(1720,3);
593 std::copy(coordsTT,coordsTT+5160,myCoords->getPointer());
594 meshTT->setCoords(myCoords);
597 meshTF=MEDCouplingUMesh::New();
598 meshTF->setName("meshExtrudedTF");
599 meshTF->setMeshDimension(3);
600 meshTF->allocateCells(340);
601 for(int i=0;i<320;i++)
602 meshTF->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,connTFH8+8*i);
603 for(int i=0;i<20;i++)
604 meshTF->insertNextCell(INTERP_KERNEL::NORM_POLYHED,connTFPOLH_I[i+1]-connTFPOLH_I[i],connTFPOLH+connTFPOLH_I[i]);
605 meshTF->finishInsertingCells();
606 myCoords=DataArrayDouble::New();
607 myCoords->alloc(567,3);
608 std::copy(coordsTF,coordsTF+1701,myCoords->getPointer());
609 meshTF->setCoords(myCoords);
613 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshMerged_1()
615 double targetCoords[26]={
616 -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,
617 0.7,-0.3, 1.7,-0.3, 0.7,0.7, 1.7,0.7
620 0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4,
623 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
624 targetMesh->setName("merge");
625 targetMesh->setMeshDimension(2);
626 targetMesh->allocateCells(10);
627 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
628 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
629 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
630 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
631 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
632 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18);
633 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21);
634 targetMesh->finishInsertingCells();
635 DataArrayDouble *myCoords=DataArrayDouble::New();
636 myCoords->alloc(13,2);
637 std::copy(targetCoords,targetCoords+26,myCoords->getPointer());
638 targetMesh->setCoords(myCoords);
643 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveMesh(double dx, double dy)
650 double targetCoords[3*2]=
652 0.+dx,0.+dy, 1.+dx,0.+dy, 2.+dx,1.+dy
654 int targetConn[2*2]={1,2, 0,1};
656 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("2Dcurve 1D mesh",1);
657 targetMesh->allocateCells(2);
659 targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
660 targetMesh->finishInsertingCells();
661 DataArrayDouble *myCoords=DataArrayDouble::New();
662 myCoords->alloc(3,2);
663 std::copy(targetCoords,targetCoords+3*2,myCoords->getPointer());
664 targetMesh->setCoords(myCoords);
669 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMesh(double dx)
671 double targetCoords[4]=
673 0.+dx, 1.+dx, 3.+dx, 4.+dx
675 int targetConn[2*3]={1,2, 0,1, 2,3};
677 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("1D mesh",1);
678 targetMesh->allocateCells(3);
680 targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
681 targetMesh->finishInsertingCells();
682 DataArrayDouble *myCoords=DataArrayDouble::New();
683 myCoords->alloc(4,1);
684 std::copy(targetCoords,targetCoords+4,myCoords->getPointer());
685 targetMesh->setCoords(myCoords);
690 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DSourceMesh_2()
692 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DSourceMesh",1);
693 ret->allocateCells(4);
694 int conn[8]={0,1,2,3,1,2,3,4};
696 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
697 ret->finishInsertingCells();
698 double coords[5]={0.3,0.7,0.9,1.0,1.12};
699 DataArrayDouble *myCoords=DataArrayDouble::New();
700 myCoords->alloc(5,1);
701 std::copy(coords,coords+5,myCoords->getPointer());
702 ret->setCoords(myCoords);
707 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_2()
709 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DTargetMesh",1);
710 ret->allocateCells(2);
711 int conn[4]={1,2,0,1};
713 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
714 ret->finishInsertingCells();
715 double coords[3]={0.5,0.75,1.2};
716 DataArrayDouble *myCoords=DataArrayDouble::New();
717 myCoords->alloc(3,1);
718 std::copy(coords,coords+3,myCoords->getPointer());
719 ret->setCoords(myCoords);
724 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveSourceMesh_2()
726 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DSourceMesh",1);
727 ret->allocateCells(4);
728 int conn[8]={0,1,2,3,1,2,3,4};
730 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
731 ret->finishInsertingCells();
732 double coords[10]={0.3,0.3,0.7,0.7,0.9,0.9,1.0,1.0,1.12,1.12};
733 DataArrayDouble *myCoords=DataArrayDouble::New();
734 myCoords->alloc(5,2);
735 std::copy(coords,coords+10,myCoords->getPointer());
736 ret->setCoords(myCoords);
741 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveTargetMesh_2()
743 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DTargetMesh",1);
744 ret->allocateCells(2);
745 int conn[4]={1,2,0,1};
747 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
748 ret->finishInsertingCells();
749 double coords[6]={0.5,0.5,0.75,0.75,1.2,1.2};
750 DataArrayDouble *myCoords=DataArrayDouble::New();
751 myCoords->alloc(3,2);
752 std::copy(coords,coords+6,myCoords->getPointer());
753 ret->setCoords(myCoords);
758 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_3()
760 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DMesh_3",1);
761 ret->allocateCells(4);
762 int conn[10]={0,1,2, 3,4, 6,5,7 ,9,8};
763 ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn);
764 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+3);
765 ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+5);
766 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+8);
767 ret->finishInsertingCells();
768 double coords[10]={0.5,1.,0.8,5.,5.21,0.5,1.1,0.7,5.,5.31};
769 DataArrayDouble *myCoords=DataArrayDouble::New();
770 myCoords->alloc(10,1);
771 std::copy(coords,coords+10,myCoords->getPointer());
772 ret->setCoords(myCoords);
777 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveTargetMesh_3()
779 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("2DCurveMesh_3",1);
780 ret->allocateCells(4);
781 int conn[10]={0,1,2, 3,4, 6,5,7 ,9,8};
782 ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn);
783 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+3);
784 ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+5);
785 ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+8);
786 ret->finishInsertingCells();
787 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};
788 DataArrayDouble *myCoords=DataArrayDouble::New();
789 myCoords->alloc(10,2);
790 std::copy(coords,coords+20,myCoords->getPointer());
791 ret->setCoords(myCoords);
796 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_3()
798 MEDCouplingUMesh *ret=MEDCouplingUMesh::New("2DMesh_3",2);
799 ret->allocateCells(10);
801 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,
802 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
804 ret->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
805 ret->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+3);
806 ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,5,conn+7);
807 ret->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+12);
808 ret->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+18);
809 ret->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+26);
810 ret->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+29);
811 ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,5,conn+33);
812 ret->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+38);
813 ret->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+44);
814 ret->finishInsertingCells();
815 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};
816 DataArrayDouble *myCoords=DataArrayDouble::New();
817 myCoords->alloc(11,2);
818 std::copy(coords,coords+22,myCoords->getPointer());
819 ret->setCoords(myCoords);
821 ret->checkCoherency();
826 * Same as build2DTargetMesh_1 but with more nodes than needed. To check tryToShareSameCoordsPermute method.
828 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_4()
830 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 };
831 int targetConn[18]={0,4,5,1, 1,5,3, 5,6,2, 7,8,5,4, 8,9,6,5};
832 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
833 targetMesh->setMeshDimension(2);
834 targetMesh->allocateCells(5);
835 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
836 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
837 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
838 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
839 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
840 targetMesh->finishInsertingCells();
841 DataArrayDouble *myCoords=DataArrayDouble::New();
842 myCoords->alloc(10,2);
843 std::copy(targetCoords,targetCoords+20,myCoords->getPointer());
844 targetMesh->setCoords(myCoords);
849 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_3()
854 MEDCouplingMultiFields *MEDCouplingBasicsTest::buildMultiFields_1()
856 ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1();
858 ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1();
860 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
861 const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4};
862 const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4};
863 const double vals2[]={5.,6.,7.,8.,9.};
864 const double vals4[]={15.,16.,17.,18.,19.};
866 ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
867 ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer());
868 ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer());
869 ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
870 ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
872 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
873 d0->setInfoOnComponent(0,"c1");
874 d1->setInfoOnComponent(0,"c6");
875 d1_1->setInfoOnComponent(0,"c9");
876 d2->setInfoOnComponent(0,"c5");
877 d4->setInfoOnComponent(0,"c7");
879 ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
882 f0->setTime(0.2,5,6);
884 ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::LINEAR_TIME);
886 std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
888 f1->setStartTime(0.7,7,8);
889 f1->setEndTime(1.2,9,10);
891 ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
894 f2->setTime(1.2,11,12);
895 f2->setEndTime(1.5,13,14);
897 ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
900 f3->setTime(1.7,15,16);
902 ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
907 std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
908 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
909 ParaMEDMEM::MEDCouplingMultiFields *ret=ParaMEDMEM::MEDCouplingMultiFields::New(fs);
927 std::vector<MEDCouplingFieldDouble *> MEDCouplingBasicsTest::buildMultiFields_2()
929 ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1();
931 ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1();
933 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
934 const double vals1[]={0.,1.,2.,3.,4.};
935 const double vals1_1[]={170.,171.,172.,173.,174.};
936 const double vals2[]={5.,6.,7.,8.,9.};
937 const double vals4[]={15.,16.,17.,18.,19.};
939 ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
940 ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer());
941 ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer());
942 ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
943 ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
945 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
946 d0->setInfoOnComponent(0,"c1");
947 d1->setInfoOnComponent(0,"c6");
948 d1_1->setInfoOnComponent(0,"c9");
949 d2->setInfoOnComponent(0,"c5");
950 d4->setInfoOnComponent(0,"c7");
952 ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
955 f0->setTime(0.2,5,6);
957 ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
959 std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
961 f1->setStartTime(0.7,7,8);
962 f1->setEndTime(1.2,9,10);
964 ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
967 f2->setTime(1.2,11,12);
968 f2->setEndTime(1.5,13,14);
970 ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
973 f3->setTime(1.7,15,16);
975 ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
980 std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
981 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
993 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMultiTypes_1()
995 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi1DMesh",1);
996 DataArrayDouble *coo=buildCoordsForMultiTypes_1();
997 const int conn[5]={0,2, 0,2,1};
998 mesh->allocateCells(2);
999 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
1000 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+2);
1001 mesh->finishInsertingCells();
1002 mesh->setCoords(coo);
1007 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DMultiTypes_1()
1009 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi2DMesh",2);
1010 DataArrayDouble *coo=buildCoordsForMultiTypes_1();
1011 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};
1012 mesh->allocateCells(4);
1013 mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
1014 mesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+3);
1015 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+9);
1016 mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+13);
1017 mesh->finishInsertingCells();
1018 mesh->setCoords(coo);
1023 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DMultiTypes_1()
1025 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi3DMesh",3);
1026 DataArrayDouble *coo=buildCoordsForMultiTypes_1();
1027 const int conn[81]={0,16,17,18,
1028 0,16,17,18,19,20,21,22,23,24,
1030 0,11,10,9,25,15,14,13,12,26,27,28,29,
1032 0,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
1033 0,9,10,11,44,45,46,47,
1034 0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 };
1035 mesh->allocateCells(8);
1036 mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
1037 mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn+4);
1038 mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+14);
1039 mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA13,13,conn+19);
1040 mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+32);
1041 mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA15,15,conn+38);
1042 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+53);
1043 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA20,20,conn+61);
1044 mesh->finishInsertingCells();
1045 mesh->setCoords(coo);
1050 DataArrayDouble *MEDCouplingBasicsTest::buildCoordsForMultiTypes_1()
1052 DataArrayDouble *coords=DataArrayDouble::New();
1053 coords->alloc(56,3);
1054 coords->setInfoOnComponent(0,"X (cm)");
1055 coords->setInfoOnComponent(1,"Y (cm)");
1056 coords->setInfoOnComponent(2,"Z (cm)");
1057 const double data[168]={
1068 4.0, 4.0, 0.0, //#10
1069 4.0, 0.0, 0.0, //#11
1070 0.0, 2.0, 0.0, //#12
1071 2.0, 4.0, 0.0, //#13
1072 4.0, 2.0, 0.0, //#14
1073 2.0, 0.0, 0.0, //#15
1074 0.0, 6.0, 0.0, //#16
1075 3.0, 3.0, 0.0, //#17
1076 1.3, 3.0, 3.0, //#18
1077 0.0, 3.0, 0.0, //#19
1078 1.5, 4.5, 0.0, //#20
1079 1.5, 1.5, 0.0, //#21
1080 0.65, 1.5, 1.5, //#22
1081 0.65, 4.5, 1.5, //#23
1082 2.15, 3.0, 1.5, //#24
1083 2.0, 2.0, 2.0, //#25
1084 3.0, 1.0, 1.0, //#26
1085 3.0, 3.0, 1.0, //#27
1086 1.0, 3.0, 1.0, //#28
1087 1.0, 1.0, 1.0, //#29
1088 0.0, 3.0, 0.0, //#30
1089 2.0, 0.0, 0.0, //#31
1090 0.0, 0.0, 6.0, //#32
1091 0.0, 3.0, 6.0, //#33
1092 3.0, 0.0, 6.0, //#34
1093 0.0, 1.5, 0.0, //#35
1094 1.5, 1.5, 0.0, //#36
1095 1.5, 0.0, 0.0, //#37
1096 0.0, 1.5, 6.0, //#38
1097 1.5, 1.5, 6.0, //#39
1098 1.5, 0.0, 6.0, //#40
1099 0.0, 0.0, 3.0, //#41
1100 0.0, 3.0, 3.0, //#42
1101 3.0, 0.0, 3.0, //#43
1102 0.0, 0.0, 4.0, //#44
1103 0.0, 4.0, 4.0, //#45
1104 4.0, 4.0, 4.0, //#46
1105 4.0, 0.0, 4.0, //#47
1106 0.0, 2.0, 4.0, //#48
1107 2.0, 4.0, 4.0, //#49
1108 4.0, 2.0, 4.0, //#50
1109 2.0, 0.0, 4.0, //#51
1110 0.0, 0.0, 2.0, //#52
1111 0.0, 4.0, 2.0, //#53
1112 4.0, 4.0, 2.0, //#54
1115 std::copy(data,data+168,coords->getPointer());
1119 MEDCouplingUMesh *MEDCouplingBasicsTest::buildHexa8Mesh_1()
1121 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Hexa8Only",3);
1122 DataArrayDouble *coo=DataArrayDouble::New();
1123 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};
1125 std::copy(coords,coords+81,coo->getPointer());
1126 const int conn[64]={3,12,13,4,0,9,10,1,
1127 4,13,14,5,1,10,11,2,
1128 6,15,16,7,3,12,13,4,
1129 7,16,17,8,4,13,14,5,
1130 12,21,22,13,9,18,19,10,
1131 13,22,23,14,10,19,20,11,
1132 15,24,25,16,12,21,22,13,
1133 16,25,26,17,13,22,23,14};
1134 mesh->allocateCells(8);
1135 for(int i=0;i<8;i++)
1136 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i);
1137 mesh->finishInsertingCells();
1138 mesh->setCoords(coo);
1143 MEDCouplingUMesh *MEDCouplingBasicsTest::buildPointe_1(MEDCouplingUMesh *& m1)
1145 MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Pointe.med",3);
1146 MEDCouplingUMesh *mesh2=MEDCouplingUMesh::New("Pointe.med",2);
1147 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};
1148 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};
1149 DataArrayDouble *coo=DataArrayDouble::New();
1151 std::copy(coords,coords+57,coo->getPointer());
1152 mesh->setCoords(coo);
1153 mesh2->setCoords(coo);
1155 mesh->allocateCells(16);
1156 for(int i=0;i<12;i++)
1157 mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+4*i);
1158 mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+48);
1159 mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+53);
1160 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+58);
1161 mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+66);
1162 mesh->finishInsertingCells();
1163 //[1,34,29,23,41,32]
1164 const int conn2[20]={0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9};
1165 mesh2->allocateCells(6);
1166 for(int i=0;i<4;i++)
1167 mesh2->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn2+3*i);
1168 mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+12);
1169 mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+16);
1170 mesh2->finishInsertingCells();
1176 double MEDCouplingBasicsTest::sumAll(const std::vector< std::map<int,double> >& matrix)
1179 for(std::vector< std::map<int,double> >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++)
1180 for(std::map<int,double>::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++)
1181 ret+=(*iter2).second;
1185 MEDCouplingUMesh *MEDCouplingBasicsTest::build2D1DSourceMesh()
1187 double sourceCoords[18]={-17., 3., -17., 8., -5., 8.,
1188 -5., 3., -9., 0., -13., 3.,
1189 -9., 8., -7., 0., -7., 8.
1191 int sourceConn[16]={0,1, 1,2, 2,3, 3,0, 3,4, 4,5, 4,6, 7,8};
1192 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1193 sourceMesh->setMeshDimension(1);
1194 sourceMesh->allocateCells(8);
1195 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn);
1196 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+2);
1197 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+4);
1198 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+6);
1199 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+8);
1200 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+10);
1201 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+12);
1202 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+14);
1203 sourceMesh->finishInsertingCells();
1204 DataArrayDouble *myCoords=DataArrayDouble::New();
1205 myCoords->alloc(9,2);
1206 std::copy(sourceCoords,sourceCoords+18,myCoords->getPointer());
1207 sourceMesh->setCoords(myCoords);
1208 myCoords->decrRef();
1212 MEDCouplingUMesh *MEDCouplingBasicsTest::build2D1DTargetMesh()
1214 double targetCoords[10]={-17., 0., -17.,6., -9.,6., -9.,0., -5., 3.};
1215 int targetConn[7]={0,1,2,3, 2,3,4};
1216 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1217 targetMesh->setMeshDimension(2);
1218 targetMesh->allocateCells(2);
1219 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
1220 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,targetConn + 4);
1221 targetMesh->finishInsertingCells();
1222 DataArrayDouble *myCoords=DataArrayDouble::New();
1223 myCoords->alloc(5,2);
1224 std::copy(targetCoords,targetCoords+10,myCoords->getPointer());
1225 targetMesh->setCoords(myCoords);
1226 myCoords->decrRef();
1230 MEDCouplingUMesh* MEDCouplingBasicsTest::build2D1DSegSourceMesh(const double shiftX,
1231 const double inclinationX)
1233 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1234 sourceMesh->setMeshDimension(1);
1237 const int nbYP1 = nbY + 1;
1238 sourceMesh->allocateCells(nbY);
1241 for (int iY = 0; iY < nbY; ++iY)
1243 sourceConn[0] = iY ;
1244 sourceConn[1] = iY + 1;
1245 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn);
1247 sourceMesh->finishInsertingCells();
1249 std::vector<double> sourceCoords;
1250 for (int iY = 0; iY < nbYP1; ++iY)
1252 sourceCoords.push_back(iY * inclinationX + shiftX);
1253 sourceCoords.push_back(iY * 4.);
1255 DataArrayDouble *myCoords=DataArrayDouble::New();
1256 myCoords->alloc(nbYP1,2);
1257 std::copy(sourceCoords.begin(),sourceCoords.end(),myCoords->getPointer());
1258 sourceMesh->setCoords(myCoords);
1259 myCoords->decrRef();
1264 MEDCouplingUMesh* MEDCouplingBasicsTest::build2D1DQuadTargetMesh(const double inclinationX)
1266 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1267 targetMesh->setMeshDimension(2);
1271 const int nbXP1 = nbX + 1;
1272 const int nbYP1 = nbY + 1;
1273 targetMesh->allocateCells(nbX * nbY);
1276 for (int iX = 0; iX < nbX; ++iX)
1278 for (int iY = 0; iY < nbY; ++iY)
1280 targetConn[0] = iY + iX * nbYP1;
1281 targetConn[1] = iY + 1 + iX * nbYP1;
1282 targetConn[2] = iY + 1 + (iX + 1) * nbYP1;
1283 targetConn[3] = iY + (iX + 1) * nbYP1;
1284 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
1287 targetMesh->finishInsertingCells();
1289 std::vector<double> targetCoords;
1290 for (int iX = 0; iX < nbXP1; ++iX)
1292 for (int iY = 0; iY < nbYP1; ++iY)
1294 targetCoords.push_back(iX * 3. + iY * inclinationX);
1295 targetCoords.push_back(iY * 4.);
1298 DataArrayDouble *myCoords=DataArrayDouble::New();
1299 myCoords->alloc(nbXP1 * nbYP1, 2);
1300 std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
1301 targetMesh->setCoords(myCoords);
1302 myCoords->decrRef();
1307 MEDCouplingUMesh* MEDCouplingBasicsTest::build2D1DTriTargetMesh(const double inclinationX)
1309 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1310 targetMesh->setMeshDimension(2);
1314 const int nbXP1 = nbX + 1;
1315 const int nbYP1 = nbY + 1;
1316 targetMesh->allocateCells(nbX * nbY * 2);
1319 for (int iX = 0; iX < nbX; ++iX)
1321 for (int iY = 0; iY < nbY; ++iY)
1323 targetConn[0] = iY + iX * nbYP1;
1324 targetConn[1] = iY + 1 + iX * nbYP1;
1325 targetConn[2] = iY + 1 + (iX + 1) * nbYP1;
1326 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
1327 targetConn[0] = iY + iX * nbYP1;
1328 targetConn[1] = iY + 1 + (iX + 1) * nbYP1;
1329 targetConn[2] = iY + (iX + 1) * nbYP1;
1330 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
1333 targetMesh->finishInsertingCells();
1335 std::vector<double> targetCoords;
1336 for (int iX = 0; iX < nbXP1; ++iX)
1338 for (int iY = 0; iY < nbYP1; ++iY)
1340 targetCoords.push_back(iX * 3. + iY * inclinationX);
1341 targetCoords.push_back(iY * 4.);
1344 DataArrayDouble *myCoords=DataArrayDouble::New();
1345 myCoords->alloc(nbXP1 * nbYP1, 2);
1346 std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
1347 targetMesh->setCoords(myCoords);
1348 myCoords->decrRef();
1353 MEDCouplingUMesh *MEDCouplingBasicsTest::build3D2DSourceMesh()
1355 double sourceCoords[63]={-12., 6., 10., -12.,10., 6., -16.,10. , 10.,
1356 -20., 0., 0., -12., 0., 0., -12., 0. , -4., -20.,0.,-4.,
1357 -20., 0., 10., -12., 0., 10., -20.,10. , 10.,
1358 -25., 5., -5., 5., 5., -5., 5., 5. , 25., -25.,5.,25.,
1359 -20., 0., 16., -18., 0., 16., -20., 2.5, 16.,
1360 -25., 0., -5., 5., 0., -5., 5., 0. , 25., -25.,0.,25.
1362 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};
1363 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1364 sourceMesh->setMeshDimension(2);
1365 sourceMesh->allocateCells(7);
1366 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,sourceConn);
1367 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+3);
1368 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,sourceConn+7);
1369 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+10);
1370 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,sourceConn+14);
1371 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+17);
1372 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+21);
1373 sourceMesh->finishInsertingCells();
1374 DataArrayDouble *myCoords=DataArrayDouble::New();
1375 myCoords->alloc(21,3);
1376 std::copy(sourceCoords,sourceCoords+63,myCoords->getPointer());
1377 sourceMesh->setCoords(myCoords);
1378 myCoords->decrRef();
1382 MEDCouplingUMesh *MEDCouplingBasicsTest::build3D2DTargetMesh()
1384 double targetCoords[45]={-20., 0., 0., -20.,10., 0., -12.,10., 0.,
1385 -12., 0., 0., -20., 0.,10., -20.,10.,10.,
1386 -12.,10.,10., -12., 0.,10., -20., 0.,18.,
1387 -20.,-5.,10., -20.,-5.,-4., -12.,-5.,-4.,
1388 -12.,-5.,10., -20., 0.,-4., -12., 0.,-4.
1390 int targetConn[20]={4,5,7,8, 0,3,2,1,4,7,6,5, 4,13,14,7,9,10,11,12};
1391 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1392 targetMesh->setMeshDimension(3);
1393 targetMesh->allocateCells(3);
1394 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1395 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn + 4);
1396 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn + 12);
1397 targetMesh->finishInsertingCells();
1398 DataArrayDouble *myCoords=DataArrayDouble::New();
1399 myCoords->alloc(15,3);
1400 std::copy(targetCoords,targetCoords+45,myCoords->getPointer());
1401 targetMesh->setCoords(myCoords);
1402 myCoords->decrRef();
1406 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DQuadSourceMesh(const double shiftX,
1407 const double inclinationX)
1409 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1410 sourceMesh->setMeshDimension(2);
1414 const int nbYP1 = nbY + 1;
1415 const int nbZP1 = nbZ + 1;
1416 sourceMesh->allocateCells(nbY * nbZ);
1419 for (int iY = 0; iY < nbY; ++iY)
1421 for (int iZ = 0; iZ < nbZ; ++iZ)
1423 sourceConn[0] = iZ + iY * nbZP1;
1424 sourceConn[1] = iZ + 1 + iY * nbZP1;
1425 sourceConn[2] = iZ + 1 + (iY + 1) * nbZP1;
1426 sourceConn[3] = iZ + (iY + 1) * nbZP1;
1427 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn);
1430 sourceMesh->finishInsertingCells();
1432 std::vector<double> sourceCoords;
1433 for (int iY = 0; iY < nbYP1; ++iY)
1435 for (int iZ = 0; iZ < nbZP1; ++iZ)
1437 sourceCoords.push_back(iY * inclinationX + shiftX);
1438 sourceCoords.push_back(iY * 4.);
1439 sourceCoords.push_back(iZ * 3.);
1443 DataArrayDouble *myCoords=DataArrayDouble::New();
1444 myCoords->alloc(nbYP1 * nbZP1,3);
1445 std::copy(sourceCoords.begin(),sourceCoords.end(),myCoords->getPointer());
1446 sourceMesh->setCoords(myCoords);
1447 myCoords->decrRef();
1452 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DTriSourceMesh(const double shiftX,
1453 const double inclinationX)
1455 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1456 sourceMesh->setMeshDimension(2);
1460 const int nbYP1 = nbY + 1;
1461 const int nbZP1 = nbZ + 1;
1462 sourceMesh->allocateCells(nbY * nbZ * 2);
1465 for (int iY = 0; iY < nbY; ++iY)
1467 for (int iZ = 0; iZ < nbZ; ++iZ)
1469 sourceConn[0] = iZ + iY * nbZP1;
1470 sourceConn[1] = iZ + 1 + iY * nbZP1;
1471 sourceConn[2] = iZ + 1 + (iY + 1) * nbZP1;
1472 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
1473 sourceConn[0] = iZ + iY * nbZP1;
1474 sourceConn[1] = iZ + (iY + 1) * nbZP1;
1475 sourceConn[2] = iZ + 1 + (iY + 1) * nbZP1;
1476 sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
1479 sourceMesh->finishInsertingCells();
1481 std::vector<double> sourceCoords;
1482 for (int iY = 0; iY < nbYP1; ++iY)
1484 for (int iZ = 0; iZ < nbZP1; ++iZ)
1486 sourceCoords.push_back(iY * inclinationX + shiftX);
1487 sourceCoords.push_back(iY * 4.);
1488 sourceCoords.push_back(iZ * 3.);
1492 DataArrayDouble *myCoords=DataArrayDouble::New();
1493 myCoords->alloc(nbYP1 * nbZP1,3);
1494 std::copy(sourceCoords.begin(),sourceCoords.end(),myCoords->getPointer());
1495 sourceMesh->setCoords(myCoords);
1496 myCoords->decrRef();
1501 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DHexaTargetMesh(const double inclinationX)
1503 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1504 targetMesh->setMeshDimension(3);
1509 const int nbXP1 = nbX + 1;
1510 const int nbYP1 = nbY + 1;
1511 const int nbZP1 = nbZ + 1;
1512 targetMesh->allocateCells(nbX * nbY * nbZ);
1515 for (int iX = 0; iX < nbX; ++iX)
1517 for (int iY = 0; iY < nbY; ++iY)
1519 for (int iZ = 0; iZ < nbZ; ++iZ)
1521 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1522 targetConn[1] = iZ + 1 + ( iY + iX * nbYP1) * nbZP1;
1523 targetConn[2] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1524 targetConn[3] = iZ + ((iY + 1) + iX * nbYP1) * nbZP1;
1525 targetConn[4] = iZ + ( iY + (iX + 1) * nbYP1) * nbZP1;
1526 targetConn[5] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1527 targetConn[6] = iZ + 1 + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1528 targetConn[7] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1529 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn);
1533 targetMesh->finishInsertingCells();
1535 std::vector<double> targetCoords;
1536 for (int iX = 0; iX < nbXP1; ++iX)
1538 for (int iY = 0; iY < nbYP1; ++iY)
1540 for (int iZ = 0; iZ < nbZP1; ++iZ)
1542 targetCoords.push_back(iX * 3. + iY * inclinationX);
1543 targetCoords.push_back(iY * 4.);
1544 targetCoords.push_back(iZ * 3.);
1548 DataArrayDouble *myCoords=DataArrayDouble::New();
1549 myCoords->alloc(nbXP1 * nbYP1 * nbZP1, 3);
1550 std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
1551 targetMesh->setCoords(myCoords);
1552 myCoords->decrRef();
1557 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DTetraTargetMesh(const double inclinationX)
1559 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1560 targetMesh->setMeshDimension(3);
1565 const int nbXP1 = nbX + 1;
1566 const int nbYP1 = nbY + 1;
1567 const int nbZP1 = nbZ + 1;
1568 targetMesh->allocateCells(nbX * nbY * nbZ * 5);
1571 for (int iX = 0; iX < nbX; ++iX)
1573 for (int iY = 0; iY < nbY; ++iY)
1575 for (int iZ = 0; iZ < nbZ; ++iZ)
1577 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1578 targetConn[1] = iZ + 1 + ( iY + iX * nbYP1) * nbZP1;
1579 targetConn[2] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1580 targetConn[3] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1581 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1582 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1583 targetConn[1] = iZ + ( iY + (iX + 1) * nbYP1) * nbZP1;
1584 targetConn[2] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1585 targetConn[3] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1586 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1587 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1588 targetConn[1] = iZ + ((iY + 1) + iX * nbYP1) * nbZP1;
1589 targetConn[2] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1590 targetConn[3] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1591 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1592 targetConn[0] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1593 targetConn[1] = iZ + 1 + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1594 targetConn[2] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1595 targetConn[3] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1596 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1597 targetConn[0] = iZ + ( iY + iX * nbYP1) * nbZP1;
1598 targetConn[1] = iZ + 1 + ((iY + 1) + iX * nbYP1) * nbZP1;
1599 targetConn[2] = iZ + 1 + ( iY + (iX + 1) * nbYP1) * nbZP1;
1600 targetConn[3] = iZ + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
1601 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
1605 targetMesh->finishInsertingCells();
1607 std::vector<double> targetCoords;
1608 for (int iX = 0; iX < nbXP1; ++iX)
1610 for (int iY = 0; iY < nbYP1; ++iY)
1612 for (int iZ = 0; iZ < nbZP1; ++iZ)
1614 targetCoords.push_back(iX * 3. + iY * inclinationX);
1615 targetCoords.push_back(iY * 4.);
1616 targetCoords.push_back(iZ * 3.);
1620 DataArrayDouble *myCoords=DataArrayDouble::New();
1621 myCoords->alloc(nbXP1 * nbYP1 * nbZP1, 3);
1622 std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
1623 targetMesh->setCoords(myCoords);
1624 myCoords->decrRef();
1629 int MEDCouplingBasicsTest::countNonZero(const std::vector< std::map<int,double> >& matrix)
1632 for(std::vector< std::map<int,double> >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++)
1633 for(std::map<int,double>::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++)
1634 if (!INTERP_KERNEL::epsilonEqual((*iter2).second, 0.)) ret +=1;
1638 void MEDCouplingBasicsTest::test2D1DMeshesIntersection(MEDCouplingUMesh *sourceMesh,
1639 MEDCouplingUMesh *targetMesh,
1640 const double correctLength,
1641 const int correctDuplicateFacesNbr,
1642 const int correctTotalIntersectFacesNbr)
1644 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
1645 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1646 INTERP_KERNEL::Interpolation2D1D myInterpolator;
1647 myInterpolator.setPrecision(1e-12);
1648 const double prec = 1.0e-5;
1649 IntersectionMatrix matrix;
1650 myInterpolator.setIntersectionType(INTERP_KERNEL::Geometric2D);
1651 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
1653 std::cout.precision(16);
1655 const double length = sumAll(matrix);
1656 LOG(1, "length = " << surf <<" correctLength = " << correctLength );
1657 CPPUNIT_ASSERT_DOUBLES_EQUAL(correctLength, length, prec * std::max(correctLength, length));
1659 INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
1660 int duplicateFacesNbr = duplicateFaces.size();
1661 LOG(1, "duplicateFacesNbr = " << duplicateFacesNbr <<" correctDuplicateFacesNbr = " << correctDuplicateFacesNbr);
1662 CPPUNIT_ASSERT_EQUAL(correctDuplicateFacesNbr, duplicateFacesNbr);
1664 if (correctTotalIntersectFacesNbr >= 0)
1666 int totalIntersectFacesNbr = countNonZero(matrix);
1667 LOG(1, "totalIntersectFacesNbr = " << totalIntersectFacesNbr <<" correctTotalIntersectFacesNbr = " << correctTotalIntersectFacesNbr );
1668 CPPUNIT_ASSERT_EQUAL(correctTotalIntersectFacesNbr, totalIntersectFacesNbr);
1671 sourceMesh->decrRef();
1672 targetMesh->decrRef();
1675 void MEDCouplingBasicsTest::test3D2DMeshesIntersection(MEDCouplingUMesh *sourceMesh,
1676 MEDCouplingUMesh *targetMesh,
1677 const double correctSurf,
1678 const int correctDuplicateFacesNbr,
1679 const int correctTotalIntersectFacesNbr)
1681 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1682 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1683 INTERP_KERNEL::Interpolation3D2D myInterpolator;
1684 myInterpolator.setPrecision(1e-12);
1685 const double prec = 1.0e-5;
1686 IntersectionMatrix matrix;
1687 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1688 for ( size_t i = 0; i < sizeof(sp)/sizeof(sp[0]); ++i )
1690 myInterpolator.setSplittingPolicy( sp[i] );
1692 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
1694 std::cout.precision(16);
1696 const double surf = sumAll(matrix);
1697 LOG(1, "surf = " << surf <<" correctSurf = " << correctSurf );
1698 CPPUNIT_ASSERT_DOUBLES_EQUAL(correctSurf, surf, prec * std::max(correctSurf, surf));
1700 INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
1701 int duplicateFacesNbr = duplicateFaces.size();
1702 LOG(1, "duplicateFacesNbr = " << duplicateFacesNbr <<" correctDuplicateFacesNbr = " << correctDuplicateFacesNbr);
1703 CPPUNIT_ASSERT_EQUAL(correctDuplicateFacesNbr, duplicateFacesNbr);
1705 if (correctTotalIntersectFacesNbr >= 0)
1707 int totalIntersectFacesNbr = countNonZero(matrix);
1708 LOG(1, "totalIntersectFacesNbr = " << totalIntersectFacesNbr <<" correctTotalIntersectFacesNbr = " << correctTotalIntersectFacesNbr );
1709 CPPUNIT_ASSERT_EQUAL(correctTotalIntersectFacesNbr, totalIntersectFacesNbr);
1713 sourceMesh->decrRef();
1714 targetMesh->decrRef();