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 "MEDCouplingBasicsTestInterp.hxx"
21 #include "MEDCouplingUMesh.hxx"
22 #include "MEDCouplingExtrudedMesh.hxx"
23 #include "MEDCouplingFieldDouble.hxx"
24 #include "MEDCouplingMemArray.hxx"
25 #include "Interpolation2D.txx"
26 #include "Interpolation3DSurf.hxx"
27 #include "Interpolation3D.txx"
28 #include "Interpolation2D1D.txx"
29 #include "Interpolation3D2D.txx"
30 #include "InterpolationCC.txx"
31 #include "InterpolationCU.txx"
32 #include "Interpolation2DCurve.hxx"
33 #include "Interpolation1D.txx"
35 #include "MEDCouplingNormalizedUnstructuredMesh.txx"
36 #include "MEDCouplingNormalizedCartesianMesh.txx"
41 using namespace ParaMEDMEM;
43 typedef std::vector<std::map<int,double> > IntersectionMatrix;
45 void MEDCouplingBasicsTestInterp::test2DInterpP0P0_1()
47 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
48 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
50 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
51 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
52 INTERP_KERNEL::Interpolation2D myInterpolator;
53 std::vector<std::map<int,double> > res;
54 INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Convex, INTERP_KERNEL::Geometric2D};
57 myInterpolator.setPrecision(1e-12);
58 myInterpolator.setIntersectionType(types[i]);
59 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
60 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
61 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][0],1e-12);
62 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
63 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
64 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12);
65 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][1],1e-12);
66 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][0],1e-12);
67 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][1],1e-12);
68 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
72 sourceMesh->decrRef();
73 targetMesh->decrRef();
76 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_1()
78 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
79 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
81 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
82 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
83 INTERP_KERNEL::Interpolation2D myInterpolator;
84 std::vector<std::map<int,double> > res;
86 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
87 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
88 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
89 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
90 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
91 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
92 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
93 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
94 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
95 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
96 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
98 sourceMesh->decrRef();
99 targetMesh->decrRef();
102 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_2()
104 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
105 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
107 std::vector<int> cellsIds(targetMesh->getNumberOfCells());
108 for(int i=0;i<targetMesh->getNumberOfCells();i++)
110 targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
112 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
113 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
114 INTERP_KERNEL::Interpolation2D myInterpolator;
115 std::vector<std::map<int,double> > res;
117 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
118 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
119 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
120 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
121 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
122 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
123 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
124 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
125 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
126 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
127 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
129 sourceMesh->decrRef();
130 targetMesh->decrRef();
133 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_3()
135 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
136 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
138 std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
139 for(int i=0;i<sourceMesh->getNumberOfCells();i++)
141 sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
143 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
144 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
145 INTERP_KERNEL::Interpolation2D myInterpolator;
146 std::vector<std::map<int,double> > res;
148 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
149 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
150 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
151 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
152 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
153 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
154 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
155 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
156 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
157 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
158 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
160 sourceMesh->decrRef();
161 targetMesh->decrRef();
164 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_4()
166 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
167 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
169 std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
170 for(int i=0;i<sourceMesh->getNumberOfCells();i++)
172 sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
173 cellsIds.resize(targetMesh->getNumberOfCells());
174 for(int i=0;i<targetMesh->getNumberOfCells();i++)
176 targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
178 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
179 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
180 INTERP_KERNEL::Interpolation2D myInterpolator;
181 std::vector<std::map<int,double> > res;
183 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
184 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
185 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
186 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
187 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
188 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
189 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
190 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
191 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
192 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
193 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
195 sourceMesh->decrRef();
196 targetMesh->decrRef();
199 void MEDCouplingBasicsTestInterp::test2DInterpP0P1_1()
201 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
202 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
204 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
205 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
206 INTERP_KERNEL::Interpolation2D myInterpolator;
207 std::vector<std::map<int,double> > res;
208 INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
211 myInterpolator.setPrecision(1e-12);
212 myInterpolator.setIntersectionType(types[i]);
213 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
214 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
215 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][0],1e-12);
216 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][1],1e-12);
217 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
218 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[2][0],1e-12);
219 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[3][1],1e-12);
220 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][0],1e-12);
221 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][1],1e-12);
222 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[5][0],1e-12);
223 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[6][1],1e-12);
224 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[7][1],1e-12);
225 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][0],1e-12);
226 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][1],1e-12);
227 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,sumAll(res),1e-12);
231 sourceMesh->decrRef();
232 targetMesh->decrRef();
235 void MEDCouplingBasicsTestInterp::test2DInterpP0P1PL_1()
237 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
238 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
240 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
241 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
242 INTERP_KERNEL::Interpolation2D myInterpolator;
243 std::vector<std::map<int,double> > res;
244 myInterpolator.setPrecision(1e-12);
245 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
246 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
247 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
248 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
249 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
250 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
251 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
252 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
253 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
254 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
255 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12);
256 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12);
257 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
258 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12);
259 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12);
260 CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12);
263 sourceMesh->decrRef();
264 targetMesh->decrRef();
267 void MEDCouplingBasicsTestInterp::test2DInterpP0P1PL_2()
269 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
270 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
272 std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
273 for(int i=0;i<sourceMesh->getNumberOfCells();i++)
275 sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
277 cellsIds.resize(targetMesh->getNumberOfCells());
278 for(int i=0;i<targetMesh->getNumberOfCells();i++)
280 targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
282 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
283 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
284 INTERP_KERNEL::Interpolation2D myInterpolator;
285 std::vector<std::map<int,double> > res;
286 myInterpolator.setPrecision(1e-12);
287 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
288 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
289 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
290 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
291 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
292 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
293 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
294 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
295 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
296 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
297 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12);
298 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12);
299 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
300 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12);
301 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12);
302 CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12);
305 sourceMesh->decrRef();
306 targetMesh->decrRef();
309 void MEDCouplingBasicsTestInterp::test2DInterpP1P0_1()
311 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
312 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
314 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
315 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
316 INTERP_KERNEL::Interpolation2D myInterpolator;
317 std::vector<std::map<int,double> > res;
318 INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
321 myInterpolator.setPrecision(1e-12);
322 myInterpolator.setIntersectionType(types[i]);
323 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
324 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
325 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
326 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[1][0],1e-12);
327 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][0],1e-12);
328 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[1][1],1e-12);
329 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[2][1],1e-12);
330 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667,res[3][2],1e-12);
331 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[2][3],1e-12);
332 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][3],1e-12);
333 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][3],1e-12);
334 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
338 sourceMesh->decrRef();
339 targetMesh->decrRef();
342 void MEDCouplingBasicsTestInterp::test2DInterpP1P0PL_1()
344 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
345 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
347 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
348 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
349 INTERP_KERNEL::Interpolation2D myInterpolator;
350 std::vector<std::map<int,double> > res;
351 myInterpolator.setPrecision(1e-12);
352 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
353 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
354 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
355 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12);
356 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12);
357 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12);
358 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12);
359 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12);
360 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
361 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12);
362 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12);
363 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
364 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12);
365 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
366 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12);
367 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12);
368 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12);
369 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12);
370 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12);
371 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12);
372 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
375 sourceMesh->decrRef();
376 targetMesh->decrRef();
379 void MEDCouplingBasicsTestInterp::test2DInterpP1P0PL_2()
381 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
382 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
384 std::vector<int >cellsIds(targetMesh->getNumberOfCells());
385 for(int i=0;i<targetMesh->getNumberOfCells();i++)
387 targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
389 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
390 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
391 INTERP_KERNEL::Interpolation2D myInterpolator;
392 std::vector<std::map<int,double> > res;
393 myInterpolator.setPrecision(1e-12);
394 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
395 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
396 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
397 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12);
398 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12);
399 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12);
400 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12);
401 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12);
402 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
403 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12);
404 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12);
405 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
406 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12);
407 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
408 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12);
409 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12);
410 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12);
411 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12);
412 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12);
413 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12);
414 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
417 sourceMesh->decrRef();
418 targetMesh->decrRef();
421 void MEDCouplingBasicsTestInterp::test2DInterpP1P1_1()
423 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
424 MEDCouplingUMesh *targetMesh=build2DTargetMesh_2();
426 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
427 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
428 INTERP_KERNEL::Interpolation2D myInterpolator;
429 std::vector<std::map<int,double> > res;
430 INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
433 myInterpolator.setPrecision(1e-12);
434 myInterpolator.setIntersectionType(types[i]);
435 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
436 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
437 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334,res[0][0],1.e-12);
438 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665,res[1][0],1.e-12);
439 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666,res[1][1],1.e-12);
440 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334,res[2][1],1.e-12);
441 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665,res[3][0],1.e-12);
442 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666668,res[3][2],1.e-12);
443 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1416666666666666,res[4][0],1.e-12);
444 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999,res[4][1],1.e-12);
445 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999,res[4][2],1.e-12);
446 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09999999999999999,res[4][3],1.e-12);
447 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666,res[5][1],1.e-12);
448 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333333,res[5][3],1.e-12);
449 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333333,res[6][2],1.e-12);
450 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666667,res[7][2],1.e-12);
451 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333331,res[7][3],1.e-12);
452 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04166666666666668,res[8][3],1.e-12);
456 sourceMesh->decrRef();
457 targetMesh->decrRef();
460 void MEDCouplingBasicsTestInterp::test2DInterpP1P1PL_1()
462 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
463 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
465 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
466 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
467 INTERP_KERNEL::Interpolation2D myInterpolator;
468 std::vector<std::map<int,double> > res;
469 myInterpolator.setPrecision(1e-12);
470 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
471 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
472 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
473 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[0][0],1.e-12);
474 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1.e-12);
475 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][1],1.e-12);
476 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[2][1],1.e-12);
477 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1.e-12);
478 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1.e-12);
479 CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][0],1.e-12);
480 CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][3],1.e-12);
481 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1.e-12);
482 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][3],1.e-12);
483 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][2],1.e-12);
484 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1.e-12);
485 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1.e-12);
486 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[8][3],1.e-12);
487 CPPUNIT_ASSERT_DOUBLES_EQUAL(25.,sumAll(res),1e-12);
490 sourceMesh->decrRef();
491 targetMesh->decrRef();
494 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_1()
496 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
497 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
499 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
500 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
501 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
502 std::vector<std::map<int,double> > res;
503 INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
506 myInterpolator.setPrecision(1e-12);
507 myInterpolator.setIntersectionType(types[i]);
508 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
509 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
510 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
511 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
512 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
513 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
514 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
515 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
516 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
517 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
521 sourceMesh->decrRef();
522 targetMesh->decrRef();
525 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0PL_1()
527 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
528 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
530 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
531 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
532 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
533 std::vector<std::map<int,double> > res;
534 myInterpolator.setPrecision(1e-12);
535 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
536 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
537 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
538 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
539 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
540 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
541 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
542 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
543 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
544 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
545 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
548 sourceMesh->decrRef();
549 targetMesh->decrRef();
552 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P1_1()
554 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
555 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
557 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
558 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
559 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
560 std::vector<std::map<int,double> > res;
561 INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
564 myInterpolator.setPrecision(1e-12);
565 myInterpolator.setIntersectionType(types[i]);
566 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
567 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
568 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][0],1e-12);
569 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][1],1e-12);
570 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
571 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2.),res[2][0],1e-12);
572 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[3][1],1e-12);
573 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][0],1e-12);
574 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][1],1e-12);
575 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[5][0],1e-12);
576 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2.),res[6][1],1e-12);
577 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[7][1],1e-12);
578 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[8][0],1e-12);
579 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[8][1],1e-12);
580 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25*sqrt(2.),sumAll(res),1e-12);
584 sourceMesh->decrRef();
585 targetMesh->decrRef();
588 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P1PL_1()
590 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
591 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
593 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
594 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
595 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
596 std::vector<std::map<int,double> > res;
597 myInterpolator.setPrecision(1e-12);
598 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
599 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
600 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
601 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
602 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
603 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
604 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
605 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
606 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
607 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
608 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12);
609 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12);
610 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
611 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12);
612 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12);
613 CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12);
616 sourceMesh->decrRef();
617 targetMesh->decrRef();
620 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0_1()
622 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
623 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
625 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
626 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
627 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
628 std::vector<std::map<int,double> > res;
629 INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
632 myInterpolator.setPrecision(1e-12);
633 myInterpolator.setIntersectionType(types[i]);
634 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
635 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
636 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
637 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[1][0],1e-12);
638 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[3][0],1e-12);
639 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2.),res[1][1],1e-12);
640 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2.),res[2][1],1e-12);
641 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667*sqrt(2.),res[3][2],1e-12);
642 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[2][3],1e-12);
643 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[3][3],1e-12);
644 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[4][3],1e-12);
645 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
649 sourceMesh->decrRef();
650 targetMesh->decrRef();
653 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0PL_1()
655 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
656 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
658 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
659 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
660 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
661 std::vector<std::map<int,double> > res;
662 myInterpolator.setPrecision(1e-12);
663 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
664 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
665 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
666 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12);
667 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12);
668 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12);
669 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12);
670 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12);
671 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
672 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12);
673 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12);
674 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
675 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12);
676 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
677 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12);
678 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12);
679 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12);
680 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12);
681 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12);
682 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12);
683 CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
686 sourceMesh->decrRef();
687 targetMesh->decrRef();
690 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P1_1()
692 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
693 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_2();
695 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
696 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
697 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
698 std::vector<std::map<int,double> > res;
699 INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
702 myInterpolator.setPrecision(1e-12);
703 myInterpolator.setIntersectionType(types[i]);
704 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
705 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
706 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334*sqrt(2.),res[0][0],1.e-12);
707 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665*sqrt(2.),res[1][0],1.e-12);
708 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666*sqrt(2.),res[1][1],1.e-12);
709 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334*sqrt(2.),res[2][1],1.e-12);
710 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665*sqrt(2.),res[3][0],1.e-12);
711 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666668*sqrt(2.),res[3][2],1.e-12);
712 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1416666666666666*sqrt(2.),res[4][0],1.e-12);
713 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999*sqrt(2.),res[4][1],1.e-12);
714 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999*sqrt(2.),res[4][2],1.e-12);
715 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09999999999999999*sqrt(2.),res[4][3],1.e-12);
716 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666*sqrt(2.),res[5][1],1.e-12);
717 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333333*sqrt(2.),res[5][3],1.e-12);
718 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333333*sqrt(2.),res[6][2],1.e-12);
719 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666667*sqrt(2.),res[7][2],1.e-12);
720 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333331*sqrt(2.),res[7][3],1.e-12);
721 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04166666666666668*sqrt(2.),res[8][3],1.e-12);
725 sourceMesh->decrRef();
726 targetMesh->decrRef();
729 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P1PL_1()
731 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
732 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
734 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
735 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
736 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
737 std::vector<std::map<int,double> > res;
738 myInterpolator.setPrecision(1e-12);
739 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
740 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
741 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
742 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[0][0],1.e-12);
743 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1.e-12);
744 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][1],1.e-12);
745 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[2][1],1.e-12);
746 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1.e-12);
747 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1.e-12);
748 CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][0],1.e-12);
749 CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][3],1.e-12);
750 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1.e-12);
751 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][3],1.e-12);
752 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][2],1.e-12);
753 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1.e-12);
754 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1.e-12);
755 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[8][3],1.e-12);
756 CPPUNIT_ASSERT_DOUBLES_EQUAL(25.,sumAll(res),1e-12);
759 sourceMesh->decrRef();
760 targetMesh->decrRef();
763 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_2()
765 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
766 MEDCouplingUMesh *targetMesh=build3DSurfTargetMeshPerm_1();
768 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
769 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
770 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
771 std::vector<std::map<int,double> > res;
772 myInterpolator.setPrecision(1e-12);
773 myInterpolator.setIntersectionType(INTERP_KERNEL::Triangulation);
775 myInterpolator.setOrientation(2);
776 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
777 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
778 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
779 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
780 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
781 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
782 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
783 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
784 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
785 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
789 myInterpolator.setOrientation(0);
790 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
791 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
792 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
793 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
794 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
795 CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.125*sqrt(2.),res[2][0],1e-12);
796 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
797 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
798 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
799 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75*sqrt(2.),sumAll(res),1e-12);
803 myInterpolator.setOrientation(1);
804 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
805 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
806 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
807 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
808 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
809 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
810 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
811 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
812 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.875*sqrt(2.),sumAll(res),1e-12);
816 myInterpolator.setOrientation(-1);
817 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
818 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
819 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
820 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),sumAll(res),1e-12);
824 sourceMesh->decrRef();
825 targetMesh->decrRef();
829 * Test of precision option implemented by Fabien that represents distance of "barycenter" to the other cell.
831 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_3()
833 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
834 std::vector<std::map<int,double> > res;
835 double vecTrans[3]={0.,0.,1.e-10};
836 double vec[3]={0.,-1.,0.};
837 double pt[3]={-0.3,-0.3,5.e-11};
839 const double deltaA=M_PI/N;
840 myInterpolator.setPrecision(1e-12);
841 myInterpolator.setIntersectionType(INTERP_KERNEL::Triangulation);
842 myInterpolator.setMaxDistance3DSurfIntersect(1e-9);
846 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2();
847 sourceMesh->rotate(pt,vec,i*deltaA);
848 MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2();
849 targetMesh->translate(vecTrans);
850 targetMesh->rotate(pt,vec,i*deltaA);
851 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
852 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
853 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
854 CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
855 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
856 sourceMesh->decrRef();
857 targetMesh->decrRef();
860 myInterpolator.setMaxDistance3DSurfIntersect(1e-11);
864 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2();
865 sourceMesh->rotate(pt,vec,i*deltaA);
866 MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2();
867 targetMesh->translate(vecTrans);
868 targetMesh->rotate(pt,vec,i*deltaA);
869 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
870 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
871 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
872 CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
873 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sumAll(res),1e-12);
874 sourceMesh->decrRef();
875 targetMesh->decrRef();
879 myInterpolator.setMaxDistance3DSurfIntersect(-1.);//unactivate fabien lookup
880 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2();
881 MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2();
882 targetMesh->translate(vecTrans);
883 myInterpolator.setBoundingBoxAdjustment(1e-11);
884 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper0(sourceMesh);
885 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper0(targetMesh);
886 myInterpolator.interpolateMeshes(sourceWrapper0,targetWrapper0,res,"P0P0");
887 CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
888 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sumAll(res),1e-12);
889 sourceMesh->decrRef();
890 targetMesh->decrRef();
893 sourceMesh=build3DSurfSourceMesh_2();
894 targetMesh=build3DSurfSourceMesh_2();
895 targetMesh->translate(vecTrans);
896 myInterpolator.setBoundingBoxAdjustment(1e-9);
897 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper1(sourceMesh);
898 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper1(targetMesh);
899 myInterpolator.interpolateMeshes(sourceWrapper1,targetWrapper1,res,"P0P0");
900 CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
901 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
902 sourceMesh->decrRef();
903 targetMesh->decrRef();
904 //keeping the same bbox adj == 1.e-11 but trying rotation
906 sourceMesh=build3DSurfSourceMesh_2();
907 sourceMesh->rotate(pt,vec,M_PI/4.);
908 targetMesh=build3DSurfSourceMesh_2();
909 targetMesh->translate(vecTrans);
910 targetMesh->rotate(pt,vec,M_PI/4.);
911 myInterpolator.setBoundingBoxAdjustment(1e-11);
912 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper2(sourceMesh);
913 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper2(targetMesh);
914 myInterpolator.interpolateMeshes(sourceWrapper2,targetWrapper2,res,"P0P0");
915 CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
916 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
917 sourceMesh->decrRef();
918 targetMesh->decrRef();
921 void MEDCouplingBasicsTestInterp::test3DInterpP0P0_1()
923 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
924 MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
926 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
927 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
928 INTERP_KERNEL::Interpolation3D myInterpolator;
929 std::vector<std::map<int,double> > res;
930 myInterpolator.setPrecision(1e-12);
931 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
932 for ( int i = 0; i < 4; ++i )
934 myInterpolator.setSplittingPolicy( sp[i] );
936 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
937 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
938 CPPUNIT_ASSERT_DOUBLES_EQUAL(8.e6,sumAll(res),1e-7);
939 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][0],1e-7);
940 CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[0][6],1e-7);
941 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][7],1e-7);
942 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][8],1e-7);
943 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][10],1e-7);
944 CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[1][2],1e-7);
945 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][7],1e-7);
946 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][8],1e-7);
947 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[2][0],1e-7);
948 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][5],1e-7);
949 CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[2][6],1e-7);
950 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][9],1e-7);
951 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][11],1e-7);
952 CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][0],1e-7);
953 CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][2],1e-7);
954 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[3][3],1e-7);
955 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][5],1e-7);
956 CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][8],1e-7);
957 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][1],1e-7);
958 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][4],1e-7);
959 CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[4][6],1e-7);
960 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][9],1e-7);
961 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[4][10],1e-7);
962 CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][2],1e-7);
963 CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[5][3],1e-7);
964 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[5][4],1e-7);
965 CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][7],1e-7);
966 CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][10],1e-7);
967 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][1],1e-7);
968 CPPUNIT_ASSERT_DOUBLES_EQUAL(250000,res[6][6],1e-7);
969 CPPUNIT_ASSERT_DOUBLES_EQUAL(541666.6666666667,res[6][9],1e-7);
970 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][11],1e-7);
971 CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][0],1e-7);
972 CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][1],1e-7);
973 CPPUNIT_ASSERT_DOUBLES_EQUAL(333333.3333333333,res[7][2],1e-7);
974 CPPUNIT_ASSERT_DOUBLES_EQUAL(624999.9999999997,res[7][3],1e-7);
975 CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][4],1e-7);
976 CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][5],1e-7);
977 CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][6],1e-7);
978 CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][7],1e-7);
979 CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][8],1e-7);
980 CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][9],1e-7);
981 CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][10],1e-7);
982 CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][11],1e-7);
985 sourceMesh->decrRef();
986 targetMesh->decrRef();
989 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_1()
991 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
992 MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
994 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
995 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
996 INTERP_KERNEL::Interpolation3D myInterpolator;
997 std::vector<std::map<int,double> > res;
998 myInterpolator.setPrecision(1e-12);
999 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1000 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1001 for ( int i = 0; i < 4; ++i )
1003 myInterpolator.setSplittingPolicy( sp[i] );
1005 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1006 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1007 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
1008 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
1009 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
1010 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
1011 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
1012 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
1013 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
1014 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
1015 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1016 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
1017 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
1018 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
1019 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
1020 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
1021 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
1022 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
1023 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
1024 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1025 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
1026 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
1027 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1028 CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1031 sourceMesh->decrRef();
1032 targetMesh->decrRef();
1035 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_2()
1037 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1038 MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1039 std::vector<int> cellsIds(targetMesh->getNumberOfCells());
1040 for(int i=0;i<targetMesh->getNumberOfCells();i++)
1042 targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
1044 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1045 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1046 INTERP_KERNEL::Interpolation3D myInterpolator;
1047 std::vector<std::map<int,double> > res;
1048 myInterpolator.setPrecision(1e-12);
1049 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1050 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1051 for ( int i = 0; i < 4; ++i )
1053 myInterpolator.setSplittingPolicy( sp[i] );
1055 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1056 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1057 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
1058 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
1059 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
1060 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
1061 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
1062 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
1063 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
1064 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
1065 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1066 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
1067 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
1068 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
1069 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
1070 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
1071 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
1072 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
1073 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
1074 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1075 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
1076 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
1077 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1078 CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1081 sourceMesh->decrRef();
1082 targetMesh->decrRef();
1085 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_3()
1087 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1088 MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1089 std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
1090 for(int i=0;i<sourceMesh->getNumberOfCells();i++)
1092 sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
1094 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1095 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1096 INTERP_KERNEL::Interpolation3D myInterpolator;
1097 std::vector<std::map<int,double> > res;
1098 myInterpolator.setPrecision(1e-12);
1099 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1100 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1101 for ( int i = 0; i < 4; ++i )
1103 myInterpolator.setSplittingPolicy( sp[i] );
1105 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1106 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1107 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
1108 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
1109 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
1110 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
1111 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
1112 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
1113 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
1114 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
1115 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1116 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
1117 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
1118 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
1119 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
1120 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
1121 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
1122 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
1123 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
1124 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1125 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
1126 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
1127 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1128 CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1131 sourceMesh->decrRef();
1132 targetMesh->decrRef();
1135 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_4()
1137 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1138 MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1139 std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
1140 for(int i=0;i<sourceMesh->getNumberOfCells();i++)
1142 sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
1143 cellsIds.resize(targetMesh->getNumberOfCells());
1144 for(int j=0;j<targetMesh->getNumberOfCells();j++)
1146 targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
1148 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1149 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1150 INTERP_KERNEL::Interpolation3D myInterpolator;
1151 std::vector<std::map<int,double> > res;
1152 myInterpolator.setPrecision(1e-12);
1153 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1154 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1155 for ( int i = 0; i < 4; ++i )
1157 myInterpolator.setSplittingPolicy( sp[i] );
1159 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1160 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1161 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
1162 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
1163 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
1164 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
1165 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
1166 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
1167 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
1168 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
1169 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1170 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
1171 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
1172 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
1173 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
1174 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
1175 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
1176 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
1177 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
1178 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1179 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
1180 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
1181 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1182 CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1185 sourceMesh->decrRef();
1186 targetMesh->decrRef();
1189 void MEDCouplingBasicsTestInterp::test3DInterpP0P1_1()
1191 MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
1192 MEDCouplingUMesh *targetMesh=build3DSourceMesh_1();
1194 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1195 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1196 INTERP_KERNEL::Interpolation3D myInterpolator;
1197 std::vector<std::map<int,double> > res;
1198 myInterpolator.setPrecision(1e-12);
1199 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1200 for ( int i = 0; i < 4; ++i )
1202 myInterpolator.setSplittingPolicy( sp[i] );
1204 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
1205 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
1206 CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[0][4],1e-7);
1207 CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[0][5],1e-7);
1208 CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[0][6],1e-7);
1209 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[0][7],1e-7);
1210 CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[1][0],1e-7);
1211 CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
1212 CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][2],1e-7);
1213 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][3],1e-7);
1214 CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][4],1e-7);
1215 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][5],1e-7);
1216 CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[1][6],1e-7);
1217 CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111111,res[2][6],1e-7);
1218 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888888,res[2][7],1e-7);
1219 CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444444,res[3][2],1e-7);
1220 CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333334,res[3][3],1e-7);
1221 CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[3][6],1e-7);
1222 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][7],1e-7);
1223 CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.111111111,res[4][5],1e-7);
1224 CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[4][7],1e-7);
1225 CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[5][1],1e-7);
1226 CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][3],1e-7);
1227 CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
1228 CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[5][7],1e-7);
1229 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][7],1e-7);
1230 CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[7][3],1e-7);
1231 CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][7],1e-7);
1232 CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[8][1],1e-7);
1233 CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][2],1e-7);
1234 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[8][3],1e-7);
1235 CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][4],1e-7);
1236 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][5],1e-7);
1237 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][6],1e-7);
1238 CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[8][7],1e-7);
1241 sourceMesh->decrRef();
1242 targetMesh->decrRef();
1245 void MEDCouplingBasicsTestInterp::test3DInterpP0P1PL_1()
1247 MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
1248 MEDCouplingUMesh *targetMesh=build3DSourceMesh_1();
1250 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1251 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1252 INTERP_KERNEL::Interpolation3D myInterpolator;
1253 std::vector<std::map<int,double> > res;
1254 myInterpolator.setPrecision(1e-12);
1255 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1256 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1257 for ( int i = 0; i < 4; ++i )
1259 myInterpolator.setSplittingPolicy( sp[i] );
1261 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
1262 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
1263 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][4],1e-12);
1264 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
1265 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1266 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1e-12);
1267 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][5],1e-12);
1268 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1e-12);
1269 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][7],1e-12);
1270 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1271 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][7],1e-12);
1272 CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,sumAll(res),1e-12);
1275 sourceMesh->decrRef();
1276 targetMesh->decrRef();
1279 void MEDCouplingBasicsTestInterp::test3DInterpP1P0_1()
1281 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1282 MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1284 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1285 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1286 INTERP_KERNEL::Interpolation3D myInterpolator;
1287 std::vector<std::map<int,double> > res;
1288 myInterpolator.setPrecision(1e-12);
1289 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1290 for ( int i = 0; i < 4; ++i )
1292 myInterpolator.setSplittingPolicy( sp[i] );
1294 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
1295 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1296 CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[0][1],1e-7);
1297 CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
1298 CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[1][5],1e-7);
1299 CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[1][8],1e-7);
1300 CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[2][1],1e-7);
1301 CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[2][3],1e-7);
1302 CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[2][8],1e-7);
1303 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][1],1e-7);
1304 CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][3],1e-7);
1305 CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[3][5],1e-7);
1306 CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[3][7],1e-7);
1307 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][8],1e-7);
1308 CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[4][0],1e-7);
1309 CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444445,res[4][1],1e-7);
1310 CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[4][8],1e-7);
1311 CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][0],1e-7);
1312 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[5][1],1e-7);
1313 CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[5][4],1e-7);
1314 CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
1315 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[5][8],1e-7);
1316 CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[6][0],1e-7);
1317 CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[6][1],1e-7);
1318 CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111112,res[6][2],1e-7);
1319 CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666667,res[6][3],1e-7);
1320 CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[6][8],1e-7);
1321 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][0],1e-7);
1322 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][2],1e-7);
1323 CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][3],1e-7);
1324 CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][4],1e-7);
1325 CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[7][5],1e-7);
1326 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][6],1e-7);
1327 CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222222,res[7][7],1e-7);
1328 CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[7][8],1e-7);
1331 sourceMesh->decrRef();
1332 targetMesh->decrRef();
1335 void MEDCouplingBasicsTestInterp::test3DInterpP1P0PL_1()
1337 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1338 MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1340 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1341 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1342 INTERP_KERNEL::Interpolation3D myInterpolator;
1343 std::vector<std::map<int,double> > res;
1344 myInterpolator.setPrecision(1e-12);
1345 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1346 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1347 for ( int i = 0; i < 4; ++i )
1349 myInterpolator.setSplittingPolicy( sp[i] );
1351 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
1352 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1353 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[0][1],1e-12);
1354 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[0][8],1e-12);
1355 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
1356 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][5],1e-12);
1357 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][8],1e-12);
1358 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
1359 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][3],1e-12);
1360 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][8],1e-12);
1361 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][1],1e-12);
1362 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][7],1e-12);
1363 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][8],1e-12);
1364 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
1365 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][1],1e-12);
1366 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][8],1e-12);
1367 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][1],1e-12);
1368 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][4],1e-12);
1369 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][8],1e-12);
1370 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][0],1e-12);
1371 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][2],1e-12);
1372 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][3],1e-12);
1373 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][8],1e-12);
1374 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[7][6],1e-12);
1375 CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[7][8],1e-12);
1376 CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1379 sourceMesh->decrRef();
1380 targetMesh->decrRef();
1383 void MEDCouplingBasicsTestInterp::test3DInterpP1P1_1()
1385 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2();
1386 MEDCouplingUMesh *targetMesh=build3DTargetMesh_2();
1388 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1389 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1390 INTERP_KERNEL::Interpolation3D myInterpolator;
1391 std::vector<std::map<int,double> > res;
1392 myInterpolator.setPrecision(1e-12);
1393 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
1394 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1395 double res3D[8][28]= {{124999.999883775978, 245370.370390364464, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 203703.703634892299, 187500.000094145857, 0.0, 0.0, 4629.6296266718, 0.0, 215277.777751402784, 209722.222322299582, 0.0, 0.0, 0.0, 0.0, 104166.666590829205, 121296.296368812196, 0.0, 250000.000003472145},
1396 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 120370.370368827047, 0.0, 0.0, 38888.888897777797, 0.0, 0.0, 45370.3703701697596, 0.0, 0.0, 45370.3703701697596, 83333.3333263888926, 0.0},
1397 {0.0, 0.0, 0.0, 97222.2222222221753, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 97222.2222222221608, 0.0, 97222.2222222222044, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
1398 {0.0, 277777.777787084982, 199074.074074073927, 0.0, 0.0, 0.0, 4629.62962962962774, 0.0, 321759.259254934732, 83333.3333333333139, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4629.62962667180363, 0.0, 0.0, 251388.88888319055, 194444.444454861077, 0.0, 79629.6296194135939, 250000.000003472145, 0.0, 0.0, 0.0, 0.0},
1399 {0.0, 0.0, 0.0, 0.0, 85185.1851851851534, 4629.62962962962774, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.518518518511, 0.0, 41666.6666666666642, 83333.3333333333285, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
1400 {0.0, 324074.07407629228, 0.0, 0.0, 0.0, 247685.185185184964, 6481.48148148147993, 0.0, 173611.11111196311, 0.0, 164814.814814814832, 0.0, 4629.62962962962865, 208333.33333418527, 0.0, 83333.3333333333285, 203703.703697273799, 249999.999999999767, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
1401 {125000.000000000015, 423611.111111110775, 134259.259259259241, 194444.444444444351, 164814.814814814745, 164351.851851851825, 203703.703703703592, 249999.999999999825, 0.0, 0.0, 0.0, 0.0, 6481.48148148147902, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
1402 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.518518518453, 0.0, 4629.62962962962956, 83333.3333333333139, 85185.1851851851825, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}};
1405 //cout.precision(18);
1406 for(std::vector<std::map<int,double> >::const_iterator iter1=res.begin();iter1!=res.end();iter1++,i++)
1408 //cout<< "res3D[" <<i<< "][]={";
1409 for(int j=0;j<28;j++)
1411 std::map<int,double>::const_iterator iter2=(*iter1).find(j);
1412 if(iter2!=(*iter1).end())
1414 //cout<< iter2->second<< ", ";
1415 sum += iter2->second;
1416 CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-5);
1421 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res3D[i][j],1e-14);
1424 //cout << "}" << endl;
1426 //cout << "Sum = " << sum << endl;
1427 CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000,sum,1.e-5);
1429 sourceMesh->decrRef();
1430 targetMesh->decrRef();
1433 void MEDCouplingBasicsTestInterp::test3DInterpP1P1PL_1()
1435 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2();
1436 MEDCouplingUMesh *targetMesh=build3DTargetMesh_2();
1438 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1439 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1440 INTERP_KERNEL::Interpolation3D myInterpolator;
1441 std::vector<std::map<int,double> > res;
1442 myInterpolator.setPrecision(1e-12);
1443 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1444 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
1445 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1446 CPPUNIT_ASSERT_DOUBLES_EQUAL(20.,res[0][24],1e-12);
1447 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[1][26],1e-12);
1448 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][21],1e-12);
1449 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[3][23],1e-12);
1450 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][14],1e-12);
1451 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[5][17],1e-12);
1452 CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[6][7],1e-12);
1453 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1454 CPPUNIT_ASSERT_DOUBLES_EQUAL(97.,sumAll(res),1e-12);
1456 sourceMesh->decrRef();
1457 targetMesh->decrRef();
1460 void MEDCouplingBasicsTestInterp::test3DInterpP0P0Empty()
1462 MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1463 sourceMesh->setMeshDimension(2);
1464 sourceMesh->allocateCells(0);
1465 sourceMesh->finishInsertingCells();
1466 DataArrayDouble *myCoords=DataArrayDouble::New();
1467 myCoords->alloc(0,0);
1468 sourceMesh->setCoords(myCoords);
1469 myCoords->decrRef();
1470 MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1471 targetMesh->setMeshDimension(2);
1472 targetMesh->allocateCells(0);
1473 targetMesh->finishInsertingCells();
1474 myCoords=DataArrayDouble::New();
1475 myCoords->alloc(0,2);
1476 targetMesh->setCoords(myCoords);
1477 myCoords->decrRef();
1478 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
1479 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1480 INTERP_KERNEL::Interpolation2D myInterpolator;
1481 std::vector<std::map<int,double> > res;
1482 myInterpolator.setPrecision(1e-12);
1483 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1485 sourceMesh->decrRef();
1486 targetMesh->decrRef();
1489 void MEDCouplingBasicsTestInterp::testInterpolationCC()
1491 double arr1[3] = { 0/2., 1/2., 2/2. };
1492 double arr2[4] = { 0/3, 1/3., 2/3., 3/3. };
1493 MEDCouplingCMesh* mesh[2];
1494 for ( int i = 0; i < 2; ++i )
1496 const double* arr = i ? arr1 : arr2;
1497 const int nb_coord = i ? 3 : 4;
1498 DataArrayDouble* coords = DataArrayDouble::New();
1499 coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, nb_coord, 1 );
1501 mesh[i] = MEDCouplingCMesh::New();
1502 mesh[i]->setCoords( coords, coords, coords );
1505 MEDCouplingNormalizedCartesianMesh<3> targetWrapper(mesh[1]);
1506 MEDCouplingNormalizedCartesianMesh<3> sourceWrapper(mesh[0]);
1507 CPPUNIT_ASSERT_EQUAL( 27,int( sourceWrapper.getNumberOfElements()));
1508 CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(0)));
1509 CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(1)));
1510 CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(2)));
1511 CPPUNIT_ASSERT_THROW( sourceWrapper.nbCellsAlongAxis(3), INTERP_KERNEL::Exception);
1513 INTERP_KERNEL::InterpolationCC myInterpolator;
1514 std::vector<std::map<int,double> > res;
1515 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1517 CPPUNIT_ASSERT_EQUAL(8,int( res.size()));
1518 CPPUNIT_ASSERT_EQUAL(8,int( res[0].size()));
1519 const double precis = 1e-7;
1520 std::set<double> vals;
1522 for ( int i = 0; i < (int)res.size(); ++i )
1523 for ( std::map<int,double>::iterator s_v = res[i].begin(); s_v != res[i].end(); ++s_v)
1528 double vv = s_v->second / precis;
1531 vvv = floor(vv+0.5);
1538 vvv = round( s_v->second / precis );
1540 vals.insert( precis * vvv );
1542 //cout << "tgt: " << i << " src: " << s_v->first << " - w: " << s_v->second << endl;
1543 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, sum, precis );
1545 std::set<double>::iterator v = vals.begin();
1546 CPPUNIT_ASSERT_EQUAL( 4, int( vals.size()) );
1547 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00462963, *v++, precis );
1548 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00925926, *v++, precis );
1549 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.01851850, *v++, precis );
1550 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703700, *v++, precis );
1556 void MEDCouplingBasicsTestInterp::testInterpolationCU1D()
1558 MEDCouplingCMesh* meshC = MEDCouplingCMesh::New();
1559 DataArrayDouble* coords = DataArrayDouble::New();
1560 double arr[4] = { -1/3., 1/3., 2/3., 4/3. };
1561 coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, 4, 1 );
1562 meshC->setCoords( coords );
1565 MEDCouplingUMesh * meshU = buildCU1DMesh_U();
1567 MEDCouplingNormalizedCartesianMesh<1> sourceWrapper(meshC);
1568 MEDCouplingNormalizedUnstructuredMesh<1,1> targetWrapper(meshU);
1569 INTERP_KERNEL::InterpolationCU myInterpolator;
1570 std::vector<std::map<int,double> > res;
1571 const double precis = 1e-13;
1572 myInterpolator.setPrecision(precis);
1573 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1575 // std::cout.precision(18);
1576 // for ( int i = 0; i < (int)res.size(); ++i )
1577 // for ( std::map<int,double>::iterator s_v = res[i].begin(); s_v != res[i].end(); ++s_v)
1579 // std::cout << "CPPUNIT_ASSERT_DOUBLES_EQUAL( "<<s_v->second<<" ,res["<<i<<"]["<<s_v->first<<"],precis);"<<std::endl;
1582 double sum = sumAll(res);
1583 CPPUNIT_ASSERT_EQUAL(3,int( res.size()));
1584 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis );
1585 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[1][0],precis);
1586 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.33333333333333 ,res[1][1],precis);
1587 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.08333333333333 ,res[1][2],precis);
1588 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25000000000000 ,res[2][2],precis);
1594 void MEDCouplingBasicsTestInterp::testInterpolationCU2D()
1596 MEDCouplingCMesh* meshC = MEDCouplingCMesh::New();
1597 DataArrayDouble* coords = DataArrayDouble::New();
1598 double arr[4] = { -1/3., 1/3., 2/3., 4/3. };
1599 coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, 4, 1 );
1600 meshC->setCoords( coords, coords );
1603 MEDCouplingUMesh * meshU = buildCU2DMesh_U();
1605 MEDCouplingNormalizedCartesianMesh<2> sourceWrapper(meshC);
1606 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(meshU);
1607 INTERP_KERNEL::InterpolationCU myInterpolator;
1608 std::vector<std::map<int,double> > res;
1609 myInterpolator.setPrecision(1e-12);
1610 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1612 const double precis = 1e-7;
1613 double sum = sumAll(res);
1614 CPPUNIT_ASSERT_EQUAL(5,int( res.size()));
1615 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis );
1616 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[0][0],precis);
1617 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[0][1],precis);
1618 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[0][3],precis);
1619 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[0][4],precis);
1620 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[1][3],precis);
1621 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[1][4],precis);
1622 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[1][6],precis);
1623 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[1][7],precis);
1624 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[2][4],precis);
1625 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[2][5],precis);
1626 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[2][7],precis);
1627 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[2][8],precis);
1628 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0416667 ,res[3][1],precis);
1629 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[3][2],precis);
1630 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[3][4],precis);
1631 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0416667 ,res[3][5],precis);
1632 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[4][1],precis);
1633 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0972222 ,res[4][2],precis);
1634 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[4][5],precis);
1636 std::vector<std::map<int,double> > resRev;
1637 myInterpolator.interpolateMeshesRev(targetWrapper,sourceWrapper,resRev,"P0P0");
1639 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][0] ,resRev[0][0],precis);
1640 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][1] ,resRev[1][0],precis);
1641 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][1] ,resRev[1][3],precis);
1642 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][1] ,resRev[1][4],precis);
1643 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][2] ,resRev[2][3],precis);
1644 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][2] ,resRev[2][4],precis);
1645 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][3] ,resRev[3][0],precis);
1646 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][3] ,resRev[3][1],precis);
1647 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][4] ,resRev[4][0],precis);
1648 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][4] ,resRev[4][1],precis);
1649 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][4] ,resRev[4][2],precis);
1650 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][4] ,resRev[4][3],precis);
1651 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][5] ,resRev[5][2],precis);
1652 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][5] ,resRev[5][3],precis);
1653 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][5] ,resRev[5][4],precis);
1654 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][6] ,resRev[6][1],precis);
1655 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][7] ,resRev[7][1],precis);
1656 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][7] ,resRev[7][2],precis);
1657 CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][8] ,resRev[8][2],precis);
1663 void MEDCouplingBasicsTestInterp::testInterpolationCU3D()
1665 MEDCouplingCMesh* meshC = MEDCouplingCMesh::New();
1666 DataArrayDouble* coords = DataArrayDouble::New();
1667 double arr[4] = { -1/3., 1/3., 2/3., 4/3. };
1668 coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, 4, 1 );
1669 meshC->setCoords( coords, coords, coords );
1672 MEDCouplingUMesh * meshU = buildCU3DMesh_U();
1674 MEDCouplingNormalizedCartesianMesh<3> sourceWrapper(meshC);
1675 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(meshU);
1676 INTERP_KERNEL::InterpolationCU myInterpolator;
1677 std::vector<std::map<int,double> > res;
1678 const double precis = 1e-13;
1679 myInterpolator.setPrecision(precis);
1680 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1682 double sum = sumAll(res);
1683 CPPUNIT_ASSERT_EQUAL(8,int( res.size()));
1684 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis );
1685 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02700000000000 ,res[0][0],precis);
1686 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00299999999999 ,res[1][0],precis);
1687 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[1][1],precis);
1688 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03000000000000 ,res[1][2],precis);
1689 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00300000000000 ,res[2][0],precis);
1690 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[2][3],precis);
1691 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[2][6],precis);
1692 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[3][0],precis);
1693 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][1],precis);
1694 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][2],precis);
1695 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][3],precis);
1696 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][4],precis);
1697 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][5],precis);
1698 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][6],precis);
1699 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][7],precis);
1700 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][8],precis);
1701 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00299999999999 ,res[4][0],precis);
1702 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[4][9],precis);
1703 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03000000000000 ,res[4][18],precis);
1704 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[5][0],precis);
1705 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][1],precis);
1706 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][2],precis);
1707 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][9],precis);
1708 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][10],precis);
1709 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][11],precis);
1710 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][18],precis);
1711 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][19],precis);
1712 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][20],precis);
1713 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[6][0],precis);
1714 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][3],precis);
1715 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][6],precis);
1716 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][9],precis);
1717 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][12],precis);
1718 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][15],precis);
1719 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][18],precis);
1720 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][21],precis);
1721 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][24],precis);
1722 CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.7037037037e-05 ,res[7][0],precis);
1723 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][1],precis);
1724 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][2],precis);
1725 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][3],precis);
1726 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][4],precis);
1727 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][5],precis);
1728 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][6],precis);
1729 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][7],precis);
1730 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][8],precis);
1731 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][9],precis);
1732 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][10],precis);
1733 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][11],precis);
1734 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][12],precis);
1735 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][13],precis);
1736 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][14],precis);
1737 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][15],precis);
1738 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][16],precis);
1739 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][17],precis);
1740 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][18],precis);
1741 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][19],precis);
1742 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][20],precis);
1743 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][21],precis);
1744 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][22],precis);
1745 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][23],precis);
1746 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][24],precis);
1747 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][25],precis);
1748 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][26],precis);
1755 void MEDCouplingBasicsTestInterp::test2DInterpP0IntegralUniform()
1757 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
1759 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1760 INTERP_KERNEL::Interpolation2D myInterpolator;
1761 std::vector<std::map<int,double> > res;
1762 CPPUNIT_ASSERT_EQUAL(5,myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
1763 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1764 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
1765 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
1766 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
1767 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
1768 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
1769 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
1771 CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
1772 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
1773 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
1774 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
1775 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12);
1776 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
1777 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][0],1e-12);
1778 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
1780 targetMesh->decrRef();
1782 targetMesh=build2DTargetMeshPerm_1();
1783 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper2(targetMesh);
1784 INTERP_KERNEL::Interpolation2D myInterpolator2;
1785 CPPUNIT_ASSERT(myInterpolator2.getMeasureAbsStatus());
1786 CPPUNIT_ASSERT_EQUAL(5,myInterpolator2.toIntegralUniform(targetWrapper2,res,"P0"));
1787 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1788 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
1789 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
1790 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
1791 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
1792 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
1793 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
1795 myInterpolator2.setMeasureAbsStatus(false);
1796 CPPUNIT_ASSERT(!myInterpolator2.getMeasureAbsStatus());
1797 CPPUNIT_ASSERT_EQUAL(5,myInterpolator2.toIntegralUniform(targetWrapper2,res,"P0"));
1798 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1799 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
1800 CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.125,res[0][1],1e-12);
1801 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
1802 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
1803 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
1804 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,sumAll(res),1e-12);
1805 targetMesh->decrRef();
1808 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0IntegralUniform()
1810 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
1811 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
1812 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
1813 std::vector<std::map<int,double> > res;
1814 CPPUNIT_ASSERT_EQUAL(5,myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
1815 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1816 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
1817 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
1818 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][2],1e-12);
1819 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][3],1e-12);
1820 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][4],1e-12);
1821 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
1823 CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
1824 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
1825 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
1826 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
1827 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
1828 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][0],1e-12);
1829 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[4][0],1e-12);
1830 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
1831 targetMesh->decrRef();
1834 void MEDCouplingBasicsTestInterp::test3DInterpP0IntegralUniform()
1836 MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1837 INTERP_KERNEL::Interpolation3D myInterpolator;
1838 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1839 std::vector<std::map<int,double> > res;
1840 CPPUNIT_ASSERT_EQUAL(8,myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
1841 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1842 CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6);
1843 CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][1],1e-6);
1844 CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][2],1e-6);
1845 CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][3],1e-6);
1846 CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][4],1e-6);
1847 CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][5],1e-6);
1848 CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][6],1e-6);
1849 CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[0][7],1e-6);
1850 CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
1852 CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
1853 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1854 CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6);
1855 CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[1][0],1e-6);
1856 CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[2][0],1e-6);
1857 CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[3][0],1e-6);
1858 CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[4][0],1e-6);
1859 CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[5][0],1e-6);
1860 CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[6][0],1e-6);
1861 CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[7][0],1e-6);
1862 CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
1864 targetMesh->decrRef();
1867 void MEDCouplingBasicsTestInterp::test2DInterpP1IntegralUniform()
1869 MEDCouplingUMesh *targetMesh=build2DSourceMesh_1();
1871 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1872 INTERP_KERNEL::Interpolation2D myInterpolator;
1873 std::vector<std::map<int,double> > res;
1874 CPPUNIT_ASSERT_EQUAL(4,myInterpolator.toIntegralUniform(targetWrapper,res,"P1"));
1875 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1876 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12);
1877 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][1],1e-12);
1878 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][2],1e-12);
1879 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][3],1e-12);
1881 CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P1"));
1882 CPPUNIT_ASSERT_EQUAL(4,(int)res.size());
1883 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12);
1884 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[1][0],1e-12);
1885 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[2][0],1e-12);
1886 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[3][0],1e-12);
1888 targetMesh->decrRef();
1891 void MEDCouplingBasicsTestInterp::test3DInterpP1IntegralUniform()
1893 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1895 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(sourceMesh);
1896 INTERP_KERNEL::Interpolation3D myInterpolator;
1897 std::vector<std::map<int,double> > res;
1898 CPPUNIT_ASSERT_EQUAL(9,myInterpolator.toIntegralUniform(targetWrapper,res,"P1"));
1899 CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1900 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6);
1901 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][1],1e-6);
1902 CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][2],1e-6);
1903 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][3],1e-6);
1904 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][4],1e-6);
1905 CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][5],1e-6);
1906 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][6],1e-6);
1907 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][7],1e-6);
1908 CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[0][8],1e-6);
1909 CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
1911 CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P1"));
1912 CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
1913 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6);
1914 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[1][0],1e-6);
1915 CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[2][0],1e-6);
1916 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[3][0],1e-6);
1917 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[4][0],1e-6);
1918 CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[5][0],1e-6);
1919 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][0],1e-6);
1920 CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][0],1e-6);
1921 CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[8][0],1e-6);
1922 CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
1923 sourceMesh->decrRef();
1926 void MEDCouplingBasicsTestInterp::test2DInterpP1P0Bary_1()
1928 MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
1929 MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
1931 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
1932 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1933 INTERP_KERNEL::Interpolation2D myInterpolator;
1934 myInterpolator.setP1P0BaryMethod(true);
1935 std::vector<std::map<int,double> > res;
1936 INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
1937 for(int i=0;i<2;i++)
1939 myInterpolator.setPrecision(1e-12);
1940 myInterpolator.setIntersectionType(types[i]);
1941 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
1942 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
1943 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669,res[0][0],1e-12);
1944 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[0][1],1e-12);
1945 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[0][2],1e-12);
1946 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][3],1e-12);
1947 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[1][0],1e-12);
1948 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[1][1],1e-12);
1949 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[1][3],1e-12);
1950 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[2][0],1e-12);
1951 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[2][1],1e-12);
1952 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[2][3],1e-12);
1953 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[3][0],1e-12);
1954 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[3][2],1e-12);
1955 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[3][3],1e-12);
1956 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[4][0],1e-12);
1957 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[4][1],1e-12);
1958 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[4][2],1e-12);
1959 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][3],1e-12);
1960 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
1964 sourceMesh->decrRef();
1965 targetMesh->decrRef();
1968 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0Bary_1()
1970 MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
1971 MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
1973 MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
1974 MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
1975 INTERP_KERNEL::Interpolation3DSurf myInterpolator;
1976 myInterpolator.setP1P0BaryMethod(true);
1977 std::vector<std::map<int,double> > res;
1978 INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
1979 for(int i=0;i<2;i++)
1981 myInterpolator.setPrecision(1e-12);
1982 myInterpolator.setIntersectionType(types[i]);
1983 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
1984 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
1985 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669*sqrt(2.),res[0][0],1e-12);
1986 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[0][1],1e-12);
1987 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[0][2],1e-12);
1988 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][3],1e-12);
1989 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[1][0],1e-12);
1990 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[1][1],1e-12);
1991 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[1][3],1e-12);
1992 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[2][0],1e-12);
1993 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[2][1],1e-12);
1994 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[2][3],1e-12);
1995 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[3][0],1e-12);
1996 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[3][2],1e-12);
1997 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[3][3],1e-12);
1998 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[4][0],1e-12);
1999 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[4][1],1e-12);
2000 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[4][2],1e-12);
2001 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][3],1e-12);
2002 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
2006 sourceMesh->decrRef();
2007 targetMesh->decrRef();
2011 void MEDCouplingBasicsTestInterp::test3DInterpP1P0Bary_1()
2013 MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2();
2014 MEDCouplingUMesh *targetMesh=build3DTargetMesh_2();
2016 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
2017 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
2018 INTERP_KERNEL::Interpolation3D myInterpolator;
2019 myInterpolator.setP1P0BaryMethod(true);
2020 std::vector<std::map<int,double> > res;
2021 myInterpolator.setPrecision(1e-12);
2022 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
2023 CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
2025 double res3D[5][28]={{104166.66658918398, 885416.666685817763, 135416.666666666541, 36458.3333333335031, 31249.9999999999018, 145833.333333333256, 41666.6666666667516, 124999.999999999971, 177083.333326388849, 0.0, 31249.9999999999636, 0.0, 41666.666620792399, 159722.22229009436, 0.0, 0.0, 41666.6666631944681, 125000, 43499.2283723790752, 164351.851924000395, 36458.3333372396883, 0.0, 0.0, 125000.000001736029, 34722.2221800900952, 13599.5370788455439, 0.0, 167438.27159690368},
2026 {0.0, 41666.6664479170649, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 125000.000161457952, 0.0, 0.0, 0.0, 0.0, 111111.11112005508, 0.0, 0.0, 291666.666656249959, 41666.6666666666933, 6944.4444415638809, 270833.333520485845, 0.0, 0.0, 124999.999989583303, 41666.6665798612958, 20833.3333186342825, 145833.333354303701, 83333.3333263888198, 27777.7777501651799},
2027 {0.0, 93750.0000000000728, 125000.000000000058, 0.0, 0.0, 72916.666666666526, 291666.666666666628, 41666.6666666667152, 197916.66666666657, 166666.666666666802, 218750.000000000116, 41666.6666666665697, 0.0, 0.0, 0.0, 0.0, 0.0, 41666.6666666666861, 0.0, 0.0, 0.0, 0.0, 0.0, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0},
2028 {72916.6666484848247, 82465.2777799315081, 0.0, 0.0, 217447.916666666686, 197916.666666666802, 0.0, 41666.6666666666715, 0.0, 0.0, 0.0, 0.0, 290364.583310396119, 125000.000018181803, 41666.6666666666351, 166666.666666666599, 0.0, 41666.6666666665551, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 27777.7777734705051, 0.0, 0.0, 27777.7778028684952},
2029 {72916.6666461071727, 172309.027782170655, 70312.5000000000437, 253906.250000000029, 0.0, 0.0, 0.0, 41666.666666666657, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 258246.527775988478, 71180.5555571812583, 253906.250006944378, 41666.6666666666861, 0.0, 41666.6666649305407, 20833.3333186342534, 6944.44445267237552, 0.0, 27777.7777953707919}};
2033 for(std::vector<std::map<int,double> >::const_iterator iter1=res.begin();iter1!=res.end();iter1++,i++)
2035 for(int j=0;j<28;j++)
2037 std::map<int,double>::const_iterator iter2=(*iter1).find(j);
2038 if(iter2!=(*iter1).end())
2040 sum += iter2->second;
2041 CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-5);
2045 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res3D[i][j],1e-14);
2049 CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000,sum,1.e-5);
2051 sourceMesh->decrRef();
2052 targetMesh->decrRef();
2055 void MEDCouplingBasicsTestInterp::test3DTo1DInterpP0P0PL_1()
2057 MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
2058 MEDCouplingUMesh *targetMesh=build1DTargetMesh_1();
2060 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
2061 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
2062 INTERP_KERNEL::Interpolation3D myInterpolator;
2063 std::vector<std::map<int,double> > res;
2064 myInterpolator.setPrecision(1e-12);
2065 myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
2066 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
2067 CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
2068 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
2069 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][4],1e-12);
2070 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][1],1e-12);
2071 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][5],1e-12);
2072 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][2],1e-12);
2073 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][6],1e-12);
2074 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][3],1e-12);
2075 CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][7],1e-12);
2076 CPPUNIT_ASSERT_DOUBLES_EQUAL(8.,sumAll(res),1e-12);
2078 sourceMesh->decrRef();
2079 targetMesh->decrRef();
2082 void MEDCouplingBasicsTestInterp::test1DInterp_1()
2084 // c1 c0 c2 - pay attention to cell order!
2085 // S: o---o------o---o
2086 // T: o---o------o---o
2089 // ---+---+------+---+---> X
2091 MEDCouplingUMesh *sourceMesh=build1DMesh(0);
2092 MEDCouplingUMesh *targetMesh=build1DMesh(0.5);
2094 MEDCouplingNormalizedUnstructuredMesh<1,1> sourceWrapper(sourceMesh);
2095 MEDCouplingNormalizedUnstructuredMesh<1,1> targetWrapper(targetMesh);
2096 INTERP_KERNEL::Interpolation1D myInterpolator;
2097 const double precis = 1e-13;
2098 myInterpolator.setPrecision(precis);
2101 std::vector<std::map<int,double> > res;
2102 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
2103 CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
2104 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[0][0], precis);
2105 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][2], precis);
2106 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][0], precis);
2107 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][1], precis);
2108 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][2], precis);
2109 CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
2113 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
2114 CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
2115 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis);
2116 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[0][2], precis);
2117 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[1][1], precis);
2118 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][3], precis);
2119 CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
2123 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
2125 CPPUNIT_ASSERT_EQUAL( 4, int( res.size()) );
2126 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis);
2127 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[1][0], precis);
2128 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][0], precis);
2129 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[2][2], precis);
2130 CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
2134 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
2135 CPPUNIT_ASSERT_EQUAL( 4, int( res.size()) );
2136 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis);
2137 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[1][1], precis);
2138 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][2], precis);
2139 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[2][2], precis);
2140 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][3], precis);
2141 CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
2143 sourceMesh->decrRef();
2144 targetMesh->decrRef();
2147 void MEDCouplingBasicsTestInterp::test2DCurveInterpP0P0_1()
2149 // coincident meshes
2150 MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
2151 MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2153 MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2154 MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2155 INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2156 const double precis = 1e-13;
2157 myInterpolator.setPrecision(precis);
2158 std::vector<std::map<int,double> > res;
2159 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
2161 CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) );
2162 CPPUNIT_ASSERT_DOUBLES_EQUAL( sqrt(2.),res[0][0], precis);
2163 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., res[1][1], precis);
2164 CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.+sqrt(2.), sumAll(res), precis);
2166 sourceMesh->decrRef();
2167 targetMesh->decrRef();
2170 void MEDCouplingBasicsTestInterp::test2DCurveInterpP0P0_2()
2172 // equal meshes shifted one from another along X by 0.5
2173 MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0.5,0);
2174 MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2176 MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2177 MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2178 INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2179 const double precis = 1e-13;
2180 myInterpolator.setPrecision(precis);
2181 myInterpolator.setMedianPlane(1.);// median line on target
2182 std::vector<std::map<int,double> > res;
2183 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
2185 double tolInters = myInterpolator.getBoundingBoxAdjustmentAbs() * sqrt(2.);
2186 CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) );
2187 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0,res[0][0], precis);
2188 CPPUNIT_ASSERT_DOUBLES_EQUAL( tolInters,res[0][1], precis);
2189 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][1], precis);
2190 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5+tolInters, sumAll(res), precis);
2192 sourceMesh->decrRef();
2193 targetMesh->decrRef();
2196 void MEDCouplingBasicsTestInterp::test2DCurveInterpP0P1_1()
2198 // coincident meshes
2199 MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
2200 MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2202 MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2203 MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2204 INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2205 const double precis = 1e-13;
2206 myInterpolator.setPrecision(precis);
2207 std::vector<std::map<int,double> > res;
2208 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
2210 const double len1 = 1., len0 = sqrt(2.);
2211 CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
2212 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[0][1], precis);
2213 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[1][0], precis);
2214 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][1], precis);
2215 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[2][0], precis);
2216 CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis);
2218 sourceMesh->decrRef();
2219 targetMesh->decrRef();
2222 void MEDCouplingBasicsTestInterp::test2DCurveInterpP1P0_1()
2224 // coincident meshes
2225 MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
2226 MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2228 MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2229 MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2230 INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2231 const double precis = 1e-13;
2232 myInterpolator.setPrecision(precis);
2233 std::vector<std::map<int,double> > res;
2234 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
2236 const double len1 = 1., len0 = sqrt(2.);
2237 CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) );
2238 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][0], precis);
2239 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[0][1], precis);
2240 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][1], precis);
2241 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[0][2], precis);
2242 CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis);
2244 sourceMesh->decrRef();
2245 targetMesh->decrRef();
2248 void MEDCouplingBasicsTestInterp::test2DCurveInterpP1P1_1()
2250 // coincident meshes
2251 MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
2252 MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2254 MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2255 MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2256 INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2257 const double precis = 1e-13;
2258 myInterpolator.setPrecision(precis);
2259 std::vector<std::map<int,double> > res;
2260 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
2262 const double len1 = 1., len0 = sqrt(2.);
2263 CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
2264 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[0][0], precis);
2265 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*(len0+len1), res[1][1], precis);
2266 CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[2][2], precis);
2267 CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis);
2269 sourceMesh->decrRef();
2270 targetMesh->decrRef();
2273 void MEDCouplingBasicsTestInterp::test2D1DBasicInterpP0P0()
2275 MEDCouplingUMesh *sourceMesh=build2D1DSourceMesh();
2276 MEDCouplingUMesh *targetMesh=build2D1DTargetMesh();
2278 MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
2279 MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
2280 INTERP_KERNEL::Interpolation2D1D myInterpolator;
2281 myInterpolator.setPrecision(1e-12);
2282 myInterpolator.setIntersectionType(INTERP_KERNEL::Geometric2D);
2283 std::vector<std::map<int,double> > matrix;
2284 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
2286 CPPUNIT_ASSERT_EQUAL(2,(int)matrix.size());
2288 CPPUNIT_ASSERT_DOUBLES_EQUAL(3., matrix[0][0],1e-12);
2289 CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][1],1e-12);
2290 CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][2],1e-12);
2291 CPPUNIT_ASSERT_DOUBLES_EQUAL(8., matrix[0][3],1e-12);
2292 CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][4],1e-12);
2293 CPPUNIT_ASSERT_DOUBLES_EQUAL(5., matrix[0][5],1e-12);
2294 CPPUNIT_ASSERT_DOUBLES_EQUAL(6., matrix[0][6],1e-12);
2295 CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][7],1e-12);
2297 CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][0],1e-12);
2298 CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][1],1e-12);
2299 CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][2],1e-12);
2300 CPPUNIT_ASSERT_DOUBLES_EQUAL(4., matrix[1][3],1e-12);
2301 CPPUNIT_ASSERT_DOUBLES_EQUAL(5., matrix[1][4],1e-12);
2302 CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][5],1e-12);
2303 CPPUNIT_ASSERT_DOUBLES_EQUAL(6., matrix[1][6],1e-12);
2304 CPPUNIT_ASSERT_DOUBLES_EQUAL(3., matrix[1][7],1e-12);
2306 INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
2307 CPPUNIT_ASSERT_EQUAL(1,(int)duplicateFaces.size());
2309 INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType correctDuplicateFaces;
2310 std::set<int> face6;
2313 correctDuplicateFaces[6] = face6;
2315 CPPUNIT_ASSERT(correctDuplicateFaces == duplicateFaces);
2318 sourceMesh->decrRef();
2319 targetMesh->decrRef();
2322 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_1()
2324 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh();
2325 MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh();
2326 test2D1DMeshesIntersection(sourceMesh, targetMesh, 16., 0, 4);
2329 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_2()
2331 const double shiftX = 3.;
2332 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
2333 MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh();
2334 test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 16., 4, 2 * 4);
2337 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_3()
2339 const double shiftX = 1.5;
2340 const double inclinationX = 3.;
2341 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2342 MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh(inclinationX);
2343 test2D1DMeshesIntersection(sourceMesh, targetMesh, 20., 0, 4);
2346 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_4()
2348 const double shiftX = 3.;
2349 const double inclinationX = 3.;
2350 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2351 MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh(inclinationX);
2352 test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 20., 4, 2 * 4);
2355 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_5()
2357 const double shiftX = 9.;
2358 const double inclinationX = 3.;
2359 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
2360 MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh(inclinationX);
2361 test2D1DMeshesIntersection(sourceMesh, targetMesh, 12., 0, 3);
2364 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_6()
2366 const double shiftX = 9.;
2367 const double inclinationX = 3.;
2368 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2369 MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh();
2370 test2D1DMeshesIntersection(sourceMesh, targetMesh, 10., 0, 2);
2373 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_1()
2375 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh();
2376 MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh();
2377 test2D1DMeshesIntersection(sourceMesh, targetMesh, 16., 0, 4);
2380 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_2()
2382 const double shiftX = 3.;
2383 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
2384 MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh();
2385 test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 16., 4, 2 * 4);
2388 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_3()
2390 const double shiftX = 1.5;
2391 const double inclinationX = 3.;
2392 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2393 MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh(inclinationX);
2394 test2D1DMeshesIntersection(sourceMesh, targetMesh, 20., 0, 8);
2397 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_4()
2399 const double shiftX = 3.;
2400 const double inclinationX = 3.;
2401 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2402 MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh(inclinationX);
2403 test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 20., 4, 8);
2406 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_5()
2408 const double shiftX = 9.;
2409 const double inclinationX = 3.;
2410 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
2411 MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh(inclinationX);
2412 test2D1DMeshesIntersection(sourceMesh, targetMesh, 12., 0, 6);
2415 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_6()
2417 const double shiftX = 9.;
2418 const double inclinationX = 3.;
2419 MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2420 MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh();
2421 test2D1DMeshesIntersection(sourceMesh, targetMesh, 20., 2, 4);
2424 void MEDCouplingBasicsTestInterp::test3D2DBasicInterpP0P0()
2426 MEDCouplingUMesh *sourceMesh=build3D2DSourceMesh();
2427 MEDCouplingUMesh *targetMesh=build3D2DTargetMesh();
2429 MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
2430 MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
2431 INTERP_KERNEL::Interpolation3D2D myInterpolator;
2432 myInterpolator.setPrecision(1e-12);
2433 std::vector<std::map<int,double> > matrix;
2434 INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
2435 for ( size_t i = 0; i < sizeof(sp)/sizeof(sp[0]); ++i )
2437 myInterpolator.setSplittingPolicy( sp[i] );
2439 myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
2441 CPPUNIT_ASSERT_EQUAL(3,(int)matrix.size());
2443 CPPUNIT_ASSERT_DOUBLES_EQUAL(0. ,matrix[0][0],1e-12);
2444 CPPUNIT_ASSERT_DOUBLES_EQUAL(0. ,matrix[0][1],1e-12);
2445 CPPUNIT_ASSERT_DOUBLES_EQUAL(40. ,matrix[0][2],1e-12);
2446 CPPUNIT_ASSERT_DOUBLES_EQUAL(8. ,matrix[0][3],1e-12);
2447 CPPUNIT_ASSERT_DOUBLES_EQUAL(2.5 ,matrix[0][4],1e-12);
2448 CPPUNIT_ASSERT_DOUBLES_EQUAL(0. ,matrix[0][5],1e-12);
2449 CPPUNIT_ASSERT_DOUBLES_EQUAL(32. ,matrix[0][6],1e-12);
2451 CPPUNIT_ASSERT_DOUBLES_EQUAL(8.*sqrt(3.),matrix[1][0],1e-12);
2452 CPPUNIT_ASSERT_DOUBLES_EQUAL(0. ,matrix[1][1],1e-12);
2453 CPPUNIT_ASSERT_DOUBLES_EQUAL(40. ,matrix[1][2],1e-12);
2454 CPPUNIT_ASSERT_DOUBLES_EQUAL(80. ,matrix[1][3],1e-12);
2455 CPPUNIT_ASSERT_DOUBLES_EQUAL(0. ,matrix[1][4],1e-12);
2456 CPPUNIT_ASSERT_DOUBLES_EQUAL(80. ,matrix[1][5],1e-12);
2457 CPPUNIT_ASSERT_DOUBLES_EQUAL(80. ,matrix[1][6],1e-12);
2459 CPPUNIT_ASSERT_DOUBLES_EQUAL(0. ,matrix[2][0],1e-12);
2460 CPPUNIT_ASSERT_DOUBLES_EQUAL(32. ,matrix[2][1],1e-12);
2461 CPPUNIT_ASSERT_DOUBLES_EQUAL(0. ,matrix[2][2],1e-12);
2462 CPPUNIT_ASSERT_DOUBLES_EQUAL(0. ,matrix[2][3],1e-12);
2463 CPPUNIT_ASSERT_DOUBLES_EQUAL(0. ,matrix[2][4],1e-12);
2464 CPPUNIT_ASSERT_DOUBLES_EQUAL(80. ,matrix[2][5],1e-12);
2465 CPPUNIT_ASSERT_DOUBLES_EQUAL(112. ,matrix[2][6],1e-12);
2467 INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
2468 CPPUNIT_ASSERT_EQUAL(3,(int)duplicateFaces.size());
2470 INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType correctDuplicateFaces;
2471 std::set<int> face2;
2474 correctDuplicateFaces[2] = face2;
2475 std::set<int> face5;
2478 correctDuplicateFaces[5] = face5;
2479 std::set<int> face6;
2483 correctDuplicateFaces[6] = face6;
2485 CPPUNIT_ASSERT(correctDuplicateFaces == duplicateFaces);
2488 sourceMesh->decrRef();
2489 targetMesh->decrRef();
2492 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_1()
2494 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh();
2495 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2496 test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 0, 20);
2499 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_2()
2501 const double shiftX = 3.;
2502 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
2503 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2504 test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 20, 2 * 20);
2507 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_3()
2509 const double shiftX = 1.5;
2510 const double inclinationX = 3.;
2511 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2512 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2513 test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0, 20);
2516 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_4()
2518 const double shiftX = 3.;
2519 const double inclinationX = 3.;
2520 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2521 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2522 test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 20, 2 * 20);
2525 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_5()
2527 const double shiftX = 9.;
2528 const double inclinationX = 3.;
2529 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
2530 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2531 test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0, 15);
2534 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_6()
2536 const double shiftX = 9.;
2537 const double inclinationX = 3.;
2538 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2539 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2540 test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0, 10);
2543 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_1()
2545 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh();
2546 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2547 test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 0, 40);
2550 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_2()
2552 const double shiftX = 3.;
2553 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
2554 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2555 test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 40, 2 * 40);
2558 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_3()
2560 const double shiftX = 1.5;
2561 const double inclinationX = 3.;
2562 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2563 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2564 test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0, 40);
2567 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_4()
2569 const double shiftX = 3.;
2570 const double inclinationX = 3.;
2571 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2572 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2573 test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 40, 2 * 40);
2576 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_5()
2578 const double shiftX = 9.;
2579 const double inclinationX = 3.;
2580 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
2581 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2582 test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0, 30);
2585 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_6()
2587 const double shiftX = 9.;
2588 const double inclinationX = 3.;
2589 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2590 MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2591 test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0, 20);
2594 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_1()
2596 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh();
2597 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2598 test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 20, 40);
2601 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_2()
2603 const double shiftX = 3.;
2604 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
2605 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2606 test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 20, 2 * 40);
2609 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_3()
2611 const double shiftX = 1.5;
2612 const double inclinationX = 3.;
2613 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2614 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2615 test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0, 100);
2618 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_4()
2620 const double shiftX = 3.;
2621 const double inclinationX = 3.;
2622 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2623 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2624 test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 20, 2 * 40);
2627 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_5()
2629 const double shiftX = 9.;
2630 const double inclinationX = 3.;
2631 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
2632 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2633 test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0, 45);
2636 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_6()
2638 const double shiftX = 9.;
2639 const double inclinationX = 3.;
2640 MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2641 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2642 test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0, 30);
2645 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_1()
2647 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh();
2648 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2649 test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 0, 40);
2652 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_2()
2654 const double shiftX = 3.;
2655 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
2656 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2657 test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 40, 40 + 80);
2660 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_3()
2662 const double shiftX = 1.5;
2663 const double inclinationX = 3.;
2664 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2665 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2666 test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0);
2669 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_4()
2671 const double shiftX = 3.;
2672 const double inclinationX = 3.;
2673 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2674 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2675 test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 40, 40 + 80);
2678 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_5()
2680 const double shiftX = 9.;
2681 const double inclinationX = 3.;
2682 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
2683 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2684 test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0);
2687 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_6()
2689 const double shiftX = 9.;
2690 const double inclinationX = 3.;
2691 MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2692 MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2693 test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0);