return new MEDCouplingFieldDiscretizationP0;
}
-const char *MEDCouplingFieldDiscretizationP0::getStringRepr() const
+std::string MEDCouplingFieldDiscretizationP0::getStringRepr() const
{
- return REPR;
+ return std::string(REPR);
}
bool MEDCouplingFieldDiscretizationP0::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
return new MEDCouplingFieldDiscretizationP1;
}
-const char *MEDCouplingFieldDiscretizationP1::getStringRepr() const
+std::string MEDCouplingFieldDiscretizationP1::getStringRepr() const
{
- return REPR;
+ return std::string(REPR);
}
bool MEDCouplingFieldDiscretizationP1::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
return new MEDCouplingFieldDiscretizationGauss(*this);
}
-const char *MEDCouplingFieldDiscretizationGauss::getStringRepr() const
+std::string MEDCouplingFieldDiscretizationGauss::getStringRepr() const
{
- return REPR;
+ std::ostringstream oss; oss << REPR << "." << std::endl;
+ if(_discr_per_cell)
+ {
+ if(_discr_per_cell->isAllocated())
+ {
+ oss << "Discretization per cell : ";
+ std::copy(_discr_per_cell->begin(),_discr_per_cell->end(),std::ostream_iterator<int>(oss,", "));
+ oss << std::endl;
+ }
+ }
+ oss << "Presence of " << _loc.size() << " localizations." << std::endl;
+ int i=0;
+ for(std::vector<MEDCouplingGaussLocalization>::const_iterator it=_loc.begin();it!=_loc.end();it++,i++)
+ {
+ oss << "+++++ Localization #" << i << " +++++" << std::endl;
+ oss << (*it).getStringRepr();
+ oss << "++++++++++" << std::endl;
+ }
+ return oss.str();
}
int MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh *) const
return new MEDCouplingFieldDiscretizationGaussNE(*this);
}
-const char *MEDCouplingFieldDiscretizationGaussNE::getStringRepr() const
+std::string MEDCouplingFieldDiscretizationGaussNE::getStringRepr() const
{
- return REPR;
+ return std::string(REPR);
}
bool MEDCouplingFieldDiscretizationGaussNE::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const = 0;
virtual bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
virtual MEDCouplingFieldDiscretization *clone() const = 0;
- virtual const char *getStringRepr() const = 0;
+ virtual std::string getStringRepr() const = 0;
virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const = 0;
virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const = 0;
public:
TypeOfField getEnum() const;
MEDCouplingFieldDiscretization *clone() const;
- const char *getStringRepr() const;
+ std::string getStringRepr() const;
bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
public:
TypeOfField getEnum() const;
MEDCouplingFieldDiscretization *clone() const;
- const char *getStringRepr() const;
+ std::string getStringRepr() const;
bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
MEDCouplingFieldDiscretization *clone() const;
- const char *getStringRepr() const;
+ std::string getStringRepr() const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
MEDCouplingFieldDiscretizationGaussNE();
TypeOfField getEnum() const;
MEDCouplingFieldDiscretization *clone() const;
- const char *getStringRepr() const;
+ std::string getStringRepr() const;
bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
#include <cmath>
#include <numeric>
#include <sstream>
+#include <iterator>
#include <algorithm>
ParaMEDMEM::MEDCouplingGaussLocalization::MEDCouplingGaussLocalization(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
return (int)_ref_coord.size()/dim;
}
+std::string ParaMEDMEM::MEDCouplingGaussLocalization::getStringRepr() const
+{
+ std::ostringstream oss;
+ oss << "CellType : " << INTERP_KERNEL::CellModel::GetCellModel(_type).getRepr() << std::endl;
+ oss << "Ref coords : "; std::copy(_ref_coord.begin(),_ref_coord.end(),std::ostream_iterator<double>(oss,", ")); oss << std::endl;
+ oss << "Localization coords : "; std::copy(_gauss_coord.begin(),_gauss_coord.end(),std::ostream_iterator<double>(oss,", ")); oss << std::endl;
+ oss << "Weight : "; std::copy(_weight.begin(),_weight.end(),std::ostream_iterator<double>(oss,", ")); oss << std::endl;
+ return oss.str();
+}
+
bool ParaMEDMEM::MEDCouplingGaussLocalization::isEqual(const MEDCouplingGaussLocalization& other, double eps) const
{
if(_type!=other._type)
int getNumberOfGaussPt() const { return (int)_weight.size(); }
int getDimension() const;
int getNumberOfPtsInRefCell() const;
+ std::string getStringRepr() const;
void checkCoherency() const throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDCouplingGaussLocalization& other, double eps) const;
void pushTinySerializationIntInfo(std::vector<int>& tinyInfo) const;
da2->decrRef();
da->decrRef();
}
+
+void MEDCouplingBasicsTest5::testBuildDescendingConnec2Of3DMesh1()
+{
+ MEDCouplingUMesh *mesh=build3DSourceMesh_1();
+ DataArrayInt *desc=DataArrayInt::New();
+ DataArrayInt *descIndx=DataArrayInt::New();
+ DataArrayInt *revDesc=DataArrayInt::New();
+ DataArrayInt *revDescIndx=DataArrayInt::New();
+ //
+ MEDCouplingUMesh *mesh2=mesh->buildDescendingConnectivity2(desc,descIndx,revDesc,revDescIndx);
+ mesh2->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(2,mesh2->getMeshDimension());
+ CPPUNIT_ASSERT_EQUAL(30,mesh2->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(31,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(31,revDescIndx->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(13,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(13,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());
+ const int expected1[48]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,-10,15,-5,-13,16,17,-14,18,-4,19,-2,20,21,22,23,24,25,-11,26,-1,-12,-25,-22,27,28,-7,-20,-24,29,-16,-18,30,-8,-28};
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+48,desc->getConstPointer()));
+ const int expected2[13]={0,4,8,12,16,20,24,28,32,36,40,44,48};
+ CPPUNIT_ASSERT(std::equal(expected2,expected2+13,descIndx->getConstPointer()));
+ const int expected3[31]={0,2,4,5,7,9,10,12,14,15,17,19,21,23,25,26,28,29,31,32,34,35,37,38,40,42,43,44,46,47,48};
+ CPPUNIT_ASSERT(std::equal(expected3,expected3+31,revDescIndx->getConstPointer()));
+ const int expected4[48]={0,8,0,6,0,0,5,1,4,1,1,9,1,11,2,2,3,2,7,2,8,3,4,3,5,3,4,10,4,5,11,5,6,10,6,6,9,7,7,10,7,8,8,9,9,11,10,11};
+ CPPUNIT_ASSERT(std::equal(expected4,expected4+48,revDesc->getConstPointer()));
+ DataArrayInt *conn=mesh2->getNodalConnectivity();
+ DataArrayInt *connIndex=mesh2->getNodalConnectivityIndex();
+ const int expected5[31]={0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120};
+ CPPUNIT_ASSERT(std::equal(expected5,expected5+31,connIndex->getConstPointer()));
+ const int expected6[120]={3,8,1,7,3,8,3,1,3,1,3,7,3,7,3,8,3,6,0,8,3,6,2,0,3,0,2,8,3,8,2,6,3,7,4,5,3,7,8,4,3,4,8,5,3,5,8,7,3,6,8,4,3,6,7,8,3,4,7,6,3,8,4,0,3,0,4,6,3,6,3,8,3,7,3,6,3,8,0,1,3,1,0,3,3,3,0,8,3,4,1,5,3,4,8,1,3,1,8,5,3,1,7,5,3,0,2,3,3,3,2,8,3,1,4,0,3,3,2,6};
+ CPPUNIT_ASSERT(std::equal(expected6,expected6+120,conn->getConstPointer()));
+ //
+ desc->decrRef();
+ descIndx->decrRef();
+ revDesc->decrRef();
+ revDescIndx->decrRef();
+ mesh2->decrRef();
+ mesh->decrRef();
+}
CPPUNIT_TEST( testBuildSlice3DSurf1 );
CPPUNIT_TEST( testDataArrayDoubleAdvSetting1 );
CPPUNIT_TEST( testDataArrayIntAdvSetting1 );
+ CPPUNIT_TEST( testBuildDescendingConnec2Of3DMesh1 );
CPPUNIT_TEST_SUITE_END();
public:
void testUMeshTessellate2D1();
void testBuildSlice3DSurf1();
void testDataArrayDoubleAdvSetting1();
void testDataArrayIntAdvSetting1();
+ void testBuildDescendingConnec2Of3DMesh1();
};
}
self.assertEqual(expected6[i],dac.getIJ(0,i));
pass
pass
+
+ def testBuildDescendingConnec2Of3DMesh1(self):
+ mesh=MEDCouplingDataForTest.build3DSourceMesh_1();
+ #
+ mesh2,desc,descIndx,revDesc,revDescIndx=mesh.buildDescendingConnectivity2();
+ mesh2.checkCoherency();
+ self.assertEqual(2,mesh2.getMeshDimension());
+ self.assertEqual(30,mesh2.getNumberOfCells());
+ self.assertEqual(31,revDescIndx.getNbOfElems()); self.assertEqual(31,revDescIndx.getNumberOfTuples());
+ self.assertEqual(13,descIndx.getNbOfElems()); self.assertEqual(13,descIndx.getNumberOfTuples());
+ self.assertEqual(48,desc.getNbOfElems()); self.assertEqual(48,desc.getNumberOfTuples());
+ self.assertEqual(48,revDesc.getNbOfElems()); self.assertEqual(48,revDesc.getNumberOfTuples());
+ expected1=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,-10,15,-5,-13,16,17,-14,18,-4,19,-2,20,21,22,23,24,25,-11,26,-1,-12,-25,-22,27,28,-7,-20,-24,29,-16,-18,30,-8,-28]
+ self.assertEqual(expected1,desc.getValues());
+ expected2=[0,4,8,12,16,20,24,28,32,36,40,44,48]
+ self.assertEqual(expected2,descIndx.getValues());
+ expected3=[0,2,4,5,7,9,10,12,14,15,17,19,21,23,25,26,28,29,31,32,34,35,37,38,40,42,43,44,46,47,48]
+ self.assertEqual(expected3,revDescIndx.getValues());
+ expected4=[0,8,0,6,0,0,5,1,4,1,1,9,1,11,2,2,3,2,7,2,8,3,4,3,5,3,4,10,4,5,11,5,6,10,6,6,9,7,7,10,7,8,8,9,9,11,10,11]
+ self.assertEqual(expected4,revDesc.getValues());
+ conn=mesh2.getNodalConnectivity();
+ connIndex=mesh2.getNodalConnectivityIndex();
+ expected5=[0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120]
+ self.assertEqual(expected5,connIndex.getValues());
+ expected6=[3,8,1,7,3,8,3,1,3,1,3,7,3,7,3,8,3,6,0,8,3,6,2,0,3,0,2,8,3,8,2,6,3,7,4,5,3,7,8,4,3,4,8,5,3,5,8,7,3,6,8,4,3,6,7,8,3,4,7,6,3,8,4,0,3,0,4,6,3,6,3,8,3,7,3,6,3,8,0,1,3,1,0,3,3,3,0,8,3,4,1,5,3,4,8,1,3,1,8,5,3,1,7,5,3,0,2,3,3,3,2,8,3,1,4,0,3,3,2,6]
+ self.assertEqual(expected6,conn.getValues());
+ pass
def setUp(self):
pass