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<std::string>::const_iterator iter=_info_on_compo.begin();iter!=_info_on_compo.end();iter++)
stream << "\"" << *iter << "\" ";
{
int oldNbOfNodes=getNumberOfNodes();
int nbOf1DCells=mesh1D->getNumberOfCells();
+ int spaceDim=getSpaceDimension();
DataArrayDouble *ret=DataArrayDouble::New();
std::vector<bool> 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<int> v;
std::vector<double> c;
double vec[3];
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<double>());
+ std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus<double>());
for(int j=0;j<oldNbOfNodes;j++)
- work=std::transform(vec,vec+3,retPtr+3*(i*oldNbOfNodes+j),work,std::plus<double>());
+ work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus<double>());
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<double>());
+ std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus<double>());
for(int j=0;j<oldNbOfNodes;j++)
- work=std::transform(vec,vec+3,retPtr+3*(i*oldNbOfNodes+j),work,std::plus<double>());
+ work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus<double>());
}
}
ret->copyStringInfoFrom(*getCoords());
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);
CPPUNIT_TEST( testGetNodeIdsNearPoints1 );
CPPUNIT_TEST( testFieldCopyTinyAttrFrom1 );
CPPUNIT_TEST( testExtrudedMesh5 );
+ CPPUNIT_TEST( testExtrudedMesh6 );
//MEDCouplingBasicsTestInterp.cxx
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
void testGetNodeIdsNearPoints1();
void testFieldCopyTinyAttrFrom1();
void testExtrudedMesh5();
+ void testExtrudedMesh6();
//MEDCouplingBasicsTestInterp.cxx
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
f2->decrRef();
}
+/*!
+ * 1D -> 2D extrusion with rotation
+ */
void MEDCouplingBasicsTest::testExtrudedMesh5()
{
const double coo1[4]={0.,1.,2.,3.5};
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();
+}
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