ret << "Description of mesh : \"" << getDescription() << "\"\n";
int tmpp1,tmpp2;
double tt=getTime(tmpp1,tmpp2);
- ret << "Time attached to the mesh (unit) : " << tt << " (" << getTimeUnit() << ")\n";
+ ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n";
ret << "Mesh and SpaceDimension dimension : " << getSpaceDimension() << "\n\nArrays :\n________\n\n";
if(_x_array)
ret << "Description of mesh : \"" << getDescription() << "\"\n";
int tmpp1,tmpp2;
double tt=getTime(tmpp1,tmpp2);
- ret << "Time attached to the mesh (unit) : " << tt << " (" << getTimeUnit() << ")\n";
+ ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n";
ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n";
ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n";
int MEDCouplingExtrudedMesh::getCellContainingPoint(const double *pos, double eps) const
{
- //not implemented yet
- return -1;
+ throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::getCellContainingPoint : not implemented yet !");
}
MEDCouplingExtrudedMesh::~MEDCouplingExtrudedMesh()
arr->getTuple(id,res);
}
+DataArrayDouble *MEDCouplingFieldDiscretizationP0::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+ std::vector<int> elts,eltsIndex;
+ mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
+ int spaceDim=mesh->getSpaceDimension();
+ int nbOfComponents=arr->getNumberOfComponents();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ ret->alloc(nbOfPoints,nbOfComponents);
+ double *ptToFill=ret->getPointer();
+ for(int i=0;i<nbOfPoints;i++,ptToFill+=nbOfComponents)
+ if(eltsIndex[i+1]-eltsIndex[i]>=1)
+ arr->getTuple(elts[eltsIndex[i]],ptToFill);
+ else
+ {
+ std::ostringstream oss; oss << "Point #" << i << " with coordinates : (";
+ std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator<double>(oss,", "));
+ oss << ") detected outside mesh : unable to apply P0::getValueOnMulti ! ";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ ret->incrRef();
+ return ret;
+}
+
/*!
* Nothing to do. It's not a bug.
*/
INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(id);
if(type!=INTERP_KERNEL::NORM_SEG2 && type!=INTERP_KERNEL::NORM_TRI3 && type!=INTERP_KERNEL::NORM_TETRA4)
throw INTERP_KERNEL::Exception("P1 getValueOn is not specified for not simplex cells !");
+ getValueInCell(mesh,id,arr,loc,res);
+}
+
+/*!
+ * This method localizes a point defined by 'loc' in a cell with id 'cellId' into mesh 'mesh'.
+ * The result is put into res expected to be of size at least arr->getNumberOfComponents()
+ */
+void MEDCouplingFieldDiscretizationP1::getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const
+{
std::vector<int> conn;
std::vector<double> coo;
- mesh->getNodeIdsOfCell(id,conn);
+ mesh->getNodeIdsOfCell(cellId,conn);
for(std::vector<int>::const_iterator iter=conn.begin();iter!=conn.end();iter++)
mesh->getCoordinatesOfNode(*iter,coo);
int spaceDim=mesh->getSpaceDimension();
std::vector<const double *> vec(nbOfNodes);
for(int i=0;i<nbOfNodes;i++)
vec[i]=&coo[i*spaceDim];
- double *tmp=new double[nbOfNodes];
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfNodes];
INTERP_KERNEL::barycentric_coords(vec,loc,tmp);
int sz=arr->getNumberOfComponents();
- double *tmp2=new double[sz];
+ INTERP_KERNEL::AutoPtr<double> tmp2=new double[sz];
std::fill(res,res+sz,0.);
for(int i=0;i<nbOfNodes;i++)
{
- arr->getTuple(conn[i],tmp2);
- std::transform(tmp2,tmp2+sz,tmp2,std::bind2nd(std::multiplies<double>(),tmp[i]));
- std::transform(res,res+sz,tmp2,res,std::plus<double>());
+ arr->getTuple(conn[i],(double *)tmp2);
+ std::transform((double *)tmp2,((double *)tmp2)+sz,(double *)tmp2,std::bind2nd(std::multiplies<double>(),tmp[i]));
+ std::transform(res,res+sz,(double *)tmp2,res,std::plus<double>());
}
- delete [] tmp;
- delete [] tmp2;
}
void MEDCouplingFieldDiscretizationP1::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const
arr->getTuple(id,res);
}
+DataArrayDouble *MEDCouplingFieldDiscretizationP1::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+ std::vector<int> elts,eltsIndex;
+ mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
+ int spaceDim=mesh->getSpaceDimension();
+ int nbOfComponents=arr->getNumberOfComponents();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ ret->alloc(nbOfPoints,nbOfComponents);
+ double *ptToFill=ret->getPointer();
+ for(int i=0;i<nbOfPoints;i++)
+ if(eltsIndex[i+1]-eltsIndex[i]>=1)
+ getValueInCell(mesh,elts[eltsIndex[i]],arr,loc+i*spaceDim,ptToFill+i*nbOfComponents);
+ else
+ {
+ std::ostringstream oss; oss << "Point #" << i << " with coordinates : (";
+ std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator<double>(oss,", "));
+ oss << ") detected outside mesh : unable to apply P1::getValueOnMulti ! ";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ ret->incrRef();
+ return ret;
+}
+
void MEDCouplingFieldDiscretizationP1::renumberValuesOnNodes(double epsOnVals, const int *old2NewPtr, DataArrayDouble *arr) const
{
renumberEntitiesFromO2NArr(epsOnVals,old2NewPtr,arr,"Node");
throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !");
}
+DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+ throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented yet for gauss points !");
+}
+
MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !");
}
+DataArrayDouble *MEDCouplingFieldDiscretizationGaussNE::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+ throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented for Gauss NE !");
+}
+
MEDCouplingMesh *MEDCouplingFieldDiscretizationGaussNE::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0;
virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0;
+ virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const = 0;
virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
virtual void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const = 0;
virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0;
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+ DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+ DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
+ protected:
+ void getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const;
public:
static const char REPR[];
static const TypeOfField TYPE;
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+ DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+ DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
_type->getValueOn(arr,_mesh,spaceLoc,res);
}
+/*!
+ * Returns a newly allocated array with 'nbOfPoints' tuples and nb of components equal to 'this->getNumberOfComponents()'.
+ */
+DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const throw(INTERP_KERNEL::Exception)
+{
+ const DataArrayDouble *arr=_time_discr->getArray();
+ return _type->getValueOnMulti(arr,_mesh,spaceLoc,nbOfPoints);
+}
+
/*!
* Returns value of 'this' on time 'time' of point 'spaceLoc' using spatial discretization.
* If 'time' is not covered by this->_time_discr an exception will be thrown.
void getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception);
void getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception);
void getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getValueOnMulti(const double *spaceLoc, int nbOfPoints) const throw(INTERP_KERNEL::Exception);
//! \b temporary
void applyLin(double a, double b, int compoId);
MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
work[i]=work[i-1]+tmp;
tmp=tmp2;
}
+ declareAsNew();
}
/*!
{
return mesh1->mergeMyselfWith(mesh2);
}
+
+void MEDCouplingMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
+{
+ int ret=getCellContainingPoint(pos,eps);
+ elts.push_back(ret);
+}
+
+void MEDCouplingMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const
+{
+ eltsIndex.resize(nbOfPoints+1);
+ eltsIndex[0]=0;
+ elts.clear();
+ int spaceDim=getSpaceDimension();
+ const double *work=pos;
+ for(int i=0;i<nbOfPoints;i++,work+=spaceDim)
+ {
+ int ret=getCellContainingPoint(work,eps);
+ if(ret>=0)
+ {
+ elts.push_back(ret);
+ eltsIndex[i+1]=eltsIndex[i]+1;
+ }
+ else
+ eltsIndex[i+1]=eltsIndex[i];
+ }
+}
virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0;
virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0;
virtual int getCellContainingPoint(const double *pos, double eps) const = 0;
+ virtual void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
+ virtual void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const;
virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const;
virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const;
ret << "Description of mesh : \"" << getDescription() << "\"\n";
int tmpp1,tmpp2;
double tt=getTime(tmpp1,tmpp2);
- ret << "Time attached to the mesh (unit) : " << tt << " (" << getTimeUnit() << ")\n";
+ ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n";
ret << "Mesh dimension : " << _mesh_dim << "\nSpace dimension : ";
if(_coords!=0)
int MEDCouplingUMeshDesc::getCellContainingPoint(const double *pos, double eps) const
{
- //not implemented yet.
- return -1;
+ throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::getCellContainingPoint : not implemented yet !");
}
namespace ParaMEDMEM
{
+ class DataArrayDouble;
class MEDCouplingUMesh;
class MEDCouplingFieldDouble;
class MEDCouplingMultiFields;
CPPUNIT_TEST( testFillFromAnalyticTwo1 );
CPPUNIT_TEST( testFillFromAnalyticThree1 );
CPPUNIT_TEST( testDAUnitVar1 );
+ CPPUNIT_TEST( testGaussCoordinates1 );
+ //CPPUNIT_TEST( testP2Localization1 ); not implemented yet
+ CPPUNIT_TEST( testGetValueOn2 );
+ CPPUNIT_TEST( testDAIGetIdsNotEqual1 );
+ CPPUNIT_TEST( testDAIComputeOffsets1 );
//MEDCouplingBasicsTestInterp.cxx
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
void testFillFromAnalyticTwo1();
void testFillFromAnalyticThree1();
void testDAUnitVar1();
+ void testGaussCoordinates1();
+ void testP2Localization1();
+ void testGetValueOn2();
+ void testDAIGetIdsNotEqual1();
+ void testDAIComputeOffsets1();
//MEDCouplingBasicsTestInterp.cxx
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
static MEDCouplingUMesh *build2DTargetMesh_3();
static MEDCouplingUMesh *build3DTargetMesh_3();
static MEDCouplingUMesh *build2DTargetMesh_4();
+ static MEDCouplingUMesh *build1DMultiTypes_1();
+ static MEDCouplingUMesh *build2DMultiTypes_1();
+ static MEDCouplingUMesh *build3DMultiTypes_1();
+ static MEDCouplingUMesh *buildHexa8Mesh_1();
+ static DataArrayDouble *buildCoordsForMultiTypes_1();
static MEDCouplingMultiFields *buildMultiFields_1();
static std::vector<MEDCouplingFieldDouble *> buildMultiFields_2();
static double sumAll(const std::vector< std::map<int,double> >& matrix);
return fs;
}
+MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMultiTypes_1()
+{
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi1DMesh",1);
+ DataArrayDouble *coo=buildCoordsForMultiTypes_1();
+ const int conn[5]={0,2, 0,2,1};
+ mesh->allocateCells(2);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+2);
+ mesh->finishInsertingCells();
+ mesh->setCoords(coo);
+ coo->decrRef();
+ return mesh;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::build2DMultiTypes_1()
+{
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi2DMesh",2);
+ DataArrayDouble *coo=buildCoordsForMultiTypes_1();
+ const int conn[21]={3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15};
+ mesh->allocateCells(4);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+3);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+9);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+13);
+ mesh->finishInsertingCells();
+ mesh->setCoords(coo);
+ coo->decrRef();
+ return mesh;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::build3DMultiTypes_1()
+{
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi3DMesh",3);
+ DataArrayDouble *coo=buildCoordsForMultiTypes_1();
+ const int conn[81]={0,16,17,18,
+ 0,16,17,18,19,20,21,22,23,24,
+ 0,11,10,9,25,
+ 0,11,10,9,25,15,14,13,12,26,27,28,29,
+ 0,30,31,32,33,34,
+ 0,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
+ 0,9,10,11,44,45,46,47,
+ 0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 };
+ mesh->allocateCells(8);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn+4);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+14);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA13,13,conn+19);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+32);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA15,15,conn+38);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+53);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA20,20,conn+61);
+ mesh->finishInsertingCells();
+ mesh->setCoords(coo);
+ coo->decrRef();
+ return mesh;
+}
+
+DataArrayDouble *MEDCouplingBasicsTest::buildCoordsForMultiTypes_1()
+{
+ DataArrayDouble *coords=DataArrayDouble::New();
+ coords->alloc(56,3);
+ coords->setInfoOnComponent(0,"X (cm)");
+ coords->setInfoOnComponent(1,"Y (cm)");
+ coords->setInfoOnComponent(2,"Z (cm)");
+ const double data[168]={
+ 0.0, 0.0, 0.0, //#0
+ 0.5, 0.5, 0.5, //#1
+ 1.0, 1.0, 1.0, //#2
+ 1.0, 1.0, 0.0, //#3
+ 2.0, 2.5, 0.0, //#4
+ 6.0, 1.5, 0.0, //#5
+ 1.0, 2.0, 0.0, //#6
+ 4.5, 2.5, 0.0, //#7
+ 4.0, 0.5, 0.0, //#8
+ 0.0, 4.0, 0.0, //#9
+ 4.0, 4.0, 0.0, //#10
+ 4.0, 0.0, 0.0, //#11
+ 0.0, 2.0, 0.0, //#12
+ 2.0, 4.0, 0.0, //#13
+ 4.0, 2.0, 0.0, //#14
+ 2.0, 0.0, 0.0, //#15
+ 0.0, 6.0, 0.0, //#16
+ 3.0, 3.0, 0.0, //#17
+ 1.3, 3.0, 3.0, //#18
+ 0.0, 3.0, 0.0, //#19
+ 1.5, 4.5, 0.0, //#20
+ 1.5, 1.5, 0.0, //#21
+ 0.65, 1.5, 1.5, //#22
+ 0.65, 4.5, 1.5, //#23
+ 2.15, 3.0, 1.5, //#24
+ 2.0, 2.0, 2.0, //#25
+ 3.0, 1.0, 1.0, //#26
+ 3.0, 3.0, 1.0, //#27
+ 1.0, 3.0, 1.0, //#28
+ 1.0, 1.0, 1.0, //#29
+ 0.0, 3.0, 0.0, //#30
+ 2.0, 0.0, 0.0, //#31
+ 0.0, 0.0, 6.0, //#32
+ 0.0, 3.0, 6.0, //#33
+ 3.0, 0.0, 6.0, //#34
+ 0.0, 1.5, 0.0, //#35
+ 1.5, 1.5, 0.0, //#36
+ 1.5, 0.0, 0.0, //#37
+ 0.0, 1.5, 6.0, //#38
+ 1.5, 1.5, 6.0, //#39
+ 1.5, 0.0, 6.0, //#40
+ 0.0, 0.0, 3.0, //#41
+ 0.0, 3.0, 3.0, //#42
+ 3.0, 0.0, 3.0, //#43
+ 0.0, 0.0, 4.0, //#44
+ 0.0, 4.0, 4.0, //#45
+ 4.0, 4.0, 4.0, //#46
+ 4.0, 0.0, 4.0, //#47
+ 0.0, 2.0, 4.0, //#48
+ 2.0, 4.0, 4.0, //#49
+ 4.0, 2.0, 4.0, //#50
+ 2.0, 0.0, 4.0, //#51
+ 0.0, 0.0, 2.0, //#52
+ 0.0, 4.0, 2.0, //#53
+ 4.0, 4.0, 2.0, //#54
+ 4.0, 0.0, 2.0 //#55
+ };
+ std::copy(data,data+168,coords->getPointer());
+ return coords;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::buildHexa8Mesh_1()
+{
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Hexa8Only",3);
+ DataArrayDouble *coo=DataArrayDouble::New();
+ const double coords[81]={0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0};
+ coo->alloc(27,3);
+ std::copy(coords,coords+81,coo->getPointer());
+ const int conn[64]={3,12,13,4,0,9,10,1,
+ 4,13,14,5,1,10,11,2,
+ 6,15,16,7,3,12,13,4,
+ 7,16,17,8,4,13,14,5,
+ 12,21,22,13,9,18,19,10,
+ 13,22,23,14,10,19,20,11,
+ 15,24,25,16,12,21,22,13,
+ 16,25,26,17,13,22,23,14};
+ mesh->allocateCells(8);
+ for(int i=0;i<8;i++)
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i);
+ mesh->finishInsertingCells();
+ mesh->setCoords(coo);
+ coo->decrRef();
+ return mesh;
+}
+
double MEDCouplingBasicsTest::sumAll(const std::vector< std::map<int,double> >& matrix)
{
double ret=0.;
CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
m2->setTime(3.14,6,7);
CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
+ m1->setTimeUnit("ms");
+ CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="ms");
+ m1->setTimeUnit("us");
+ CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="us");
+ CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
+ m2->setTimeUnit("us");
+ CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
m2->setTime(3.14,6,8);
CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
m2->setTime(3.14,7,7);
da->decrRef();
}
+void MEDCouplingBasicsTest::testGaussCoordinates1()
+{
+ //Testing 1D cell types
+ MEDCouplingUMesh *m1=build1DMultiTypes_1();
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
+ f->setMesh(m1);
+ std::vector<double> wg1(1); wg1[0]=0.3;
+ std::vector<double> gsCoo1(1); gsCoo1[0]=0.2;
+ std::vector<double> refCoo1(2); refCoo1[0]=-1.0; refCoo1[1]=1.0;
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG2,refCoo1,gsCoo1,wg1);
+ std::vector<double> wg2(wg1);
+ std::vector<double> gsCoo2(1); gsCoo2[0]=0.2;
+ std::vector<double> refCoo2(3); refCoo2[0]=-1.0; refCoo2[1]=1.0; refCoo2[2]=0.0;
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG3,refCoo2,gsCoo2,wg2);
+ //
+ DataArrayDouble *resToTest=f->getLocalizationOfDiscr();
+ CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(2,resToTest->getNumberOfTuples());
+ const double expected1[6]={0.6,0.6,0.6, 0.6,0.6,0.6};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],resToTest->getIJ(0,i),1e-14);
+ resToTest->decrRef();
+ //
+ m1->decrRef();
+ f->decrRef();
+ //Testing 2D cell types
+ MEDCouplingUMesh *m2=build2DMultiTypes_1();
+ f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
+ f->setMesh(m2);
+ std::vector<double> wg3(2); wg3[0]=0.3; wg3[1]=0.3;
+ const double tria3CooGauss[4]={ 0.1, 0.8, 0.2, 0.7 };
+ std::vector<double> gsCoo3(tria3CooGauss,tria3CooGauss+4);
+ const double tria3CooRef[6]={ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 };
+ std::vector<double> refCoo3(tria3CooRef,tria3CooRef+6);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,refCoo3,gsCoo3,wg3);
+ std::vector<double> wg4(3); wg4[0]=0.3; wg4[1]=0.3; wg4[2]=0.3;
+ const double tria6CooGauss[6]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 };
+ std::vector<double> gsCoo4(tria6CooGauss,tria6CooGauss+6);
+ const double tria6CooRef[12]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5};
+ std::vector<double> refCoo4(tria6CooRef,tria6CooRef+12);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,refCoo4,gsCoo4,wg4);
+ std::vector<double> wg5(4); wg5[0]=0.3; wg5[1]=0.3; wg5[2]=0.3; wg5[3]=0.3;
+ const double quad4CooGauss[8]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 };
+ std::vector<double> gsCoo5(quad4CooGauss,quad4CooGauss+8);
+ const double quad4CooRef[8]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0};
+ std::vector<double> refCoo5(quad4CooRef,quad4CooRef+8);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,refCoo5,gsCoo5,wg5);
+ std::vector<double> wg6(4); wg6[0]=0.3; wg6[1]=0.3; wg6[2]=0.3; wg6[3]=0.3;
+ const double quad8CooGauss[8]={ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 };
+ std::vector<double> gsCoo6(quad8CooGauss,quad8CooGauss+8);
+ const double quad8CooRef[16]={ -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, -1.0, 0.0};
+ std::vector<double> refCoo6(quad8CooRef,quad8CooRef+16);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD8,refCoo6,gsCoo6,wg6);
+ //
+ resToTest=f->getLocalizationOfDiscr();
+ CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(13,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+ const double expected2[39]={5.1,1.55,0.0, 4.7,1.65,0.0, //TRI3
+ 2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,//TRI6
+ 2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,//QUAD4
+ 2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 };//QUAD8
+ for(int i=0;i<39;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],resToTest->getIJ(0,i),1e-14);
+ resToTest->decrRef();
+ //
+ m2->decrRef();
+ f->decrRef();
+ //Testing 3D cell types
+ MEDCouplingUMesh *m3=build3DMultiTypes_1();
+ f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
+ f->setMesh(m3);
+ //
+ std::vector<double> wg7(1); wg7[0]=0.3;
+ const double tetra4CooGauss[3]={0.34, 0.16, 0.21};
+ std::vector<double> gsCoo7(tetra4CooGauss,tetra4CooGauss+3);
+ const double tetra4CooRef[12]={0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0};
+ std::vector<double> refCoo7(tetra4CooRef,tetra4CooRef+12);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA4,refCoo7,gsCoo7,wg7);
+ std::vector<double> wg8(1); wg8[0]=0.3;
+ const double tetra10CooGauss[3]={0.2, 0.3, 0.1};
+ std::vector<double> gsCoo8(tetra10CooGauss,tetra10CooGauss+3);
+ const double tetra10CooRef[30]={0.0,1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0, 1.0,0.0,0.0, 0.0,0.5,0.0, 0.0,0.0,0.5, 0.0,0.5,0.5, 0.5,0.5,0.0, 0.5,0.0,0.0, 0.5,0.0,0.5};
+ std::vector<double> refCoo8(tetra10CooRef,tetra10CooRef+30);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA10,refCoo8,gsCoo8,wg8);
+ std::vector<double> wg9(1); wg9[0]=0.3;
+ const double pyra5CooGauss[3]={0.2, 0.3, 0.1};
+ std::vector<double> gsCoo9(pyra5CooGauss,pyra5CooGauss+3);
+ const double pyra5CooRef[15]={1.0,0.0,0.0, 0.0,1.0,0.0, -1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,1.0};
+ std::vector<double> refCoo9(pyra5CooRef,pyra5CooRef+15);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA5,refCoo9,gsCoo9,wg9);
+ std::vector<double> wg10(1); wg10[0]=0.3;
+ const double pyra13CooGauss[3]={0.1, 0.2, 0.7};
+ std::vector<double> gsCoo10(pyra13CooGauss,pyra13CooGauss+3);
+ const double pyra13CooRef[39]={1.0,0.0,0.0, 0.0,1.0,0.0,-1.0,0.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.5,0.5,0.0,-0.5,0.5,0.0,-0.5,-0.5,0.0,0.5,-0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5,-0.5,0.0,0.5,0.0,-0.5,0.5};
+ std::vector<double> refCoo10(pyra13CooRef,pyra13CooRef+39);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA13,refCoo10,gsCoo10,wg10);
+ std::vector<double> wg11(1); wg11[0]=0.3;
+ const double penta6CooGauss[3]={0.2, 0.3, 0.1};
+ std::vector<double> gsCoo11(penta6CooGauss,penta6CooGauss+3);
+ const double penta6CooRef[18]={-1.0,1.0,0.0,-1.0,-0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0};
+ std::vector<double> refCoo11(penta6CooRef,penta6CooRef+18);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA6,refCoo11,gsCoo11,wg11);
+ std::vector<double> wg12(1); wg12[0]=0.3;
+ const double penta15CooGauss[3]={0.2, 0.3,0.15};
+ std::vector<double> gsCoo12(penta15CooGauss,penta15CooGauss+3);
+ const double penta15CooRef[45]={-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,-1.0,0.5,0.5,-1.0,0.0,0.5,-1.0,0.5,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.5,0.5,1.0,0.0, 0.5,1.0,0.5,0.0};
+ std::vector<double> refCoo12(penta15CooRef,penta15CooRef+45);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA15,refCoo12,gsCoo12,wg12);
+ std::vector<double> wg13(1); wg13[0]=0.3;
+ const double hexa8CooGauss[3]={0.2,0.3,0.15};
+ std::vector<double> gsCoo13(hexa8CooGauss,hexa8CooGauss+3);
+ const double hexa8CooRef[24]={-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0};
+ std::vector<double> refCoo13(hexa8CooRef,hexa8CooRef+24);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA8,refCoo13,gsCoo13,wg13);
+ std::vector<double> wg14(1); wg14[0]=0.3;
+ const double hexa20CooGauss[3]={0.11,0.3,0.55};
+ std::vector<double> gsCoo14(hexa20CooGauss,hexa20CooGauss+3);
+ const double hexa20CooRef[60]={-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,0.0,-1.0,-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,-1.0,0.0,-1.0,-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0,0.0,-1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,-1.0,0.0,1.0};
+ std::vector<double> refCoo14(hexa20CooRef,hexa20CooRef+60);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA20,refCoo14,gsCoo14,wg14);
+ //
+ resToTest=f->getLocalizationOfDiscr();
+ CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(8,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+ const double expected3[24]={1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255};
+ for(int i=0;i<24;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],resToTest->getIJ(0,i),1e-14);
+ resToTest->decrRef();
+ //
+ m3->decrRef();
+ f->decrRef();
+}
+
+/*!
+ * Not activated test ! To be implemented ! WARNING Hexa8 should be replaced by Quad8...
+ */
+void MEDCouplingBasicsTest::testP2Localization1()
+{
+ MEDCouplingUMesh *m=buildHexa8Mesh_1();
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
+ DataArrayDouble *da=DataArrayDouble::New();
+ const double vals1[27]={1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0};
+ da->alloc(27,1);
+ std::copy(vals1,vals1+27,da->getPointer());
+ f->setMesh(m);
+ f->setArray(da);
+ da->decrRef();
+ //
+ const double point1[3]={0.25,0.75,0.25};
+ //const double points1[6]={0.25,0.75,0.25,1.0,1.0,1.0};
+ double res1[3];
+ f->getValueOn(point1,res1);
+ //
+ f->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testGetValueOn2()
+{
+ MEDCouplingUMesh *m=build2DTargetMesh_1();
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ f->setMesh(m);
+ DataArrayDouble *arr=DataArrayDouble::New();
+ int nbOfCells=m->getNumberOfCells();
+ arr->alloc(nbOfCells,3);
+ f->setArray(arr);
+ arr->decrRef();
+ const double values1[15]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.};
+ std::copy(values1,values1+15,arr->getPointer());
+ const double loc[10]={-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45};
+ f->checkCoherency();
+ DataArrayDouble *locs=f->getValueOnMulti(loc,5);
+ CPPUNIT_ASSERT_EQUAL(5,locs->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
+ for(int j=0;j<15;j++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(values1[j],locs->getIJ(0,j),1e-12);
+ locs->decrRef();
+ f->decrRef();
+ // Testing ON_NODES
+ f=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME);
+ f->setMesh(m);
+ arr=DataArrayDouble::New();
+ int nbOfNodes=m->getNumberOfNodes();
+ arr->alloc(nbOfNodes,3);
+ f->setArray(arr);
+ arr->decrRef();
+ const double values2[27]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.};
+ std::copy(values2,values2+27,arr->getPointer());
+ const double loc2[8]={0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432};
+ const double expected2[12]={9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272};
+ f->checkCoherency();
+ locs=f->getValueOnMulti(loc2,4);
+ CPPUNIT_ASSERT_EQUAL(4,locs->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],locs->getIJ(0,i),1e-12);
+ f->decrRef();
+ locs->decrRef();
+ //
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIGetIdsNotEqual1()
+{
+ DataArrayInt *d=DataArrayInt::New();
+ const int vals1[10]={2,3,5,6,8,5,5,6,1,-5};
+ d->alloc(10,1);
+ std::copy(vals1,vals1+10,d->getPointer());
+ DataArrayInt *d2=d->getIdsNotEqual(5);
+ CPPUNIT_ASSERT_EQUAL(7,d2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfComponents());
+ const int expected1[7]={0,1,3,4,7,8,9};
+ for(int i=0;i<7;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],d2->getIJ(0,i));
+ d->rearrange(2);
+ CPPUNIT_ASSERT_THROW(d->getIdsNotEqual(5),INTERP_KERNEL::Exception);
+ const int vals2[3]={-4,5,6};
+ std::vector<int> vals3(vals2,vals2+3);
+ d->rearrange(1);
+ DataArrayInt *d3=d->getIdsNotEqualList(vals3);
+ CPPUNIT_ASSERT_EQUAL(5,d3->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d3->getNumberOfComponents());
+ const int expected2[5]={0,1,4,8,9};
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d3->getIJ(0,i));
+ d3->decrRef();
+ d->decrRef();
+ d2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIComputeOffsets1()
+{
+ DataArrayInt *d=DataArrayInt::New();
+ const int vals1[6]={3,5,1,2,0,8};
+ const int expected1[6]={0,3,8,9,11,11};
+ d->alloc(6,1);
+ std::copy(vals1,vals1+6,d->getPointer());
+ d->computeOffsets();
+ CPPUNIT_ASSERT_EQUAL(6,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],d->getIJ(0,i));
+ d->decrRef();
+}
%feature("docstring");
%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
+%newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::getArray;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::getEndArray;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::deepCpy;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti;
%newobject ParaMEDMEM::MEDCouplingFieldTemplate::New;
%newobject ParaMEDMEM::DataArrayInt::New;
%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
%newobject ParaMEDMEM::DataArrayInt::invertArrayO2N2N2O;
%newobject ParaMEDMEM::DataArrayInt::invertArrayN2O2O2N;
%newobject ParaMEDMEM::DataArrayInt::getIdsEqual;
+%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqual;
%newobject ParaMEDMEM::DataArrayInt::getIdsEqualList;
+%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqualList;
%newobject ParaMEDMEM::DataArrayInt::Aggregate;
%newobject ParaMEDMEM::DataArrayInt::Meld;
%newobject ParaMEDMEM::DataArrayInt::BuildUnion;
delete [] pos;
return ret;
}
+
+ PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+ std::vector<int> elts,eltsIndex;
+ self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ d0->alloc(elts.size(),1);
+ d1->alloc(eltsIndex.size(),1);
+ std::copy(elts.begin(),elts.end(),d0->getPointer());
+ std::copy(eltsIndex.begin(),eltsIndex.end(),d1->getPointer());
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ return ret;
+ }
+
+ PyObject *getCellsContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+ std::vector<int> elts;
+ self->getCellsContainingPoint(pos,eps,elts);
+ return convertIntArrToPyList2(elts);
+ }
void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
{
return ret;
}
- PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception)
- {
- int sz;
- double *pos=convertPyToNewDblArr2(p,&sz);
- std::vector<int> elts,eltsIndex;
- self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
- delete [] pos;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
- d0->alloc(elts.size(),1);
- d1->alloc(eltsIndex.size(),1);
- std::copy(elts.begin(),elts.end(),d0->getPointer());
- std::copy(eltsIndex.begin(),eltsIndex.end(),d1->getPointer());
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- d0->incrRef();
- d1->incrRef();
- return ret;
- }
-
- PyObject *getCellsContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
- {
- int sz;
- double *pos=convertPyToNewDblArr2(p,&sz);
- std::vector<int> elts;
- self->getCellsContainingPoint(pos,eps,elts);
- delete [] pos;
- return convertIntArrToPyList2(elts);
- }
-
static PyObject *MergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
{
std::vector<const ParaMEDMEM::MEDCouplingUMesh *> meshes;
TypeOfField getTypeOfField() const throw(INTERP_KERNEL::Exception);
NatureOfField getNature() const throw(INTERP_KERNEL::Exception);
virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDiscretization *getDiscretization() const throw(INTERP_KERNEL::Exception);
int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
self->getValueOn(spaceLoc,res);
return convertDblArrToPyList(res,sz);
}
+
+ DataArrayDouble *getValueOnMulti(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<double> tmp=convertPyToNewDblArr2(li,&size);
+ int spaceDim=self->getMesh()->getSpaceDimension();
+ int nbOfPoints=size/spaceDim;
+ if(size%spaceDim!=0)
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be a multiple of self.getMesh().getSpaceDimension() !");
+ }
+ return self->getValueOnMulti(tmp,nbOfPoints);
+ }
+ else
+ {
+ DataArrayDouble *da2=reinterpret_cast< DataArrayDouble * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayDouble instance expected !");
+ da2->checkAllocated();
+ int size=da2->getNumberOfTuples();
+ int nbOfCompo=da2->getNumberOfComponents();
+ if(nbOfCompo!=self->getMesh()->getSpaceDimension())
+ {
+ throw INTERP_KERNEL::Exception("Invalid DataArrayDouble nb of components ! Expected same as self.getMesh().getSpaceDimension() !");
+ }
+ return self->getValueOnMulti(da2->getConstPointer(),size);
+ }
+ }
+
PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception)
{
int sz;
self.assertTrue(not m1.isEqual(m2,1e-12));
m2.setTime(3.14,6,7);
self.assertTrue(m1.isEqual(m2,1e-12));
+ m1.setTimeUnit("ms");
+ self.assertTrue(m1.getTimeUnit()=="ms");
+ m1.setTimeUnit("us");
+ self.assertTrue(m1.getTimeUnit()=="us");
+ self.assertTrue(not m1.isEqual(m2,1e-12));
+ m2.setTimeUnit("us");
+ self.assertTrue(m1.isEqual(m2,1e-12));
m2.setTime(3.14,6,8);
self.assertTrue(not m1.isEqual(m2,1e-12));
m2.setTime(3.14,7,7);
self.assertTrue(vs[1]=="m^2/kJ");
self.assertTrue(vs[2]=="MW/s");
pass
+
+ def testGaussCoordinates1(self):
+ #Testing 1D cell types
+ m1=MEDCouplingDataForTest.build1DMultiTypes_1();
+ f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+ f.setMesh(m1);
+ wg1=[0.3];
+ gsCoo1=[0.2];
+ refCoo1=[-1.0,1.0];
+ f.setGaussLocalizationOnType(NORM_SEG2,refCoo1,gsCoo1,wg1);
+ wg2=wg1;
+ gsCoo2=[0.2];
+ refCoo2=[-1.0,1.0,0.0];
+ f.setGaussLocalizationOnType(NORM_SEG3,refCoo2,gsCoo2,wg2);
+ #
+ resToTest=f.getLocalizationOfDiscr();
+ self.assertEqual(3,resToTest.getNumberOfComponents());
+ self.assertEqual(2,resToTest.getNumberOfTuples());
+ expected1=[0.6,0.6,0.6, 0.6,0.6,0.6]
+ for i in xrange(6):
+ self.assertAlmostEqual(expected1[i],resToTest.getIJ(0,i),14);
+ pass
+ #
+ #Testing 2D cell types
+ m2=MEDCouplingDataForTest.build2DMultiTypes_1();
+ f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+ f.setMesh(m2);
+ wg3=[0.3,0.3];
+ tria3CooGauss=[ 0.1, 0.8, 0.2, 0.7 ]
+ gsCoo3=tria3CooGauss
+ tria3CooRef=[ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 ]
+ refCoo3=tria3CooRef;
+ f.setGaussLocalizationOnType(NORM_TRI3,refCoo3,gsCoo3,wg3);
+ wg4=[0.3,0.3,0.3];
+ tria6CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 ]
+ gsCoo4=tria6CooGauss;
+ tria6CooRef=[0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5]
+ refCoo4=tria6CooRef;
+ f.setGaussLocalizationOnType(NORM_TRI6,refCoo4,gsCoo4,wg4);
+ wg5=[0.3,0.3,0.3,0.3];
+ quad4CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 ]
+ gsCoo5=quad4CooGauss;
+ quad4CooRef=[-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0]
+ refCoo5=quad4CooRef;
+ f.setGaussLocalizationOnType(NORM_QUAD4,refCoo5,gsCoo5,wg5);
+ wg6=[0.3,0.3,0.3,0.3];
+ quad8CooGauss=[ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 ]
+ gsCoo6=quad8CooGauss;
+ quad8CooRef=[ -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, -1.0, 0.0]
+ refCoo6=quad8CooRef;
+ f.setGaussLocalizationOnType(NORM_QUAD8,refCoo6,gsCoo6,wg6);
+ #
+ resToTest=f.getLocalizationOfDiscr();
+ self.assertEqual(3,resToTest.getNumberOfComponents());
+ self.assertEqual(13,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+ expected2=[5.1,1.55,0.0, 4.7,1.65,0.0,
+ 2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,#TRI6
+ 2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,#QUAD4
+ 2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 ];#QUAD8
+ for i in xrange(39):
+ self.assertAlmostEqual(expected2[i],resToTest.getIJ(0,i),14);
+ pass
+ #
+ #Testing 3D cell types
+ m3=MEDCouplingDataForTest.build3DMultiTypes_1();
+ f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+ f.setMesh(m3);
+ #
+ wg7=[0.3];
+ tetra4CooGauss=[0.34, 0.16, 0.21]
+ gsCoo7=tetra4CooGauss;
+ tetra4CooRef=[0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0]
+ refCoo7=tetra4CooRef;
+ f.setGaussLocalizationOnType(NORM_TETRA4,refCoo7,gsCoo7,wg7);
+ wg8=[0.3];
+ tetra10CooGauss=[0.2, 0.3, 0.1]
+ gsCoo8=tetra10CooGauss;
+ tetra10CooRef=[0.0,1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0, 1.0,0.0,0.0, 0.0,0.5,0.0, 0.0,0.0,0.5, 0.0,0.5,0.5, 0.5,0.5,0.0, 0.5,0.0,0.0, 0.5,0.0,0.5]
+ refCoo8=tetra10CooRef;
+ f.setGaussLocalizationOnType(NORM_TETRA10,refCoo8,gsCoo8,wg8);
+ wg9=[0.3];
+ pyra5CooGauss=[0.2, 0.3, 0.1]
+ gsCoo9=pyra5CooGauss;
+ pyra5CooRef=[1.0,0.0,0.0, 0.0,1.0,0.0, -1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,1.0]
+ refCoo9=pyra5CooRef;
+ f.setGaussLocalizationOnType(NORM_PYRA5,refCoo9,gsCoo9,wg9);
+ wg10=[0.3];
+ pyra13CooGauss=[0.1, 0.2, 0.7]
+ gsCoo10=pyra13CooGauss;
+ pyra13CooRef=[1.0,0.0,0.0, 0.0,1.0,0.0,-1.0,0.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.5,0.5,0.0,-0.5,0.5,0.0,-0.5,-0.5,0.0,0.5,-0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5,-0.5,0.0,0.5,0.0,-0.5,0.5]
+ refCoo10=pyra13CooRef;
+ f.setGaussLocalizationOnType(NORM_PYRA13,refCoo10,gsCoo10,wg10);
+ wg11=[0.3];
+ penta6CooGauss=[0.2, 0.3, 0.1]
+ gsCoo11=penta6CooGauss;
+ penta6CooRef=[-1.0,1.0,0.0,-1.0,-0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0]
+ refCoo11=penta6CooRef;
+ f.setGaussLocalizationOnType(NORM_PENTA6,refCoo11,gsCoo11,wg11);
+ wg12=[0.3];
+ penta15CooGauss=[0.2, 0.3,0.15]
+ gsCoo12=penta15CooGauss;
+ penta15CooRef=[-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,-1.0,0.5,0.5,-1.0,0.0,0.5,-1.0,0.5,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.5,0.5,1.0,0.0, 0.5,1.0,0.5,0.0]
+ refCoo12=penta15CooRef;
+ f.setGaussLocalizationOnType(NORM_PENTA15,refCoo12,gsCoo12,wg12);
+ wg13=[0.3];
+ hexa8CooGauss=[0.2,0.3,0.15]
+ gsCoo13=hexa8CooGauss;
+ hexa8CooRef=[-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0]
+ refCoo13=hexa8CooRef;
+ f.setGaussLocalizationOnType(NORM_HEXA8,refCoo13,gsCoo13,wg13);
+ wg14=[0.3];
+ hexa20CooGauss=[0.11,0.3,0.55]
+ gsCoo14=hexa20CooGauss;
+ hexa20CooRef=[-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,0.0,-1.0,-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,-1.0,0.0,-1.0,-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0,0.0,-1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,-1.0,0.0,1.0]
+ refCoo14=hexa20CooRef;
+ f.setGaussLocalizationOnType(NORM_HEXA20,refCoo14,gsCoo14,wg14);
+ #
+ resToTest=f.getLocalizationOfDiscr();
+ self.assertEqual(3,resToTest.getNumberOfComponents());
+ self.assertEqual(8,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+ expected3=[1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255]
+ for i in xrange(24):
+ self.assertAlmostEqual(expected3[i],resToTest.getIJ(0,i),14);
+ pass
+ #
+ pass
+
+ def testGetValueOn2(self):
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ f=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
+ f.setMesh(m);
+ arr=DataArrayDouble.New();
+ nbOfCells=m.getNumberOfCells();
+ f.setArray(arr);
+ values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.]
+ arr.setValues(values1,nbOfCells,3);
+ loc=[-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45]
+ f.checkCoherency();
+ locs=f.getValueOnMulti(loc);
+ self.assertEqual(5,locs.getNumberOfTuples());
+ self.assertEqual(3,locs.getNumberOfComponents());
+ for j in xrange(15):
+ self.assertAlmostEqual(values1[j],locs.getIJ(0,j),12);
+ pass
+ # Testing ON_NODES
+ f=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
+ f.setMesh(m);
+ arr=DataArrayDouble.New();
+ nbOfNodes=m.getNumberOfNodes();
+ f.setArray(arr);
+ values2=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.]
+ arr.setValues(values2,nbOfNodes,3);
+ loc2=[0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432]
+ expected2=[9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272]
+ f.checkCoherency();
+ loc3=DataArrayDouble.New()
+ loc3.setValues(loc2,4,2);
+ locs=f.getValueOnMulti(loc3);
+ self.assertEqual(4,locs.getNumberOfTuples());
+ self.assertEqual(3,locs.getNumberOfComponents());
+ for i in xrange(12):
+ self.assertAlmostEqual(expected2[i],locs.getIJ(0,i),12);
+ pass
+ #
+ pass
+
+ def testDAIGetIdsNotEqual1(self):
+ d=DataArrayInt.New();
+ vals1=[2,3,5,6,8,5,5,6,1,-5]
+ d.setValues(vals1,10,1);
+ d2=d.getIdsNotEqual(5);
+ self.assertEqual(7,d2.getNumberOfTuples());
+ self.assertEqual(1,d2.getNumberOfComponents());
+ expected1=[0,1,3,4,7,8,9]
+ for i in xrange(7):
+ self.assertEqual(expected1[i],d2.getIJ(0,i));
+ pass
+ d.rearrange(2);
+ self.assertRaises(InterpKernelException,d.getIdsNotEqual,5);
+ vals2=[-4,5,6]
+ vals3=vals2;
+ d.rearrange(1);
+ d3=d.getIdsNotEqualList(vals3);
+ self.assertEqual(5,d3.getNumberOfTuples());
+ self.assertEqual(1,d3.getNumberOfComponents());
+ expected2=[0,1,4,8,9]
+ for i in xrange(5):
+ self.assertEqual(expected2[i],d3.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIComputeOffsets1(self):
+ d=DataArrayInt.New();
+ vals1=[3,5,1,2,0,8]
+ expected1=[0,3,8,9,11,11]
+ d.setValues(vals1,6,1);
+ d.computeOffsets();
+ self.assertEqual(6,d.getNumberOfTuples());
+ self.assertEqual(1,d.getNumberOfComponents());
+ for i in xrange(6):
+ self.assertEqual(expected1[i],d.getIJ(0,i));
+ pass
+ pass
def setUp(self):
pass
f4.setName("f4");
return [f0,f1,f2,f3,f4]
+ def build1DMultiTypes_1(self):
+ mesh=MEDCouplingUMesh.New("Multi1DMesh",1);
+ coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1();
+ conn=[0,2, 0,2,1]
+ mesh.allocateCells(2);
+ mesh.insertNextCell(NORM_SEG2,2,conn[0:2])
+ mesh.insertNextCell(NORM_SEG3,3,conn[2:5])
+ mesh.finishInsertingCells();
+ mesh.setCoords(coo);
+ return mesh;
+
+ def build2DMultiTypes_1(self):
+ mesh=MEDCouplingUMesh.New("Multi2DMesh",2);
+ coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1();
+ conn=[3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15]
+ mesh.allocateCells(4);
+ mesh.insertNextCell(NORM_TRI3,3,conn[0:3])
+ mesh.insertNextCell(NORM_TRI6,6,conn[3:9])
+ mesh.insertNextCell(NORM_QUAD4,4,conn[9:13])
+ mesh.insertNextCell(NORM_QUAD8,8,conn[13:21])
+ mesh.finishInsertingCells();
+ mesh.setCoords(coo);
+ return mesh;
+
+ def build3DMultiTypes_1(self):
+ mesh=MEDCouplingUMesh.New("Multi3DMesh",3);
+ coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1();
+ conn=[0,16,17,18,
+ 0,16,17,18,19,20,21,22,23,24,
+ 0,11,10,9,25,
+ 0,11,10,9,25,15,14,13,12,26,27,28,29,
+ 0,30,31,32,33,34,
+ 0,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
+ 0,9,10,11,44,45,46,47,
+ 0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 ];
+ mesh.allocateCells(8);
+ mesh.insertNextCell(NORM_TETRA4,4,conn[0:4])
+ mesh.insertNextCell(NORM_TETRA10,10,conn[4:14])
+ mesh.insertNextCell(NORM_PYRA5,5,conn[14:19])
+ mesh.insertNextCell(NORM_PYRA13,13,conn[19:32])
+ mesh.insertNextCell(NORM_PENTA6,6,conn[32:38])
+ mesh.insertNextCell(NORM_PENTA15,15,conn[38:53])
+ mesh.insertNextCell(NORM_HEXA8,8,conn[53:61])
+ mesh.insertNextCell(NORM_HEXA20,20,conn[61:81])
+ mesh.finishInsertingCells();
+ mesh.setCoords(coo);
+ return mesh;
+
+ def buildCoordsForMultiTypes_1(self):
+ coords=DataArrayDouble.New();
+ data=[0.0,0.0,0.0, 0.5,0.5,0.5, 1.0,1.0,1.0, 1.0,1.0,0.0, 2.0,2.5,0.0, 6.0,1.5,0.0, 1.0,2.0,0.0, 4.5,2.5,0.0, 4.0,0.5,0.0, 0.0,4.0,0.0, 4.0,4.0,0.0, 4.0,0.0,0.0, 0.0,2.0,0.0, 2.0,4.0,0.0, 4.0,2.0,0.0, 2.0,0.0,0.0, 0.0,6.0,0.0, 3.0,3.0,0.0, 1.3,3.0,3.0, 0.0,3.0,0.0, 1.5,4.5,0.0, 1.5,1.5,0.0, 0.65,1.5,1.5, 0.65,4.5,1.5, 2.15,3.0,1.5, 2.0,2.0,2.0, 3.0,1.0,1.0, 3.0,3.0,1.0, 1.0,3.0,1.0, 1.0,1.0,1.0, 0.0,3.0,0.0, 2.0,0.0,0.0, 0.0,0.0,6.0, 0.0,3.0,6.0, 3.0,0.0,6.0, 0.0,1.5,0.0, 1.5,1.5,0.0, 1.5,0.0,0.0, 0.0,1.5,6.0, 1.5,1.5,6.0, 1.5,0.0,6.0, 0.0,0.0,3.0, 0.0,3.0,3.0, 3.0,0.0,3.0, 0.0,0.0,4.0, 0.0,4.0,4.0, 4.0,4.0,4.0, 4.0,0.0,4.0, 0.0,2.0,4.0, 2.0,4.0,4.0, 4.0,2.0,4.0, 2.0,0.0,4.0, 0.0,0.0,2.0, 0.0,4.0,2.0, 4.0,4.0,2.0, 4.0,0.0,2.0]
+ coords.setValues(data,56,3);
+ coords.setInfoOnComponent(0,"X (cm)");
+ coords.setInfoOnComponent(1,"Y (cm)");
+ coords.setInfoOnComponent(2,"Z (cm)");
+ return coords
+
+ def buildHexa8Mesh_1(self):
+ mesh=MEDCouplingUMesh.New("Hexa8Only",3);
+ coo=DataArrayDouble.New();
+ coords=[0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0]
+ coo.setValues(coords,27,3);
+ conn=[3,12,13,4,0,9,10,1,
+ 4,13,14,5,1,10,11,2,
+ 6,15,16,7,3,12,13,4,
+ 7,16,17,8,4,13,14,5,
+ 12,21,22,13,9,18,19,10,
+ 13,22,23,14,10,19,20,11,
+ 15,24,25,16,12,21,22,13,
+ 16,25,26,17,13,22,23,14];
+ mesh.allocateCells(8);
+ for i in xrange(8):
+ mesh.insertNextCell(NORM_HEXA8,8,conn[8*i:8*(i+1)])
+ pass
+ mesh.finishInsertingCells();
+ mesh.setCoords(coo);
+ return mesh;
+
build2DTargetMesh_1=classmethod(build2DTargetMesh_1)
build2DSourceMesh_1=classmethod(build2DSourceMesh_1)
build3DTargetMesh_1=classmethod(build3DTargetMesh_1)
build2DTargetMesh_4=classmethod(build2DTargetMesh_4)
buildMultiFields_1=classmethod(buildMultiFields_1)
buildMultiFields_2=classmethod(buildMultiFields_2)
+ build1DMultiTypes_1=classmethod(build1DMultiTypes_1)
+ build2DMultiTypes_1=classmethod(build2DMultiTypes_1)
+ build3DMultiTypes_1=classmethod(build3DMultiTypes_1)
+ buildCoordsForMultiTypes_1=classmethod(buildCoordsForMultiTypes_1)
+ buildHexa8Mesh_1=classmethod(buildHexa8Mesh_1)
pass