1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MEDFileMesh.hxx"
21 #include "MEDCouplingFieldDouble.hxx"
23 #include "InterpolationOptionsTest.hxx"
24 #include "MEDCouplingNormalizedUnstructuredMesh.txx"
25 #include "Interpolation2D.txx"
26 #include "TestInterpKernelUtils.hxx"
31 using namespace ParaMEDMEM;
35 void InterpolationOptionsTest::setUp()
40 void InterpolationOptionsTest::tearDown()
45 * Test that creates a tree in 2D and check that
46 * the results are correct in three
48 * a non matching search
50 * a bbox overlapping the bboxes of the tree
52 void InterpolationOptionsTest::test_InterpolationOptions()
54 std::string sourcename=INTERP_TEST::getResourceFile("square1.med");
55 MEDFileUMesh *source_mesh=MEDFileUMesh::New(sourcename.c_str(),"Mesh_2");
57 std::string targetname=INTERP_TEST::getResourceFile("square2.med");
58 MEDFileUMesh *target_mesh=MEDFileUMesh::New(targetname.c_str(),"Mesh_3");
60 MEDCouplingUMesh *source_mesh_mc=source_mesh->getMeshAtLevel(0);
61 MEDCouplingFieldDouble *source_field=MEDCouplingFieldDouble::New(ON_CELLS);
62 source_field->setMesh(source_mesh_mc); source_mesh_mc->decrRef();
63 DataArrayDouble *arr=DataArrayDouble::New(); arr->alloc(source_mesh_mc->getNumberOfCells(),1);
64 source_field->setArray(arr); arr->decrRef();
65 double *value=arr->getPointer();
66 for(int i=0; i<source_mesh_mc->getNumberOfCells(); i++)
68 MEDCouplingUMesh *target_mesh_mc=target_mesh->getMeshAtLevel(0);
69 MEDCouplingFieldDouble *target_field=MEDCouplingFieldDouble::New(ON_CELLS);
70 target_field->setMesh(target_mesh_mc); target_mesh_mc->decrRef();
71 arr=DataArrayDouble::New(); arr->alloc(target_mesh_mc->getNumberOfCells(),1);
72 target_field->setArray(arr); arr->decrRef();
73 double* targetvalue=arr->getPointer();
74 for(int i=0; i<target_mesh_mc->getNumberOfCells(); i++)
76 // Ok at this point we have our mesh in MED-Memory format.
77 // Go to wrap med_source_mesh and med_target_mesh.
78 MEDCouplingNormalizedUnstructuredMesh<2,2> wrap_source_mesh(source_mesh_mc);
79 MEDCouplingNormalizedUnstructuredMesh<2,2> wrap_target_mesh(target_mesh_mc);
80 // Go for interpolation...
81 INTERP_KERNEL::Interpolation2D myInterpolator;
82 //optionnal call to parametrize your interpolation. First precision, tracelevel, intersector wanted.
83 myInterpolator.setPrecision(1e-7);
84 myInterpolator.setPrintLevel(1);
85 source_mesh->decrRef();
86 source_field->decrRef();
87 target_field->decrRef();
88 target_mesh->decrRef();