1 // Copyright (C) 2007-2013 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 "InterpolationOptionsTest.hxx"
21 #include "MEDNormalizedUnstructuredMesh.txx"
22 #include "Interpolation2D.txx"
23 #include "TestInterpKernelUtils.hxx"
29 void InterpolationOptionsTest::setUp()
34 void InterpolationOptionsTest::tearDown()
39 * Test that creates a tree in 2D and check that
40 * the results are correct in three
42 * a non matching search
44 * a bbox overlapping the bboxes of the tree
46 void InterpolationOptionsTest::test_InterpolationOptions()
48 string sourcename=INTERP_TEST::getResourceFile("square1.med");
49 MEDMEM::MESH *source_mesh=new MEDMEM::MESH(MED_DRIVER,sourcename,"Mesh_2");
51 string targetname=INTERP_TEST::getResourceFile("square2.med");
52 MEDMEM::MESH *target_mesh=new MEDMEM::MESH(MED_DRIVER,targetname,"Mesh_3");
54 const MEDMEM::SUPPORT *source_support=source_mesh->getSupportOnAll(MED_EN::MED_CELL);
55 MEDMEM::FIELD<double> *source_field=new FIELD<double>(source_support,1);
56 double* value=const_cast<double*>(source_field->getValue());
57 for (int i=0; i<source_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); i++)
59 const MEDMEM::SUPPORT *target_support=target_mesh->getSupportOnAll(MED_EN::MED_CELL);
60 MEDMEM::FIELD<double> *target_field=new FIELD<double>(target_support,1);
61 double* targetvalue=const_cast<double*>(target_field->getValue());
62 for (int i=0; i<target_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); i++)
64 // Ok at this point we have our mesh in MED-Memory format.
65 // Go to wrap med_source_mesh and med_target_mesh.
66 MEDNormalizedUnstructuredMesh<2,2> wrap_source_mesh(source_mesh);
67 MEDNormalizedUnstructuredMesh<2,2> wrap_target_mesh(target_mesh);
68 // Go for interpolation...
69 INTERP_KERNEL::Interpolation2D myInterpolator;
70 //optionnal call to parametrize your interpolation. First precision, tracelevel, intersector wanted.
71 myInterpolator.setPrecision(1e-7);
72 myInterpolator.setPrintLevel(1);
73 source_mesh->removeReference();
74 source_field->removeReference();
75 target_field->removeReference();
76 target_mesh->removeReference();