-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// Author : Anthony Geay (CEA/DEN)
#include "MEDCouplingRemapperTest.hxx"
#include "MEDCouplingUMesh.hxx"
MEDCouplingFieldDouble *targetField=MEDCouplingFieldDouble::New(ON_CELLS);
targetField->setNature(ConservativeVolumic);
- targetField->setMesh(sourceMesh);
+ targetField->setMesh(targetMesh);
DataArrayDouble *array=DataArrayDouble::New();
array->alloc(targetMesh->getNumberOfCells(),1);
targetField->setArray(array);
//
MEDCouplingRemapper remapper;
remapper.setPrecision(1e-12);
- remapper.setIntersectionType(INTERP_KERNEL::Geometric2D);
+ remapper.setIntersectionType(INTERP_KERNEL::Triangulation);
CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(meshNE,meshTTE,"P0P0"));
MEDCouplingFieldDouble *srcField=MEDCouplingFieldDouble::New(ON_CELLS);
srcField->setNature(IntegralGlobConstraint);
sourceMesh->decrRef();
targetMesh->decrRef();
}
+
+void MEDCouplingRemapperTest::testBugNonRegression1()
+{
+ // source
+ DataArrayDouble *coordsSrc(DataArrayDouble::New());
+ const double coordsSrcData[18]={-6.25,3.6084391824351605,264.85199999999998,-6.25,3.6084391824351605,289.05200000000002,-6.2499999999999991,-3.6084391824351618,264.85199999999998,-6.2499999999999991,-3.6084391824351618,289.05200000000002,-1.7763568394002505e-15,4.4408920985006262e-15,264.85199999999998,-1.7763568394002505e-15,4.4408920985006262e-15,289.05200000000002};
+ coordsSrc->useArray(coordsSrcData,false,CPP_DEALLOC,6,3);
+ DataArrayInt *connSrc(DataArrayInt::New()),*connISrc(DataArrayInt::New());
+ const int connSrcData[7]={16,2,0,4,3,1,5};
+ connSrc->useArray(connSrcData,false,CPP_DEALLOC,7,1);
+ const int connISrcData[2]={0,7};
+ connISrc->useArray(connISrcData,false,CPP_DEALLOC,2,1);
+ MEDCouplingUMesh *srcMesh(MEDCouplingUMesh::New("source",3));
+ srcMesh->setCoords(coordsSrc);
+ srcMesh->setConnectivity(connSrc,connISrc,true);
+ coordsSrc->decrRef(); connSrc->decrRef(); connISrc->decrRef();
+ // target
+ DataArrayDouble *coordsTrg(DataArrayDouble::New());
+const double coordsTrgData[36]={-2,1.1547005383792521,264.85199999999998,-2,0.57735026918962618,264.85199999999998,-2.5,0.2886751345948132,264.85199999999998,-2.5,1.443375672974065,264.85199999999998,-3.0000000000000004,1.1547005383792526,264.85199999999998,-3.0000000000000004,0.57735026918962662,264.85199999999998,-2,1.1547005383792521,289.05200000000002,-2,0.57735026918962618,289.05200000000002,-2.5,0.2886751345948132,289.05200000000002,-2.5,1.443375672974065,289.05200000000002,-3.0000000000000004,1.1547005383792526,289.05200000000002,-3.0000000000000004,0.57735026918962662,289.05200000000002};
+ coordsTrg->useArray(coordsTrgData,false,CPP_DEALLOC,12,3);
+ DataArrayInt *connTrg=DataArrayInt::New();
+ const int connTrgData[44]={31,0,1,2,5,4,3,-1,7,6,9,10,11,8,-1,3,9,6,0,-1,4,10,9,3,-1,5,11,10,4,-1,2,8,11,5,-1,1,7,8,2,-1,0,6,7,1};
+ connTrg->useArray(connTrgData,false,CPP_DEALLOC,44,1);
+ DataArrayInt *connITrg=DataArrayInt::New();
+ const int connITrgData[2]={0,44};
+ connITrg->useArray(connITrgData,false,CPP_DEALLOC,2,1);
+ MEDCouplingUMesh *trgMesh=MEDCouplingUMesh::New("target",3);
+ trgMesh->setCoords(coordsTrg);
+ trgMesh->setConnectivity(connTrg,connITrg,true);
+ coordsTrg->decrRef(); connTrg->decrRef(); connITrg->decrRef();
+ // Go !
+ const double valExpected(20.957814771583468);
+ MEDCouplingRemapper remapper;
+ remapper.setPrecision(1e-12);
+ remapper.setIntersectionType(INTERP_KERNEL::Triangulation);
+ CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(srcMesh,trgMesh,"P0P0"));
+ std::vector<std::map<int,double> > matrx(remapper.getCrudeMatrix());
+ CPPUNIT_ASSERT_EQUAL(1,(int)matrx.size());
+ CPPUNIT_ASSERT_EQUAL(1,(int)matrx[0].size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valExpected,matrx[0][0],1e-13);
+ //
+ srcMesh->decrRef(); trgMesh->decrRef();
+}
+