-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014 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 "MEDCouplingBasicsTest1.hxx"
#include "MEDCouplingUMesh.hxx"
DataArrayDouble *arr4=DataArrayDouble::New();
arr4->alloc(7,2);
double *tmp2=arr4->getPointer();
- const int arr4Ref[14]={0.8,10.8,1.9,11.9,2.1,12.1,3.2,13.2,4.3,14.3,5.4,15.4,6.5,16.5};
+ const double arr4Ref[14]={0.8,10.8,1.9,11.9,2.1,12.1,3.2,13.2,4.3,14.3,5.4,15.4,6.5,16.5};
std::copy(arr4Ref,arr4Ref+14,tmp2);
CPPUNIT_ASSERT_EQUAL(7,arr4->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(2,arr4->getNumberOfComponents());
int tab4[4*nbOfCells]={
1, 2, 8, 7, 2, 3, 9, 8, 3, 4, 10, 9, 4, 5, 11, 10, 5, 0, 6, 11,
0, 1, 7, 6, };
-
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NORM_TRI3),3);
+ CPPUNIT_ASSERT(MEDCouplingMesh::IsStaticGeometricType(INTERP_KERNEL::NORM_TRI3));
+ CPPUNIT_ASSERT(MEDCouplingMesh::IsLinearGeometricType(INTERP_KERNEL::NORM_TRI3));
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetDimensionOfGeometricType(INTERP_KERNEL::NORM_TRI3),2);
+ CPPUNIT_ASSERT_EQUAL(std::string(MEDCouplingMesh::GetReprOfGeometricType(INTERP_KERNEL::NORM_TRI3)),std::string("NORM_TRI3"));
+ CPPUNIT_ASSERT_THROW(MEDCouplingMesh::GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NORM_POLYGON),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(!MEDCouplingMesh::IsStaticGeometricType(INTERP_KERNEL::NORM_POLYGON));
+ CPPUNIT_ASSERT(MEDCouplingMesh::IsLinearGeometricType(INTERP_KERNEL::NORM_POLYGON));
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetDimensionOfGeometricType(INTERP_KERNEL::NORM_POLYGON),2);
+ CPPUNIT_ASSERT_EQUAL(std::string(MEDCouplingMesh::GetReprOfGeometricType(INTERP_KERNEL::NORM_POLYGON)),std::string("NORM_POLYGON"));
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NORM_TRI6),6);
+ CPPUNIT_ASSERT(MEDCouplingMesh::IsStaticGeometricType(INTERP_KERNEL::NORM_TRI6));
+ CPPUNIT_ASSERT(!MEDCouplingMesh::IsLinearGeometricType(INTERP_KERNEL::NORM_TRI6));
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetDimensionOfGeometricType(INTERP_KERNEL::NORM_TRI6),2);
+ CPPUNIT_ASSERT_EQUAL(std::string(MEDCouplingMesh::GetReprOfGeometricType(INTERP_KERNEL::NORM_TRI6)),std::string("NORM_TRI6"));
MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(8);
for(int i=0;i<nbOfCells;i++,curConn+=4)
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,curConn);
mesh->finishInsertingCells();
- CPPUNIT_ASSERT_EQUAL(30,mesh->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)30,mesh->getNodalConnectivity()->getNbOfElems());
CPPUNIT_ASSERT_EQUAL(nbOfCells,mesh->getNumberOfCells());
//test 0 - no copy no ownership
DataArrayDouble *myCoords=DataArrayDouble::New();
targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7);
targetMesh->finishInsertingCells();
+ CPPUNIT_ASSERT_THROW(targetMesh->checkCoherency(),INTERP_KERNEL::Exception);
DataArrayDouble *myCoords=DataArrayDouble::New();
myCoords->alloc(9,3);
std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
mesh->getReverseNodalConnectivity(revNodal,revNodalIndx);
const int revNodalExpected[18]={0,0,1,1,2,0,3,0,1,2,3,4,2,4,3,3,4,4};
const int revNodalIndexExpected[10]={0,1,3,5,7,12,14,15,17,18};
- CPPUNIT_ASSERT_EQUAL(18,revNodal->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(10,revNodalIndx->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)18,revNodal->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)10,revNodalIndx->getNbOfElems());
CPPUNIT_ASSERT(std::equal(revNodalExpected,revNodalExpected+18,revNodal->getPointer()));
CPPUNIT_ASSERT(std::equal(revNodalIndexExpected,revNodalIndexExpected+10,revNodalIndx->getPointer()));
//
mesh2->checkCoherency();
CPPUNIT_ASSERT_EQUAL(1,mesh2->getMeshDimension());
CPPUNIT_ASSERT_EQUAL(13,mesh2->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(6,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(6,descIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(18,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,desc->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(18,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,revDesc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)14,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)6,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(6,descIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)18,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,desc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)18,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,revDesc->getNumberOfTuples());
const int expected1[18]={0,1,2,3, 2,4,5, 6,7,4, 8,9,1,10, 11,12,6,9};
CPPUNIT_ASSERT(std::equal(expected1,expected1+18,desc->getConstPointer()));
const int expected2[6]={0,4,7,10,14,18};
mesh2->checkCoherency();
CPPUNIT_ASSERT_EQUAL(1,mesh2->getMeshDimension());
CPPUNIT_ASSERT_EQUAL(13,mesh2->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(6,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(6,descIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(18,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,desc->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(18,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,revDesc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)14,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)6,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(6,descIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)18,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,desc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)18,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,revDesc->getNumberOfTuples());
CPPUNIT_ASSERT(std::equal(expected1,expected1+18,desc->getConstPointer()));
CPPUNIT_ASSERT(std::equal(expected2,expected2+6,descIndx->getConstPointer()));
CPPUNIT_ASSERT(std::equal(expected3,expected3+14,revDescIndx->getConstPointer()));
mesh2->checkCoherency();
CPPUNIT_ASSERT_EQUAL(2,mesh2->getMeshDimension());
CPPUNIT_ASSERT_EQUAL(36,mesh2->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(9,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(9,descIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(48,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,desc->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(48,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,revDesc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)37,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)9,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(9,descIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)48,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,desc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)48,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,revDesc->getNumberOfTuples());
const int expected1[9]={0, 6, 12, 18, 24, 30, 36, 42, 48};
const int expected2[48]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 11, 12, 4, 13, 14, 15, 16, 17, 10, 18, 19, 13, 1, 20, 21, 22, 23, 24, 7, 25, 26, 27, 28, 22, 12, 29, 23, 30, 31, 32, 17, 33, 28, 34, 35, 30};
const int expected3[37]={0, 1, 3, 4, 6, 8, 9, 10, 12, 13, 14, 16, 17, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 32, 34, 35, 36, 37, 38, 40, 41, 43, 44, 45, 46, 47, 48};
mesh2->checkCoherency();
CPPUNIT_ASSERT_EQUAL(2,mesh2->getMeshDimension());
CPPUNIT_ASSERT_EQUAL(36,mesh2->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(9,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(9,descIndx->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(48,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,desc->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(48,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,revDesc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)37,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(37,revDescIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)9,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(9,descIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)48,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,desc->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)48,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(48,revDesc->getNumberOfTuples());
CPPUNIT_ASSERT(std::equal(expected1,expected1+9,descIndx->getConstPointer()));
CPPUNIT_ASSERT(std::equal(expected2,expected2+48,desc->getConstPointer()));
CPPUNIT_ASSERT(std::equal(expected3,expected3+37,revDescIndx->getConstPointer()));
MEDCouplingUMesh *subMesh=dynamic_cast<MEDCouplingUMesh *>(subMeshSimple);
CPPUNIT_ASSERT(subMesh);
std::string name(subMesh->getName());
- CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*mesh->getAllTypes().begin());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(mesh->getAllTypes().begin())));
- CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllTypes().size());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin());
- CPPUNIT_ASSERT(name=="PartOf_Toto");
+ CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*mesh->getAllGeoTypes().begin());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(mesh->getAllGeoTypes().begin())));
+ CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllGeoTypes().size());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllGeoTypes().begin());
+ CPPUNIT_ASSERT(name=="Toto");
CPPUNIT_ASSERT(mesh->getCoords()==subMesh->getCoords());
CPPUNIT_ASSERT_EQUAL(2,subMesh->getNumberOfCells());
const int subConn[10]={4,0,3,4,1,4,7,8,5,4};
const int subConnIndex[3]={0,5,10};
- CPPUNIT_ASSERT_EQUAL(10,subMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(3,subMesh->getNodalConnectivityIndex()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)10,subMesh->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)3,subMesh->getNodalConnectivityIndex()->getNbOfElems());
CPPUNIT_ASSERT(std::equal(subConn,subConn+10,subMesh->getNodalConnectivity()->getPointer()));
CPPUNIT_ASSERT(std::equal(subConnIndex,subConnIndex+3,subMesh->getNodalConnectivityIndex()->getPointer()));
subMesh->decrRef();
subMesh=dynamic_cast<MEDCouplingUMesh *>(subMeshSimple);
CPPUNIT_ASSERT(subMesh);
name=subMesh->getName();
- CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllTypes().size());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllTypes().begin());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(subMesh->getAllTypes().begin())));
- CPPUNIT_ASSERT(name=="PartOf_Toto");
+ CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllGeoTypes().size());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllGeoTypes().begin());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(subMesh->getAllGeoTypes().begin())));
+ CPPUNIT_ASSERT(name=="Toto");
CPPUNIT_ASSERT(mesh->getCoords()==subMesh->getCoords());
CPPUNIT_ASSERT_EQUAL(3,subMesh->getNumberOfCells());
const int subConn2[14]={4,0,3,4,1,3,4,5,2,4,6,7,4,3};
const int subConnIndex2[4]={0,5,9,14};
- CPPUNIT_ASSERT_EQUAL(14,subMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(4,subMesh->getNodalConnectivityIndex()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)14,subMesh->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)4,subMesh->getNodalConnectivityIndex()->getNbOfElems());
CPPUNIT_ASSERT(std::equal(subConn2,subConn2+14,subMesh->getNodalConnectivity()->getPointer()));
CPPUNIT_ASSERT(std::equal(subConnIndex2,subConnIndex2+4,subMesh->getNodalConnectivityIndex()->getPointer()));
const int tab3[3]={0,1,2};
MEDCouplingPointSet *subMeshSimple2=subMeshSimple->buildPartOfMySelf(tab3,tab3+3,true);
subMesh->decrRef();
name=subMeshSimple2->getName();
- CPPUNIT_ASSERT(name=="PartOf_Toto");
+ CPPUNIT_ASSERT(name=="Toto");
subMeshSimple2->decrRef();
//
mesh->decrRef();
MEDCouplingPointSet *subMeshSimple=mesh->buildPartOfMySelfNode(tab1,tab1+4,true);
MEDCouplingUMesh *subMesh=dynamic_cast<MEDCouplingUMesh *>(subMeshSimple);
CPPUNIT_ASSERT(subMesh);
- CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllTypes().size());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin());
+ CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllGeoTypes().size());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllGeoTypes().begin());
CPPUNIT_ASSERT_EQUAL(1,subMesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(5,subMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(2,subMesh->getNodalConnectivityIndex()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)5,subMesh->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)2,subMesh->getNodalConnectivityIndex()->getNbOfElems());
const int subConn[5]={4,7,8,5,4};
const int subConnIndex[3]={0,5};
CPPUNIT_ASSERT(std::equal(subConn,subConn+5,subMesh->getNodalConnectivity()->getPointer()));
subMeshSimple=mesh->buildPartOfMySelfNode(tab1,tab1+2,false);
subMesh=dynamic_cast<MEDCouplingUMesh *>(subMeshSimple);
CPPUNIT_ASSERT(subMesh);
- CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllTypes().size());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllTypes().begin());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllTypes().begin()));
+ CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllGeoTypes().size());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllGeoTypes().begin());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllGeoTypes().begin()));
CPPUNIT_ASSERT_EQUAL(3,subMesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(14,subMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(4,subMesh->getNodalConnectivityIndex()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)14,subMesh->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)4,subMesh->getNodalConnectivityIndex()->getNbOfElems());
const int subConn2[14]={3,4,5,2,4,6,7,4,3,4,7,8,5,4};
const int subConnIndex2[4]={0,4,9,14};
CPPUNIT_ASSERT(std::equal(subConn2,subConn2+14,subMesh->getNodalConnectivity()->getPointer()));
subMeshSimple=mesh->buildPartOfMySelfNode(tab2,tab2+7,true);
subMesh=dynamic_cast<MEDCouplingUMesh *>(subMeshSimple);
CPPUNIT_ASSERT(subMesh);
- CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllTypes().size());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllTypes().begin());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllTypes().begin()));
+ CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllGeoTypes().size());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllGeoTypes().begin());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllGeoTypes().begin()));
CPPUNIT_ASSERT_EQUAL(3,subMesh->getNumberOfCells());
subMeshSimple->decrRef();
//
void MEDCouplingBasicsTest1::testZipCoords()
{
MEDCouplingUMesh *mesh=build2DTargetMesh_1();
- CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
+ CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size());
CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension());
CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes());
CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells());
DataArrayDouble *oldCoords=mesh->getCoords();
oldCoords->incrRef();
mesh->zipCoords();
- CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
+ CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size());
CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension());
CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes());
CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells());
const int expectedTraducer[9]={0,1,-1,2,3,4,-1,5,6};
CPPUNIT_ASSERT(std::equal(expectedTraducer,expectedTraducer+9,traducer->getPointer()));
traducer->decrRef();
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllGeoTypes().begin());
CPPUNIT_ASSERT_EQUAL(2,subMesh->getNumberOfCells());
const int subConn[10]={4,0,2,3,1,4,5,6,4,3};
const int subConnIndex[3]={0,5,10};
CPPUNIT_ASSERT_EQUAL(7,subMesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(10,subMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(3,subMesh->getNodalConnectivityIndex()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)10,subMesh->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)3,subMesh->getNodalConnectivityIndex()->getNbOfElems());
CPPUNIT_ASSERT(std::equal(subConn,subConn+10,subMesh->getNodalConnectivity()->getPointer()));
CPPUNIT_ASSERT(std::equal(subConnIndex,subConnIndex+3,subMesh->getNodalConnectivityIndex()->getPointer()));
subMesh->decrRef();
subMeshPtSet=mesh->buildPartOfMySelf(tab1,tab1+2,false);
subMesh=dynamic_cast<MEDCouplingUMesh *>(subMeshPtSet);
CPPUNIT_ASSERT(subMesh);
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllGeoTypes().begin());
CPPUNIT_ASSERT_EQUAL(2,subMesh->getNumberOfCells());
CPPUNIT_ASSERT_EQUAL(7,subMesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(10,subMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(3,subMesh->getNodalConnectivityIndex()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)10,subMesh->getNodalConnectivity()->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL((std::size_t)3,subMesh->getNodalConnectivityIndex()->getNbOfElems());
CPPUNIT_ASSERT(std::equal(subConn,subConn+10,subMesh->getNodalConnectivity()->getPointer()));
CPPUNIT_ASSERT(std::equal(subConnIndex,subConnIndex+3,subMesh->getNodalConnectivityIndex()->getPointer()));
subMesh->decrRef();
CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells());
const int cells1[5]={0,1,2,3,4};
MEDCouplingPointSet *m1_1=m4->buildPartOfMySelf(cells1,cells1+5,true);
- m1_1->setName(m1->getName());
+ m1_1->setName(m1->getName().c_str());
CPPUNIT_ASSERT(m1->isEqual(m1_1,1e-12));
const int cells2[5]={5,6,7,8,9};
MEDCouplingPointSet *m2_1=m4->buildPartOfMySelf(cells2,cells2+5,true);
- m2_1->setName(m2->getName());
+ m2_1->setName(m2->getName().c_str());
CPPUNIT_ASSERT(m2->isEqual(m2_1,1e-12));
const int cells3[5]={10,11,12,13,14};
MEDCouplingPointSet *m3_1=m4->buildPartOfMySelf(cells3,cells3+5,true);
- m3_1->setName(m3->getName());
+ m3_1->setName(m3->getName().c_str());
CPPUNIT_ASSERT(m3->isEqual(m3_1,1e-12));
m1_1->decrRef(); m2_1->decrRef(); m3_1->decrRef();
//
std::string name=f3->getName();
CPPUNIT_ASSERT(name=="MeasureOfMesh_");
CPPUNIT_ASSERT(f3->getTypeOfField()==ON_CELLS);
- CPPUNIT_ASSERT(f3->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f3->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(1,f3->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(7,f3->getNumberOfTuples());
double values[7]={0.25,0.125,0.125,0.25,0.25,0.5,0.5};
void MEDCouplingBasicsTest1::testFillFromAnalytic()
{
MEDCouplingUMesh *m=build2DTargetMesh_1();
+ m->setTime(3.4,5,6); m->setTimeUnit("us");
+ int a,b;
MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_CELLS,1,func1);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.4,f1->getTime(a,b),1.e-14);
+ CPPUNIT_ASSERT_EQUAL(5,a); CPPUNIT_ASSERT_EQUAL(6,b);
+ CPPUNIT_ASSERT_EQUAL(std::string(f1->getTimeUnit()),std::string("us"));
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_CELLS);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
double values1[5]={-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9};
f1=m->fillFromAnalytic(ON_NODES,1,func1);
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
double values2[9]={-0.6,-0.1,0.4,-0.1,0.4,0.9,0.4,0.9,1.4};
f1=m->fillFromAnalytic(ON_NODES,2,func2);
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
double values3[18]={-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8};
MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_CELLS,1,"y+x");
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_CELLS);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
double values1[5]={-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9};
f1=m->fillFromAnalytic(ON_NODES,1,"y+2*x");
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
double values2[9]={-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1};
f1=m->fillFromAnalytic(ON_NODES,1,"2.*x+y");
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
tmp=f1->getArray()->getConstPointer();
f1=m->fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+2*(x+y)*JVec");
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
double values3[18]={-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8};
MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_NODES,2,func2);
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
f1->applyFunc(1,func1);
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
double values1[9]={-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2};
MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_NODES,2,func2);
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
//
CPPUNIT_ASSERT_THROW(f2->applyFunc("a/0"),INTERP_KERNEL::Exception);
f2->applyFunc("abs(u)^2.4+2*u");
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
double values2[18]={-0.9065304805418678, -0.85105859001709905, -0.19601892829446504, -0.37898777756476987,
//
f1->applyFunc(1,"x+y");
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
double values1[9]={-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2};
MEDCouplingFieldDouble *f3=(*f1)+(*f2);
f3->checkCoherency();
CPPUNIT_ASSERT(f3->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f3->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f3->getTimeDiscretization()==ONE_TIME);
double values1[9]={-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8};
const double *tmp=f3->getArray()->getConstPointer();
std::transform(tmp,tmp+9,values1,values1,std::minus<double>());
f3=(*f1)*(*f2);
f3->checkCoherency();
CPPUNIT_ASSERT(f3->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f3->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f3->getTimeDiscretization()==ONE_TIME);
double values2[9]={0.36,0.01,0.16,0.01,0.16,0.81,0.16,0.81,1.96};
tmp=f3->getArray()->getConstPointer();
std::transform(tmp,tmp+9,values2,values2,std::minus<double>());
MEDCouplingFieldDouble *f4=(*f1)-(*f3);
f4->checkCoherency();
CPPUNIT_ASSERT(f4->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f4->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f4->getTimeDiscretization()==ONE_TIME);
double values3[9]={0.6,0.1,-0.4,0.1,-0.4,-0.9,-0.4,-0.9,-1.4};
tmp=f4->getArray()->getConstPointer();
std::transform(tmp,tmp+9,values3,values3,std::minus<double>());
f4=(*f3)/(*f2);
f4->checkCoherency();
CPPUNIT_ASSERT(f4->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f4->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f4->getTimeDiscretization()==ONE_TIME);
tmp=f4->getArray()->getConstPointer();
for(int i=0;i<9;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,tmp[i],1.e-12);
f3->decrRef();
f4->decrRef();
//
- f4=f2->buildNewTimeReprFromThis(ONE_TIME,false);
+ f4=f2->buildNewTimeReprFromThis(NO_TIME,false);
f4->checkCoherency();
CPPUNIT_ASSERT(f4->getArray()==f2->getArray());
CPPUNIT_ASSERT(f4->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f4->getTimeDiscretization()==ONE_TIME);
+ CPPUNIT_ASSERT(f4->getTimeDiscretization()==NO_TIME);
CPPUNIT_ASSERT_THROW(f3=(*f1)+(*f4),INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *f5=f4->buildNewTimeReprFromThis(NO_TIME,false);
+ MEDCouplingFieldDouble *f5=f4->buildNewTimeReprFromThis(ONE_TIME,false);
CPPUNIT_ASSERT(f4->getArray()==f5->getArray());
CPPUNIT_ASSERT(f5->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f5->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f5->getTimeDiscretization()==ONE_TIME);
f3=(*f1)+(*f5);
tmp=f3->getArray()->getConstPointer();
double values4[9]={-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8};
f4->decrRef();
f3->decrRef();
//
- f4=f2->buildNewTimeReprFromThis(ONE_TIME,true);
+ f4=f2->buildNewTimeReprFromThis(NO_TIME,true);
f4->checkCoherency();
CPPUNIT_ASSERT(f4->getArray()!=f2->getArray());
CPPUNIT_ASSERT(f4->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f4->getTimeDiscretization()==ONE_TIME);
+ CPPUNIT_ASSERT(f4->getTimeDiscretization()==NO_TIME);
CPPUNIT_ASSERT_THROW(f3=(*f1)+(*f4),INTERP_KERNEL::Exception);
- f5=f4->buildNewTimeReprFromThis(NO_TIME,true);
+ f5=f4->buildNewTimeReprFromThis(ONE_TIME,true);
CPPUNIT_ASSERT(f4->getArray()!=f5->getArray());
CPPUNIT_ASSERT(f2->getArray()!=f5->getArray());
CPPUNIT_ASSERT(f5->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f5->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f5->getTimeDiscretization()==ONE_TIME);
f3=(*f1)+(*f5);
tmp=f3->getArray()->getConstPointer();
double values5[9]={-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8};
void MEDCouplingBasicsTest1::testOperationsOnFields2()
{
MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ m->setTime(3.4,5,6); m->setTimeUnit("us");
+ int a,b;
MEDCouplingFieldDouble *f1=m->fillFromAnalytic(ON_NODES,1,"x+y+z");
MEDCouplingFieldDouble *f2=m->fillFromAnalytic(ON_NODES,1,"a*a+b+c*c");
MEDCouplingFieldDouble *f3=(*f1)/(*f2);
f3->checkCoherency();
CPPUNIT_ASSERT(f3->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f3->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f3->getTimeDiscretization()==ONE_TIME);
const double expected1[9]={-2.4999999999999991, 1.2162162162162162, 0.77868852459016391,
0.7407407407407407, 1.129032258064516, 0.81632653061224492,
0.86538461538461531, 1.0919540229885056, 0.84302325581395343};
f2->decrRef();
//
f1=m->buildOrthogonalField();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.4,f1->getTime(a,b),1.e-14);
+ CPPUNIT_ASSERT_EQUAL(5,a); CPPUNIT_ASSERT_EQUAL(6,b);
+ CPPUNIT_ASSERT_EQUAL(std::string(f1->getTimeUnit()),std::string("us"));
f2=m->fillFromAnalytic(ON_CELLS,1,"x");
f3=(*f1)*(*f2);
const double expected2[15]={-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637};
(*f1)/=(*f2);
f1->checkCoherency();
CPPUNIT_ASSERT(f1->getTypeOfField()==ON_NODES);
- CPPUNIT_ASSERT(f1->getTimeDiscretization()==NO_TIME);
+ CPPUNIT_ASSERT(f1->getTimeDiscretization()==ONE_TIME);
const double expected1[9]={-2.4999999999999991, 1.2162162162162162, 0.77868852459016391,
0.7407407407407407, 1.129032258064516, 0.81632653061224492,
0.86538461538461531, 1.0919540229885056, 0.84302325581395343};
CPPUNIT_ASSERT_EQUAL(3,(int)v.size());
std::vector<const MEDCouplingUMesh *> v2(v.begin(),v.end());
MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(v2);
- m2->setName(m1->getName());
+ m2->setName(m1->getName().c_str());
CPPUNIT_ASSERT(m1->isEqual(m2,1.e-12));
for(std::vector<MEDCouplingUMesh *>::const_iterator iter=v.begin();iter!=v.end();iter++)
(*iter)->decrRef();
{
MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
double pos[12]={0.,0.,0.4,0.4,0.,0.4,0.1,0.1,0.25,0.,0.65,0.};
- std::vector<int> t1,t2;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> t1,t2;
//2D basic
targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2);
- CPPUNIT_ASSERT_EQUAL(6,(int)t1.size());
- CPPUNIT_ASSERT_EQUAL(7,(int)t2.size());
+ CPPUNIT_ASSERT_EQUAL(6,(int)t1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(7,(int)t2->getNbOfElems());
const int expectedValues1[6]={0,4,3,0,1,2};
const int expectedValues2[7]={0,1,2,3,4,5,6};
- CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues1));
- CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2));
+ CPPUNIT_ASSERT(std::equal(t1->begin(),t1->end(),expectedValues1));
+ CPPUNIT_ASSERT(std::equal(t2->begin(),t2->end(),expectedValues2));
//2D with no help of bounding box.
double center[2]={0.2,0.2};
MEDCouplingPointSet::Rotate2DAlg(center,0.78539816339744830962,6,pos);
targetMesh->rotate(center,0,0.78539816339744830962);
- t1.clear(); t2.clear();
targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2);
- CPPUNIT_ASSERT_EQUAL(6,(int)t1.size());
- CPPUNIT_ASSERT_EQUAL(7,(int)t2.size());
- CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues1));
- CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2));
+ CPPUNIT_ASSERT_EQUAL(6,(int)t1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(7,(int)t2->getNbOfElems());
+ CPPUNIT_ASSERT(std::equal(t1->begin(),t1->end(),expectedValues1));
+ CPPUNIT_ASSERT(std::equal(t2->begin(),t2->end(),expectedValues2));
//2D outside
const double pos1bis[2]={-0.3303300858899107,-0.11819805153394641};
CPPUNIT_ASSERT_EQUAL(-1,targetMesh->getCellContainingPoint(pos1bis,1e-12));
//test limits 2D
targetMesh=build2DTargetMesh_1();
const double pos2[2]={0.2,-0.05};
- t1.clear();
- targetMesh->getCellsContainingPoint(pos2,1e-12,t1);
- CPPUNIT_ASSERT_EQUAL(2,(int)t1.size());
+ std::vector<int> t11;
+ t11.clear();
+ targetMesh->getCellsContainingPoint(pos2,1e-12,t11);
+ CPPUNIT_ASSERT_EQUAL(2,(int)t11.size());
const int expectedValues3[2]={0,1};
- CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues3));
+ CPPUNIT_ASSERT(std::equal(t11.begin(),t11.end(),expectedValues3));
const double pos3[2]={0.2,0.2};
- t1.clear();
- targetMesh->getCellsContainingPoint(pos3,1e-12,t1);
- CPPUNIT_ASSERT_EQUAL(5,(int)t1.size());
+ t11.clear();
+ targetMesh->getCellsContainingPoint(pos3,1e-12,t11);
+ CPPUNIT_ASSERT_EQUAL(5,(int)t11.size());
const int expectedValues4[5]={0,1,2,3,4};
- CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues4));
+ CPPUNIT_ASSERT(std::equal(t11.begin(),t11.end(),expectedValues4));
CPPUNIT_ASSERT_EQUAL(0,targetMesh->getCellContainingPoint(pos3,1e-12));
targetMesh->decrRef();
//3D
const double pos4[3]={25.,25.,25.};
CPPUNIT_ASSERT_EQUAL(0,targetMesh->getCellContainingPoint(pos4,1e-12));
const double pos5[3]={50.,50.,50.};
- t1.clear();
- targetMesh->getCellsContainingPoint(pos5,1e-12,t1);
- CPPUNIT_ASSERT_EQUAL(8,(int)t1.size());
+ t11.clear();
+ targetMesh->getCellsContainingPoint(pos5,1e-12,t11);
+ CPPUNIT_ASSERT_EQUAL(8,(int)t11.size());
const int expectedValues5[8]={0,1,2,3,4,5,6,7};
- CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues5));
+ CPPUNIT_ASSERT(std::equal(t11.begin(),t11.end(),expectedValues5));
const double pos6[3]={0., 50., 0.};
- t1.clear();
- targetMesh->getCellsContainingPoint(pos6,1e-12,t1);
- CPPUNIT_ASSERT_EQUAL(2,(int)t1.size());
+ t11.clear();
+ targetMesh->getCellsContainingPoint(pos6,1e-12,t11);
+ CPPUNIT_ASSERT_EQUAL(2,(int)t11.size());
const int expectedValues6[2]={0,2};
- CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues6));
+ CPPUNIT_ASSERT(std::equal(t11.begin(),t11.end(),expectedValues6));
//3D outside
const double pos7[3]={-1.0,-1.0,0.};
CPPUNIT_ASSERT_EQUAL(-1,targetMesh->getCellContainingPoint(pos7,1e-12));
CPPUNIT_ASSERT_EQUAL(3,(int) dis.size());
CPPUNIT_ASSERT_EQUAL((int) INTERP_KERNEL::NORM_HEXA8,dis[0]);
CPPUNIT_ASSERT_EQUAL(27,dis[1]);
- CPPUNIT_ASSERT_EQUAL(0,dis[2]);
+ CPPUNIT_ASSERT_EQUAL(-1,dis[2]);
std::vector<const DataArrayInt *> idsPerType;
- CPPUNIT_ASSERT_THROW(mesh1->checkTypeConsistencyAndContig(dis, idsPerType),INTERP_KERNEL::Exception);
- dis[2]=-1;
CPPUNIT_ASSERT(!(mesh1->checkTypeConsistencyAndContig(dis, idsPerType)));
dis[0]=(int) INTERP_KERNEL::NORM_QUAD4;
CPPUNIT_ASSERT_THROW(mesh1->checkTypeConsistencyAndContig(dis, idsPerType),INTERP_KERNEL::Exception);
dis[2]=0;
DataArrayInt *ids=DataArrayInt::New();
ids->alloc(10,1);
- ids->fillWithValue(111);
+ ids->fillWithValue(23);
idsPerType.push_back(ids);
DataArrayInt* check=mesh1->checkTypeConsistencyAndContig(dis, idsPerType);
CPPUNIT_ASSERT(check);
mesh1->splitProfilePerType(ids,code,idsInPflPerType,pfls);
CPPUNIT_ASSERT_EQUAL(3,(int)code.size());
CPPUNIT_ASSERT_EQUAL((int) INTERP_KERNEL::NORM_HEXA8,code[0]);
- CPPUNIT_ASSERT_EQUAL(27,code[1]);
+ CPPUNIT_ASSERT_EQUAL(10,code[1]);
CPPUNIT_ASSERT_EQUAL(0,code[2]);
CPPUNIT_ASSERT_EQUAL(1,(int)idsInPflPerType.size());
CPPUNIT_ASSERT_EQUAL(1,(int)pfls.size());
- CPPUNIT_ASSERT(idsInPflPerType[0]->isEqual(*ids));
+ DataArrayInt *exp=DataArrayInt::New(); exp->alloc(10,1); exp->iota(0);
+ CPPUNIT_ASSERT(idsInPflPerType[0]->isEqual(*exp));
+ exp->decrRef();
CPPUNIT_ASSERT(pfls[0]->isEqual(*ids));
idsInPflPerType[0]->decrRef();
pfls[0]->decrRef();
int cells2[2]={25,26};
DataArrayInt* arr1;
- MEDCouplingUMesh *partMesh2=
- dynamic_cast<MEDCouplingUMesh *>(mesh1->buildPartAndReduceNodes(cells2,cells2+2,arr1));
+ MEDCouplingCMesh *partMesh2=
+ dynamic_cast<MEDCouplingCMesh *>(mesh1->buildPartAndReduceNodes(cells2,cells2+2,arr1));
CPPUNIT_ASSERT(partMesh2);
CPPUNIT_ASSERT_EQUAL(2,partMesh2->getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8));
CPPUNIT_ASSERT_EQUAL(12,partMesh2->getNumberOfNodes());
CPPUNIT_ASSERT_EQUAL(3,m1->getSpaceDimension());
m1->changeSpaceDimension(2);
CPPUNIT_ASSERT_EQUAL(2,m1->getSpaceDimension());
- m1->setName(m2->getName());
+ m1->setName(m2->getName().c_str());
CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
m1->changeSpaceDimension(3);
CPPUNIT_ASSERT_EQUAL(3,m1->getSpaceDimension());
m1->decrRef();
m2->decrRef();
}
+
+void MEDCouplingBasicsTest1::testSetConnectivity()
+{
+ MEDCouplingUMesh *m1 = build1DTargetMesh_1();
+
+ DataArrayInt * conn = DataArrayInt::New();
+ DataArrayInt * connI = DataArrayInt::New();
+ m1->setConnectivity(conn, connI, true); // was SEG-Faulting with empty arrays
+ conn->decrRef();
+ connI->decrRef();
+ m1->decrRef();
+}