From: ageay Date: Wed, 1 Dec 2010 09:27:14 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=542dc8b402af7b1926252c51e7d08c259cab827d;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index bc8750b14..cf6aa2a1d 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -86,7 +86,7 @@ bool DataArray::areInfoEquals(const DataArray& other) const void DataArray::reprWithoutNameStream(std::ostream& stream) const { - stream << "Nb of components : "<< getNumberOfComponents() << "\n"; + stream << "Number of components : "<< getNumberOfComponents() << "\n"; stream << "Info of these components : "; for(std::vector::const_iterator iter=_info_on_compo.begin();iter!=_info_on_compo.end();iter++) stream << "\"" << *iter << "\" "; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index be045a618..9db650a54 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -2069,13 +2069,14 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslation(const MEDCoupli { int oldNbOfNodes=getNumberOfNodes(); int nbOf1DCells=mesh1D->getNumberOfCells(); + int spaceDim=getSpaceDimension(); DataArrayDouble *ret=DataArrayDouble::New(); std::vector isQuads; int nbOfLevsInVec=isQuad?2*nbOf1DCells+1:nbOf1DCells+1; - ret->alloc(oldNbOfNodes*nbOfLevsInVec,3); + ret->alloc(oldNbOfNodes*nbOfLevsInVec,spaceDim); double *retPtr=ret->getPointer(); const double *coords=getCoords()->getConstPointer(); - double *work=std::copy(coords,coords+3*oldNbOfNodes,retPtr); + double *work=std::copy(coords,coords+spaceDim*oldNbOfNodes,retPtr); std::vector v; std::vector c; double vec[3]; @@ -2088,17 +2089,17 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslation(const MEDCoupli c.resize(0); mesh1D->getCoordinatesOfNode(v[isQuad?2:1],c); mesh1D->getCoordinatesOfNode(v[0],c); - std::transform(c.begin(),c.begin()+3,c.begin()+3,vec,std::minus()); + std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus()); for(int j=0;j()); + work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus()); if(isQuad) { c.resize(0); mesh1D->getCoordinatesOfNode(v[1],c); mesh1D->getCoordinatesOfNode(v[0],c); - std::transform(c.begin(),c.begin()+3,c.begin()+3,vec,std::minus()); + std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus()); for(int j=0;j()); + work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus()); } } ret->copyStringInfoFrom(*getCoords()); @@ -2130,6 +2131,8 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(con throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : not implemented for quadratic cells !"); int oldNbOfNodes=getNumberOfNodes(); int nbOf1DCells=mesh1D->getNumberOfCells(); + if(nbOf1DCells<2) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !"); DataArrayDouble *ret=DataArrayDouble::New(); int nbOfLevsInVec=nbOf1DCells+1; ret->alloc(oldNbOfNodes*nbOfLevsInVec,2); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx index 2d5614869..50adf47ac 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx @@ -156,6 +156,7 @@ namespace ParaMEDMEM CPPUNIT_TEST( testGetNodeIdsNearPoints1 ); CPPUNIT_TEST( testFieldCopyTinyAttrFrom1 ); CPPUNIT_TEST( testExtrudedMesh5 ); + CPPUNIT_TEST( testExtrudedMesh6 ); //MEDCouplingBasicsTestInterp.cxx CPPUNIT_TEST( test2DInterpP0P0_1 ); CPPUNIT_TEST( test2DInterpP0P0PL_1 ); @@ -340,6 +341,7 @@ namespace ParaMEDMEM void testGetNodeIdsNearPoints1(); void testFieldCopyTinyAttrFrom1(); void testExtrudedMesh5(); + void testExtrudedMesh6(); //MEDCouplingBasicsTestInterp.cxx void test2DInterpP0P0_1(); void test2DInterpP0P0PL_1(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index 279740819..4ce40a70e 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -3352,6 +3352,9 @@ void MEDCouplingBasicsTest::testFieldCopyTinyAttrFrom1() f2->decrRef(); } +/*! + * 1D -> 2D extrusion with rotation + */ void MEDCouplingBasicsTest::testExtrudedMesh5() { const double coo1[4]={0.,1.,2.,3.5}; @@ -3409,3 +3412,54 @@ void MEDCouplingBasicsTest::testExtrudedMesh5() b->decrRef(); a->decrRef(); } + +/*! + * 1D -> 2D extrusion without rotation + */ +void MEDCouplingBasicsTest::testExtrudedMesh6() +{ + const double coo1[4]={0.,1.,2.,3.5}; + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(4,1); + std::copy(coo1,coo1+4,a->getPointer()); + MEDCouplingCMesh *b=MEDCouplingCMesh::New(); + b->setCoordsAt(0,a); + MEDCouplingUMesh *c=b->buildUnstructured(); + CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension()); + c->changeSpaceDimension(2); + // + DataArrayDouble *d=DataArrayDouble::New(); + d->alloc(5,1); + d->iota(); + MEDCouplingCMesh *e=MEDCouplingCMesh::New(); + e->setCoordsAt(0,d); + MEDCouplingUMesh *f=e->buildUnstructured(); + DataArrayDouble *d2=f->getCoords()->applyFunc("x*x/2"); + f->setCoords(d2); + f->changeSpaceDimension(2); + // + const double center[2]={0.,0.}; + f->rotate(center,0,M_PI/3); + MEDCouplingUMesh *g=c->buildExtrudedMeshFromThis(f,0); + g->checkCoherency(); + const double expected1[]={ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 }; + MEDCouplingFieldDouble *f1=g->getMeasureField(true); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-12); + + const double expected2[]={0.625, 0.21650635094610962, 1.625, 0.21650635094610959, 2.8750000000000004, 0.21650635094610965, 1.1250000000000002, 1.0825317547305482, 2.125, 1.0825317547305482, 3.3750000000000004, 1.0825317547305484, 2.125, 2.8145825622994254, 3.125, 2.8145825622994254, 4.375, 2.8145825622994254, 3.6250000000000009, 5.4126587736527414, 4.625, 5.4126587736527414, 5.875, 5.4126587736527414}; + DataArrayDouble *f2=g->getBarycenterAndOwner(); + for(int i=0;i<24;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f2->getIJ(0,i),1e-12); + // + f1->decrRef(); + f2->decrRef(); + g->decrRef(); + f->decrRef(); + e->decrRef(); + d->decrRef(); + d2->decrRef(); + c->decrRef(); + b->decrRef(); + a->decrRef(); +} diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 97bd6c5c5..4e56ef238 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -5005,6 +5005,42 @@ class MEDCouplingBasicsTest(unittest.TestCase): pass # pass + + def testExtrudedMesh6(self): + coo1=[0.,1.,2.,3.5] + a=DataArrayDouble.New(); + a.setValues(coo1,4,1); + b=MEDCouplingCMesh.New(); + b.setCoordsAt(0,a); + c=b.buildUnstructured(); + self.assertEqual(1,c.getSpaceDimension()); + c.changeSpaceDimension(2); + # + d=DataArrayDouble.New(); + d.alloc(5,1); + d.iota(); + e=MEDCouplingCMesh.New(); + e.setCoordsAt(0,d); + f=e.buildUnstructured(); + d2=f.getCoords().applyFunc("x*x/2"); + f.setCoords(d2); + f.changeSpaceDimension(2); + # + center=[0.,0.] + f.rotate(center,[],pi/3); + g=c.buildExtrudedMeshFromThis(f,0); + g.checkCoherency(); + expected1=[ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 ] + f1=g.getMeasureField(True); + for i in xrange(12): + self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),12); + pass + expected2=[0.625, 0.21650635094610962, 1.625, 0.21650635094610959, 2.8750000000000004, 0.21650635094610965, 1.1250000000000002, 1.0825317547305482, 2.125, 1.0825317547305482, 3.3750000000000004, 1.0825317547305484, 2.125, 2.8145825622994254, 3.125, 2.8145825622994254, 4.375, 2.8145825622994254, 3.6250000000000009, 5.4126587736527414, 4.625, 5.4126587736527414, 5.875, 5.4126587736527414] + f2=g.getBarycenterAndOwner(); + for i in xrange(24): + self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),12); + pass + pass def setUp(self): pass