From 5bd6f8beeda7221a6861df71cd5ba0ca64dd276a Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 8 Apr 2011 17:00:37 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDCoupling/MEDCouplingMemArray.cxx | 2 + .../Test/MEDCouplingBasicsTest.hxx | 5 ++ .../Test/MEDCouplingBasicsTest0.cxx | 33 ++++++++++ .../Test/MEDCouplingBasicsTest4.cxx | 62 +++++++++++++++++++ src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 60 ++++++++++++++++++ .../MEDCouplingDataForTest.py | 30 +++++++++ 6 files changed, 192 insertions(+) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 855dc3843..bfe6ea7a5 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -284,6 +284,7 @@ void DataArrayDouble::cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL: const double *ptI=other.getConstPointer(); for(int i=0;i buildMultiFields_2(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx index 526668689..d3deac12f 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx @@ -1132,6 +1132,39 @@ MEDCouplingUMesh *MEDCouplingBasicsTest::buildHexa8Mesh_1() return mesh; } +MEDCouplingUMesh *MEDCouplingBasicsTest::buildPointe_1(MEDCouplingUMesh *& m1) +{ + MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Pointe.med",3); + MEDCouplingUMesh *mesh2=MEDCouplingUMesh::New("Pointe.med",2); + const double coords[57]={0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 0.0, 2.0, 1.0, -2.0, 0.0, 1.0, 0.0, -2.0, 1.0, 1.0, 1.0, 2.0, -1.0, 1.0, 2.0, -1.0, -1.0, 2.0, 1.0, -1.0, 2.0, 1.0, 1.0, 3.0, -1.0, 1.0, 3.0, -1.0, -1.0, 3.0, 1.0, -1.0, 3.0, 1.0, 1.0, 4.0, -1.0, 1.0, 4.0, -1.0, -1.0, 4.0, 1.0, -1.0, 4.0, 0.0, 0.0, 5.0}; + const int conn[74]={0,1,2,5,0,1,3,2,0,1,4,3,0,1,5,4,1,6,3,2,1,7,4,3,1,8,5,4,1,9,2,5,1,6,2,9,1,7,3,6,1,8,4,7,1,9,5,8, 6,7,8,9,1,14,17,16,15,18, 10,11,12,13,6,7,8,9,14,15,16,17,10,11,12,13}; + DataArrayDouble *coo=DataArrayDouble::New(); + coo->alloc(19,3); + std::copy(coords,coords+57,coo->getPointer()); + mesh->setCoords(coo); + mesh2->setCoords(coo); + coo->decrRef(); + mesh->allocateCells(16); + for(int i=0;i<12;i++) + mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+4*i); + mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+48); + mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+53); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+58); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+66); + mesh->finishInsertingCells(); + //[1,34,29,23,41,32] + const int conn2[20]={0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9}; + mesh2->allocateCells(6); + for(int i=0;i<4;i++) + mesh2->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn2+3*i); + mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+12); + mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+16); + mesh2->finishInsertingCells(); + m1=mesh2; + // + return mesh; +} + double MEDCouplingBasicsTest::sumAll(const std::vector< std::map >& matrix) { double ret=0.; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index 017cb95eb..82f5389d3 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -956,3 +956,65 @@ void MEDCouplingBasicsTest::testUnPolyze2() m->decrRef(); m2->decrRef(); } + +void MEDCouplingBasicsTest::testDACpyFrom1() +{ + DataArrayDouble *d=DataArrayDouble::New(); + d->alloc(12,1); + d->iota(14.); + d->rearrange(3); + d->setName("Toto"); + d->setInfoOnComponent(0,"X [m]"); + d->setInfoOnComponent(1,"Y [m]"); + d->setInfoOnComponent(2,"Z [m]"); + // + DataArrayDouble *d1=DataArrayDouble::New(); + CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12)); + d1->cpyFrom(*d); + CPPUNIT_ASSERT(d->isEqual(*d1,1e-12)); + d1->cpyFrom(*d); + CPPUNIT_ASSERT(d->isEqual(*d1,1e-12)); + d1->rearrange(2); + CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12)); + d1->cpyFrom(*d); + CPPUNIT_ASSERT(d->isEqual(*d1,1e-12)); + // + DataArrayInt *d2=d->convertToIntArr(); + DataArrayInt *d4=DataArrayInt::New(); + CPPUNIT_ASSERT(!d2->isEqual(*d4)); + d4->cpyFrom(*d2); + CPPUNIT_ASSERT(d2->isEqual(*d4)); + d4->cpyFrom(*d2); + CPPUNIT_ASSERT(d2->isEqual(*d4)); + d4->rearrange(2); + CPPUNIT_ASSERT(!d2->isEqual(*d4)); + d4->cpyFrom(*d2); + CPPUNIT_ASSERT(d2->isEqual(*d4)); + // + d->decrRef(); + d1->decrRef(); + d2->decrRef(); + d4->decrRef(); +} + +void MEDCouplingBasicsTest::testDAITransformWithIndArr1() +{ + const int tab1[4]={17,18,22,19}; + const int tab2[12]={0,1,1,3,3,0,1,3,2,2,3,0}; + const int expected[12]={17,18,18,19,19,17,18,19,22,22,19,17}; + DataArrayInt *d=DataArrayInt::New(); + d->alloc(4,1); + std::copy(tab1,tab1+4,d->getPointer()); + DataArrayInt *d1=DataArrayInt::New(); + d1->alloc(12,1); + std::copy(tab2,tab2+12,d1->getPointer()); + // + d1->transformWithIndArr(d->getConstPointer(),d->getConstPointer()+d->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(12,d1->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,d1->getNumberOfComponents()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected[i],d1->getIJ(i,0)); + // + d->decrRef(); + d1->decrRef(); +} diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 8378332de..1d49f3e5c 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -7022,6 +7022,66 @@ class MEDCouplingBasicsTest(unittest.TestCase): m2.unPolyze(); self.assertTrue(m3.isEqual(m2,1e-12)); pass + + def testDACpyFrom1(self): + d=DataArrayDouble.New(); + d.alloc(12,1); + d.iota(14.); + d.rearrange(3); + d.setName("Toto"); + d.setInfoOnComponent(0,"X [m]"); + d.setInfoOnComponent(1,"Y [m]"); + d.setInfoOnComponent(2,"Z [m]"); + # + d1=DataArrayDouble.New(); + self.assertTrue(not d.isEqual(d1,1e-12)); + d1.cpyFrom(d); + self.assertTrue(d.isEqual(d1,1e-12)); + d1.cpyFrom(d); + self.assertTrue(d.isEqual(d1,1e-12)); + d1.rearrange(2); + self.assertTrue(not d.isEqual(d1,1e-12)); + d1.cpyFrom(d); + self.assertTrue(d.isEqual(d1,1e-12)); + # + d2=d.convertToIntArr(); + d4=DataArrayInt.New(); + self.assertTrue(not d2.isEqual(d4)); + d4.cpyFrom(d2); + self.assertTrue(d2.isEqual(d4)); + d4.cpyFrom(d2); + self.assertTrue(d2.isEqual(d4)); + d4.rearrange(2); + self.assertTrue(not d2.isEqual(d4)); + d4.cpyFrom(d2); + self.assertTrue(d2.isEqual(d4)); + pass + + def testDAITransformWithIndArr1(self): + tab1=[17,18,22,19] + tab2=[0,1,1,3,3,0,1,3,2,2,3,0] + expected=[17,18,18,19,19,17,18,19,22,22,19,17] + d=DataArrayInt.New(); + d.setValues(tab1,4,1); + d1=DataArrayInt.New(); + d1.setValues(tab2,12,1); + d2=d1[:] + # + d1.transformWithIndArr(d); + self.assertEqual(12,d1.getNumberOfTuples()); + self.assertEqual(1,d1.getNumberOfComponents()); + for i in xrange(12): + self.assertEqual(expected[i],d1.getIJ(i,0)); + pass + # + d1=d2 + d1.transformWithIndArr(tab1) + self.assertEqual(12,d1.getNumberOfTuples()); + self.assertEqual(1,d1.getNumberOfComponents()); + for i in xrange(12): + self.assertEqual(expected[i],d1.getIJ(i,0)); + pass + pass def setUp(self): pass diff --git a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py index 421222d63..184f94d24 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py @@ -535,6 +535,35 @@ class MEDCouplingDataForTest: mesh.setCoords(coo); return mesh; + def buildPointe_1(self): + mesh=MEDCouplingUMesh.New("Pointe.med",3); + mesh2=MEDCouplingUMesh.New("Pointe.med",2); + coords=[0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 0.0, 2.0, 1.0, -2.0, 0.0, 1.0, 0.0, -2.0, 1.0, 1.0, 1.0, 2.0, -1.0, 1.0, 2.0, -1.0, -1.0, 2.0, 1.0, -1.0, 2.0, 1.0, 1.0, 3.0, -1.0, 1.0, 3.0, -1.0, -1.0, 3.0, 1.0, -1.0, 3.0, 1.0, 1.0, 4.0, -1.0, 1.0, 4.0, -1.0, -1.0, 4.0, 1.0, -1.0, 4.0, 0.0, 0.0, 5.0] + conn=[0,1,2,5,0,1,3,2,0,1,4,3,0,1,5,4,1,6,3,2,1,7,4,3,1,8,5,4,1,9,2,5,1,6,2,9,1,7,3,6,1,8,4,7,1,9,5,8, 6,7,8,9,1,14,17,16,15,18, 10,11,12,13,6,7,8,9,14,15,16,17,10,11,12,13] + coo=DataArrayDouble.New(); + coo.setValues(coords,19,3); + mesh.setCoords(coo); + mesh2.setCoords(coo); + mesh.allocateCells(16); + for i in xrange(12): + mesh.insertNextCell(NORM_TETRA4,4,conn[4*i:4*i+4]) + pass + mesh.insertNextCell(NORM_PYRA5,5,conn[48:53]) + mesh.insertNextCell(NORM_PYRA5,5,conn[53:58]) + mesh.insertNextCell(NORM_HEXA8,8,conn[58:66]) + mesh.insertNextCell(NORM_HEXA8,8,conn[66:74]) + mesh.finishInsertingCells(); + #[1,34,29,23,41,32] + conn2=[0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9] + mesh2.allocateCells(6); + for i in xrange(4): + mesh2.insertNextCell(NORM_TRI3,3,conn2[3*i:3*i+3]) + pass + mesh2.insertNextCell(NORM_QUAD4,4,conn2[12:16]) + mesh2.insertNextCell(NORM_QUAD4,4,conn2[16:20]) + mesh2.finishInsertingCells(); + return [mesh,mesh2] + build2DTargetMesh_1=classmethod(build2DTargetMesh_1) build2DSourceMesh_1=classmethod(build2DSourceMesh_1) build3DTargetMesh_1=classmethod(build3DTargetMesh_1) @@ -557,4 +586,5 @@ class MEDCouplingDataForTest: build3DMultiTypes_1=classmethod(build3DMultiTypes_1) buildCoordsForMultiTypes_1=classmethod(buildCoordsForMultiTypes_1) buildHexa8Mesh_1=classmethod(buildHexa8Mesh_1) + buildPointe_1=classmethod(buildPointe_1) pass -- 2.39.2