static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
ConvexIntersector(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf, double medianPlane,
+ double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane,
bool doRotate, int orientation, int printLevel);
double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS);
double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector<double>& sourceCoords, bool isSourceQuad);
{
CONVINTERSECTOR_TEMPLATE
CONVEX_INTERSECTOR_::ConvexIntersector(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf,
+ double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf,
double medianPlane, bool doRotate , int oriantation, int printLevel)
- :InterpType<MyMeshType,MyMatrix,CONVEX_INTERSECTOR_ >(meshT,meshS,dimCaracteristic, precision, md3DSurf, medianPlane, doRotate, oriantation, printLevel),
+ :InterpType<MyMeshType,MyMatrix,CONVEX_INTERSECTOR_ >(meshT,meshS,dimCaracteristic, precision, md3DSurf, minDot3DSurf, medianPlane, doRotate, oriantation, printLevel),
_epsilon(precision*dimCaracteristic)
{
if(PlanarIntersector<MyMeshType,MyMatrix>::_print_level >= 1)
const CellModel& cellModel(CellModel::GetCellModel(_my_geometry));
switch( _my_geometry )
{
+ case NORM_POINT1:
+ _my_local_ref_dim = 0;
+ _my_local_nb_ref = 1;
+ point1Init();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ break;
+
case NORM_SEG2:
_my_local_ref_dim = 1;
_my_local_nb_ref = 2;
}
break;
+ case NORM_TRI7:
+ _my_local_ref_dim = 2;
+ _my_local_nb_ref = 7;
+ tria7aInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ break;
+
case NORM_QUAD4:
{
_my_local_ref_dim = 2;
break;
case NORM_PENTA15:
- _my_local_ref_dim = 3;
- _my_local_nb_ref = 15;
- penta15aInit();
- aSatify = isSatisfy();
-
- if(!aSatify)
- {
- penta15bInit();
- aSatify = isSatisfy();
- CHECK_MACRO;
- }
- break;
+ {
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 15;
+ MapToShapeFunction PENTA15PTR[]={Penta15aInit,Penta15bInit};
+ std::size_t NB_OF_PENTA15PTR(sizeof(PENTA15PTR)/sizeof(MapToShapeFunction));
+ for(std::size_t i=0;i<NB_OF_PENTA15PTR && !aSatify;i++)
+ {
+ (PENTA15PTR[i])(*this);
+ aSatify = isSatisfy();
+ }
+ CHECK_MACRO;
+ break;
+ }
case NORM_HEXA8:
{
}
break;
+ case NORM_HEXA27:
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 27;
+ hexa27aInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO
+ break;
+
default:
- throw INTERP_KERNEL::Exception("Not manged cell type !");
+ throw INTERP_KERNEL::Exception("Not managed cell type !");
break;
}
}
return &_my_function_value[ _my_nb_ref*theGaussId ];
}
+void GaussInfo::point1Init()
+{
+ double *funValue(&_my_function_value[0]);
+ funValue[0] = 1. ;
+}
+
/*!
* Init Segment 2 Reference coordinates ans Shape function.
*/
SHAPE_FUN_MACRO_END;
}
+void GaussInfo::tria7aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ break;
+ case 2:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ break;
+ case 3:
+ coords[0] = 0.5;
+ coords[1] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.5;
+ coords[1] = 0.5;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.5;
+ break;
+ case 6:
+ coords[0] = 0.3333333333333333;
+ coords[1] = 0.3333333333333333;
+ break;
+
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0]=1-3*(gc[0]+gc[1])+2*(gc[0]*gc[0]+gc[1]*gc[1])+7*gc[0]*gc[1]-3*gc[0]*gc[1]*(gc[0]+gc[1]);
+ funValue[1]=gc[0]*(-1+2*gc[0]+3*gc[1]-3*gc[1]*(gc[0]+gc[1]));
+ funValue[2]=gc[1]*(-1.+3.*gc[0]+2.*gc[1]-3.*gc[0]*(gc[0]+gc[1]));
+ funValue[3]=4*gc[0]*(1-gc[0]-4*gc[1]+3*gc[1]*(gc[0]+gc[1]));
+ funValue[4]=4*gc[0]*gc[1]*(-2+3*(gc[0]+gc[1]));
+ funValue[5]=4*gc[1]*(1-4*gc[0]-gc[1]+3*gc[0]*(gc[0]+gc[1]));
+ funValue[6]=27*gc[0]*gc[1]*(1-gc[0]-gc[1]);
+ SHAPE_FUN_MACRO_END;
+}
+
/*!
* Init Quadrangle Reference coordinates ans Shape function.
* Case A.
coords[1] = 0.0;
coords[2] = 0.0;
break;
- case 3:
+ case 1:
coords[0] = 0.0;
- coords[1] = 1.0;
+ coords[1] = -1.0;
coords[2] = 0.0;
break;
case 2:
coords[1] = 0.0;
coords[2] = 0.0;
break;
- case 1:
+ case 3:
coords[0] = 0.0;
- coords[1] = -1.0;
+ coords[1] = 1.0;
coords[2] = 0.0;
break;
case 4:
coords[1] = 0.0;
coords[2] = 1.0;
break;
- case 8:
+ case 5:
coords[0] = 0.5;
- coords[1] = 0.5;
+ coords[1] = -0.5;
coords[2] = 0.0;
break;
- case 7:
+ case 6:
coords[0] = -0.5;
- coords[1] = 0.5;
+ coords[1] = -0.5;
coords[2] = 0.0;
break;
- case 6:
+ case 7:
coords[0] = -0.5;
- coords[1] = -0.5;
+ coords[1] = 0.5;
coords[2] = 0.0;
break;
- case 5:
+ case 8:
coords[0] = 0.5;
- coords[1] = -0.5;
+ coords[1] = 0.5;
coords[2] = 0.0;
break;
case 9:
coords[1] = 0.0;
coords[2] = 0.5;
break;
- case 12:
+ case 10:
coords[0] = 0.0;
- coords[1] = 0.5;
+ coords[1] = -0.5;
coords[2] = 0.5;
break;
case 11:
coords[1] = 0.0;
coords[2] = 0.5;
break;
- case 10:
+ case 12:
coords[0] = 0.0;
- coords[1] = -0.5;
+ coords[1] = 0.5;
coords[2] = 0.5;
break;
LOCAL_COORD_MACRO_END;
SHAPE_FUN_MACRO_BEGIN;
- funValue[0] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)*
- (gc[0] - 0.5)/(1.0 - gc[2]);
- funValue[3] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] - gc[1] + gc[2] - 1.0)*
- (gc[1] - 0.5)/(1.0 - gc[2]);
- funValue[2] = 0.5*(+gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] + gc[1] + gc[2] - 1.0)*
- (-gc[0] - 0.5)/(1.0 - gc[2]);
- funValue[1] = 0.5*(+gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)*
- (-gc[1] - 0.5)/(1.0 - gc[2]);
-
- funValue[4] = 2.0*gc[2]*(gc[2] - 0.5);
-
- funValue[8] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)*
- (gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
- funValue[7] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)*
- (gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
- funValue[6] = 0.5*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)*
- (-gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
- funValue[5] = 0.5*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)*
- (-gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
-
- funValue[9] = 0.5*gc[2]*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)/
- (1.0 - gc[2]);
- funValue[12] = 0.5*gc[2]*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)/
- (1.0 - gc[2]);
- funValue[11] = 0.5*gc[2]*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)/
- (1.0 - gc[2]);
- funValue[10] = 0.5*gc[2]*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)/
- (1.0 - gc[2]);
+ funValue[0] =0.5*(-gc[0]+gc[1]+gc[2]-1.0)*(-gc[0]-gc[1]+gc[2]-1.0)*(gc[0]-0.5)/(1.0-gc[2]);
+ funValue[1] =0.5*(+gc[0]+gc[1]+gc[2]-1.0)*(-gc[0]+gc[1]+gc[2]-1.0)*(-gc[1]-0.5)/(1.0-gc[2]);
+ funValue[2] =0.5*(+gc[0]-gc[1]+gc[2]-1.0)*(+gc[0]+gc[1]+gc[2]-1.0)*(-gc[0]-0.5)/(1.0-gc[2]);
+ funValue[3] =0.5*(-gc[0]-gc[1]+gc[2]-1.0)*(+gc[0]-gc[1]+gc[2]-1.0)*(gc[1]-0.5)/(1.0-gc[2]);
+
+ funValue[4] =2.*gc[2]*(gc[2]-0.5);
+
+ funValue[5] =-0.5*(gc[0]+gc[1]+gc[2]-1.0)*(-gc[0]+gc[1]+gc[2]-1.0)*(-gc[0]-gc[1]+gc[2]-1.0)/(1.0-gc[2]);
+ funValue[6] =-0.5*(gc[0]-gc[1]+gc[2]-1.0)*(gc[0]+gc[1]+gc[2]-1.0)*(-gc[0]+gc[1]+gc[2]-1.0)/(1.0-gc[2]);
+ funValue[7] =-0.5*(-gc[0]-gc[1]+gc[2]-1.0)*(gc[0]-gc[1]+gc[2]-1.0)*(gc[0]+gc[1]+gc[2]-1.0)/(1.0-gc[2]);
+ funValue[8] =-0.5*(-gc[0]+gc[1]+gc[2]-1.0)*(-gc[0]-gc[1]+gc[2]-1.0)*(gc[0]-gc[1]+gc[2]-1.0)/(1.0-gc[2]);
+
+ funValue[9] =gc[2]*(-gc[0]+gc[1]+gc[2]-1.0)*(-gc[0]-gc[1]+gc[2]-1.0)/(1.0-gc[2]);
+ funValue[10]=gc[2]*(gc[0]+gc[1]+gc[2]-1.0)*(-gc[0]+gc[1]+gc[2]-1.0)/(1.0-gc[2]);
+ funValue[11]=gc[2]*(gc[0]-gc[1]+gc[2]-1.0)*(gc[0]+gc[1]+gc[2]-1.0)/(1.0-gc[2]);
+ funValue[12]=gc[2]*(-gc[0]-gc[1]+gc[2]-1.0)*(gc[0]-gc[1]+gc[2]-1.0)/(1.0-gc[2]);
+
SHAPE_FUN_MACRO_END;
}
SHAPE_FUN_MACRO_END;
}
+void GaussInfo::hexa27aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 4:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 5:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ case 6:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ case 7:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 8:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = -1.0;
+ break;
+ case 9:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 10:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = -1.0;
+ break;
+ case 11:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 12:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 13:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ case 14:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 15:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 16:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 17:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 18:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 19:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 20:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = -1.0;
+ break;
+ case 21:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 22:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 23:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 24:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 25:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 26:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] =0.125*gc[0]*(gc[0]-1.)*gc[1]*(gc[1]-1.)*gc[2]*(gc[2]-1.);
+ funValue[1] =0.125*gc[0]*(gc[0]-1.)*gc[1]*(gc[1]+1.)*gc[2]*(gc[2]-1.);
+ funValue[2] =0.125*gc[0]*(gc[0]+1.)*gc[1]*(gc[1]+1.)*gc[2]*(gc[2]-1.);
+ funValue[3] =0.125*gc[0]*(gc[0]+1.)*gc[1]*(gc[1]-1.)*gc[2]*(gc[2]-1.);
+ funValue[4] =0.125*gc[0]*(gc[0]-1.)*gc[1]*(gc[1]-1.)*gc[2]*(gc[2]+1.);
+ funValue[5] =0.125*gc[0]*(gc[0]-1.)*gc[1]*(gc[1]+1.)*gc[2]*(gc[2]+1.);
+ funValue[6] =0.125*gc[0]*(gc[0]+1.)*gc[1]*(gc[1]+1.)*gc[2]*(gc[2]+1.);
+ funValue[7] =0.125*gc[0]*(gc[0]+1.)*gc[1]*(gc[1]-1.)*gc[2]*(gc[2]+1.);
+ funValue[8] =0.25*gc[0]*(gc[0]-1.)*(1.-gc[1]*gc[1])*gc[2]*(gc[2]-1.);
+ funValue[9] =0.25*(1.-gc[0]*gc[0])*gc[1]*(gc[1]+1.)*gc[2]*(gc[2]-1.);
+ funValue[10]=0.25*gc[0]*(gc[0]+1.)*(1.-gc[1]*gc[1])*gc[2]*(gc[2]-1.);
+ funValue[11]=0.25*(1.-gc[0]*gc[0])*gc[1]*(gc[1]-1.)*gc[2]*(gc[2]-1.);
+ funValue[12]=0.25*gc[0]*(gc[0]-1.)*(1.-gc[1]*gc[1])*gc[2]*(gc[2]+1.);
+ funValue[13]=0.25*(1.-gc[0]*gc[0])*gc[1]*(gc[1]+1.)*gc[2]*(gc[2]+1.);
+ funValue[14]=0.25*gc[0]*(gc[0]+1.)*(1.-gc[1]*gc[1])*gc[2]*(gc[2]+1.);
+ funValue[15]=0.25*(1.-gc[0]*gc[0])*gc[1]*(gc[1]-1.)*gc[2]*(gc[2]+1.);
+ funValue[16]=0.25*gc[0]*(gc[0]-1.)*gc[1]*(gc[1]-1.)*(1.-gc[2]*gc[2]);
+ funValue[17]=0.25*gc[0]*(gc[0]-1.)*gc[1]*(gc[1]+1.)*(1.-gc[2]*gc[2]);
+ funValue[18]=0.25*gc[0]*(gc[0]+1.)*gc[1]*(gc[1]+1.)*(1.-gc[2]*gc[2]);
+ funValue[19]=0.25*gc[0]*(gc[0]+1.)*gc[1]*(gc[1]-1.)*(1.-gc[2]*gc[2]);
+ funValue[20]=0.5*(1.-gc[0]*gc[0])*(1.-gc[1]*gc[1])*gc[2]*(gc[2]-1.);
+ funValue[21]=0.5*gc[0]*(gc[0]-1.)*(1.-gc[1]*gc[1])*(1.-gc[2]*gc[2]);
+ funValue[22]=0.5*(1.-gc[0]*gc[0])*gc[1]*(gc[1]+1.)*(1.-gc[2]*gc[2]);
+ funValue[23]=0.5*gc[0]*(gc[0]+1.)*(1.-gc[1]*gc[1])*(1.-gc[2]*gc[2]);
+ funValue[24]=0.5*(1.-gc[0]*gc[0])*gc[1]*(gc[1]-1.)*(1.-gc[2]*gc[2]);
+ funValue[25]=0.5*(1.-gc[0]*gc[0])*(1.-gc[1]*gc[1])*gc[2]*(gc[2]+1.);
+ funValue[26]=(1.-gc[0]*gc[0])*(1.-gc[1]*gc[1])*(1.-gc[2]*gc[2]);
+
+ SHAPE_FUN_MACRO_END;
+}
////////////////////////////////////////////////////////////////////////////////////////////////
// GAUSS COORD CLASS //
protected:
bool isSatisfy();
-
+
+ void point1Init();
+
//1D
void seg2Init();
void seg3Init();
void tria3bInit();
void tria6aInit();
void tria6bInit();
+ void tria7aInit();
void quad4aInit();
static void Quad4aInit(GaussInfo& obj) { obj.quad4aInit(); }
static void Penta6DegTria3bInit(GaussInfo& obj) { obj.penta6DegTria3bInit(); }
void penta15aInit();
+ static void Penta15aInit(GaussInfo& obj) { obj.penta15aInit(); }
void penta15bInit();
+ static void Penta15bInit(GaussInfo& obj) { obj.penta15bInit(); }
void hexa8aInit();
static void Hexa8aInit(GaussInfo& obj) { obj.hexa8aInit(); }
static void Hexa8DegQuad4cInit(GaussInfo& obj) { obj.hexa8DegQuad4cInit(); }
void hexa20aInit();
void hexa20bInit();
-
+ void hexa27aInit();
private:
//INFORMATION from MEDMEM
return fabs(p1.first-p2.first)<QUADRATIC_PLANAR::_precision;
}
+/**
+ * This method takes in input nodes in \a subNodes (using \a coo)
+ *
+ * \param [in,out] subNodes to be sorted
+ * \return true if a reordering was necessary false if not.
+ */
+bool Edge::sortSubNodesAbs(const double *coo, std::vector<int>& subNodes)
+{
+ Bounds b;
+ b.prepareForAggregation();
+ b.aggregate(getBounds());
+ double xBary,yBary;
+ double dimChar(b.getCaracteristicDim());
+ b.getBarycenter(xBary,yBary);
+ applySimilarity(xBary,yBary,dimChar);
+ _start->applySimilarity(xBary,yBary,dimChar);
+ _end->applySimilarity(xBary,yBary,dimChar);
+ //
+ std::size_t sz(subNodes.size()),i(0);
+ std::vector< std::pair<double,Node *> > an2(sz);
+ std::map<Node *, int> m;
+ for(std::vector<int>::const_iterator it=subNodes.begin();it!=subNodes.end();it++,i++)
+ {
+ Node *n(new Node(coo[2*(*it)],coo[2*(*it)+1]));
+ n->applySimilarity(xBary,yBary,dimChar);
+ m[n]=*it;
+ an2[i]=std::pair<double,Node *>(getCharactValueBtw0And1(*n),n);
+ }
+ std::sort(an2.begin(),an2.end());
+ //
+ bool ret(false);
+ for(i=0;i<sz;i++)
+ {
+ int id(m[an2[i].second]);
+ if(id!=subNodes[i])
+ { subNodes[i]=id; ret=true; }
+ }
+ //
+ for(std::map<INTERP_KERNEL::Node *,int>::const_iterator it2=m.begin();it2!=m.end();it2++)
+ (*it2).first->decrRef();
+ return ret;
+}
+
/**
* Sort nodes so that they all lie consecutively on the edge that has been cut.
*/
virtual double getCurveLength() const = 0;
virtual void getBarycenter(double *bary) const = 0;
virtual void getBarycenterOfZone(double *bary) const = 0;
+ virtual void getMiddleOfPoints(const double *p1, const double *p2, double *mid) const = 0;
//! Retrieves a point that is owning to this, well placed for IN/OUT detection of this. Typically midlle of this is returned.
virtual Node *buildRepresentantOfMySelf() const = 0;
//! Given a magnitude specified by sub-type returns if in or not. See getCharactValue method.
virtual void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const = 0;
bool isEqual(const Edge& other) const;
public:
+ bool sortSubNodesAbs(const double *coo, std::vector<int>& subNodes);
void sortIdsAbs(const std::vector<INTERP_KERNEL::Node *>& addNodes, const std::map<INTERP_KERNEL::Node *, int>& mapp1, const std::map<INTERP_KERNEL::Node *, int>& mapp2, std::vector<int>& edgesThis);
virtual void fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const = 0;
+tmp2*(tmp4-tmp3+(tmp3*tmp3*tmp3-tmp4*tmp4*tmp4)/3.)/2.;
}
+void EdgeArcCircle::getMiddleOfPoints(const double *p1, const double *p2, double *mid) const
+{
+ double dx1((p1[0]-_center[0])/_radius),dy1((p1[1]-_center[1])/_radius),dx2((p2[0]-_center[0])/_radius),dy2((p2[1]-_center[1])/_radius);
+ double angle1(GetAbsoluteAngleOfNormalizedVect(dx1,dy1)),angle2(GetAbsoluteAngleOfNormalizedVect(dx2,dy2));
+ //
+ double myDelta1(angle1-_angle0),myDelta2(angle2-_angle0);
+ if(_angle>0.)
+ { myDelta1=myDelta1>=0.?myDelta1:myDelta1+2.*M_PI; myDelta2=myDelta2>=0.?myDelta2:myDelta2+2.*M_PI; }
+ else
+ { myDelta1=myDelta1<=0.?myDelta1:myDelta1-2.*M_PI; myDelta2=myDelta2<=0.?myDelta2:myDelta2-2.*M_PI; }
+ ////
+ mid[0]=_center[0]+_radius*cos(_angle0+(myDelta1+myDelta2)/2.);
+ mid[1]=_center[1]+_radius*sin(_angle0+(myDelta1+myDelta2)/2.);
+}
+
/*!
* Characteristic value used is angle in ]_Pi;Pi[ from axe 0x.
*/
double getCurveLength() const;
void getBarycenter(double *bary) const;
void getBarycenterOfZone(double *bary) const;
+ void getMiddleOfPoints(const double *p1, const double *p2, double *mid) const;
bool isIn(double characterVal) const;
Node *buildRepresentantOfMySelf() const;
bool isLower(double val1, double val2) const;
bary[1]=(x1-x2)*(y1*(y1+y2)+y2*y2)/6.;
}
+/*!
+ * Here \a this is not used (contrary to EdgeArcCircle class).
+ */
+void EdgeLin::getMiddleOfPoints(const double *p1, const double *p2, double *mid) const
+{
+ mid[0]=(p1[0]+p2[0])/2.;
+ mid[1]=(p1[1]+p2[1])/2.;
+}
+
double EdgeLin::getCurveLength() const
{
double x=(*_start)[0]-(*_end)[0];
double getCurveLength() const;
void getBarycenter(double *bary) const;
void getBarycenterOfZone(double *bary) const;
+ void getMiddleOfPoints(const double *p1, const double *p2, double *mid) const;
bool isIn(double characterVal) const;
Node *buildRepresentantOfMySelf() const;
double getCharactValue(const Node& node) const;
QuadraticPolygon *QuadraticPolygon::BuildLinearPolygon(std::vector<Node *>& nodes)
{
- QuadraticPolygon *ret=new QuadraticPolygon;
+ QuadraticPolygon *ret(new QuadraticPolygon);
std::size_t size=nodes.size();
for(std::size_t i=0;i<size;i++)
{
QuadraticPolygon *QuadraticPolygon::BuildArcCirclePolygon(std::vector<Node *>& nodes)
{
- QuadraticPolygon *ret=new QuadraticPolygon;
+ QuadraticPolygon *ret(new QuadraticPolygon);
std::size_t size=nodes.size();
for(std::size_t i=0;i<size/2;i++)
+
{
EdgeLin *e1,*e2;
e1=new EdgeLin(nodes[i],nodes[i+size/2]);
return ret;
}
+Edge *QuadraticPolygon::BuildLinearEdge(std::vector<Node *>& nodes)
+{
+ if(nodes.size()!=2)
+ throw INTERP_KERNEL::Exception("QuadraticPolygon::BuildLinearEdge : input vector is expected to be of size 2 !");
+ Edge *ret(new EdgeLin(nodes[0],nodes[1]));
+ nodes[0]->decrRef(); nodes[1]->decrRef();
+ return ret;
+}
+
+Edge *QuadraticPolygon::BuildArcCircleEdge(std::vector<Node *>& nodes)
+{
+ if(nodes.size()!=3)
+ throw INTERP_KERNEL::Exception("QuadraticPolygon::BuildArcCircleEdge : input vector is expected to be of size 3 !");
+ EdgeLin *e1(new EdgeLin(nodes[0],nodes[2])),*e2(new EdgeLin(nodes[2],nodes[1]));
+ SegSegIntersector inters(*e1,*e2);
+ bool colinearity=inters.areColinears();
+ delete e1; delete e2;
+ Edge *ret(0);
+ if(colinearity)
+ ret=new EdgeLin(nodes[0],nodes[1]);
+ else
+ ret=new EdgeArcCircle(nodes[0],nodes[2],nodes[1]);
+ nodes[0]->decrRef(); nodes[1]->decrRef(); nodes[2]->decrRef();
+ return ret;
+}
+
void QuadraticPolygon::BuildDbgFile(const std::vector<Node *>& nodes, const char *fileName)
{
std::ofstream file(fileName);
INTERPKERNEL_EXPORT QuadraticPolygon(const char *fileName);
INTERPKERNEL_EXPORT static QuadraticPolygon *BuildLinearPolygon(std::vector<Node *>& nodes);
INTERPKERNEL_EXPORT static QuadraticPolygon *BuildArcCirclePolygon(std::vector<Node *>& nodes);
+ INTERPKERNEL_EXPORT static Edge *BuildLinearEdge(std::vector<Node *>& nodes);
+ INTERPKERNEL_EXPORT static Edge *BuildArcCircleEdge(std::vector<Node *>& nodes);
INTERPKERNEL_EXPORT static void BuildDbgFile(const std::vector<Node *>& nodes, const char *fileName);
INTERPKERNEL_EXPORT ~QuadraticPolygon();
INTERPKERNEL_EXPORT void closeMe() const;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
Geometric2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation);
+ double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation);
double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS);
double intersectGeometry1D(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS,
bool& isColinear);
{
INTERSECTOR_TEMPLATE
GEO2D_INTERSECTOR::Geometric2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double md3DSurf, double medianPlane,
+ double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane,
double precision, int orientation):
- InterpType<MyMeshType,MyMatrix,GEO2D_INTERSECTOR >(meshT,meshS,dimCaracteristic, precision, md3DSurf, medianPlane, true, orientation, 0)
+ InterpType<MyMeshType,MyMatrix,GEO2D_INTERSECTOR >(meshT,meshS,dimCaracteristic, precision, md3DSurf, minDot3DSurf, medianPlane, true, orientation, 0)
{
QUADRATIC_PLANAR::_precision=precision;
}
QuadraticPolygon *p2=buildPolygonFrom(CoordsS,tS);
double ret=p1->intersectWithAbs(*p2);
delete p1; delete p2;
- return ret;
+ return orientation*ret;
}
INTERSECTOR_TEMPLATE
QuadraticPolygon *p2=buildPolygonOfOneEdgeFrom(CoordsS,tS);
double ret=p1->intersectWithAbs1D(*p2, isColinear);
delete p1; delete p2;
- return ret;
+ return orientation*ret;
}
INTERSECTOR_TEMPLATE
case Geometric2D:
intersector=new Geometric2DIntersector<MyMeshType,MatrixType,Planar2D1DIntersectorP0P0>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
const double INTERP_KERNEL::InterpolationOptions::DFT_MAX_DIST_3DSURF_INTERSECT=-1.;
+const double INTERP_KERNEL::InterpolationOptions::DFT_MIN_DOT_BTW_3DSURF_INTERSECT=-1.;
+
const char INTERP_KERNEL::InterpolationOptions::PRECISION_STR[]="Precision";
const char INTERP_KERNEL::InterpolationOptions::MEDIANE_PLANE_STR[]="MedianPlane";
const char INTERP_KERNEL::InterpolationOptions::MAX_DISTANCE_3DSURF_INSECT_STR[]="MaxDistance3DSurfIntersect";
+const char INTERP_KERNEL::InterpolationOptions::MIN_DOT_BTW_3DSURF_INSECT_STR[]="MinDotBetween3DSurfIntersect";
+
const char INTERP_KERNEL::InterpolationOptions::PRINT_LEV_STR[]="PrintLevel";
const char INTERP_KERNEL::InterpolationOptions::DO_ROTATE_STR[]="DoRotate";
_bounding_box_adjustment=DFT_SURF3D_ADJ_EPS;
_bounding_box_adjustment_abs=0.;
_max_distance_for_3Dsurf_intersect=DFT_MAX_DIST_3DSURF_INTERSECT;
+ _min_dot_btw_3Dsurf_intersect=DFT_MIN_DOT_BTW_3DSURF_INTERSECT;
_orientation=0;
_measure_abs=true;
_splitting_policy=PLANAR_FACE_5;
setMaxDistance3DSurfIntersect(value);
return true;
}
+ else if(key==MIN_DOT_BTW_3DSURF_INSECT_STR)
+ {
+ setMinDotBtwPlane3DSurfIntersect(value);
+ return true;
+ }
else
return false;
}
oss << "Bounding box adj : " << _bounding_box_adjustment << std::endl;
oss << "Bounding box adj abs : " << _bounding_box_adjustment_abs << std::endl;
oss << "Max distance for 3DSurf intersect : " << _max_distance_for_3Dsurf_intersect << std::endl;
+ oss << "Min dot between plane for 3DSurf intersect : " << _min_dot_btw_3Dsurf_intersect << std::endl;
oss << "Orientation : " << _orientation << std::endl;
oss << "Measure abs : " << _measure_abs << std::endl;
oss << "Splitting policy : " << getSplittingPolicyRepr() << std::endl;
//! this measure is absolute \b not relative to the cell size
double _bounding_box_adjustment_abs ;
double _max_distance_for_3Dsurf_intersect;
+ double _min_dot_btw_3Dsurf_intersect;
int _orientation ;
bool _measure_abs;
SplittingPolicy _splitting_policy ;
double getMaxDistance3DSurfIntersect() const { return _max_distance_for_3Dsurf_intersect; }
void setMaxDistance3DSurfIntersect(double bba) { _max_distance_for_3Dsurf_intersect=bba; }
+ double getMinDotBtwPlane3DSurfIntersect() const { return _min_dot_btw_3Dsurf_intersect; }
+ void setMinDotBtwPlane3DSurfIntersect(double v) { _min_dot_btw_3Dsurf_intersect=v; }
+
int getOrientation() const { return _orientation; }
void setOrientation(int o) { _orientation=o; }
static const double DFT_MEDIAN_PLANE;
static const double DFT_SURF3D_ADJ_EPS;
static const double DFT_MAX_DIST_3DSURF_INTERSECT;
+ static const double DFT_MIN_DOT_BTW_3DSURF_INTERSECT;
public:
static const char PRECISION_STR[];
static const char MEDIANE_PLANE_STR[];
static const char BOUNDING_BOX_ADJ_STR[];
static const char BOUNDING_BOX_ADJ_ABS_STR[];
static const char MAX_DISTANCE_3DSURF_INSECT_STR[];
+ static const char MIN_DOT_BTW_3DSURF_INSECT_STR[];
static const char PRINT_LEV_STR[];
static const char DO_ROTATE_STR[];
static const char ORIENTATION_STR[];
intersector=new TriangulationIntersector<MyMeshType,MatrixType,PlanarIntersectorP0P0>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getOrientation(),
InterpolationOptions::getPrintLevel());
intersector=new ConvexIntersector<MyMeshType,MatrixType,PlanarIntersectorP0P0>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getDoRotate(),
InterpolationOptions::getOrientation(),
case Geometric2D:
intersector=new Geometric2DIntersector<MyMeshType,MatrixType,PlanarIntersectorP0P0>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
case PointLocator:
intersector=new PointLocator2DIntersector<MyMeshType,MatrixType,PlanarIntersectorP0P0>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
intersector=new TriangulationIntersector<MyMeshType,MatrixType,PlanarIntersectorP0P1>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getOrientation(),
InterpolationOptions::getPrintLevel());
intersector=new ConvexIntersector<MyMeshType,MatrixType,PlanarIntersectorP0P1>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getDoRotate(),
InterpolationOptions::getOrientation(),
case Geometric2D:
intersector=new Geometric2DIntersector<MyMeshType,MatrixType,PlanarIntersectorP0P1>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
case PointLocator:
intersector=new PlanarIntersectorP0P1PL<MyMeshType,MatrixType>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
intersector=new TriangulationIntersector<MyMeshType,MatrixType,PlanarIntersectorP0P1Bary>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getOrientation(),
InterpolationOptions::getPrintLevel());
case BarycentricGeo2D:
intersector=new Geometric2DIntersector<MyMeshType,MatrixType,PlanarIntersectorP0P1Bary>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
intersector=new TriangulationIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getOrientation(),
InterpolationOptions::getPrintLevel());
intersector=new ConvexIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getDoRotate(),
InterpolationOptions::getOrientation(),
case Geometric2D:
intersector=new Geometric2DIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
break;
case PointLocator:
intersector=new PlanarIntersectorP1P0PL<MyMeshType,MatrixType>(myMeshT, myMeshS, _dim_caracteristic,
- InterpolationOptions::getMaxDistance3DSurfIntersect(),
- InterpolationOptions::getMedianPlane(),
- InterpolationOptions::getPrecision(),
- InterpolationOptions::getOrientation());
+ InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
+ InterpolationOptions::getMedianPlane(),
+ InterpolationOptions::getPrecision(),
+ InterpolationOptions::getOrientation());
break;
case Barycentric:
intersector=new TriangulationIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0Bary>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getOrientation(),
InterpolationOptions::getPrintLevel());
case BarycentricGeo2D:
intersector=new Geometric2DIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P0Bary>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
intersector=new TriangulationIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P1>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getOrientation(),
InterpolationOptions::getPrintLevel());
intersector=new ConvexIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P1>(myMeshT,myMeshS,_dim_caracteristic,
InterpolationOptions::getPrecision(),
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getDoRotate(),
InterpolationOptions::getOrientation(),
case Geometric2D:
intersector=new Geometric2DIntersector<MyMeshType,MatrixType,PlanarIntersectorP1P1>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
case PointLocator:
intersector=new PlanarIntersectorP1P1PL<MyMeshType,MatrixType>(myMeshT, myMeshS, _dim_caracteristic,
InterpolationOptions::getMaxDistance3DSurfIntersect(),
+ InterpolationOptions::getMinDotBtwPlane3DSurfIntersect(),
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrecision(),
InterpolationOptions::getOrientation());
inline std::vector<double> reconstruct_polygon(const std::vector<double>& V)
{
- std::size_t taille=V.size();
+ int taille((int)V.size());
//VB : why 6 ?
COS[0]=1.0;
SIN[0]=0.0;
//angle[0]=0.0;
- for(std::size_t i=0; i<taille/2-1;i++)
+ for(int i=0; i<taille/2-1;i++)
{
std::vector<double> Trigo=calcul_cos_et_sin(&Bary[0],&V[0],&V[2*(i+1)]);
COS[i+1]=Trigo[0];
Pt_ordonne.reserve(taille);
// std::multimap<double,int> Ordre;
std::multimap<std::pair<double,double>,int, AngleLess> CosSin;
- for(std::size_t i=0;i<taille/2;i++)
+ for(int i=0;i<taille/2;i++)
{
// Ordre.insert(std::make_pair(angle[i],i));
CosSin.insert(std::make_pair(std::make_pair(SIN[i],COS[i]),i));
INTERSECTOR_CU2D::IntersectorCU2D(const MyCMeshType& meshS,
const MyUMeshType& meshT):
IntersectorCU<MyCMeshType, MyUMeshType, MyMatrix, IntersectorCU2D<MyCMeshType,MyUMeshType,MyMatrix> >( meshS, meshT ),
- _intersector(meshT, meshT, 0,0,0,0,0,0 )
+ _intersector(meshT, meshT, 0,0,0,0,0,0,0 )
{
if ( MyCMeshType::MY_SPACEDIM != 2 || MyCMeshType::MY_MESHDIM != 2 ||
MyUMeshType::MY_SPACEDIM != 2 || MyUMeshType::MY_MESHDIM != 2 )
static const NumberingPolicy numPol=MyMeshType::My_numPol;
protected:
Planar2D1DIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
+ double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
public:
int getNumberOfRowsOfResMatrix() const;
int getNumberOfColsOfResMatrix() const;
{
template<class MyMeshType, class MyMatrix, class ConcreteP0P0Intersector>
Planar2D1DIntersectorP0P0<MyMeshType,MyMatrix,ConcreteP0P0Intersector>::Planar2D1DIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf, double medianPlane,
+ double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane,
bool doRotate, int orientation, int printLevel):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel)
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,doRotate,orientation,printLevel)
{
}
typedef typename std::map<int,std::set<int> > DuplicateFacesType;
public:
//! \addtogroup InterpKerGrpIntPlan @{
- PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
+ PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
//! @}
virtual ~PlanarIntersector();
void createBoundingBoxes(const MyMeshType& mesh, std::vector<double>& bbox);
void adjustBoundingBoxes(std::vector<double>& bbox, double surf3DAdjustmentEps, double surf3DAdjustmentEpsAbs);
inline void getElemBB(double* bb, const MyMeshType& mesh, ConnType iP, ConnType nb_nodes);
- static int projection(double *Coords_A, double *Coords_B,
- int nb_NodesA, int nb_NodesB, double epsilon, double md3DSurf, double median_plane, bool do_rotate);
+ static int Projection(double *Coords_A, double *Coords_B,
+ int nb_NodesA, int nb_NodesB, double epsilon, double md3DSurf, double minDot3DSurf, double median_plane, bool do_rotate);
virtual const DuplicateFacesType* getIntersectFaces() const
{
return NULL;
const MyMeshType& _meshS;
double _dim_caracteristic;
double _max_distance_3Dsurf_intersect;
+ double _min_dot_btw_3Dsurf_intersect;
double _precision;
double _median_plane;
bool _do_rotate;
namespace INTERP_KERNEL
{
template<class MyMeshType, class MyMatrix>
- PlanarIntersector<MyMeshType,MyMatrix>::PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel):
+ PlanarIntersector<MyMeshType,MyMatrix>::PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel):
_meshT(meshT),_meshS(meshS),
- _dim_caracteristic(dimCaracteristic),_max_distance_3Dsurf_intersect(md3DSurf),_precision(precision),_median_plane(medianPlane),
+ _dim_caracteristic(dimCaracteristic),_max_distance_3Dsurf_intersect(md3DSurf),_min_dot_btw_3Dsurf_intersect(minDot3DSurf),_precision(precision),_median_plane(medianPlane),
_do_rotate(doRotate),_orientation(orientation),_print_level(printLevel)
{
_connectT=meshT.getConnectivityPtr();
template<class MyMeshType, class MyMatrix>
int PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(double *Coords_A, double *Coords_B, int nb_NodesA, int nb_NodesB)
{
- return projection(Coords_A,Coords_B,nb_NodesA,nb_NodesB,_dim_caracteristic*_precision,_max_distance_3Dsurf_intersect,_median_plane,_do_rotate);
+ return Projection(Coords_A,Coords_B,nb_NodesA,nb_NodesB,_dim_caracteristic*_precision,_max_distance_3Dsurf_intersect,_min_dot_btw_3Dsurf_intersect,_median_plane,_do_rotate);
}
template<class MyMeshType, class MyMatrix>
- int PlanarIntersector<MyMeshType,MyMatrix>::projection(double *Coords_A, double *Coords_B,
- int nb_NodesA, int nb_NodesB, double epsilon, double md3DSurf, double median_plane, bool do_rotate)
+ int PlanarIntersector<MyMeshType,MyMatrix>::Projection(double *Coords_A, double *Coords_B,
+ int nb_NodesA, int nb_NodesB, double epsilon, double md3DSurf, double minDot3DSurf, double median_plane, bool do_rotate)
{
double normal_A[3]={0,0,0};
double normal_B[3]={0,0,0};
bool same_orientation;
//Find the normal to cells A and B
- int i_A1=1;
- while(i_A1<nb_NodesA && distance2<SPACEDIM>(Coords_A,&Coords_A[SPACEDIM*i_A1])< epsilon) i_A1++;
- int i_A2=i_A1+1;
+ int i_A1(1);
+ while(i_A1<nb_NodesA && distance2<SPACEDIM>(Coords_A,&Coords_A[SPACEDIM*i_A1])< epsilon)
+ i_A1++;
+ int i_A2(i_A1+1);
crossprod<SPACEDIM>(Coords_A, &Coords_A[SPACEDIM*i_A1], &Coords_A[SPACEDIM*i_A2],normal_A);
- double normA = sqrt(dotprod<SPACEDIM>(normal_A,normal_A));
+ double normA(sqrt(dotprod<SPACEDIM>(normal_A,normal_A)));
while(i_A2<nb_NodesA && normA < epsilon)
{
crossprod<SPACEDIM>(Coords_A, &Coords_A[SPACEDIM*i_A1], &Coords_A[SPACEDIM*i_A2],normal_A);
normA = sqrt(dotprod<SPACEDIM>(normal_A,normal_A));
}
- int i_B1=1;
- while(i_B1<nb_NodesB && distance2<SPACEDIM>(Coords_B,Coords_B+SPACEDIM*i_B1)< epsilon) i_B1++;
- int i_B2=i_B1+1;
+ int i_B1(1);
+ while(i_B1<nb_NodesB && distance2<SPACEDIM>(Coords_B,Coords_B+SPACEDIM*i_B1)< epsilon)
+ i_B1++;
+ int i_B2(i_B1+1);
crossprod<SPACEDIM>(Coords_B, Coords_B+SPACEDIM*i_B1, Coords_B+SPACEDIM*i_B2,normal_B);
- double normB = sqrt(dotprod<SPACEDIM>(normal_B,normal_B));
+ double normB(sqrt(dotprod<SPACEDIM>(normal_B,normal_B)));
while(i_B2<nb_NodesB && normB < epsilon)
{
crossprod<SPACEDIM>(Coords_B, Coords_B+SPACEDIM*i_B1, Coords_B+SPACEDIM*i_B2,normal_B);
if(md3DSurf>0.)
{
double coords_GA[3];
- for (int i=0;i<3;i++)
+ for(int i=0;i<3;i++)
{
coords_GA[i]=0.;
for (int j=0;j<nb_NodesA;j++)
coords_GA[i]/=nb_NodesA;
}
double G1[3],G2[3],G3[3];
- for (int i=0;i<3;i++)
- {
- G1[i]=Coords_B[i]-coords_GA[i];
- G2[i]=Coords_B[i+3]-coords_GA[i];
- G3[i]=Coords_B[i+6]-coords_GA[i];
- }
- double prodvect[3];
- prodvect[0]=G1[1]*G2[2]-G1[2]*G2[1];
- prodvect[1]=G1[2]*G2[0]-G1[0]*G2[2];
- prodvect[2]=G1[0]*G2[1]-G1[1]*G2[0];
- double prodscal=prodvect[0]*G3[0]+prodvect[1]*G3[1]+prodvect[2]*G3[2];
- if(fabs(prodscal)>md3DSurf)
- return 0;
+ for(int i=0;i<3;i++)
+ {
+ G1[i]=Coords_B[i]-coords_GA[i];
+ G2[i]=Coords_B[i+3]-coords_GA[i];
+ G3[i]=Coords_B[i+6]-coords_GA[i];
+ }
+ double prodvect[3];
+ prodvect[0]=G1[1]*G2[2]-G1[2]*G2[1];
+ prodvect[1]=G1[2]*G2[0]-G1[0]*G2[2];
+ prodvect[2]=G1[0]*G2[1]-G1[1]*G2[0];
+ double prodscal=prodvect[0]*G3[0]+prodvect[1]*G3[1]+prodvect[2]*G3[2];
+ if(fabs(prodscal)>md3DSurf)
+ return 0;
}
if(i_A2<nb_NodesA && i_B2<nb_NodesB)
{
//Build the normal of the median plane
- same_orientation = dotprod<SPACEDIM>(normal_A,normal_B)>=0;
+
+ double dotProd(dotprod<SPACEDIM>(normal_A,normal_B)/(normA*normB));
+
+ if(fabs(dotProd)<minDot3DSurf)
+ return 0;
+
+ same_orientation=(dotProd>=0);
if(!same_orientation)
- for(int idim =0; idim< SPACEDIM; idim++) normal_A[idim] *=-1;
+ for(int idim =0; idim< SPACEDIM; idim++)
+ normal_A[idim] *=-1;
- double normBB= sqrt(dotprod<SPACEDIM>(normal_B,normal_B));
+ double normBB(sqrt(dotprod<SPACEDIM>(normal_B,normal_B)));
for(int idim =0; idim< SPACEDIM; idim++)
linear_comb[idim] = median_plane*normal_A[idim]/normA + (1-median_plane)*normal_B[idim]/normBB;
double norm= sqrt(dotprod<SPACEDIM>(linear_comb,linear_comb));
//Necessarily: norm>epsilon, no need to check
- for(int idim =0; idim< SPACEDIM; idim++) linear_comb[idim]/=norm;
+ for(int idim =0; idim< SPACEDIM; idim++)
+ linear_comb[idim]/=norm;
//Project the nodes of A and B on the median plane
for(int i_A=0; i_A<nb_NodesA; i_A++)
TranslationRotationMatrix rotation;
//rotate3DTriangle(Coords_A, &Coords_A[SPACEDIM*i_A1], &Coords_A[SPACEDIM*i_A2], rotation);
rotate3DTriangle(Coords_B, Coords_B+SPACEDIM*i_B1, Coords_B+SPACEDIM*i_B2, rotation);
- for (int i=0; i<nb_NodesA; i++) rotation.transform_vector(Coords_A+SPACEDIM*i);
- for (int i=0; i<nb_NodesB; i++) rotation.transform_vector(Coords_B+SPACEDIM*i);
+ for (int i=0; i<nb_NodesA; i++)
+ rotation.transform_vector(Coords_A+SPACEDIM*i);
+ for (int i=0; i<nb_NodesB; i++)
+ rotation.transform_vector(Coords_B+SPACEDIM*i);
}
- if(same_orientation)
- return 1;
- else return -1;
+ return same_orientation?1:-1;
}
else
{
std::cout << " i_B1= " << i_B1 << " i_B2= " << i_B2 << std::endl;
std::cout << " distance2<SPACEDIM>(&Coords_B[0],&Coords_B[i_B1])= " << distance2<SPACEDIM>(Coords_B,Coords_B+i_B1) << std::endl;
std::cout << "normal_B = " << normal_B[0] << " ; " << normal_B[1] << " ; " << normal_B[2] << std::endl;
-
return 1;
}
}
typedef typename MyMeshType::MyConnType ConnType;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
protected:
- PlanarIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
+ PlanarIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
public:
int getNumberOfRowsOfResMatrix() const;
int getNumberOfColsOfResMatrix() const;
{
template<class MyMeshType, class MyMatrix, class ConcreteP0P0Intersector>
PlanarIntersectorP0P0<MyMeshType,MyMatrix,ConcreteP0P0Intersector>::PlanarIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf, double medianPlane,
+ double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane,
bool doRotate, int orientation, int printLevel):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel)
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,doRotate,orientation,printLevel)
{
}
typedef typename MyMeshType::MyConnType ConnType;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
protected:
- PlanarIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
+ PlanarIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
public:
void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
int getNumberOfRowsOfResMatrix() const;
{
template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
PlanarIntersectorP0P1<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::PlanarIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf, double medianPlane,
+ double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane,
bool doRotate, int orientation, int printLevel):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel)
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,doRotate,orientation,printLevel)
{
}
typedef typename MyMeshType::MyConnType ConnType;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
protected:
- PlanarIntersectorP0P1Bary(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
+ PlanarIntersectorP0P1Bary(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
public:
void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
int getNumberOfRowsOfResMatrix() const;
template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
PlanarIntersectorP0P1Bary<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::PlanarIntersectorP0P1Bary(const MyMeshType& meshT, const MyMeshType& meshS,
double dimCaracteristic, double precision,
- double md3DSurf, double medianPlane,
+ double md3DSurf, double minDot3DSurf, double medianPlane,
bool doRotate, int orientation, int printLevel):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,
- medianPlane,doRotate,orientation,printLevel)
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,
+ medianPlane,doRotate,orientation,printLevel)
{
// SPEC:
// "Limitation. For the P0P1 barycentric improvement only triangle target cells in 2D and
typedef typename MyMeshType::MyConnType ConnType;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
- PlanarIntersectorP0P1PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation);
+ PlanarIntersectorP0P1PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation);
void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
int getNumberOfRowsOfResMatrix() const;
int getNumberOfColsOfResMatrix() const;
{
template<class MyMeshType, class MyMatrix>
PlanarIntersectorP0P1PL<MyMeshType,MyMatrix>::PlanarIntersectorP0P1PL(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double md3DSurf,
+ double dimCaracteristic, double md3DSurf, double minDot3DSurf,
double medianPlane, double precision, int orientation):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,true,orientation,0)
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,true,orientation,0)
{
}
typedef typename MyMeshType::MyConnType ConnType;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
protected:
- PlanarIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
+ PlanarIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
public:
void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
int getNumberOfRowsOfResMatrix() const;
{
template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
PlanarIntersectorP1P0<MyMeshType,MyMatrix,ConcreteP1P0Intersector>::PlanarIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf, double medianPlane,
+ double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane,
bool doRotate, int orientation, int printLevel):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel)
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,doRotate,orientation,printLevel)
{
}
typedef typename MyMeshType::MyConnType ConnType;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
protected:
- PlanarIntersectorP1P0Bary(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
+ PlanarIntersectorP1P0Bary(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
public:
void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
int getNumberOfRowsOfResMatrix() const;
PLAN_INTER_TEMPLATE
PLAN_INTERSECTOR::PlanarIntersectorP1P0Bary(const MyMeshType& meshT, const MyMeshType& meshS,
double dimCaracteristic, double precision,
- double md3DSurf, double medianPlane,
+ double md3DSurf, double minDot3DSurf, double medianPlane,
bool doRotate, int orientation, int printLevel):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,
medianPlane,doRotate,orientation,printLevel)
{
// SPEC:
typedef typename MyMeshType::MyConnType ConnType;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
- PlanarIntersectorP1P0PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation);
+ PlanarIntersectorP1P0PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation);
void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
int getNumberOfRowsOfResMatrix() const;
int getNumberOfColsOfResMatrix() const;
{
template<class MyMeshType, class MyMatrix>
PlanarIntersectorP1P0PL<MyMeshType,MyMatrix>::PlanarIntersectorP1P0PL(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double md3DSurf,
+ double dimCaracteristic, double md3DSurf, double minDot3DSurf,
double medianPlane, double precision, int orientation):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,true,orientation,0)
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,true,orientation,0)
{
}
typedef typename MyMeshType::MyConnType ConnType;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
protected:
- PlanarIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
+ PlanarIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
public:
void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
int getNumberOfRowsOfResMatrix() const;
{
template<class MyMeshType, class MyMatrix, class ConcreteP1P1Intersector>
PlanarIntersectorP1P1<MyMeshType,MyMatrix,ConcreteP1P1Intersector>::PlanarIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf, double medianPlane,
+ double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane,
bool doRotate, int orientation, int printLevel):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel)
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,doRotate,orientation,printLevel)
{
}
typedef typename MyMeshType::MyConnType ConnType;
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
- PlanarIntersectorP1P1PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation);
+ PlanarIntersectorP1P1PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation);
void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
int getNumberOfRowsOfResMatrix() const;
int getNumberOfColsOfResMatrix() const;
{
template<class MyMeshType, class MyMatrix>
PlanarIntersectorP1P1PL<MyMeshType,MyMatrix>::PlanarIntersectorP1P1PL(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double md3DSurf,
+ double dimCaracteristic, double md3DSurf, double minDot3DSurf,
double medianPlane, double precision, int orientation):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,true,orientation,0)
+ PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,true,orientation,0)
{
}
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
PointLocator2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation);
+ double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation);
double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS);
double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector<double>& sourceCoords, bool isSourceQuad);
double intersectGeometryGeneral(const std::vector<double>& targetCoords, const std::vector<double>& sourceCoords);
{
INTERSECTOR_TEMPLATE
PTLOC2D_INTERSECTOR::PointLocator2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double md3DSurf, double medianPlane,
+ double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane,
double precision, int orientation):
- InterpType<MyMeshType,MyMatrix,PTLOC2D_INTERSECTOR >(meshT,meshS,dimCaracteristic, precision, md3DSurf, medianPlane, true, orientation, 0)
+ InterpType<MyMeshType,MyMatrix,PTLOC2D_INTERSECTOR >(meshT,meshS,dimCaracteristic, precision, md3DSurf, minDot3DSurf, medianPlane, true, orientation, 0)
{
}
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
TriangulationIntersector(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf, double medianPlane, int orientation, int printLevel);
+ double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, int orientation, int printLevel);
double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS);
double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector<double>& sourceCoords, bool isSourceQuad);
double intersectGeometryGeneral(const std::vector<double>& targetCoords, const std::vector<double>& sourceCoords);
{
TRI_INTER_TEMPLATE
TRI_INTERSECTOR::TriangulationIntersector(const MyMeshType& meshT, const MyMeshType& meshS,
- double DimCaracteristic, double Precision, double md3DSurf,
+ double DimCaracteristic, double Precision, double md3DSurf, double minDot3DSurf,
double MedianPlane, int orientation, int PrintLevel)
- :InterpType<MyMeshType,MyMatrix,TRI_INTERSECTOR >(meshT,meshS,DimCaracteristic, Precision, md3DSurf,
+ :InterpType<MyMeshType,MyMatrix,TRI_INTERSECTOR >(meshT,meshS,DimCaracteristic, Precision, md3DSurf, minDot3DSurf,
MedianPlane, true, orientation, PrintLevel)
{
if(PlanarIntersector<MyMeshType,MyMatrix>::_print_level >= 1)
UnitTetra3D2DIntersectionTest.cxx
UnitTetraIntersectionBaryTest.cxx
TestInterpKernelUtils.cxx
+ ThreeDSurfProjectionTest.cxx
)
SET(TestINTERP_KERNEL_SOURCES
#include <cppunit/extensions/HelperMacros.h>
+#include "InterpKernelTestExport.hxx"
+
/**
* \brief Class tested by TestBogusClass : not very useful
*/
-class BogusClass {
+class INTERPKERNELTEST_EXPORT BogusClass {
friend class TestBogusClass;
public:
* \brief Class used to figure out CppUnit : not very useful
*
*/
-class TestBogusClass : public CppUnit::TestFixture
+class INTERPKERNELTEST_EXPORT TestBogusClass : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( TestBogusClass );
#include "MultiElement2DTests.hxx"
#include "MultiElementTetraTests.hxx"
#include "SingleElementTetraTests.hxx"
+#include "ThreeDSurfProjectionTest.hxx"
using namespace INTERP_TEST;
CPPUNIT_TEST_SUITE_REGISTRATION( MultiElement2DTests );
CPPUNIT_TEST_SUITE_REGISTRATION( MultiElementTetraTests );
CPPUNIT_TEST_SUITE_REGISTRATION( SingleElementTetraTests );
-
+CPPUNIT_TEST_SUITE_REGISTRATION( ThreeDSurfProjectionTest );
// --- generic Main program from KERNEL_SRC/src/Basics/Test
#include "BasicMainTest.hxx"
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "ThreeDSurfProjectionTest.hxx"
+#include "PlanarIntersector.txx"
+
+class MyMeshType
+{
+public:
+ static const int MY_SPACEDIM=3;
+ static const int MY_MESHDIM=3;
+ static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE;
+ typedef int MyConnType;
+};
+
+class MyMatrixType
+{
+};
+
+void INTERP_TEST::ThreeDSurfProjectionTest::test1()
+{
+ // Two triangles coo and coo2 are perfectly // each others with a distance equal to 1e-6.
+ // A little rotation to make it more funny.
+ //coo=DataArrayDouble([0.,0.,0.,1.,0.,0.,0.,1.,0.],3,3)
+ //eps=1e-6
+ //coo2=DataArrayDouble([0.,0.,eps,1.,0.,eps,0.,1.,eps],3,3)
+ //MEDCouplingPointSet.Rotate3DAlg([0.,0.,0.],[2.,1.,3.],0.3,coo)
+ //MEDCouplingPointSet.Rotate3DAlg([0.,0.,0.],[2.,1.,3.],0.3,coo2)
+ const double coo[9]={0.,0.,0.,0.96809749223257568,0.24332379388106262,-0.059839592782071335,-0.23056279077409292,0.95852673990234838,0.16753294721527912};
+ const double coo2[9]={9.8122602102980502e-08,-1.4839144255482456e-7,9.8404874611628791e-7,0.96809759035517784,0.24332364548962007,-0.059838608733325221,-0.23056269265149082,0.9585265915109058,0.16753393126402524};
+ double *tmp0(new double[9]),*tmp1(new double[9]);
+ int ret;
+ //eps=1e-2. eps is a tolerance to detect that two points are the same or not in a same polygon.
+ // here the max 3D distance is 1e-5 > 1e-6 so 1 is expected
+ std::copy(coo,coo+9,tmp0);
+ std::copy(coo2,coo2+9,tmp1);
+ ret=INTERP_KERNEL::PlanarIntersector<MyMeshType,MyMatrixType>::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,-1.,0.5,true);
+ CPPUNIT_ASSERT_EQUAL(1,ret);
+ const double expected0[9]={0.,0.,0.,1.,0.,0.,0.,1.,0.};
+ for(int i=0;i<9;i++)
+ {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected0[i],tmp0[i],1e-15);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected0[i],tmp1[i],1e-15);
+ }
+ // here the max 3D distance is 1e-8 < 1e-6 so 0 is expected
+ std::copy(coo,coo+9,tmp0);
+ std::copy(coo2,coo2+9,tmp1);
+ ret=INTERP_KERNEL::PlanarIntersector<MyMeshType,MyMatrixType>::Projection(tmp0,tmp1,3,3,1e-2,1e-8/* <- */,-1.,0.5,true);
+ CPPUNIT_ASSERT_EQUAL(0,ret);
+ // here testing when max 3D distance is 1e-5 > 1e-6 with inverted cells
+ std::copy(coo,coo+9,tmp0);
+ std::copy(coo2,coo2+3,tmp1+6); std::copy(coo2+3,coo2+6,tmp1+3); std::copy(coo2+6,coo2+9,tmp1);
+ ret=INTERP_KERNEL::PlanarIntersector<MyMeshType,MyMatrixType>::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,-1.,0.5,true);
+ CPPUNIT_ASSERT_EQUAL(-1,ret);
+ const double expected1[9]={-0.7071067811865476,-0.7071067811865476,0.,0.,-1.4142135623730951,0.,-1.4142135623730951,-1.4142135623730951,0.};
+ const double expected2[9]={-1.4142135623730951,-1.4142135623730951,0.,0.,-1.4142135623730951,0.,-0.7071067811865476,-0.7071067811865476,0.};
+ for(int i=0;i<9;i++)
+ {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],tmp0[i],1e-14);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],tmp1[i],1e-14);
+ }
+ //
+ delete [] tmp0;
+ delete [] tmp1;
+}
+
+void INTERP_TEST::ThreeDSurfProjectionTest::test2()
+{// here the two triangles have their center of inertia very close (eps) but the angle between the two planes is "big"
+ //coo=DataArrayDouble([0.,0.,0.,1.,0.,0.,0.,1.,0.],3,3)
+ //coocpy=coo.deepCpy()
+ //MEDCouplingPointSet.Rotate3DAlg([0.,0.,0.],[-1,-1.,0.],pi/3,coocpy)
+ //coocpy+=[eps*sqrt(3)/2,eps/2,eps*0.]
+ //
+ const double coo[9]={0.,0.,0.,0.96809749223257568,0.24332379388106262,-0.059839592782071335,-0.23056279077409292,0.95852673990234838,0.16753294721527912};
+ const double coo2[9]={7.2311562622637225e-07,6.8998795679738294e-07,3.1943866106249849e-08,0.72852072144314628,0.33125439126063028,0.5996079016637561,0.0090154262465889021,0.87059752249869415,-0.49191448334281612};
+ double *tmp0(new double[9]),*tmp1(new double[9]);
+ int ret;
+ //eps=1e-2. eps is a tolerance to detect that two points are the same or not in a same polygon.
+ // here the max 3D distance is 1e-5 > 1e-6 so 1 is expected
+ std::copy(coo,coo+9,tmp0);
+ std::copy(coo2,coo2+9,tmp1);
+ ret=INTERP_KERNEL::PlanarIntersector<MyMeshType,MyMatrixType>::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,-1.,0.5,true);
+ CPPUNIT_ASSERT_EQUAL(1,ret);
+ // here the max 3D distance is 1e-8 < 1e-6 so 0 is expected
+ std::copy(coo,coo+9,tmp0);
+ std::copy(coo2,coo2+9,tmp1);
+ ret=INTERP_KERNEL::PlanarIntersector<MyMeshType,MyMatrixType>::Projection(tmp0,tmp1,3,3,1e-2,1e-8/* <- */,-1.,0.5,true);
+ CPPUNIT_ASSERT_EQUAL(0,ret);
+ // again max 3D distance is 1e-5 > 1e-6 so 1 is expected
+ std::copy(coo,coo+9,tmp0);
+ std::copy(coo2,coo2+9,tmp1);
+ ret=INTERP_KERNEL::PlanarIntersector<MyMeshType,MyMatrixType>::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,-1.,0.5,true);
+ CPPUNIT_ASSERT_EQUAL(1,ret);
+ // again max 3D distance is 1e-5 > 1e-6 but minDot set to 0.8. 0 expected. because the angle is pi/4 so cos(pi/3) > 0.8
+ std::copy(coo,coo+9,tmp0);
+ std::copy(coo2,coo2+9,tmp1);
+ ret=INTERP_KERNEL::PlanarIntersector<MyMeshType,MyMatrixType>::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,0.8/* <- */,0.5,true);
+ CPPUNIT_ASSERT_EQUAL(0,ret);
+ // again max 3D distance is 1e-5 > 1e-6 but minDot set to 0.7. 1 expected. because the angle is pi/4 so cos(pi/3) < 0.49
+ std::copy(coo,coo+9,tmp0);
+ std::copy(coo2,coo2+9,tmp1);
+ ret=INTERP_KERNEL::PlanarIntersector<MyMeshType,MyMatrixType>::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,0.49/* <- */,0.5,true);
+ CPPUNIT_ASSERT_EQUAL(1,ret);
+ // again max 3D distance is 1e-5 > 1e-6 but minDot set to 0.7. 0 expected. because the angle is pi/4 so cos(pi/3) > 0.51
+ std::copy(coo,coo+9,tmp0);
+ std::copy(coo2,coo2+9,tmp1);
+ ret=INTERP_KERNEL::PlanarIntersector<MyMeshType,MyMatrixType>::Projection(tmp0,tmp1,3,3,1e-2,1e-5/* <- */,0.51/* <- */,0.5,true);
+ CPPUNIT_ASSERT_EQUAL(0,ret);
+ //
+ delete [] tmp0;
+ delete [] tmp1;
+}
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __THREEDSURFPROJECTIONTEST_HXX__
+#define __THREEDSURFPROJECTIONTEST_HXX__
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "InterpKernelTestExport.hxx"
+
+namespace INTERP_TEST
+{
+ /**
+ * \brief Class dedicated of the test of the preprocessing of 3D surf cells before performing invoking 2D algorithms.
+ */
+ class INTERPKERNELTEST_EXPORT ThreeDSurfProjectionTest : public CppUnit::TestFixture
+ {
+ CPPUNIT_TEST_SUITE( ThreeDSurfProjectionTest );
+ CPPUNIT_TEST ( test1 );
+ CPPUNIT_TEST ( test2 );
+ CPPUNIT_TEST_SUITE_END();
+ public:
+ void test1();
+ void test2();
+ };
+}
+
+#endif
* referred by \a this mesh.
* \throw If \a i is not one of [0,1,2].
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mccmesh_getCoordsAt "Here is a C++ example".<br>
* \ref py_mccmesh_getCoordsAt "Here is a Python example".
+ * \endif
*/
const DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const
{
* referred by \a this mesh.
* \throw If \a i is not one of [0,1,2].
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mccmesh_getCoordsAt "Here is a C++ example".<br>
* \ref py_mccmesh_getCoordsAt "Here is a Python example".
+ * \endif
*/
DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i)
{
* \throw If \a arr->getNumberOfComponents() != 1.
* \throw If \a i is not one of [0,1,2].
*
+ * \if ENABLE_EXAMPLES
* \ref medcouplingcppexamplesCmeshStdBuild1 "Here is a C++ example".<br>
* \ref medcouplingpyexamplesCmeshStdBuild1 "Here is a Python example".
+ * \endif
*/
void MEDCouplingCMesh::setCoordsAt(int i, const DataArrayDouble *arr)
{
* axis. It must be an array of one component or \c NULL.
* \throw If \a coords*->getNumberOfComponents() != 1.
*
+ * \if ENABLE_EXAMPLES
* \ref medcouplingcppexamplesCmeshStdBuild1 "Here is a C++ example".<br>
* \ref medcouplingpyexamplesCmeshStdBuild1 "Here is a Python example".
+ * \endif
*/
void MEDCouplingCMesh::setCoords(const DataArrayDouble *coordsX, const DataArrayDouble *coordsY, const DataArrayDouble *coordsZ)
{
MEDCOUPLING_EXPORT virtual void copyTinyStringsFrom(const MEDCouplingField *other);
MEDCOUPLING_EXPORT void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
MEDCOUPLING_EXPORT const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
+ MEDCOUPLING_EXPORT ParaMEDMEM::MEDCouplingMesh *getMesh() { return const_cast<ParaMEDMEM::MEDCouplingMesh *>(_mesh); }
MEDCOUPLING_EXPORT void setName(const std::string& name) { _name=name; }
MEDCOUPLING_EXPORT std::string getDescription() const { return _desc; }
MEDCOUPLING_EXPORT void setDescription(const std::string& desc) { _desc=desc; }
const TypeOfField MEDCouplingFieldDiscretizationKriging::TYPE=ON_NODES_KR;
// doc is here http://www.code-aster.org/V2/doc/default/fr/man_r/r3/r3.01.01.pdf
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_POINT1[1]={0.};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG2[2]={1.,1.};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG3[3]={0.5555555555555556,0.8888888888888888,0.5555555555555556};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG4[4]={0.347854845137454,0.347854845137454,0.652145154862546,0.652145154862546};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_QUAD8[8]={1.,1.,1.,1.,1.,1.,1.,1.};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_QUAD9[9]={0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_TETRA4[4]={0.041666666666666664,0.041666666666666664,0.041666666666666664,0.041666666666666664};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_TETRA10[10]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.};//to check
const double MEDCouplingFieldDiscretizationGaussNE::FGP_PENTA6[6]={0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_PENTA15[15]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.};//to check
const double MEDCouplingFieldDiscretizationGaussNE::FGP_HEXA8[8]={1.,1.,1.,1.,1.,1.,1.,1.};
-const double MEDCouplingFieldDiscretizationGaussNE::FGP_HEXA27[27]={0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.7023319615912208};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_HEXA20[20]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_HEXA27[27]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_PYRA5[5]={0.13333333333333333,0.13333333333333333,0.13333333333333333,0.13333333333333333,0.13333333333333333};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_PYRA13[13]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.};//to check
const double MEDCouplingFieldDiscretizationGaussNE::REF_SEG2[2]={-1.,1.};
const double MEDCouplingFieldDiscretizationGaussNE::REF_SEG3[3]={-1.,1.,0.};
const double MEDCouplingFieldDiscretizationGaussNE::REF_SEG4[4]={-1.,1.,-0.3333333333333333,0.3333333333333333};
const double MEDCouplingFieldDiscretizationGaussNE::REF_PENTA15[45]={-1.,1.,0.,-1.,0.,1.,-1.,0.,0.,1.,1.,0.,1.,0.,1.,1.,0.,0.,-1.,0.5,0.5,-1.,0.,0.5,-1.,0.5,0.,0.,1.,0.,0.,0.,1.,0.,0.,0.,1.,0.5,0.5,1.,0.,0.5,1.,0.5,0.};
const double MEDCouplingFieldDiscretizationGaussNE::REF_HEXA8[24]={-1.,-1.,-1.,1.,-1.,-1.,1.,1.,-1.,-1.,1.,-1.,-1.,-1.,1.,1.,-1.,1.,1.,1.,1.,-1.,1.,1.};
const double MEDCouplingFieldDiscretizationGaussNE::REF_HEXA20[60]={-1.,-1.,-1.,1.,-1.,-1.,1.,1.,-1.,-1.,1.,-1.,-1.,-1.,1.,1.,-1.,1.,1.,1.,1.,-1.,1.,1.,0.,-1.,-1.,1.,0.,-1.,0.,1.,-1.,-1.,0.,-1.,-1.,-1.,0.,1.,-1.,0.,1.,1.,0.,-1.,1.,0.,0.,-1.,1.,1.,0.,1.,0.,1.,1.,-1.,0.,1.};
-const double MEDCouplingFieldDiscretizationGaussNE::REF_HEXA27[81]={-1.,-1.,-1.,1.,-1.,-1.,1.,1.,-1.,-1.,1.,-1.,-1.,-1.,1.,1.,-1.,1.,1.,1.,1.,-1.,1.,1.,0.,-1.,-1.,1.,0.,-1.,0.,1.,-1.,-1.,0.,-1.,-1.,-1.,0.,1.,-1.,0.,1.,1.,0.,-1.,1.,0.,0.,-1.,1.,1.,0.,1.,0.,1.,1.,-1.,0.,1.,0.,0.,-1.,0.,-1.,0.,1.,0.,0.,0.,1.,0.,-1.,0.,0.,0.,0.,1.,0.,0.,0.};
+const double MEDCouplingFieldDiscretizationGaussNE::REF_HEXA27[81]={-1.,-1.,-1.,-1.,1.,-1.,1.,1.,-1.,1.,-1.,-1.,-1.,-1.,1.,-1.,1.,1.,1.,1.,1.,1.,-1.,1.,-1.,0.,-1.,0.,1.,-1.,1.,0.,-1.,0.,-1.,-1.,-1.,0.,1.,0.,1.,1.,1.,0.,1.,0.,-1.,1.,-1.,-1.,0.,-1.,1.,0.,1.,1.,0.,1.,-1.,0.,0.,0.,-1.,-1.,0.,0.,0.,1.,0.,1.,0.,0.,0.,-1.,0.,0.,0.,1.,0.,0.,0.};
const double MEDCouplingFieldDiscretizationGaussNE::REF_PYRA5[15]={1.,0.,0.,0.,1.,0.,-1.,0.,0.,0.,-1.,0.,0.,0.,1.};
-const double MEDCouplingFieldDiscretizationGaussNE::REF_PYRA13[39]={1.,0.,0.,0.,1.,0.,-1.,0.,0.,0.,-1.,0.,0.,0.,1.,0.5,0.5,0.,-0.5,0.5,0.,-0.5,-0.5,0.,0.5,-0.5,0.,0.5,0.,0.5,0.,0.5,0.5,-0.5,0.,0.5,0.,-0.5,0.5};
+const double MEDCouplingFieldDiscretizationGaussNE::REF_PYRA13[39]={1.,0.,0.,0.,-1.,0.,-1.,0.,0.,0.,1.,0.,0.,0.,1.,0.5,-0.5,0.,-0.5,-0.5,0.,-0.5,0.5,0.,0.5,0.5,0.,0.5,0.,0.5,0.,-0.5,0.5,-0.5,0.,0.5,0.,0.5,0.5};
const double MEDCouplingFieldDiscretizationGaussNE::LOC_SEG2[2]={0.577350269189626,-0.577350269189626};
const double MEDCouplingFieldDiscretizationGaussNE::LOC_SEG3[3]={-0.774596669241,0.,0.774596669241};
const double MEDCouplingFieldDiscretizationGaussNE::LOC_SEG4[4]={0.339981043584856,-0.339981043584856,0.861136311594053,-0.861136311594053};
const double MEDCouplingFieldDiscretizationGaussNE::LOC_QUAD8[16]={-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.,-0.774596669241483,0.774596669241483,0.,0.,0.774596669241483,-0.774596669241483,0.};
const double MEDCouplingFieldDiscretizationGaussNE::LOC_QUAD9[18]={-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.,-0.774596669241483,0.774596669241483,0.,0.,0.774596669241483,-0.774596669241483,0.,0.,0.};
const double MEDCouplingFieldDiscretizationGaussNE::LOC_TETRA4[12]={0.1381966011250105,0.1381966011250105,0.1381966011250105,0.1381966011250105,0.1381966011250105,0.5854101966249685,0.1381966011250105,0.5854101966249685,0.1381966011250105,0.5854101966249685,0.1381966011250105,0.1381966011250105};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_TETRA10[30]={0.,1.,0.,0.,0.,1.,0.,0.,0.,1.,0.,0.,0.,0.5,0.5,0.,0.,0.5,0.,0.5,0.,0.5,0.5,0.,0.5,0.,0.5,0.5,0.,0.};//to check
const double MEDCouplingFieldDiscretizationGaussNE::LOC_PENTA6[18]={-0.5773502691896258,0.5,0.5,-0.5773502691896258,0.,0.5,-0.5773502691896258,0.5,0.,0.5773502691896258,0.5,0.5,0.5773502691896258,0.,0.5,0.5773502691896258,0.5,0.};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_PENTA15[45]={-1.,1.,0.,-1.,0.,1.,-1.,0.,0.,1.,1.,0.,1.,0.,1.,1.,0.,0.,-1.,0.5,0.5,-1.,0.,0.5,-1.,0.5,0.,0.,1.,0.,0.,0.,1.,0.,0.,0.,1.,0.5,0.5,1.,0.,0.5,1.,0.5,0.};//to check
const double MEDCouplingFieldDiscretizationGaussNE::LOC_HEXA8[24]={-0.5773502691896258,-0.5773502691896258,-0.5773502691896258,-0.5773502691896258,-0.5773502691896258,0.5773502691896258,-0.5773502691896258,0.5773502691896258,-0.5773502691896258,-0.5773502691896258,0.5773502691896258,0.5773502691896258,0.5773502691896258,-0.5773502691896258,-0.5773502691896258,0.5773502691896258,-0.5773502691896258,0.5773502691896258,0.5773502691896258,0.5773502691896258,-0.5773502691896258,0.5773502691896258,0.5773502691896258,0.5773502691896258};
-const double MEDCouplingFieldDiscretizationGaussNE::LOC_HEXA27[81]={-0.7745966692414834,-0.7745966692414834,-0.7745966692414834,-0.7745966692414834,-0.7745966692414834,0.,-0.7745966692414834,-0.7745966692414834,0.7745966692414834,-0.7745966692414834,0.,-0.7745966692414834,-0.7745966692414834,0.,0.,-0.7745966692414834,0.,0.7745966692414834,-0.7745966692414834,0.7745966692414834,-0.7745966692414834,-0.7745966692414834,0.7745966692414834,0.,-0.7745966692414834,0.7745966692414834,0.7745966692414834,0.,-0.7745966692414834,-0.7745966692414834,0,-0.7745966692414834,0.,0.,-0.7745966692414834,0.7745966692414834,0.,0.,-0.7745966692414834,0.,0.,0.,0.,0.,0.7745966692414834,0.,0.7745966692414834,-0.7745966692414834,0.,0.7745966692414834,0.,0.,0.7745966692414834,0.7745966692414834,0.7745966692414834,-0.7745966692414834,-0.7745966692414834,0.7745966692414834,-0.7745966692414834,0.,0.7745966692414834,-0.7745966692414834,0.7745966692414834,0.7745966692414834,0,-0.7745966692414834,0.7745966692414834,0.,0.,0.7745966692414834,0.,0.7745966692414834,0.7745966692414834,0.7745966692414834,-0.7745966692414834,0.7745966692414834,0.7745966692414834,0.,0.7745966692414834,0.7745966692414834,0.7745966692414834};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_HEXA20[60]={-1.,-1.,-1.,1.,-1.,-1.,1.,1.,-1.,-1.,1.,-1.,-1.,-1.,1.,1.,-1.,1.,1.,1.,1.,-1.,1.,1.,0.,-1.,-1.,1.,0.,-1.,0.,1.,-1.,-1.,0.,-1.,-1.,-1.,0.,1.,-1.,0.,1.,1.,0.,-1.,1.,0.,0.,-1.,1.,1.,0.,1.,0.,1.,1.,-1.,0.,1.};//to check
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_HEXA27[81]={-1.,-1.,-1.,-1.,1.,-1.,1.,1.,-1.,1.,-1.,-1.,-1.,-1.,1.,-1.,1.,1.,1.,1.,1.,1.,-1.,1.,-1.,0.,-1.,0.,1.,-1.,1.,0.,-1.,0.,-1.,-1.,-1.,0.,1.,0.,1.,1.,1.,0.,1.,0.,-1.,1.,-1.,-1.,0.,-1.,1.,0.,1.,1.,0.,1.,-1.,0.,0.,0.,-1.,-1.,0.,0.,0.,1.,0.,1.,0.,0.,0.,-1.,0.,0.,0.,1.,0.,0.,0.};
const double MEDCouplingFieldDiscretizationGaussNE::LOC_PYRA5[15]={0.5,0.,0.1531754163448146,0.,0.5,0.1531754163448146,-0.5,0.,0.1531754163448146,0.,-0.5,0.1531754163448146,0.,0.,0.6372983346207416};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_PYRA13[39]={1.,0.,0.,0.,-1.,0.,-1.,0.,0.,0.,1.,0.,0.,0.,0.999999999999,0.5,-0.5,0.,-0.5,-0.5,0.,-0.5,0.5,0.,0.5,0.5,0.,0.5,0.,0.5,0.,-0.5,0.5,-0.5,0.,0.5,0.,0.5,0.5};//to check 0.99999... to avoid nan ! on node #4 of PYRA13
MEDCouplingFieldDiscretization::MEDCouplingFieldDiscretization():_precision(DFLT_PRECISION)
{
{
switch(geoType)
{
+ case INTERP_KERNEL::NORM_POINT1:
+ lgth=(int)sizeof(FGP_POINT1)/sizeof(double);
+ return FGP_POINT1;
case INTERP_KERNEL::NORM_SEG2:
lgth=(int)sizeof(FGP_SEG2)/sizeof(double);
return FGP_SEG2;
case INTERP_KERNEL::NORM_TETRA4:
lgth=(int)sizeof(FGP_TETRA4)/sizeof(double);
return FGP_TETRA4;
+ case INTERP_KERNEL::NORM_TETRA10:
+ lgth=(int)sizeof(FGP_TETRA10)/sizeof(double);
+ return FGP_TETRA10;
case INTERP_KERNEL::NORM_PENTA6:
lgth=(int)sizeof(FGP_PENTA6)/sizeof(double);
return FGP_PENTA6;
+ case INTERP_KERNEL::NORM_PENTA15:
+ lgth=(int)sizeof(FGP_PENTA15)/sizeof(double);
+ return FGP_PENTA15;
case INTERP_KERNEL::NORM_HEXA8:
lgth=(int)sizeof(FGP_HEXA8)/sizeof(double);
return FGP_HEXA8;
+ case INTERP_KERNEL::NORM_HEXA20:
+ lgth=(int)sizeof(FGP_HEXA20)/sizeof(double);
+ return FGP_HEXA20;
case INTERP_KERNEL::NORM_HEXA27:
lgth=(int)sizeof(FGP_HEXA27)/sizeof(double);
return FGP_HEXA27;
case INTERP_KERNEL::NORM_PYRA5:
lgth=(int)sizeof(FGP_PYRA5)/sizeof(double);
return FGP_PYRA5;
+ case INTERP_KERNEL::NORM_PYRA13:
+ lgth=(int)sizeof(FGP_PYRA13)/sizeof(double);
+ return FGP_PYRA13;
default:
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType : only SEG[2,3,4], TRI[3,6,7], QUAD[4,9], TETRA4, PENTA6, HEXA[8,27], PYRA5 supported !");
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType : only SEG[2,3,4], TRI[3,6,7], QUAD[4,9], TETRA[4,10], PENTA[6,15], HEXA[8,20,27], PYRA[5,13] supported !");
}
}
{
switch(geoType)
{
+ case INTERP_KERNEL::NORM_POINT1:
+ lgth=0;
+ return 0;
case INTERP_KERNEL::NORM_SEG2:
lgth=(int)sizeof(REF_SEG2)/sizeof(double);
return REF_SEG2;
{
switch(geoType)
{
+ case INTERP_KERNEL::NORM_POINT1:
+ {
+ lgth=0;
+ return 0;
+ }
case INTERP_KERNEL::NORM_SEG2:
{
lgth=(int)sizeof(LOC_SEG2)/sizeof(double);
lgth=(int)sizeof(LOC_TETRA4)/sizeof(double);
return LOC_TETRA4;
}
+ case INTERP_KERNEL::NORM_TETRA10:
+ {
+ lgth=(int)sizeof(LOC_TETRA10)/sizeof(double);
+ return LOC_TETRA10;
+ }
case INTERP_KERNEL::NORM_PENTA6:
{
lgth=(int)sizeof(LOC_PENTA6)/sizeof(double);
return LOC_PENTA6;
}
+ case INTERP_KERNEL::NORM_PENTA15:
+ {
+ lgth=(int)sizeof(LOC_PENTA15)/sizeof(double);
+ return LOC_PENTA15;
+ }
case INTERP_KERNEL::NORM_HEXA8:
{
lgth=(int)sizeof(LOC_HEXA8)/sizeof(double);
return LOC_HEXA8;
}
+ case INTERP_KERNEL::NORM_HEXA20:
+ {
+ lgth=(int)sizeof(LOC_HEXA20)/sizeof(double);
+ return LOC_HEXA20;
+ }
case INTERP_KERNEL::NORM_HEXA27:
{
lgth=(int)sizeof(LOC_HEXA27)/sizeof(double);
lgth=(int)sizeof(LOC_PYRA5)/sizeof(double);
return LOC_PYRA5;
}
+ case INTERP_KERNEL::NORM_PYRA13:
+ {
+ lgth=(int)sizeof(LOC_PYRA13)/sizeof(double);
+ return LOC_PYRA13;
+ }
default:
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType : only SEG[2,3,4], TRI[3,6,7], QUAD[4,8,9], TETRA[4,10], PENTA[6,15], HEXA[8,20,27], PYRA[5,13] supported !");
}
public:
static const char REPR[];
static const TypeOfField TYPE;
+ static const double FGP_POINT1[1];
static const double FGP_SEG2[2];
static const double FGP_SEG3[3];
static const double FGP_SEG4[4];
static const double FGP_QUAD8[8];
static const double FGP_QUAD9[9];
static const double FGP_TETRA4[4];
- //static const double FGP_TETRA10[10];
+ static const double FGP_TETRA10[10];//to check
static const double FGP_PENTA6[6];
- //static const double FGP_PENTA15[15];
+ static const double FGP_PENTA15[15];//to check
static const double FGP_HEXA8[8];
+ static const double FGP_HEXA20[20];//to check
static const double FGP_HEXA27[27];
static const double FGP_PYRA5[5];
- //static const double FGP_PYRA13[13];
+ static const double FGP_PYRA13[13];//to check
static const double REF_SEG2[2];
static const double REF_SEG3[3];
static const double REF_SEG4[4];
static const double LOC_QUAD8[16];
static const double LOC_QUAD9[18];
static const double LOC_TETRA4[12];
- //static const double LOC_TETRA10[30];
+ static const double LOC_TETRA10[30];//to check
static const double LOC_PENTA6[18];
- //static const double LOC_PENTA15[45];
+ static const double LOC_PENTA15[45];//to check
static const double LOC_HEXA8[24];
+ static const double LOC_HEXA20[60];//to check
static const double LOC_HEXA27[81];
static const double LOC_PYRA5[15];
- //static const double LOC_PYRA13[39];
+ static const double LOC_PYRA13[39];//to check
};
class MEDCouplingFieldDiscretizationKriging : public MEDCouplingFieldDiscretizationOnNodes
* \return MEDCouplingFieldDouble* - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_buildNewTimeReprFromThis "Here is a C++ example."<br>
* \ref py_mcfielddouble_buildNewTimeReprFromThis "Here is a Python example."
+ * \endif
* \sa clone()
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const
* \throw If \a check == \c true and \a old2NewBg contains equal ids.
* \throw If mesh nature does not allow renumbering (e.g. structured mesh).
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_renumberCells "Here is a C++ example".<br>
* \ref py_mcfielddouble_renumberCells "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::renumberCells(const int *old2NewBg, bool check)
{
* \throw If mesh nature does not allow renumbering (e.g. structured mesh).
* \throw If values at merged nodes deffer more than \a eps.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_renumberNodes "Here is a C++ example".<br>
* \ref py_mcfielddouble_renumberNodes "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::renumberNodes(const int *old2NewBg, double eps)
{
* \param [in] part - an array of cell ids to include to the result field.
* \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The caller is to delete this field using decrRef() as it is no more needed.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_subpart1 "Here is a C++ example".<br>
* \ref py_mcfielddouble_subpart1 "Here is a Python example".
+ * \endif
* \sa MEDCouplingFieldDouble::buildSubPartRange
*/
*
* \throw if there is presence of an invalid cell id in [ \a partBg, \a partEnd ) regarding the number of cells of \a this->getMesh().
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_subpart1 "Here a C++ example."<br>
* \ref py_mcfielddouble_subpart1 "Here a Python example."
+ * \endif
* \sa ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart(const DataArrayInt *) const, MEDCouplingFieldDouble::buildSubPartRange
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const int *partBg, const int *partEnd) const
* \throw If the mesh is not set.
* \throw If the mesh is not a structured one.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_getValueOnPos "Here is a C++ example".<br>
* \ref py_mcfielddouble_getValueOnPos "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const
{
* \throw If the mesh is not set.
* \throw If \a spaceLoc is out of the spatial discretization.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_getValueOn "Here is a C++ example".<br>
* \ref py_mcfielddouble_getValueOn "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) const
{
* \throw If the mesh is not set.
* \throw If any point in \a spaceLoc is out of the spatial discretization.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_getValueOnMulti "Here is a C++ example".<br>
* \ref py_mcfielddouble_getValueOnMulti "Here is a Python example".
+ * \endif
*/
DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const
{
* \throw If \a spaceLoc is out of the spatial discretization.
* \throw If \a time is not covered by \a this->_time_discr.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_getValueOn_time "Here is a C++ example".<br>
* \ref py_mcfielddouble_getValueOn_time "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const
{
* \throw If \a func returns \c false.
* \throw If the spatial discretization of \a this field is NULL.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_fillFromAnalytic_c_func "Here is a C++ example".
+ * \endif
*/
void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, FunctionToEvaluate func)
{
* \throw If the spatial discretization of \a this field is NULL.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_fillFromAnalytic "Here is a C++ example".<br>
* \ref py_mcfielddouble_fillFromAnalytic "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const std::string& func)
{
* \throw If the spatial discretization of \a this field is NULL.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_fillFromAnalytic2 "Here is a C++ example".<br>
* \ref py_mcfielddouble_fillFromAnalytic2 "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const std::string& func)
{
* \throw If the spatial discretization of \a this field is NULL.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_fillFromAnalytic3 "Here is a C++ example".<br>
* \ref py_mcfielddouble_fillFromAnalytic3 "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
{
* This function is to compute a field value basing on a current field value.
* \throw If \a func returns \c false.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_applyFunc_c_func "Here is a C++ example".
+ * \endif
*/
void MEDCouplingFieldDouble::applyFunc(int nbOfComp, FunctionToEvaluate func)
{
* \throw If the spatial discretization of \a this field is NULL.
* \throw If the mesh is not set.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_applyFunc_val "Here is a C++ example".<br>
* \ref py_mcfielddouble_applyFunc_val "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::applyFunc(int nbOfComp, double val)
{
* This function is to compute a field value basing on a current field value.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_applyFunc "Here is a C++ example".<br>
* \ref py_mcfielddouble_applyFunc "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func)
{
* This function is to compute a new field value basing on a current field value.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_applyFunc2 "Here is a C++ example".<br>
* \ref py_mcfielddouble_applyFunc2 "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const std::string& func)
{
* This function is to compute a new field value basing on a current field value.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_applyFunc3 "Here is a C++ example".<br>
* \ref py_mcfielddouble_applyFunc3 "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
{
* This function is to compute a field value basing on a current field value.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_applyFunc_same_nb_comp "Here is a C++ example".<br>
* \ref py_mcfielddouble_applyFunc_same_nb_comp "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::applyFunc(const std::string& func)
{
* \throw If the two meshes do not match.
* \throw If field values at merged nodes (if any) deffer more than \a eps.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_changeUnderlyingMesh "Here is a C++ example".<br>
* \ref py_mcfielddouble_changeUnderlyingMesh "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double precOnMesh, double eps)
{
renumberCellsWithoutMesh(cellCor->getConstPointer(),false);
if(nodeCor)
renumberNodesWithoutMesh(nodeCor->getConstPointer(),nodeCor->getMaxValueInArray()+1,eps);
- setMesh(const_cast<MEDCouplingMesh *>(other));
+ setMesh(other);
}
/*!
* \throw If the two fields are not coherent for merge.
* \throw If field values at merged nodes (if any) deffer more than \a eps.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_substractInPlaceDM "Here is a C++ example".<br>
* \ref py_mcfielddouble_substractInPlaceDM "Here is a Python example".
+ * \endif
* \sa changeUnderlyingMesh().
*/
void MEDCouplingFieldDouble::substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double precOnMesh, double eps)
* \throw If the spatial discretization of \a f1 is NULL.
* \throw If the time discretization of \a f1 is NULL.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_MergeFields "Here is a C++ example".<br>
* \ref py_mcfielddouble_MergeFields "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
{
* \throw If \a a is empty.
* \throw If the fields are not compatible for the merge.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_MergeFields "Here is a C++ example".<br>
* \ref py_mcfielddouble_MergeFields "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a)
{
* \throw If the fields are not strictly compatible (areStrictlyCompatible()), i.e. they
* differ not only in values.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_MaxFields "Here is a C++ example".<br>
* \ref py_mcfielddouble_MaxFields "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
{
* \throw If the fields are not strictly compatible (areStrictlyCompatible()), i.e. they
* differ not only in values.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_MaxFields "Here is a C++ example".<br>
* \ref py_mcfielddouble_MaxFields "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingFieldDouble::MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
{
* \throw If the mesh is not set.
* \throw If any of the fields has no name.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcfielddouble_WriteVTK "Here is a C++ example".<br>
* \ref py_mcfielddouble_WriteVTK "Here is a Python example".
+ * \endif
*/
void MEDCouplingFieldDouble::WriteVTK(const std::string& fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary)
{
* \throw If a component index (\a i) is not valid:
* \a i < 0 || \a i >= \a this->getNumberOfComponents().
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_KeepSelectedComponents "Here is a Python example".
+ * \endif
*/
DataArray *DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const
{
* \throw If \a this is not allocated.
* \throw If \a this and \a other arrays have different number of tuples.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarraydouble_meldwith "Here is a C++ example".
*
* \ref py_mcdataarraydouble_meldwith "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::meldWith(const DataArrayDouble *other)
{
* \throw If \a this is not allocated.
* \throw If the number of components is not in [1,2,3,4].
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarraydouble_findcommontuples "Here is a C++ example".
*
* \ref py_mcdataarraydouble_findcommontuples "Here is a Python example".
+ * \endif
* \sa DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(), DataArrayDouble::areIncludedInMe
*/
void DataArrayDouble::findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const
* \throw If \a this is not allocated.
* \throw If the number of components is not in [1,2,3,4].
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_getdifferentvalues "Here is a Python example".
+ * \endif
*/
DataArrayDouble *DataArrayDouble::getDifferentValues(double prec, int limitTupleId) const
{
* \throw If \a compoIds.size() != \a a->getNumberOfComponents().
* \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents().
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setselectedcomponents "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds)
{
* \throw If \a strictCompoCompare == \a true && \a a->getNumberOfComponents() !=
* \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvalues1 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvaluessimple1 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp)
{
* \throw In the second *mode of usage*, if \a a->getNumberOfTuples() != 1 or
* <em> a->getNumberOfComponents() != (endComp - bgComp)</em>.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvalues2 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValues2(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare)
{
* \throw If any index of tuple/component given by <em>bgTuples / bgComp</em> is
* out of a valid range for \a this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvaluessimple2 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvalues3 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarraydouble_setpartofvaluessimple3 "Here is a Python example".
+ * \endif
*/
void DataArrayDouble::setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp)
{
*
* \sa DataArrayDouble::getIdsNotInRange
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarraydouble_getidsinrange "Here is a C++ example".<br>
* \ref py_mcdataarraydouble_getidsinrange "Here is a Python example".
+ * \endif
*/
DataArrayInt *DataArrayDouble::getIdsInRange(double vmin, double vmax) const
{
* The caller is to delete this result array using decrRef() as it is no more
* needed.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarrayint_invertarrayo2n2n2o "Here is a C++ example".<br>
* \ref py_mcdataarrayint_invertarrayo2n2n2o "Here is a Python example".
+ * \endif
*/
DataArrayInt *DataArrayInt::invertArrayO2N2N2O(int newNbOfElem) const
{
* The caller is to delete this result array using decrRef() as it is no more
* needed.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarrayint_invertarrayn2o2o2n "Here is a C++ example".
*
* \ref py_mcdataarrayint_invertarrayn2o2o2n "Here is a Python example".
+ * \endif
*/
DataArrayInt *DataArrayInt::invertArrayN2O2O2N(int oldNbOfElem) const
{
* \throw If \a this->getNumberOfTuples() != \a other->getNumberOfTuples().
* \throw If \a other includes a value which is not in \a this array.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarrayint_buildpermutationarr "Here is a C++ example".
*
* \ref py_mcdataarrayint_buildpermutationarr "Here is a Python example".
+ * \endif
*/
DataArrayInt *DataArrayInt::buildPermutationArr(const DataArrayInt& other) const
{
* \throw If a component index (\a i) is not valid:
* \a i < 0 || \a i >= \a this->getNumberOfComponents().
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_keepselectedcomponents "Here is a Python example".
+ * \endif
*/
DataArray *DataArrayInt::keepSelectedComponents(const std::vector<int>& compoIds) const
{
* \throw If \a this is not allocated.
* \throw If \a this and \a other arrays have different number of tuples.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarrayint_meldwith "Here is a C++ example".
*
* \ref py_mcdataarrayint_meldwith "Here is a Python example".
+ * \endif
*/
void DataArrayInt::meldWith(const DataArrayInt *other)
{
* \throw If \a compoIds.size() != \a a->getNumberOfComponents().
* \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents().
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setselectedcomponents "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds)
{
* \throw If \a strictCompoCompare == \a true && \a a->getNumberOfComponents() !=
* \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvalues1 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvaluessimple1 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp)
{
* \throw In the second *mode of usage*, if \a a->getNumberOfTuples() != 1 or
* <em> a->getNumberOfComponents() != (endComp - bgComp)</em>.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvalues2 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValues2(const DataArrayInt *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare)
{
* \throw If any index of tuple/component given by <em>bgTuples / bgComp</em> is
* out of a valid range for \a this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvaluessimple2 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvalues3 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvaluessimple3 "Here is a Python example".
+ * \endif
*/
void DataArrayInt::setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp)
{
else
r=s1;
}
- DataArrayInt *ret=DataArrayInt::New();
+ DataArrayInt *ret(DataArrayInt::New());
ret->alloc((int)r.size(),1);
std::copy(r.begin(),r.end(),ret->getPointer());
return ret;
}
+/*!
+ * This method allows to put a vector of vector of integer into a more compact data stucture (skyline).
+ * This method is not available into python because no available optimized data structure available to map std::vector< std::vector<int> >.
+ *
+ * \param [in] v the input data structure to be translate into skyline format.
+ * \param [out] data the first element of the skyline format. The user is expected to deal with newly allocated array.
+ * \param [out] dataIndex the second element of the skyline format.
+ */
+void DataArrayInt::PutIntoToSkylineFrmt(const std::vector< std::vector<int> >& v, DataArrayInt *& data, DataArrayInt *& dataIndex)
+{
+ int sz((int)v.size());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret0(DataArrayInt::New()),ret1(DataArrayInt::New());
+ ret1->alloc(sz+1,1);
+ int *pt(ret1->getPointer()); *pt=0;
+ for(int i=0;i<sz;i++,pt++)
+ pt[1]=pt[0]+(int)v[i].size();
+ ret0->alloc(ret1->back(),1);
+ pt=ret0->getPointer();
+ for(int i=0;i<sz;i++)
+ pt=std::copy(v[i].begin(),v[i].end(),pt);
+ data=ret0.retn(); dataIndex=ret1.retn();
+}
+
/*!
* Returns a new DataArrayInt which contains a complement of elements of \a this
* one-dimensional array. I.e. the result array contains all elements from the range [0,
MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& arr);
MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& arr);
+ MEDCOUPLING_EXPORT static void PutIntoToSkylineFrmt(const std::vector< std::vector<int> >& v, DataArrayInt *& data, DataArrayInt *& dataIndex);
MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const;
MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const;
MEDCOUPLING_EXPORT DataArrayInt *buildSubstractionOptimized(const DataArrayInt *other) const;
* \throw If a component index (\a i) is not valid:
* \a i < 0 || \a i >= \a this->getNumberOfComponents().
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_keepselectedcomponents "Here is a Python example".
+ * \endif
*/
DataArray *DataArrayChar::keepSelectedComponents(const std::vector<int>& compoIds) const
{
* \throw If \a this is not allocated.
* \throw If \a this and \a other arrays have different number of tuples.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcdataarrayint_meldwith "Here is a C++ example".
*
* \ref py_mcdataarrayint_meldwith "Here is a Python example".
+ * \endif
*/
void DataArrayChar::meldWith(const DataArrayChar *other)
{
* \throw If \a strictCompoCompare == \a true && \a a->getNumberOfComponents() !=
* \c len(\c range(\a bgComp,\a endComp,\a stepComp)).
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvalues1 "Here is a Python example".
+ * \endif
*/
void DataArrayChar::setPartOfValues1(const DataArrayChar *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvaluessimple1 "Here is a Python example".
+ * \endif
*/
void DataArrayChar::setPartOfValuesSimple1(char a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp)
{
* \throw In the second *mode of usage*, if \a a->getNumberOfTuples() != 1 or
* <em> a->getNumberOfComponents() != (endComp - bgComp)</em>.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvalues2 "Here is a Python example".
+ * \endif
*/
void DataArrayChar::setPartOfValues2(const DataArrayChar *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare)
{
* \throw If any index of tuple/component given by <em>bgTuples / bgComp</em> is
* out of a valid range for \a this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvaluessimple2 "Here is a Python example".
+ * \endif
*/
void DataArrayChar::setPartOfValuesSimple2(char a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvalues3 "Here is a Python example".
+ * \endif
*/
void DataArrayChar::setPartOfValues3(const DataArrayChar *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare)
{
* non-empty range of increasing indices or indices are out of a valid range
* for \this array.
*
+ * \if ENABLE_EXAMPLES
* \ref py_mcdataarrayint_setpartofvaluessimple3 "Here is a Python example".
+ * \endif
*/
void DataArrayChar::setPartOfValuesSimple3(char a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp)
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcmesh_fillFromAnalytic "Here is a C++ example".<br>
* \ref py_mcmesh_fillFromAnalytic "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, const std::string& func) const
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcmesh_fillFromAnalytic2 "Here is a C++ example".<br>
* \ref py_mcmesh_fillFromAnalytic2 "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic2(TypeOfField t, int nbOfComp, const std::string& func) const
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If computing \a func fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcmesh_fillFromAnalytic3 "Here is a C++ example".<br>
* \ref py_mcmesh_fillFromAnalytic3 "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) const
{
* \param [in,out] elts - vector returning ids of the found cells. It is cleared
* before inserting ids.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getCellsContainingPoint "Here is a C++ example".<br>
* \ref py_mcumesh_getCellsContainingPoint "Here is a Python example".
+ * \endif
*/
void MEDCouplingMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
{
* Number of cells in contact with the *i*-th point is
* \a eltsIndex[ *i*+1 ] - \a eltsIndex[ *i* ].
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getCellsContainingPoints "Here is a C++ example".<br>
* \ref py_mcumesh_getCellsContainingPoints "Here is a Python example".
+ * \endif
*/
void MEDCouplingMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& elts, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& eltsIndex) const
{
* \throw If the coordinates array is not set.
* \throw If \a nodeId is not a valid index for the coordinates array.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcpointset_getcoordinatesofnode "Here is a C++ example".<br>
* \ref py_mcpointset_getcoordinatesofnode "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const
{
* is to delete this array using decrRef() as it is no more needed.
* \throw If the coordinates array is not set.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcpointset_findcommonnodes "Here is a C++ example".<br>
* \ref py_mcpointset_findcommonnodes "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::findCommonNodes(double prec, int limitNodeId, DataArrayInt *&comm, DataArrayInt *&commIndex) const
{
* array using decrRef() as it is no more needed.
* \throw If the coordinates array is not set.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcpointset_getnodeidsnearpoint "Here is a C++ example".<br>
* \ref py_mcpointset_getnodeidsnearpoint "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double eps) const
{
* The caller is to delete this array using decrRef() as it is no more needed.
* \throw If the coordinates array is not set.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcpointset_getnodeidsnearpoints "Here is a C++ example".<br>
* \ref py_mcpointset_getnodeidsnearpoints "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, int nbOfPoints, double eps, DataArrayInt *& c, DataArrayInt *& cI) const
{
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_renumberNodes "Here is a C++ example".<br>
* \ref py_mcumesh_renumberNodes "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNodes)
{
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_renumberNodes "Here is a C++ example".<br>
* \ref py_mcumesh_renumberNodes "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes)
{
* pre-allocated by the caller.
* \throw If the coordinates array is not set.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcpointset_getBoundingBox "Here is a C++ example".<br>
* \ref py_mcpointset_getBoundingBox "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::getBoundingBox(double *bbox) const
{
* \throw If \a vector == NULL && \a this->getSpaceDimension() == 3.
* \throw If Magnitude of \a vector is zero.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcpointset_rotate "Here is a C++ example".<br>
* \ref py_mcpointset_rotate "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::rotate(const double *center, const double *vector, double angle)
{
* \throw If the coordinates array is not set.
* \throw If \a vector == NULL.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcpointset_translate "Here is a C++ example".<br>
* \ref py_mcpointset_translate "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::translate(const double *vector)
{
* \throw If the coordinates array is not set.
* \throw If \a point == NULL.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcpointset_scale "Here is a C++ example".<br>
* \ref py_mcpointset_scale "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::scale(const double *point, double factor)
{
{
std::vector<double> cpy(res);
int nbNodes=(int)std::distance(startConn,endConn);
- INTERP_KERNEL::PlanarIntersector<DummyClsMCPS,int>::projection(&res[0],&cpy[0],nbNodes,nbNodes,1.e-12,0.,0.,true);
+ INTERP_KERNEL::PlanarIntersector<DummyClsMCPS,int>::Projection(&res[0],&cpy[0],nbNodes,nbNodes,1.e-12,0./*max distance*/,-1./*min dot*/,0.,true);
res.resize(2*nbNodes);
for(int i=0;i<nbNodes;i++)
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If any node id in \a begin is not valid.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_buildPartOfMySelfNode "Here is a C++ example".<br>
* \ref py_mcumesh_buildPartOfMySelfNode "Here is a Python example".
+ * \endif
*/
MEDCouplingPointSet *MEDCouplingPointSet::buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If the nodal connectivity includes an invalid id.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_zipConnectivityTraducer "Here is a C++ example".<br>
* \ref py_mcumesh_zipConnectivityTraducer "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingPointSet::zipConnectivityTraducer(int compType, int startCellId)
{
* to delete this array using decrRef() as it is no more needed.
* \throw If the two meshes do not match.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_checkDeepEquivalWith "Here is a C++ example".<br>
* \ref py_mcumesh_checkDeepEquivalWith "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception)
* to delete this array using decrRef() as it is no more needed.
* \throw If the two meshes do not match.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_checkDeepEquivalWith "Here is a C++ example".<br>
* \ref py_mcumesh_checkDeepEquivalWith "Here is a Python example".
+ * \endif
*/
void MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception)
*
* \sa MEDCouplingPointSet::getCellIdsFullyIncludedInNodeIds
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getCellIdsLyingOnNodes "Here is a C++ example".<br>
* \ref py_mcumesh_getCellIdsLyingOnNodes "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingPointSet::getCellIdsLyingOnNodes(const int *begin, const int *end, bool fullyIn) const
{
*
* \sa MEDCouplingPointSet::getCellIdsLyingOnNodes
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getCellIdsFullyIncludedInNodeIds "Here is a C++ example".<br>
* \ref py_mcumesh_getCellIdsFullyIncludedInNodeIds "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingPointSet::getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If the nodal connectivity includes an invalid id.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_zipCoordsTraducer "Here is a C++ example".<br>
* \ref py_mcumesh_zipCoordsTraducer "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingPointSet::zipCoordsTraducer()
{
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_mergeNodes "Here is a C++ example".<br>
* \ref py_mcumesh_mergeNodes "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingPointSet::mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes)
{
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_mergeNodes "Here is a C++ example".<br>
* \ref py_mcumesh_mergeNodes "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingPointSet::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes)
{
const MEDCouplingPointSet *src_mesh=static_cast<const MEDCouplingPointSet *>(_src_ft->getMesh());
const MEDCouplingPointSet *target_mesh=static_cast<const MEDCouplingPointSet *>(_target_ft->getMesh());
std::string srcMeth,trgMeth;
- std::string method=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth);
+ std::string method(checkAndGiveInterpolationMethodStr(srcMeth,trgMeth));
const int srcMeshDim=src_mesh->getMeshDimension();
int srcSpaceDim=-1;
if(srcMeshDim!=-1)
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
}
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D1D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
}
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D2D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
+ std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
throw INTERP_KERNEL::Exception("MEDCouplingRemapper::checkAndGiveInterpolationMethodStr : it appears that no all field templates have their mesh set !");
srcMeth=_src_ft->getDiscretization()->getRepr();
trgMeth=_target_ft->getDiscretization()->getRepr();
- std::string method(srcMeth); method+=trgMeth;
+ return BuildMethodFrom(srcMeth,trgMeth);
+}
+
+std::string MEDCouplingRemapper::BuildMethodFrom(const std::string& meth1, const std::string& meth2)
+{
+ std::string method(meth1); method+=meth2;
return method;
}
MEDCOUPLINGREMAPPER_EXPORT const std::vector<std::map<int,double> >& getCrudeMatrix() const;
MEDCOUPLINGREMAPPER_EXPORT int getNumberOfColsOfMatrix() const;
MEDCOUPLINGREMAPPER_EXPORT static void PrintMatrix(const std::vector<std::map<int,double> >& m);
+ MEDCOUPLINGREMAPPER_EXPORT static std::string BuildMethodFrom(const std::string& meth1, const std::string& meth2);
private:
int prepareInterpKernelOnly();
int prepareInterpKernelOnlyUU();
*
* \param [in] nbOfCells - estimation of the number of cell \a this mesh will contain.
*
+ * \if ENABLE_EXAMPLES
* \ref medcouplingcppexamplesUmeshStdBuild1 "Here is a C++ example".<br>
* \ref medcouplingpyexamplesUmeshStdBuild1 "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::allocateCells(int nbOfCells)
{
* \param [in] size - number of nodes constituting this cell.
* \param [in] nodalConnOfCell - the connectivity of the cell to add.
*
+ * \if ENABLE_EXAMPLES
* \ref medcouplingcppexamplesUmeshStdBuild1 "Here is a C++ example".<br>
* \ref medcouplingpyexamplesUmeshStdBuild1 "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell)
{
* Compacts data arrays to release unused memory. This method is to be called after
* finishing cell insertion using \a this->insertNextCell().
*
+ * \if ENABLE_EXAMPLES
* \ref medcouplingcppexamplesUmeshStdBuild1 "Here is a C++ example".<br>
* \ref medcouplingpyexamplesUmeshStdBuild1 "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::finishInsertingCells()
{
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getReverseNodalConnectivity "Here is a C++ example".<br>
* \ref py_mcumesh_getReverseNodalConnectivity "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const
{
* \throw If \a desc == NULL || \a descIndx == NULL || \a revDesc == NULL || \a
* revDescIndx == NULL.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_buildDescendingConnectivity "Here is a C++ example".<br>
* \ref py_mcumesh_buildDescendingConnectivity "Here is a Python example".
+ * \endif
* \sa buildDescendingConnectivity2()
*/
MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
* \throw If \a desc == NULL || \a descIndx == NULL || \a revDesc == NULL || \a
* revDescIndx == NULL.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_buildDescendingConnectivity2 "Here is a C++ example".<br>
* \ref py_mcumesh_buildDescendingConnectivity2 "Here is a Python example".
+ * \endif
* \sa buildDescendingConnectivity()
*/
MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity2(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
* \throw If the nodal connectivity of cells is node defined.
* \throw If dimension of \a this mesh is not either 2 or 3.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_convertToPolyTypes "Here is a C++ example".<br>
* \ref py_mcumesh_convertToPolyTypes "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::convertToPolyTypes(const int *cellIdsToConvertBg, const int *cellIdsToConvertEnd)
{
int dim=getMeshDimension();
if(dim<2 || dim>3)
throw INTERP_KERNEL::Exception("Invalid mesh dimension : must be 2 or 3 !");
- int nbOfCells=getNumberOfCells();
+ int nbOfCells(getNumberOfCells());
if(dim==2)
{
const int *connIndex=_nodal_connec_index->getConstPointer();
}
else
{
- int *connIndex=_nodal_connec_index->getPointer();
- int connIndexLgth=_nodal_connec_index->getNbOfElems();
- const int *connOld=_nodal_connec->getConstPointer();
- int connOldLgth=_nodal_connec->getNbOfElems();
- std::vector<int> connNew(connOld,connOld+connOldLgth);
+ int *connIndex(_nodal_connec_index->getPointer());
+ const int *connOld(_nodal_connec->getConstPointer());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> connNew(DataArrayInt::New()),connNewI(DataArrayInt::New()); connNew->alloc(0,1); connNewI->alloc(1,1); connNewI->setIJ(0,0,0);
+ std::vector<bool> toBeDone(nbOfCells,false);
for(const int *iter=cellIdsToConvertBg;iter!=cellIdsToConvertEnd;iter++)
{
if(*iter>=0 && *iter<nbOfCells)
+ toBeDone[*iter]=true;
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::convertToPolyTypes : On rank #" << std::distance(cellIdsToConvertBg,iter) << " value is " << *iter << " which is not";
+ oss << " in range [0," << nbOfCells << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ for(int cellId=0;cellId<nbOfCells;cellId++)
+ {
+ int pos(connIndex[cellId]),posP1(connIndex[cellId+1]);
+ int lgthOld(posP1-pos-1);
+ if(toBeDone[cellId])
{
- int pos=connIndex[*iter];
- int posP1=connIndex[(*iter)+1];
- int lgthOld=posP1-pos-1;
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)connNew[pos]);
- connNew[pos]=INTERP_KERNEL::NORM_POLYHED;
- unsigned nbOfFaces=cm.getNumberOfSons2(&connNew[pos+1],lgthOld);
- int *tmp=new int[nbOfFaces*lgthOld];
- int *work=tmp;
- for(int j=0;j<(int)nbOfFaces;j++)
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)connOld[pos]);
+ unsigned nbOfFaces(cm.getNumberOfSons2(connOld+pos+1,lgthOld));
+ int *tmp(new int[nbOfFaces*lgthOld+1]);
+ int *work=tmp; *work++=INTERP_KERNEL::NORM_POLYHED;
+ for(unsigned j=0;j<nbOfFaces;j++)
{
INTERP_KERNEL::NormalizedCellType type;
- unsigned offset=cm.fillSonCellNodalConnectivity2(j,&connNew[pos+1],lgthOld,work,type);
+ unsigned offset=cm.fillSonCellNodalConnectivity2(j,connOld+pos+1,lgthOld,work,type);
work+=offset;
*work++=-1;
}
- std::size_t newLgth=std::distance(tmp,work)-1;
- std::size_t delta=newLgth-lgthOld;
- std::transform(connIndex+(*iter)+1,connIndex+connIndexLgth,connIndex+(*iter)+1,std::bind2nd(std::plus<int>(),delta));
- connNew.insert(connNew.begin()+posP1,tmp+lgthOld,tmp+newLgth);
- std::copy(tmp,tmp+lgthOld,connNew.begin()+pos+1);
+ std::size_t newLgth(std::distance(tmp,work)-1);//-1 for last -1
+ connNew->pushBackValsSilent(tmp,tmp+newLgth);
+ connNewI->pushBackSilent(connNewI->back()+(int)newLgth);
delete [] tmp;
}
else
{
- std::ostringstream oss; oss << "MEDCouplingUMesh::convertToPolyTypes : On rank #" << std::distance(cellIdsToConvertBg,iter) << " value is " << *iter << " which is not";
- oss << " in range [0," << nbOfCells << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ connNew->pushBackValsSilent(connOld+pos,connOld+posP1);
+ connNewI->pushBackSilent(connNewI->back()+posP1-pos);
}
}
- _nodal_connec->alloc((int)connNew.size(),1);
- int *newConnPtr=_nodal_connec->getPointer();
- std::copy(connNew.begin(),connNew.end(),newConnPtr);
+ setConnectivity(connNew,connNewI,false);//false because computeTypes called just behind.
}
computeTypes();
}
* \throw If \a this mesh contains polyhedrons with the valid connectivity.
* \throw If \a this mesh contains polyhedrons with odd number of nodes.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a C++ example".<br>
* \ref py_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::convertExtrudedPolyhedra()
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If the nodal connectivity includes an invalid id.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getNodeIdsInUse "Here is a C++ example".<br>
* \ref py_mcumesh_getNodeIdsInUse "Here is a Python example".
+ * \endif
* \sa computeNodeIdsAlg()
*/
DataArrayInt *MEDCouplingUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const
* \throw If the nodal connectivity of cells is not defined.
* \throw If the nodal connectivity includes an invalid id.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_zipCoordsTraducer "Here is a C++ example".<br>
* \ref py_mcumesh_zipCoordsTraducer "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer()
{
* \return bool - \c true if all cells of \a other mesh are present in the \a this
* mesh.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_areCellsIncludedIn "Here is a C++ example".<br>
* \ref py_mcumesh_areCellsIncludedIn "Here is a Python example".
+ * \endif
* \sa checkDeepEquivalOnSameNodesWith()
* \sa checkGeoEquivalWith()
*/
* \throw If the nodal connectivity of cells is not defined.
* \throw If any cell id in the array \a begin is not valid.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_buildPartOfMySelf "Here is a C++ example".<br>
* \ref py_mcumesh_buildPartOfMySelf "Here is a Python example".
+ * \endif
*/
MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If any node id in \a begin is not valid.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_buildFacePartOfMySelfNode "Here is a C++ example".<br>
* \ref py_mcumesh_buildFacePartOfMySelfNode "Here is a Python example".
+ * \endif
*/
MEDCouplingPointSet *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const
{
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_buildBoundaryMesh "Here is a C++ example".<br>
* \ref py_mcumesh_buildBoundaryMesh "Here is a Python example".
+ * \endif
*/
MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const
{
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is node defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_findBoundaryNodes "Here is a C++ example".<br>
* \ref py_mcumesh_findBoundaryNodes "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingUMesh::findBoundaryNodes() const
{
* See \ref MEDCouplingArrayRenumbering for more info on renumbering modes.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_renumberNodesInConn "Here is a C++ example".<br>
* \ref py_mcumesh_renumberNodesInConn "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::renumberNodesInConn(const int *newNodeNumbersO2N)
{
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getCellsInBoundingBox "Here is a C++ example".<br>
* \ref py_mcumesh_getCellsInBoundingBox "Here is a Python example".
+ * \endif
*/
DataArrayInt *MEDCouplingUMesh::getCellsInBoundingBox(const double *bbox, double eps) const
{
* \return DataArrayDouble * - a new instance of DataArrayDouble. The caller is to
* delete this array using decrRef() as it is no more needed.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getPartMeasureField "Here is a C++ example".<br>
* \ref py_mcumesh_getPartMeasureField "Here is a Python example".
+ * \endif
* \sa getMeasureField()
*/
DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const int *begin, const int *end) const
* \throw If the mesh and space dimension is not as specified above.
* \sa buildOrthogonalField()
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_buildPartOrthogonalField "Here is a C++ example".<br>
* \ref py_mcumesh_buildPartOrthogonalField "Here is a Python example".
+ * \endif
*/
MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *begin, const int *end) const
{
* \throw If the coordinates array is not set.
* \throw If \a this->getMeshDimension() != \a this->getSpaceDimension().
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getCellsContainingPoint "Here is a C++ example".<br>
* \ref py_mcumesh_getCellsContainingPoint "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
{
INTERP_KERNEL::NormalizedCellType getTypeOfElement(int) const { return (INTERP_KERNEL::NormalizedCellType)0; }
// end
};
+
+ /*!
+ * Warning the nodes in \a m should be decrRefed ! To avoid that Node * pointer be replaced by another instance.
+ */
+ INTERP_KERNEL::Edge *MEDCouplingUMeshBuildQPFromEdge2(INTERP_KERNEL::NormalizedCellType typ, const int *bg, const double *coords2D, std::map<INTERP_KERNEL::Node *,int>& m)
+ {
+ INTERP_KERNEL::Edge *ret=0;
+ INTERP_KERNEL::Node *n0(new INTERP_KERNEL::Node(coords2D[2*bg[0]],coords2D[2*bg[0]+1])),*n1(new INTERP_KERNEL::Node(coords2D[2*bg[1]],coords2D[2*bg[1]+1]));
+ m[n0]=bg[0]; m[n1]=bg[1];
+ switch(typ)
+ {
+ case INTERP_KERNEL::NORM_SEG2:
+ {
+ ret=new INTERP_KERNEL::EdgeLin(n0,n1);
+ break;
+ }
+ case INTERP_KERNEL::NORM_SEG3:
+ {
+ INTERP_KERNEL::Node *n2(new INTERP_KERNEL::Node(coords2D[2*bg[2]],coords2D[2*bg[2]+1])); m[n2]=bg[2];
+ INTERP_KERNEL::EdgeLin *e1(new INTERP_KERNEL::EdgeLin(n0,n2)),*e2(new INTERP_KERNEL::EdgeLin(n2,n1));
+ INTERP_KERNEL::SegSegIntersector inters(*e1,*e2);
+ // is the SEG3 degenerated, and thus can be reduced to a SEG2?
+ bool colinearity(inters.areColinears());
+ delete e1; delete e2;
+ if(colinearity)
+ { ret=new INTERP_KERNEL::EdgeLin(n0,n1); }
+ else
+ { ret=new INTERP_KERNEL::EdgeArcCircle(n0,n2,n1); }
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMeshBuildQPFromEdge2 : Expecting a mesh with spaceDim==2 and meshDim==1 !");
+ }
+ return ret;
+ }
INTERP_KERNEL::Edge *MEDCouplingUMeshBuildQPFromEdge(INTERP_KERNEL::NormalizedCellType typ, std::map<int, std::pair<INTERP_KERNEL::Node *,bool> >& mapp2, const int *bg)
{
* \throw If the coordinates array is not set.
* \throw If \a this->getMeshDimension() != \a this->getSpaceDimension().
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getCellsContainingPoints "Here is a C++ example".<br>
* \ref py_mcumesh_getCellsContainingPoints "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps,
MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& elts, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& eltsIndex) const
* \throw If \a this->getMeshDimension() != 2.
* \throw If \a this->getSpaceDimension() != 3.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_are2DCellsNotCorrectlyOriented "Here is a C++ example".<br>
* \ref py_mcumesh_are2DCellsNotCorrectlyOriented "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::are2DCellsNotCorrectlyOriented(const double *vec, bool polyOnly, std::vector<int>& cells) const
{
* \throw If \a this->getMeshDimension() != 2.
* \throw If \a this->getSpaceDimension() != 3.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_are2DCellsNotCorrectlyOriented "Here is a C++ example".<br>
* \ref py_mcumesh_are2DCellsNotCorrectlyOriented "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::orientCorrectly2DCells(const double *vec, bool polyOnly)
{
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a C++ example".<br>
* \ref py_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a Python example".
+ * \endif
*/
void MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented(std::vector<int>& cells) const
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If the reparation fails.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a C++ example".<br>
* \ref py_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a Python example".
+ * \endif
* \sa MEDCouplingUMesh::findAndCorrectBadOriented3DCells
*/
void MEDCouplingUMesh::orientCorrectlyPolyhedrons()
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_findAndCorrectBadOriented3DExtrudedCells "Here is a C++ example".<br>
* \ref py_mcumesh_findAndCorrectBadOriented3DExtrudedCells "Here is a Python example".
+ * \endif
* \sa MEDCouplingUMesh::findAndCorrectBadOriented3DCells
*/
DataArrayInt *MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells()
DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree(double arcDetEps) const
{
int mDim(getMeshDimension()),sDim(getSpaceDimension());
- if(mDim!=2 || sDim!=2)
+ if((mDim==3 && sDim==3) || (mDim==2 && sDim==3) || (mDim==1 && sDim==1) || ( mDim==1 && sDim==3)) // Compute refined boundary box for quadratic elements only in 2D.
return getBoundingBoxForBBTreeFast();
- else
+ if((mDim==2 && sDim==2) || (mDim==1 && sDim==2))
{
bool presenceOfQuadratic(false);
for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=_types.begin();it!=_types.end();it++)
if(cm.isQuadratic())
presenceOfQuadratic=true;
}
- if(presenceOfQuadratic)
+ if(!presenceOfQuadratic)
+ return getBoundingBoxForBBTreeFast();
+ if(mDim==2 && sDim==2)
return getBoundingBoxForBBTree2DQuadratic(arcDetEps);
else
- return getBoundingBoxForBBTreeFast();
+ return getBoundingBoxForBBTree1DQuadratic(arcDetEps);
}
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getBoundingBoxForBBTree : Managed dimensions are (mDim=1,sDim=1), (mDim=1,sDim=2), (mDim=1,sDim=3), (mDim=2,sDim=2), (mDim=2,sDim=3) and (mDim=3,sDim=3) !");
}
/*!
}
/*!
- * This method aggregate the bbox regarding foreach 2D cell in \a this the whole shape. So this method is particulary useful for 2D meshes having quadratic cells
- * because for this type of cells getBoundingBoxForBBTreeFast method may return invalid bounding boxes.
+ * This method aggregates the bbox of each 2D cell in \a this considering the whole shape. This method is particularly
+ * useful for 2D meshes having quadratic cells
+ * because for this type of cells getBoundingBoxForBBTreeFast method may return invalid bounding boxes (since it just considers
+ * the two extremities of the arc of circle).
*
* \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12)
* \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components.
* \throw If \a this is not fully defined.
* \throw If \a this is not a mesh with meshDimension equal to 2.
* \throw If \a this is not a mesh with spaceDimension equal to 2.
+ * \sa MEDCouplingUMesh::getBoundingBoxForBBTree1DQuadratic
*/
DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic(double arcDetEps) const
{
checkFullyDefined();
- int spaceDim(getSpaceDimension()),mDim(getMeshDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes());
- if(mDim!=2 || spaceDim!=2)
+ int spaceDim(getSpaceDimension()),mDim(getMeshDimension()),nbOfCells(getNumberOfCells());
+ if(spaceDim!=2 || mDim!=2)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic : This method should be applied on mesh with mesh dimension equal to 2 and space dimension also equal to 2!");
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
double *bbox(ret->getPointer());
{
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*connI]));
int sz(connI[1]-connI[0]-1);
- INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=1e-12;
+ INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=arcDetEps;
std::vector<INTERP_KERNEL::Node *> nodes(sz);
INTERP_KERNEL::QuadraticPolygon *pol(0);
for(int j=0;j<sz;j++)
return ret.retn();
}
+/*!
+ * This method aggregates the bbox of each 1D cell in \a this considering the whole shape. This method is particularly
+ * useful for 2D meshes having quadratic cells
+ * because for this type of cells getBoundingBoxForBBTreeFast method may return invalid bounding boxes (since it just considers
+ * the two extremities of the arc of circle).
+ *
+ * \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12)
+ * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components.
+ * \throw If \a this is not fully defined.
+ * \throw If \a this is not a mesh with meshDimension equal to 1.
+ * \throw If \a this is not a mesh with spaceDimension equal to 2.
+ * \sa MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic
+ */
+DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree1DQuadratic(double arcDetEps) const
+{
+ checkFullyDefined();
+ int spaceDim(getSpaceDimension()),mDim(getMeshDimension()),nbOfCells(getNumberOfCells());
+ if(spaceDim!=2 || mDim!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getBoundingBoxForBBTree1DQuadratic : This method should be applied on mesh with mesh dimension equal to 1 and space dimension also equal to 2!");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
+ double *bbox(ret->getPointer());
+ const double *coords(_coords->getConstPointer());
+ const int *conn(_nodal_connec->getConstPointer()),*connI(_nodal_connec_index->getConstPointer());
+ for(int i=0;i<nbOfCells;i++,bbox+=4,connI++)
+ {
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*connI]));
+ int sz(connI[1]-connI[0]-1);
+ INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=arcDetEps;
+ std::vector<INTERP_KERNEL::Node *> nodes(sz);
+ INTERP_KERNEL::Edge *edge(0);
+ for(int j=0;j<sz;j++)
+ {
+ int nodeId(conn[*connI+1+j]);
+ nodes[j]=new INTERP_KERNEL::Node(coords[nodeId*2],coords[nodeId*2+1]);
+ }
+ if(!cm.isQuadratic())
+ edge=INTERP_KERNEL::QuadraticPolygon::BuildLinearEdge(nodes);
+ else
+ edge=INTERP_KERNEL::QuadraticPolygon::BuildArcCircleEdge(nodes);
+ const INTERP_KERNEL::Bounds& b(edge->getBounds());
+ bbox[0]=b.getXMin(); bbox[1]=b.getXMax(); bbox[2]=b.getYMin(); bbox[3]=b.getYMax(); edge->decrRef();
+ }
+ return ret.retn();
+}
+
/// @cond INTERNAL
namespace ParaMEDMEMImpl
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*
+ * \if ENABLE_EXAMPLES
* \ref cpp_mcumesh_getPartBarycenterAndOwner "Here is a C++ example".<br>
* \ref py_mcumesh_getPartBarycenterAndOwner "Here is a Python example".
+ * \endif
*/
DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const int *begin, const int *end) const
{
*/
bool MEDCouplingUMesh::IsPolygonWellOriented(bool isQuadratic, const double *vec, const int *begin, const int *end, const double *coords)
{
+ std::size_t i, ip1;
double v[3]={0.,0.,0.};
std::size_t sz=std::distance(begin,end);
if(isQuadratic)
sz/=2;
- for(std::size_t i=0;i<sz;i++)
+ for(i=0;i<sz;i++)
{
v[0]+=coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]+2]-coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]+1];
v[1]+=coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]]-coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+2];
v[2]+=coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+1]-coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]];
}
- return vec[0]*v[0]+vec[1]*v[1]+vec[2]*v[2]>0.;
+ double ret = vec[0]*v[0]+vec[1]*v[1]+vec[2]*v[2];
+
+ // Try using quadratic points if standard points are degenerated (for example a QPOLYG with two
+ // SEG3 forming a circle):
+ if (fabs(ret) < INTERP_KERNEL::DEFAULT_ABS_TOL && isQuadratic)
+ {
+ v[0] = 0.0; v[1] = 0.0; v[2] = 0.0;
+ for(std::size_t j=0;j<sz;j++)
+ {
+ if (j%2) // current point i is quadratic, next point i+1 is standard
+ {
+ i = sz+j;
+ ip1 = (j+1)%sz; // ip1 = "i+1"
+ }
+ else // current point i is standard, next point i+1 is quadratic
+ {
+ i = j;
+ ip1 = j+sz;
+ }
+ v[0]+=coords[3*begin[i]+1]*coords[3*begin[ip1]+2]-coords[3*begin[i]+2]*coords[3*begin[ip1]+1];
+ v[1]+=coords[3*begin[i]+2]*coords[3*begin[ip1]]-coords[3*begin[i]]*coords[3*begin[ip1]+2];
+ v[2]+=coords[3*begin[i]]*coords[3*begin[ip1]+1]-coords[3*begin[i]+1]*coords[3*begin[ip1]];
+ }
+ ret = vec[0]*v[0]+vec[1]*v[1]+vec[2]*v[2];
+ }
+ return (ret>0.);
}
/*!
}
}
-/*!
- * This method makes the assumption spacedimension == meshdimension == 2.
- * This method works only for linear cells.
- *
- * \return a newly allocated array containing the connectivity of a polygon type enum included (NORM_POLYGON in pos#0)
- */
-DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMesh() const
+DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMeshLinear(const MEDCouplingUMesh *skin, const DataArrayInt *n2o) const
{
- if(getMeshDimension()!=2 || getSpaceDimension()!=2)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : meshdimension, spacedimension must be equal to 2 !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=computeSkin();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=m->zipCoordsTraducer();
- int nbOfNodesExpected=m->getNumberOfNodes();
- if(m->getNumberOfCells()!=nbOfNodesExpected)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : the mesh 2D in input appears to be not in a single part or a quadratic 2D mesh !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o=o2n->invertArrayO2N2N2O(m->getNumberOfNodes());
- const int *n2oPtr=n2o->getConstPointer();
+ int nbOfNodesExpected(skin->getNumberOfNodes());
+ const int *n2oPtr(n2o->getConstPointer());
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> revNodal(DataArrayInt::New()),revNodalI(DataArrayInt::New());
- m->getReverseNodalConnectivity(revNodal,revNodalI);
- const int *revNodalPtr=revNodal->getConstPointer(),*revNodalIPtr=revNodalI->getConstPointer();
- const int *nodalPtr=m->getNodalConnectivity()->getConstPointer();
- const int *nodalIPtr=m->getNodalConnectivityIndex()->getConstPointer();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(nbOfNodesExpected+1,1);
- int *work=ret->getPointer(); *work++=INTERP_KERNEL::NORM_POLYGON;
+ skin->getReverseNodalConnectivity(revNodal,revNodalI);
+ const int *revNodalPtr(revNodal->getConstPointer()),*revNodalIPtr(revNodalI->getConstPointer());
+ const int *nodalPtr(skin->getNodalConnectivity()->getConstPointer());
+ const int *nodalIPtr(skin->getNodalConnectivityIndex()->getConstPointer());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(nbOfNodesExpected+1,1);
+ int *work(ret->getPointer()); *work++=INTERP_KERNEL::NORM_POLYGON;
if(nbOfNodesExpected<1)
return ret.retn();
- int prevCell=0;
- int prevNode=nodalPtr[nodalIPtr[0]+1];
+ int prevCell(0),prevNode(nodalPtr[nodalIPtr[0]+1]);
*work++=n2oPtr[prevNode];
for(int i=1;i<nbOfNodesExpected;i++)
{
conn.erase(prevNode);
if(conn.size()==1)
{
- int curNode=*(conn.begin());
+ int curNode(*(conn.begin()));
*work++=n2oPtr[curNode];
std::set<int> shar(revNodalPtr+revNodalIPtr[curNode],revNodalPtr+revNodalIPtr[curNode+1]);
shar.erase(prevCell);
prevNode=curNode;
}
else
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : presence of unexpected 2 !");
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshLinear : presence of unexpected 2 !");
}
else
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : presence of unexpected 1 !");
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshLinear : presence of unexpected 1 !");
}
else
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : presence of unexpected cell !");
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshLinear : presence of unexpected cell !");
+ }
+ return ret.retn();
+}
+
+DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMeshQuadratic(const MEDCouplingUMesh *skin, const DataArrayInt *n2o) const
+{
+ int nbOfNodesExpected(skin->getNumberOfNodes());
+ int nbOfTurn(nbOfNodesExpected/2);
+ const int *n2oPtr(n2o->getConstPointer());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> revNodal(DataArrayInt::New()),revNodalI(DataArrayInt::New());
+ skin->getReverseNodalConnectivity(revNodal,revNodalI);
+ const int *revNodalPtr(revNodal->getConstPointer()),*revNodalIPtr(revNodalI->getConstPointer());
+ const int *nodalPtr(skin->getNodalConnectivity()->getConstPointer());
+ const int *nodalIPtr(skin->getNodalConnectivityIndex()->getConstPointer());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(nbOfNodesExpected+1,1);
+ int *work(ret->getPointer()); *work++=INTERP_KERNEL::NORM_QPOLYG;
+ if(nbOfNodesExpected<1)
+ return ret.retn();
+ int prevCell(0),prevNode(nodalPtr[nodalIPtr[0]+1]);
+ *work=n2oPtr[prevNode]; work[nbOfTurn]=n2oPtr[nodalPtr[nodalIPtr[0]+3]]; work++;
+ for(int i=1;i<nbOfTurn;i++)
+ {
+ if(nodalIPtr[prevCell+1]-nodalIPtr[prevCell]==4)
+ {
+ std::set<int> conn(nodalPtr+nodalIPtr[prevCell]+1,nodalPtr+nodalIPtr[prevCell]+3);
+ conn.erase(prevNode);
+ if(conn.size()==1)
+ {
+ int curNode(*(conn.begin()));
+ *work=n2oPtr[curNode];
+ std::set<int> shar(revNodalPtr+revNodalIPtr[curNode],revNodalPtr+revNodalIPtr[curNode+1]);
+ shar.erase(prevCell);
+ if(shar.size()==1)
+ {
+ int curCell(*(shar.begin()));
+ work[nbOfTurn]=n2oPtr[nodalPtr[nodalIPtr[curCell]+3]];
+ prevCell=curCell;
+ prevNode=curNode;
+ work++;
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshQuadratic : presence of unexpected 2 !");
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshQuadratic : presence of unexpected 1 !");
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMeshQuadratic : presence of unexpected cell !");
}
return ret.retn();
}
+/*!
+ * This method makes the assumption spacedimension == meshdimension == 2.
+ * This method works only for linear cells.
+ *
+ * \return a newly allocated array containing the connectivity of a polygon type enum included (NORM_POLYGON in pos#0)
+ */
+DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMesh() const
+{
+ if(getMeshDimension()!=2 || getSpaceDimension()!=2)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : meshdimension, spacedimension must be equal to 2 !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> skin(computeSkin());
+ int oldNbOfNodes(skin->getNumberOfNodes());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(skin->zipCoordsTraducer());
+ int nbOfNodesExpected(skin->getNumberOfNodes());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(oldNbOfNodes));
+ int nbCells(skin->getNumberOfCells());
+ if(nbCells==nbOfNodesExpected)
+ return buildUnionOf2DMeshLinear(skin,n2o);
+ else if(2*nbCells==nbOfNodesExpected)
+ return buildUnionOf2DMeshQuadratic(skin,n2o);
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : the mesh 2D in input appears to be not in a single part of a 2D mesh !");
+}
+
/*!
* This method makes the assumption spacedimension == meshdimension == 3.
* This method works only for linear cells.
}
}
+void IKGeo2DInternalMapper2(INTERP_KERNEL::Node *n, const std::map<INTERP_KERNEL::Node *,int>& m, int forbVal0, int forbVal1, std::vector<int>& isect)
+{
+ std::map<INTERP_KERNEL::Node *,int>::const_iterator it(m.find(n));
+ if(it==m.end())
+ throw INTERP_KERNEL::Exception("Internal error in remapping !");
+ int v((*it).second);
+ if(v==forbVal0 || v==forbVal1)
+ return ;
+ if(std::find(isect.begin(),isect.end(),v)==isect.end())
+ isect.push_back(v);
+}
+
+bool IKGeo2DInternalMapper(const INTERP_KERNEL::ComposedEdge& c, const std::map<INTERP_KERNEL::Node *,int>& m, int forbVal0, int forbVal1, std::vector<int>& isect)
+{
+ int sz(c.size());
+ if(sz<=1)
+ return false;
+ bool presenceOfOn(false);
+ for(int i=0;i<sz;i++)
+ {
+ INTERP_KERNEL::ElementaryEdge *e(c[i]);
+ if(e->getLoc()!=INTERP_KERNEL::FULL_ON_1)
+ continue ;
+ IKGeo2DInternalMapper2(e->getStartNode(),m,forbVal0,forbVal1,isect);
+ IKGeo2DInternalMapper2(e->getEndNode(),m,forbVal0,forbVal1,isect);
+ }
+ return presenceOfOn;
+}
+
+/**
+ * This method split some of edges of 2D cells in \a this. The edges to be split are specified in \a subNodesInSeg and in \a subNodesInSegI using index storage mode.
+ * To do the work this method can optionnaly needs information about middle of subedges for quadratic cases if a minimal creation of new nodes is wanted.
+ * So this method try to reduce at most the number of new nodes. The only case that can lead this method to add nodes if a SEG3 is split without information of middle.
+ * \b WARNING : is returned value is different from 0 a call to MEDCouplingUMesh::mergeNodes is necessary to avoid to have a non conform mesh.
+ *
+ * \return int - the number of new nodes created (in most of cases 0).
+ *
+ * \throw If \a this is not coherent.
+ * \throw If \a this has not spaceDim equal to 2.
+ * \throw If \a this has not meshDim equal to 2.
+ * \throw If some subcells needed to be split are orphan.
+ * \sa MEDCouplingUMesh::conformize2D
+ */
+int MEDCouplingUMesh::split2DCells(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *midOpt, const DataArrayInt *midOptI)
+{
+ if(!desc || !descI || !subNodesInSeg || !subNodesInSegI)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : the 4 first arrays must be not null !");
+ desc->checkAllocated(); descI->checkAllocated(); subNodesInSeg->checkAllocated(); subNodesInSegI->checkAllocated();
+ if(getSpaceDimension()!=2 || getMeshDimension()!=2)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : This method only works for meshes with spaceDim=2 and meshDim=2 !");
+ if(midOpt==0 && midOptI==0)
+ {
+ split2DCellsLinear(desc,descI,subNodesInSeg,subNodesInSegI);
+ return 0;
+ }
+ else if(midOpt!=0 && midOptI!=0)
+ return split2DCellsQuadratic(desc,descI,subNodesInSeg,subNodesInSegI,midOpt,midOptI);
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : middle parameters must be set to null for all or not null for all.");
+}
+
+/*!
+ * \b WARNING this method is \b potentially \b non \b const (if returned array is empty).
+ * \b WARNING this method lead to have a non geometric type sorted mesh (for MED file users) !
+ * This method performs a conformization of \b this. So if a edge in \a this can be split into entire edges in \a this this method
+ * will suppress such edges to use sub edges in \a this. So this method does not add nodes in \a this if merged edges have same nature each other (Linear,Quadratic).
+ * Whatever the returned value, this method does not alter the order of cells in \a this neither the orientation of cells.
+ * The modified cells if any are systematically declared as NORM_POLYGON or NORM_QPOLYG depending on the
+ *
+ * This method expects that \b this has a meshDim equal 2 and spaceDim equal to 2 too.
+ * This method expects that all nodes in \a this are not closer than \a eps.
+ * If it is not the case you can invoke MEDCouplingUMesh::mergeNodes before calling this method.
+ *
+ * \param [in] eps the relative error to detect merged edges.
+ * \return DataArrayInt * - The list of cellIds in \a this that have been subdivided. If empty, nothing changed in \a this (as if it were a const method). The array is a newly allocated array
+ * that the user is expected to deal with.
+ *
+ * \throw If \a this is not coherent.
+ * \throw If \a this has not spaceDim equal to 2.
+ * \throw If \a this has not meshDim equal to 2.
+ * \sa MEDCouplingUMesh::mergeNodes, MEDCouplingUMesh::split2DCells
+ */
+DataArrayInt *MEDCouplingUMesh::conformize2D(double eps)
+{
+ static const int SPACEDIM=2;
+ checkCoherency();
+ if(getSpaceDimension()!=2 || getMeshDimension()!=2)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::conformize2D : This method only works for meshes with spaceDim=2 and meshDim=2 !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc1(DataArrayInt::New()),descIndx1(DataArrayInt::New()),revDesc1(DataArrayInt::New()),revDescIndx1(DataArrayInt::New());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mDesc(buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1));
+ const int *c(mDesc->getNodalConnectivity()->getConstPointer()),*ci(mDesc->getNodalConnectivityIndex()->getConstPointer()),*rd(revDesc1->getConstPointer()),*rdi(revDescIndx1->getConstPointer());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bboxArr(mDesc->getBoundingBoxForBBTree());
+ const double *bbox(bboxArr->begin()),*coords(getCoords()->begin());
+ int nCell(getNumberOfCells()),nDescCell(mDesc->getNumberOfCells());
+ std::vector< std::vector<int> > intersectEdge(nDescCell),overlapEdge(nDescCell);
+ std::vector<double> addCoo;
+ BBTree<SPACEDIM,int> myTree(bbox,0,0,nDescCell,-eps);
+ INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps;
+ INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps;
+ for(int i=0;i<nDescCell;i++)
+ {
+ std::vector<int> candidates;
+ myTree.getIntersectingElems(bbox+i*2*SPACEDIM,candidates);
+ for(std::vector<int>::const_iterator it=candidates.begin();it!=candidates.end();it++)
+ if(*it>i)
+ {
+ std::map<INTERP_KERNEL::Node *,int> m;
+ INTERP_KERNEL::Edge *e1(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[i]],c+ci[i]+1,coords,m)),
+ *e2(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[*it]],c+ci[*it]+1,coords,m));
+ INTERP_KERNEL::MergePoints merge;
+ INTERP_KERNEL::QuadraticPolygon c1,c2;
+ e1->intersectWith(e2,merge,c1,c2);
+ e1->decrRef(); e2->decrRef();
+ if(IKGeo2DInternalMapper(c1,m,c[ci[i]+1],c[ci[i]+2],intersectEdge[i]))
+ overlapEdge[i].push_back(*it);
+ if(IKGeo2DInternalMapper(c2,m,c[ci[*it]+1],c[ci[*it]+2],intersectEdge[*it]))
+ overlapEdge[*it].push_back(i);
+ for(std::map<INTERP_KERNEL::Node *,int>::const_iterator it2=m.begin();it2!=m.end();it2++)
+ (*it2).first->decrRef();
+ }
+ }
+ // splitting done. sort intersect point in intersectEdge.
+ std::vector< std::vector<int> > middle(nDescCell);
+ int nbOf2DCellsToBeSplit(0);
+ bool middleNeedsToBeUsed(false);
+ std::vector<bool> cells2DToTreat(nDescCell,false);
+ for(int i=0;i<nDescCell;i++)
+ {
+ std::vector<int>& isect(intersectEdge[i]);
+ int sz((int)isect.size());
+ if(sz>1)
+ {
+ std::map<INTERP_KERNEL::Node *,int> m;
+ INTERP_KERNEL::Edge *e(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[i]],c+ci[i]+1,coords,m));
+ e->sortSubNodesAbs(coords,isect);
+ e->decrRef();
+ for(std::map<INTERP_KERNEL::Node *,int>::const_iterator it2=m.begin();it2!=m.end();it2++)
+ (*it2).first->decrRef();
+ }
+ if(sz!=0)
+ {
+ int idx0(rdi[i]),idx1(rdi[i+1]);
+ if(idx1-idx0!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::conformize2D : internal error #0 !");
+ if(!cells2DToTreat[rd[idx0]])
+ {
+ cells2DToTreat[rd[idx0]]=true;
+ nbOf2DCellsToBeSplit++;
+ }
+ // try to reuse at most eventual 'middle' of SEG3
+ std::vector<int>& mid(middle[i]);
+ mid.resize(sz+1,-1);
+ if((INTERP_KERNEL::NormalizedCellType)c[ci[i]]==INTERP_KERNEL::NORM_SEG3)
+ {
+ middleNeedsToBeUsed=true;
+ const std::vector<int>& candidates(overlapEdge[i]);
+ std::vector<int> trueCandidates;
+ for(std::vector<int>::const_iterator itc=candidates.begin();itc!=candidates.end();itc++)
+ if((INTERP_KERNEL::NormalizedCellType)c[ci[*itc]]==INTERP_KERNEL::NORM_SEG3)
+ trueCandidates.push_back(*itc);
+ int stNode(c[ci[i]+1]),endNode(isect[0]);
+ for(int j=0;j<sz+1;j++)
+ {
+ for(std::vector<int>::const_iterator itc=trueCandidates.begin();itc!=trueCandidates.end();itc++)
+ {
+ int tmpSt(c[ci[*itc]+1]),tmpEnd(c[ci[*itc]+2]);
+ if((tmpSt==stNode && tmpEnd==endNode) || (tmpSt==endNode && tmpEnd==stNode))
+ { mid[j]=*itc; break; }
+ }
+ stNode=endNode;
+ endNode=j<sz-1?isect[j+1]:c[ci[i]+2];
+ }
+ }
+ }
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()),notRet(DataArrayInt::New()); ret->alloc(nbOf2DCellsToBeSplit,1);
+ if(nbOf2DCellsToBeSplit==0)
+ return ret.retn();
+ //
+ int *retPtr(ret->getPointer());
+ for(int i=0;i<nCell;i++)
+ if(cells2DToTreat[i])
+ *retPtr++=i;
+ //
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> mSafe,nSafe,oSafe,pSafe,qSafe,rSafe;
+ DataArrayInt *m(0),*n(0),*o(0),*p(0),*q(0),*r(0);
+ MEDCouplingUMesh::ExtractFromIndexedArrays(ret->begin(),ret->end(),desc1,descIndx1,m,n); mSafe=m; nSafe=n;
+ DataArrayInt::PutIntoToSkylineFrmt(intersectEdge,o,p); oSafe=o; pSafe=p;
+ if(middleNeedsToBeUsed)
+ { DataArrayInt::PutIntoToSkylineFrmt(middle,q,r); qSafe=q; rSafe=r; }
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> modif(static_cast<MEDCouplingUMesh *>(buildPartOfMySelf(ret->begin(),ret->end(),true)));
+ int nbOfNodesCreated(modif->split2DCells(mSafe,nSafe,oSafe,pSafe,qSafe,rSafe));
+ setCoords(modif->getCoords());//if nbOfNodesCreated==0 modif and this have the same coordinates pointer so this line has no effect. But for quadratic cases this line is important.
+ setPartOfMySelf(ret->begin(),ret->end(),*modif);
+ {
+ bool areNodesMerged; int newNbOfNodes;
+ if(nbOfNodesCreated!=0)
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(mergeNodes(eps,areNodesMerged,newNbOfNodes));
+ }
+ return ret.retn();
+}
+
/*!
* This method is private and is the first step of Partition of 2D mesh (spaceDim==2 and meshDim==2).
* It builds the descending connectivity of the two meshes, and then using a binary tree
return ret0.retn();
}
+/*!
+ * It is the linear part of MEDCouplingUMesh::split2DCells. Here no additionnal nodes will be added in \b this. So coordinates pointer remain unchanged (is not even touch).
+ *
+ * \sa MEDCouplingUMesh::split2DCells
+ */
+void MEDCouplingUMesh::split2DCellsLinear(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI)
+{
+ checkConnectivityFullyDefined();
+ int ncells(getNumberOfCells()),lgthToReach(getMeshLength()+subNodesInSeg->getNumberOfTuples());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()); c->alloc((std::size_t)lgthToReach);
+ const int *subPtr(subNodesInSeg->begin()),*subIPtr(subNodesInSegI->begin()),*descPtr(desc->begin()),*descIPtr(descI->begin()),*oldConn(getNodalConnectivity()->begin());
+ int *cPtr(c->getPointer()),*ciPtr(getNodalConnectivityIndex()->getPointer());
+ int prevPosOfCi(ciPtr[0]);
+ for(int i=0;i<ncells;i++,ciPtr++,descIPtr++)
+ {
+ int offset(descIPtr[0]),sz(descIPtr[1]-descIPtr[0]),deltaSz(0);
+ *cPtr++=(int)INTERP_KERNEL::NORM_POLYGON; *cPtr++=oldConn[prevPosOfCi+1];
+ for(int j=0;j<sz;j++)
+ {
+ int offset2(subIPtr[descPtr[offset+j]]),sz2(subIPtr[descPtr[offset+j]+1]-subIPtr[descPtr[offset+j]]);
+ for(int k=0;k<sz2;k++)
+ *cPtr++=subPtr[offset2+k];
+ if(j!=sz-1)
+ *cPtr++=oldConn[prevPosOfCi+j+2];
+ deltaSz+=sz2;
+ }
+ prevPosOfCi=ciPtr[1];
+ ciPtr[1]=ciPtr[0]+1+sz+deltaSz;//sz==old nb of nodes because (nb of subedges=nb of nodes for polygons)
+ }
+ if(c->end()!=cPtr)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCellsLinear : Some of edges to be split are orphan !");
+ _nodal_connec->decrRef();
+ _nodal_connec=c.retn(); _types.clear(); _types.insert(INTERP_KERNEL::NORM_POLYGON);
+}
+
+int internalAddPoint(const INTERP_KERNEL::Edge *e, int id, const double *coo, int startId, int endId, DataArrayDouble& addCoo, int& nodesCnter)
+{
+ if(id!=-1)
+ return id;
+ else
+ {
+ int ret(nodesCnter++);
+ double newPt[2];
+ e->getMiddleOfPoints(coo+2*startId,coo+2*endId,newPt);
+ addCoo.insertAtTheEnd(newPt,newPt+2);
+ return ret;
+ }
+}
+
+/*!
+ * It is the quadratic part of MEDCouplingUMesh::split2DCells. Here some additionnal nodes can be added at the end of coordinates array object.
+ *
+ * \return int - the number of new nodes created.
+ * \sa MEDCouplingUMesh::split2DCells
+ */
+int MEDCouplingUMesh::split2DCellsQuadratic(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *mid, const DataArrayInt *midI)
+{
+ checkCoherency();
+ int ncells(getNumberOfCells()),lgthToReach(getMeshLength()+2*subNodesInSeg->getNumberOfTuples()),nodesCnt(getNumberOfNodes());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()); c->alloc((std::size_t)lgthToReach);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> addCoo(DataArrayDouble::New()); addCoo->alloc(0,1);
+ const int *subPtr(subNodesInSeg->begin()),*subIPtr(subNodesInSegI->begin()),*descPtr(desc->begin()),*descIPtr(descI->begin()),*oldConn(getNodalConnectivity()->begin());
+ const int *midPtr(mid->begin()),*midIPtr(midI->begin());
+ const double *oldCoordsPtr(getCoords()->begin());
+ int *cPtr(c->getPointer()),*ciPtr(getNodalConnectivityIndex()->getPointer());
+ int prevPosOfCi(ciPtr[0]);
+ for(int i=0;i<ncells;i++,ciPtr++,descIPtr++)
+ {
+ int offset(descIPtr[0]),sz(descIPtr[1]-descIPtr[0]),deltaSz(sz);
+ for(int j=0;j<sz;j++)
+ { int sz2(subIPtr[descPtr[offset+j]+1]-subIPtr[descPtr[offset+j]]); deltaSz+=sz2; }
+ *cPtr++=(int)INTERP_KERNEL::NORM_QPOLYG; cPtr[0]=oldConn[prevPosOfCi+1];
+ for(int j=0;j<sz;j++)//loop over subedges of oldConn
+ {
+ int offset2(subIPtr[descPtr[offset+j]]),sz2(subIPtr[descPtr[offset+j]+1]-subIPtr[descPtr[offset+j]]),offset3(midIPtr[descPtr[offset+j]]);
+ if(sz2==0)
+ {
+ if(j<sz-1)
+ cPtr[1]=oldConn[prevPosOfCi+2+j];
+ cPtr[deltaSz]=oldConn[prevPosOfCi+1+j+sz]; cPtr++;
+ continue;
+ }
+ std::vector<INTERP_KERNEL::Node *> ns(3);
+ ns[0]=new INTERP_KERNEL::Node(oldCoordsPtr[2*oldConn[prevPosOfCi+1+j]],oldCoordsPtr[2*oldConn[prevPosOfCi+1+j]+1]);
+ ns[1]=new INTERP_KERNEL::Node(oldCoordsPtr[2*oldConn[prevPosOfCi+1+(1+j)%sz]],oldCoordsPtr[2*oldConn[prevPosOfCi+1+(1+j)%sz]+1]);
+ ns[2]=new INTERP_KERNEL::Node(oldCoordsPtr[2*oldConn[prevPosOfCi+1+sz+j]],oldCoordsPtr[2*oldConn[prevPosOfCi+1+sz+j]+1]);
+ MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> e(INTERP_KERNEL::QuadraticPolygon::BuildArcCircleEdge(ns));
+ for(int k=0;k<sz2;k++)//loop over subsplit of current subedge
+ {
+ cPtr[1]=subPtr[offset2+k];
+ cPtr[deltaSz]=internalAddPoint(e,midPtr[offset3+k],oldCoordsPtr,cPtr[0],cPtr[1],*addCoo,nodesCnt); cPtr++;
+ }
+ int tmpEnd(oldConn[prevPosOfCi+1+(j+1)%sz]);
+ if(j!=sz-1)
+ { cPtr[1]=tmpEnd; }
+ cPtr[deltaSz]=internalAddPoint(e,midPtr[offset3+sz2],oldCoordsPtr,cPtr[0],tmpEnd,*addCoo,nodesCnt); cPtr++;
+ }
+ prevPosOfCi=ciPtr[1]; cPtr+=deltaSz;
+ ciPtr[1]=ciPtr[0]+1+2*deltaSz;//sz==old nb of nodes because (nb of subedges=nb of nodes for polygons)
+ }
+ if(c->end()!=cPtr)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCellsQuadratic : Some of edges to be split are orphan !");
+ _nodal_connec->decrRef();
+ _nodal_connec=c.retn(); _types.clear(); _types.insert(INTERP_KERNEL::NORM_QPOLYG);
+ addCoo->rearrange(2);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo(DataArrayDouble::Aggregate(getCoords(),addCoo));//info are copied from getCoords() by using Aggregate
+ setCoords(coo);
+ return addCoo->getNumberOfTuples();
+}
+
MEDCouplingUMeshCellIterator::MEDCouplingUMeshCellIterator(MEDCouplingUMesh *mesh):_mesh(mesh),_cell(new MEDCouplingUMeshCell(mesh)),
_own_cell(true),_cell_id(-1),_nb_cell(0)
{
MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const;
MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTreeFast() const;
MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree2DQuadratic(double arcDetEps=1e-12) const;
+ MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree1DQuadratic(double arcDetEps=1e-12) const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy);
MEDCOUPLING_EXPORT bool isFullyQuadratic() const;
MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const;
MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
MEDCOUPLING_EXPORT DataArrayDouble *getPartBarycenterAndOwner(const int *begin, const int *end) const;
MEDCOUPLING_EXPORT DataArrayDouble *computePlaneEquationOf3DFaces() const;
+ MEDCOUPLING_EXPORT DataArrayInt *conformize2D(double eps);
+ MEDCOUPLING_EXPORT int split2DCells(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *midOpt=0, const DataArrayInt *midOptI=0);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a);
DataArrayInt *convertLinearCellsToQuadratic2D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const;
DataArrayInt *convertLinearCellsToQuadratic3D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const;
DataArrayInt *convertLinearCellsToQuadratic3D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const;
+ DataArrayInt *buildUnionOf2DMeshLinear(const MEDCouplingUMesh *skin, const DataArrayInt *n2o) const;
+ DataArrayInt *buildUnionOf2DMeshQuadratic(const MEDCouplingUMesh *skin, const DataArrayInt *n2o) const;
template<int SPACEDIM>
void getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints,
double eps, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& elts, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& eltsIndex) const;
const int *desc, const int *descIndx, std::vector< std::pair<int,int> >& cut3DSurf) throw(INTERP_KERNEL::Exception);
void assemblyForSplitFrom3DSurf(const std::vector< std::pair<int,int> >& cut3DSurf,
const int *desc, const int *descIndx, DataArrayInt *nodalRes, DataArrayInt *nodalResIndx, DataArrayInt *cellIds) const throw(INTERP_KERNEL::Exception);
+ void split2DCellsLinear(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI);
+ int split2DCellsQuadratic(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *mid, const DataArrayInt *midI);
public:
MEDCOUPLING_EXPORT static DataArrayInt *ComputeRangesFromTypeDistribution(const std::vector<int>& code);
MEDCOUPLING_EXPORT static const int N_MEDMEM_ORDER=24;
m2->decrRef();
}
+void MEDCouplingBasicsTest2::testCellOrientation3()
+{
+ MEDCouplingUMesh *m = MEDCouplingUMesh::New("circle", 2);
+
+ double coords[8]={ 0.,0., 0.,0., 0.,0., 0.,0.};
+ coords[0] = cos(-M_PI/4.0); coords[1] = sin(-M_PI/4.0);
+ coords[2] = cos(3*M_PI/4.0); coords[3] = sin(3*M_PI/4.0);
+ coords[4] = cos(5*M_PI/4.0); coords[5] = sin(5*M_PI/4.0);
+ coords[6] = cos(M_PI/4.0); coords[7] = sin(M_PI/4.0);
+
+ int conn[4]= { 0,1,2,3 };
+ double vec[3]={0.,0.,-1.};
+ m->allocateCells(1);
+ m->insertNextCell(INTERP_KERNEL::NORM_QPOLYG,4,conn);
+ m->finishInsertingCells();
+ DataArrayDouble *myCoords=DataArrayDouble::New();
+ myCoords->alloc(4,2);
+ std::copy(coords,coords+8,myCoords->getPointer());
+ m->setCoords(myCoords);
+ myCoords->decrRef();
+ m->changeSpaceDimension(3);
+
+ std::vector<int> res1;
+ m->are2DCellsNotCorrectlyOriented(vec,false,res1);
+ CPPUNIT_ASSERT(res1.empty());
+ vec[2] = 1.0;
+ res1.clear();
+ m->are2DCellsNotCorrectlyOriented(vec,false,res1);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res1.size());
+ m->decrRef();
+}
+
/*!
* This test check polyhedron true barycenter computation.
*/
CPPUNIT_TEST( testGaussPointNEField1 );
CPPUNIT_TEST( testCellOrientation1 );
CPPUNIT_TEST( testCellOrientation2 );
+ CPPUNIT_TEST( testCellOrientation3 );
CPPUNIT_TEST( testPolyhedronBarycenter );
CPPUNIT_TEST( testNormL12Integ1D );
CPPUNIT_TEST( testAreaBary2D );
void testGaussPointNEField1();
void testCellOrientation1();
void testCellOrientation2();
+ void testCellOrientation3();
void testPolyhedronBarycenter();
void testNormL12Integ1D();
void testAreaBary2D();
d2->decrRef();
}
+void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp7()
+{
+ double eps = 1.0e-8;
+ // coordinates circle - SEE getCircle() on the Python side
+ DataArrayDouble *coords1=DataArrayDouble::New();
+ const double coordsData1[16]={0.5328427124746189, -0.08284271247461905, -0.03284271247461901, 0.4828427124746191, -0.03284271247461906, -0.082842712474619, 0.5328427124746191, 0.482842712474619};
+ coords1->useArray(coordsData1,false,CPP_DEALLOC,8,2);
+ // connectivity
+ DataArrayInt *conn1=DataArrayInt::New();
+ const int connData1[5]={INTERP_KERNEL::NORM_QPOLYG,0,1,2,3};
+ conn1->useArray(connData1,false,CPP_DEALLOC,5,1);
+ DataArrayInt *connI1=DataArrayInt::New();
+ const int connIData1[2]={0,5};
+ connI1->useArray(connIData1,false,CPP_DEALLOC,2,1);
+ MEDCouplingUMesh *m1=MEDCouplingUMesh::New("circle",2);
+ m1->setCoords(coords1);
+ m1->setConnectivity(conn1,connI1,true);
+ coords1->decrRef(); conn1->decrRef(); connI1->decrRef();
+
+ // square
+ DataArrayDouble *coords2=DataArrayDouble::New();
+ const double coordsData2[8]={-0.5,-0.5, -0.5, 0.5, 0.5, 0.5, 0.5,-0.5};
+ coords2->useArray(coordsData2,false,CPP_DEALLOC,4,2);
+ // connectivity
+ DataArrayInt *conn2=DataArrayInt::New();
+ const int connData2[5]={INTERP_KERNEL::NORM_POLYGON, 0,1,2,3};
+ conn2->useArray(connData2,false,CPP_DEALLOC,5,1);
+ DataArrayInt *connI2=DataArrayInt::New();
+ const int connIData2[2]={0,5};
+ connI2->useArray(connIData2,false,CPP_DEALLOC,2,1);
+ MEDCouplingUMesh *m2=MEDCouplingUMesh::New("square",2);
+ m2->setCoords(coords2);
+ m2->setConnectivity(conn2,connI2,true);
+ coords2->decrRef(); conn2->decrRef(); connI2->decrRef();
+
+ DataArrayInt * resToM1 = 0, * resToM2 = 0;
+ MEDCouplingUMesh *m_intersec=MEDCouplingUMesh::Intersect2DMeshes(m2, m1, eps, resToM1, resToM2);
+ m_intersec->zipCoords();
+
+ const double coo_tgt[34]={-0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.03284271247461901, 0.4828427124746191, \
+ -0.014575131106459124, 0.5000000000000001, 0.5, -0.11224989991991996, 0.24271243444677046, 0.5, 0.5, 0.19387505004004, \
+ -0.04799910280454185, -0.06682678787499614, -0.023843325638122054, 0.4915644577163915, 0.5, -0.30612494995996, 0.0, -0.5,\
+ -0.5, 0.0, -0.25728756555322957, 0.5, -0.023843325638122026, 0.49156445771639157, -0.04799910280454181, -0.06682678787499613};
+ const int conn_tgt[22]={32, 5, 2, 6, 4, 7, 8, 9, 10, 32, 6, 3, 0, 1, 5, 4, 11, 12, 13, 14, 15, 16};
+ const int connI_tgt[3]={0, 9, 22};
+ const int res1_tgt[2] = {0, 0};
+ const int res2_tgt[2] = {0, -1};
+
+ CPPUNIT_ASSERT(std::equal(conn_tgt,conn_tgt+22,m_intersec->getNodalConnectivity()->getConstPointer()));
+ CPPUNIT_ASSERT(std::equal(connI_tgt,connI_tgt+3,m_intersec->getNodalConnectivityIndex()->getConstPointer()));
+ CPPUNIT_ASSERT(std::equal(res1_tgt,res1_tgt+2,resToM1->getConstPointer()));
+ CPPUNIT_ASSERT(std::equal(res2_tgt,res2_tgt+2,resToM2->getConstPointer()));
+ for(int i=0;i<34;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(coo_tgt[i],m_intersec->getCoords()->getIJ(0,i),1e-12);
+ m1->decrRef(); m2->decrRef(); m_intersec->decrRef();
+ resToM1->decrRef(); resToM2->decrRef();
+}
+
void MEDCouplingBasicsTest5::testDAIBuildSubstractionOptimized1()
{
const int tab1[7]={1,3,5,6,7,9,13};
CPPUNIT_TEST( testDAIPartitionByDifferentValues1 );
CPPUNIT_TEST( testDAICheckMonotonic1 );
CPPUNIT_TEST( testIntersect2DMeshesTmp6 );
+ CPPUNIT_TEST( testIntersect2DMeshesTmp7 );
CPPUNIT_TEST( testDAIBuildSubstractionOptimized1 );
CPPUNIT_TEST( testDAIIsStrictlyMonotonic1 );
CPPUNIT_TEST( testSimplexize3 );
void testDAIPartitionByDifferentValues1();
void testDAICheckMonotonic1();
void testIntersect2DMeshesTmp6();
+ void testIntersect2DMeshesTmp7();
void testDAIBuildSubstractionOptimized1();
void testDAIIsStrictlyMonotonic1();
void testSimplexize3();
pass
pass
+ def testCellOrientation3(self):
+ from cmath import rect
+
+ c = [rect(1.0, i*pi/4.0) for i in range(8)]
+ coords = [c[-1].real,c[-1].imag, c[3].real,c[3].imag,
+ c[5].real,c[5].imag, c[1].real,c[1].imag]
+ connec = [0,1,2,3]
+ baseMesh = MEDCouplingUMesh.New("circle", 2)
+ baseMesh.allocateCells(1)
+ meshCoords = DataArrayDouble.New(coords, 4, 2)
+ baseMesh.setCoords(meshCoords)
+ baseMesh.insertNextCell(NORM_QPOLYG, connec) # a circle
+ baseMesh.finishInsertingCells()
+ baseMesh.changeSpaceDimension(3)
+ Oz = [0.0, 0.0, -1.0]
+ cell_lst = baseMesh.are2DCellsNotCorrectlyOriented(Oz, False)
+ self.assertEqual(cell_lst.getNumberOfTuples(), 0)
+ Oz[2] = 1.0
+ cell_lst = baseMesh.are2DCellsNotCorrectlyOriented(Oz, False)
+ self.assertEqual(cell_lst.getNumberOfTuples(), 1)
+
def testPolyhedronBarycenter(self):
connN=[0,3,2,1, -1, 4,5,6,7, -1, 0,4,7,3, -1, 3,7,6,2, -1, 2,6,5,1, -1, 1,5,4,0];
coords=[0.,0.,0., 1.,0.,0., 1.,1.,0., 0.,1.,0., 0.,0.,1., 1.,0.,1., 1.,1.,1., 0.,1.,1., 0.5, 0.5, 0.5];
else:
self.assertTrue(False)
pass
- try:
- da2=da[5:8,-2]
- except InterpKernelException as e:
- self.assertTrue(True)
- else:
- self.assertTrue(False)
- pass
+ self.assertTrue(da[5:8,-2].isEqualWithoutConsideringStr(DataArrayInt([23,26,29])))
da2=da[5:8,:-2]
self.assertEqual([22, 25, 28],da2.getValues())
try:
else:
self.assertTrue(False)
pass
- try:
- da2=da[5:8,-2]
- except InterpKernelException as e:
- self.assertTrue(True)
- else:
- self.assertTrue(False)
- pass
+ self.assertTrue(da[5:8,-2].isEqualWithoutConsideringStr(DataArrayDouble([23.,26.,29.]),1e-12))
da2=da[5:8,:-2]
self.assertEqual([22., 25., 28.],da2.getValues())
try:
def testSwigGetItem3(self):
da=DataArrayInt.New([4,5,6])
self.assertEqual(5,da[1])
- self.assertRaises(InterpKernelException,da.__getitem__,-1)
+ self.assertEqual(6,da[-1])
self.assertRaises(InterpKernelException,da.__getitem__,3)
da=DataArrayInt.New([4,5,6,7,8,9],2,3)
self.assertEqual(9,da[1,2])
da=DataArrayDouble.New([4.1,5.2,6.3])
self.assertAlmostEqual(5.2,da[1],12)
- self.assertRaises(InterpKernelException,da.__getitem__,-1)
+ self.assertAlmostEqual(6.3,da[-1],12)
self.assertRaises(InterpKernelException,da.__getitem__,3)
da=DataArrayDouble.New([4.12,5.12,6.12,7.12,8.12,9.12],2,3)
self.assertAlmostEqual(9.12,da[1,2],12)
# Check coordinates:
self.assertTrue(m3.getCoords().isEqual(m5.getCoords(), eps))
+ def testIntersect2DMeshesTmp7(self):
+ eps = 1.0e-8
+ coords = [-0.5,-0.5, -0.5, 0.5, 0.5, 0.5, 0.5,-0.5]
+ connec = range(4)
+ m1 = MEDCouplingUMesh.New("box", 2)
+ m1.allocateCells(1)
+ meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+ m1.setCoords(meshCoords)
+ m1.insertNextCell(NORM_POLYGON, connec)
+ m1.finishInsertingCells()
+
+ m2 = MEDCouplingDataForTest.buildCircle(0.25, 0.2, 0.4)
+ # Was looping indefinitly:
+ m_intersec, resToM1, resToM2 = MEDCouplingUMesh.Intersect2DMeshes(m1, m2, eps)
+ m_intersec.zipCoords()
+ coo_tgt = DataArrayDouble([-0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.03284271247461901, 0.4828427124746191,
+ -0.014575131106459124, 0.5000000000000001, 0.5, -0.11224989991991996, 0.24271243444677046, 0.5, 0.5, 0.19387505004004,
+ -0.04799910280454185, -0.06682678787499614, -0.023843325638122054, 0.4915644577163915, 0.5, -0.30612494995996, 0.0, -0.5,
+ -0.5, 0.0, -0.25728756555322957, 0.5, -0.023843325638122026, 0.49156445771639157, -0.04799910280454181, -0.06682678787499613], 17 ,2)
+ conn_tgt = [32, 5, 2, 6, 4, 7, 8, 9, 10, 32, 6, 3, 0, 1, 5, 4, 11, 12, 13, 14, 15, 16]
+ connI_tgt = [0, 9, 22]
+ res1_tgt = [0, 0]
+ res2_tgt = [0, -1]
+ self.assert_(coo_tgt.isEqualWithoutConsideringStr(m_intersec.getCoords(), 1e-12))
+ self.assertEqual(conn_tgt, m_intersec.getNodalConnectivity().getValues())
+ self.assertEqual(connI_tgt, m_intersec.getNodalConnectivityIndex().getValues())
+ self.assertEqual(res1_tgt, resToM1.getValues())
+ self.assertEqual(res2_tgt, resToM2.getValues())
+
def testDAIBuildUnique1(self):
d=DataArrayInt([1,2,2,3,3,3,3,4,5,5,7,7,7,19])
e=d.buildUnique()
self.assertEqual(c.getSpaceDimension(),1)
pass
+ def testSwig2BuildSpreadZonesWithPolyOnQPolyg1(self):
+ nx=6
+ ny=6
+ m=MEDCouplingCMesh()
+ arr1=DataArrayDouble(nx) ; arr1.iota()
+ arr2=DataArrayDouble(ny) ; arr2.iota()
+ m.setCoords(arr1,arr2)
+ m=m.buildUnstructured()
+ da=DataArrayInt.Range(nx-1,(nx-1)*(ny-1),nx)
+ m2=m[da] ; m2.simplexize(0)
+ dan=da.buildComplement(m.getNumberOfCells())
+ m1=m[dan]
+ m=MEDCouplingUMesh.MergeUMeshesOnSameCoords(m1,m2)
+ #
+ m.convertLinearCellsToQuadratic()
+ m1=m[::2] ; m2=m[1::2] ; m2.convertAllToPoly()
+ m=MEDCouplingUMesh.MergeUMeshesOnSameCoords(m1,m2)
+ p=m.buildSpreadZonesWithPoly()
+ self.assertTrue(p.getNodalConnectivity().isEqual(DataArrayInt([32,1,0,6,12,18,24,30,31,32,33,34,35,29,23,17,11,5,4,3,2,36,37,94,62,72,83,84,86,89,99,92,93,82,71,60,51,49,46,43,40])))
+ self.assertTrue(p.getNodalConnectivityIndex().isEqual(DataArrayInt([0,41])))
+ self.assertTrue(p.getCoords().isEqual(DataArrayDouble([0.,0.,1.,0.,2.,0.,3.,0.,4.,0.,5.,0.,0.,1.,1.,1.,2.,1.,3.,1.,4.,1.,5.,1.,0.,2.,1.,2.,2.,2.,3.,2.,4.,2.,5.,2.,0.,3.,1.,3.,2.,3.,3.,3.,4.,3.,5.,3.,0.,4.,1.,4.,2.,4.,3.,4.,4.,4.,5.,4.,0.,5.,1.,5.,2.,5.,3.,5.,4.,5.,5.,5.,0.5,0.,0.,0.5,0.5,1.,1.,0.5,1.5,0.,1.5,1.,2.,0.5,2.5,0.,2.5,1.,3.,0.5,3.5,0.,3.5,1.,4.,0.5,4.5,0.,4.5,1.,5.,0.5,1.,1.5,1.5,2.,2.,1.5,2.5,2.,3.,1.5,3.5,2.,4.,1.5,4.5,2.,5.,1.5,0.5,2.,0.,2.5,0.5,3.,1.,2.5,2.,2.5,2.5,3.,3.,2.5,3.5,3.,4.,2.5,4.5,3.,5.,2.5,0.,3.5,0.5,4.,1.,3.5,1.5,3.,1.5,4.,2.,3.5,3.,3.5,3.5,4.,4.,3.5,4.5,4.,5.,3.5,0.,4.5,0.5,5.,1.,4.5,1.5,5.,2.,4.5,2.5,4.,2.5,5.,3.,4.5,4.,4.5,4.5,5.,5.,4.5,0.,1.5,0.5,1.5,1.5,2.5,2.5,3.5,3.5,4.5,3.5,5.0],100,2),1e-13))
+ pass
+
+ def testSwig2Conformize2D1(self):
+ eps = 1.0e-8
+ coo = [0.,-0.5,0.,0.,0.5,0.,0.5,-0.5,0.25,
+ -0.1,0.25,0.,0.5,-0.1,0.,0.5,0.5,0.5,0.25,0.4,0.25,0.5,0.5,0.4]
+ conn = [5,5,2,6,4,5,6,3,0,1,5,4,5,10,8,11,9,5,11,2,1,7,10,9]
+ connI = [0,5,12,17,24]
+ m = MEDCouplingUMesh("box",2)
+ cooArr = DataArrayDouble(coo,len(coo)/2,2)
+ m.setCoords(cooArr)
+ m.setConnectivity(DataArrayInt(conn),DataArrayInt(connI))
+ m.mergeNodes(eps)
+ m.checkCoherency()
+ self.assertTrue(m.conformize2D(eps).isEqual(DataArrayInt([3])))
+ self.assertEqual(m.getCoords().getHiddenCppPointer(),cooArr.getHiddenCppPointer()) # check that coordinates remain the same here
+ self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([5,5,2,6,4,5,6,3,0,1,5,4,5,10,8,11,9,5,11,2,5,1,7,10,9])))
+ self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,12,17,25])))
+ pass
+
+ def testSwig2Conformize2D2(self):
+ eps = 1.0e-8
+ coo=DataArrayDouble([-10,-6,0,-6,0,0,7,0,-10,2,0,2,0,6,7,6,0,8,7,8,-10,12,-4,12,0,12,0,11,7,11,-4,16,0,16,7,16],18,2)
+ conn=DataArrayInt([2,3,7,6, 13,16,17,14, 4,10,12,5, 9,14,13,8, 8,9,7,6, 5,4,0,1, 16,12,11,15])
+ m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4)
+ m.setCoords(coo)
+ m.setNodalConnectivity(conn)
+ m=m.buildUnstructured()
+ self.assertTrue(m.conformize2D(eps).isEqual(DataArrayInt([0,1,2,5])))
+ self.assertEqual(m.getCoords().getHiddenCppPointer(),coo.getHiddenCppPointer()) # check that coordinates remain the same here
+ self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([5,2,3,7,6,5, 5,13,12,16,17,14, 5,4,10,11,12,13,8,6,5, 4,9,14,13,8, 4,8,9,7,6, 5,5,4,0,1,2, 4,16,12,11,15])))
+ self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,6,12,21,26,31,37,42])))
+ pass
+
+ def testSwigSplit2DCells1(self):
+ coo=DataArrayDouble([[0,0],[1,0],[1,1],[0,1],[0.5,0],[1,0.5],[0.5,1],[0.,0.5]])
+ m=MEDCouplingUMesh("mesh",2)
+ m.setCoords(coo)
+ m.allocateCells()
+ m.insertNextCell(NORM_QUAD8,[0,1,2,3,4,5,6,7])
+ _,d,di,_,_=m.buildDescendingConnectivity()
+ subb=DataArrayInt([5])
+ subbi=DataArrayInt([0,0,1,1,1])
+ mid=DataArrayInt([-1,-1])
+ midi=DataArrayInt([0,0,2,2,2])
+ self.assertEqual(2,m.split2DCells(d,di,subb,subbi,mid,midi))
+ self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([32,0,1,5,2,3,4,8,9,6,7])))
+ self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,11])))
+ self.assertTrue(m.getCoords().isEqual(DataArrayDouble([[0,0],[1,0],[1,1],[0,1],[0.5,0],[1,0.5],[0.5,1],[0.,0.5],[1.,0.25],[1.,0.75]]),1e-12))
+ pass
+
+ def testSwig2Conformize2D3(self):
+ eps = 1.0e-8
+ coo=DataArrayDouble([-10,-6,0,-6,0,0,7,0,-10,2,0,2,0,6.5,7,6.5,0,8,7,8,-10,12,-4,12,0,12,0,11,7,11,-4,16,0,16,7,16],18,2)
+ conn=DataArrayInt([2,3,7,6, 13,16,17,14, 4,10,12,5, 9,14,13,8, 8,9,7,6, 5,4,0,1, 16,12,11,15])
+ m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4)
+ m.setCoords(coo)
+ m.setNodalConnectivity(conn)
+ m=m.buildUnstructured()
+ m.convertLinearCellsToQuadratic()
+ self.assertTrue(m.conformize2D(eps).isEqual(DataArrayInt([0,1,2,5])))
+ self.assertTrue(m.getCoords().getHiddenCppPointer()!=coo.getHiddenCppPointer()) # coordinates are not the same here contrary to testSwig2Conformize2D2 ...
+ self.assertTrue(m.getCoords()[:18].isEqual(coo,1e-12)) # but the 18 first nodes are the same
+ pass
+
+ def testSwig2Conformize2D4(self):
+ eps = 1.0e-8
+ coo=DataArrayDouble([-10,-6,0,-6,0,0,7,0,-10,2,0,2,0,6.5,7,6.5,0,8,7,8,-10,12,-4,12,0,12,0,11,7,11,-4,16,0,16,7,16],18,2)
+ conn=DataArrayInt([2,3,7,6, 13,16,17,14, 4,10,12,5, 9,14,13,8, 8,9,7,6, 5,4,0,1, 16,12,11,15])
+ m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4)
+ m.setCoords(coo)
+ m.setNodalConnectivity(conn)
+ m=m.buildUnstructured()
+ m.convertLinearCellsToQuadratic()
+ self.assertEqual(42,m.getNumberOfNodes())
+ oldCoo=m.getCoords().deepCpy()
+ m.conformize2D(eps)
+ self.assertTrue(m.getCoords()[:42].isEqual(oldCoo,1e-12))
+ self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([32,2,3,7,6,5,18,19,20,42,43,32,13,12,16,17,14,44,38,23,24,25,32,4,10,11,12,13,8,6,5,26,45,39,44,31,34,42,29,8,9,14,13,8,30,25,31,32,8,8,9,7,6,32,33,20,34,32,5,4,0,1,2,29,35,36,46,43,8,16,12,11,15,38,39,40,41])))
+ self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,11,22,39,48,57,68,77])))
+ self.assertTrue(m.getCoords().isEqual(DataArrayDouble([[-10.,-6.0],[0.,-6.0],[0.,0.0],[7.,0.0],[-10.,2.0],[0.,2.0],[0.,6.5],[7.,6.5],[0.,8.0],[7.,8.0],[-10.,12.0],[-4.,12.0],[0.,12.0],[0.,11.0],[7.,11.0],[-4.,16.0],[0.,16.0],[7.,16.0],[3.5, 0.0],[7.,3.25],[3.5, 6.5],[0.,3.25],[0.,13.5],[3.5, 16.0],[7.,13.5],[3.5, 11.0],[-10.,7.0],[-5.,12.0],[0.,7.0],[-5.,2.0],[7.,9.5],[0.,9.5],[3.5, 8.0],[7.,7.25],[0.,7.25],[-10.,-2.0],[-5.,-6.0],[0.,-2.0],[0.,14.0],[-2.,12.0],[-4.,14.0],[-2.,16.0],[0.,4.25],[0.,1.0],[0.,11.5],[-7.,12.0],[0.,-3.]]),1e-12))
+ pass
+
+ def testSwig2Conformize2D5(self):
+ eps=1e-8
+ coo=DataArrayDouble([[2,2],[2,-6],[10,-2],[-2,-2],[6,0],[6,-4],[2,7],[2,4.5],[-1.4641016151377544,0],[-1.950753362380551,-1.3742621398390762],[-7,-3],[-0.8284271247461898,-4.82842712474619],[0.26794919243112281,3.5],[0,1.4641016151377548],[-4.4753766811902755,-2.1871310699195381],[-3.9142135623730949,-3.9142135623730949],[-1.8042260651806146,-3.23606797749979]])
+ m=MEDCouplingUMesh("mesh",2)
+ m.allocateCells()
+ m.setCoords(coo)
+ m.insertNextCell(NORM_TRI6,[1,2,0,5,4,3])
+ m.insertNextCell(NORM_TRI6,[8,6,0,12,7,13])
+ m.insertNextCell(NORM_TRI6,[11,9,10,16,14,15])
+ self.assertTrue(m.conformize2D(eps).isEqual(DataArrayInt([0])))
+ self.assertTrue(m.getCoords().isEqual(DataArrayDouble([2.,2.,2.,-6.,10.,-2.,-2.,-2.,6.,0.,6.,-4.,2.,7.,2.,4.5,-1.4641016151377544,0.,-1.950753362380551,-1.3742621398390762,-7.,-3.,-0.8284271247461898,-4.82842712474619,0.2679491924311228,3.5,8.881784197001252e-16,1.4641016151377548,-4.4753766811902755,-2.187131069919538,-3.914213562373095,-3.914213562373095,-1.8042260651806146,-3.236067977499789,-1.7705659643687133,-0.6647725630649153,0.46926627053963865,-5.695518130045146],19,2),1e-12))
+ self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([32,1,2,0,8,9,11,5,4,13,17,16,18,6,8,6,0,12,7,13,6,11,9,10,16,14,15])))
+ self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,13,20,27])))
+ pass
+
+ def testSwigExtendedSlice1(self):
+ d=DataArrayInt([5,6,7])
+ self.assertTrue(d[2:].isEqual(DataArrayInt([7])))
+ self.assertTrue(d[3:].isEqual(DataArrayInt([])))
+ try:
+ d[4:]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ d=DataArrayInt([5,6,7,8])
+ self.assertEqual(d[-1],8)
+ self.assertEqual(d[-4],5)
+ try:
+ d[-5]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ self.assertTrue(d[2::-1].isEqual(DataArrayInt([7,6,5])))
+ self.assertTrue(d[0::-1].isEqual(DataArrayInt([5])))
+ self.assertTrue(d[-1::-1].isEqual(DataArrayInt([8,7,6,5])))
+ self.assertTrue(d[-3::-1].isEqual(DataArrayInt([6,5])))
+ self.assertTrue(d[-5::-1].isEqual(DataArrayInt([])))
+ try:
+ d[-6::-1]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ d=DataArrayInt([])
+ self.assertTrue(d[0:].isEqual(DataArrayInt([])))
+ #
+ d=DataArrayDouble([5,6,7])
+ self.assertTrue(d[2:].isEqual(DataArrayDouble([7]),1e-12))
+ self.assertTrue(d[3:].isEqual(DataArrayDouble([]),1e-12))
+ try:
+ d[4:]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ d=DataArrayDouble([5,6,7,8])
+ self.assertAlmostEqual(d[-1],8.,12)
+ self.assertAlmostEqual(d[-4],5.,12)
+ try:
+ d[-5]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ self.assertTrue(d[2::-1].isEqual(DataArrayDouble([7,6,5]),1e-12))
+ self.assertTrue(d[0::-1].isEqual(DataArrayDouble([5]),1e-12))
+ self.assertTrue(d[-1::-1].isEqual(DataArrayDouble([8,7,6,5]),1e-12))
+ self.assertTrue(d[-3::-1].isEqual(DataArrayDouble([6,5]),1e-12))
+ self.assertTrue(d[-5::-1].isEqual(DataArrayDouble([]),1e-12))
+ try:
+ d[-6::-1]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ d=DataArrayDouble([])
+ self.assertTrue(d[0:].isEqual(DataArrayDouble([]),1e-12))
+ pass
+
+ def testSwig2Hexa27GP1(self):
+ """ This test focused on shape functions of hexa27.
+ """
+ coo=DataArrayDouble([[0.,2.,2.],[0.,0.,2.],[2.,0.,2.],[2.,2.,2.],[0.,2.,0.],[0.,0.,0.],[2.,0.,0.],[2.,2.,0.], [0.,1.,2.],[1.,0.,2.],[2.,1.,2.],[1.,2.,2.], [0.,1.,0.],[1.,0.,0.],[2.,1.,0.],[1.,2.,0.], [0.,2.,1.],[0.,0.,1.],[2.,0.,1.],[2.,2.,1.], [1.,1.,2.], [0.,1.,1.],[1.,0.,1.],[2.,1.,1.],[1.,2.,1.], [1.,1.,0.], [1.,1.,1.]])
+ m=MEDCouplingUMesh("mesh",3) ; m.setCoords(coo)
+ m.allocateCells()
+ # the cell description is exactly those described in the description of HEXA27 in MED file 3.0.7 documentation
+ m.insertNextCell(NORM_HEXA27,[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])
+ refCoo=[-1.,-1.,-1.,-1.,1.,-1.,1.,1.,-1.,1.,-1.,-1.,-1.,-1.,1.,-1.,1.,1.,1.,1.,1.,1.,-1.,1.,-1.,0.,-1.,0.,1.,-1.,1.,0.,-1.,0.,-1.,-1.,-1.,0.,1.,0.,1.,1.,1.,0.,1.,0.,-1.,1.,-1.,-1.,0.,-1.,1.,0.,1.,1.,0.,1.,-1.,0.,0.,0.,-1.,-1.,0.,0.,0.,1.,0.,1.,0.,0.,0.,-1.,0.,0.,0.,1.,0.,0.,0.]
+ weights=[0.1714677640603571,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.43895747599451346,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.43895747599451346,0.27434842249657115,0.43895747599451346,0.7023319615912209,0.43895747599451346,0.27434842249657115,0.43895747599451346,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.43895747599451346,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.1714677640603571]
+ gCoords=[-0.774596669241483,-0.774596669241483,-0.774596669241483,-0.774596669241483,-0.774596669241483,0.0,-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.0,-0.774596669241483,-0.774596669241483,0.0,0.0,-0.774596669241483,0.0,0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.774596669241483,0.0,-0.774596669241483,-0.774596669241483,0.0,-0.774596669241483,0.0,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,-0.774596669241483,0.0,0.0,0.0,0.0,0.0,0.774596669241483,0.0,0.774596669241483,-0.774596669241483,0.0,0.774596669241483,0.0,0.0,0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.0,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,0.0,0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,0.0,0.774596669241483,0.774596669241483,0.774596669241483]
+ fGauss=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fGauss.setName("fGauss")
+ fGauss.setMesh(m)
+ fGauss.setGaussLocalizationOnType(NORM_HEXA27,refCoo,gCoords,weights)
+ arr=DataArrayDouble(fGauss.getNumberOfTuplesExpected()) ; arr.iota()
+ fGauss.setArray(arr)
+ arrOfDisc=fGauss.getLocalizationOfDiscr()
+ # the test is here
+ self.assertTrue(arrOfDisc.isEqual(DataArrayDouble([0.2254033307585172,1.7745966692414836,1.7745966692414834,0.22540333075851715,1.7745966692414834,1.,0.22540333075851715,1.7745966692414836,0.22540333075851715,0.22540333075851715,1.,1.7745966692414834,0.2254033307585171,1.,1.,0.22540333075851715,1.0000000000000002,0.2254033307585171,0.22540333075851715,0.22540333075851715,1.7745966692414838,0.22540333075851715,0.22540333075851715,1.,0.22540333075851715,0.22540333075851715,0.22540333075851715,1.,1.7745966692414832,1.7745966692414834,1.,1.774596669241483,1.,1.0000000000000002,1.7745966692414832,0.22540333075851712,1.,1.,1.774596669241483,1.,1.,1.,1.,1.,0.2254033307585171,1.,0.22540333075851715,1.7745966692414834,1.,0.2254033307585171,1.,1.0000000000000002,0.22540333075851715,0.2254033307585171,1.7745966692414834,1.7745966692414834,1.7745966692414836,1.7745966692414832,1.7745966692414834,1.0000000000000002,1.7745966692414834,1.7745966692414836,0.22540333075851712,1.7745966692414832,1.,1.7745966692414834,1.774596669241483,1.,1.,1.7745966692414832,1.0000000000000002,0.22540333075851712,1.7745966692414836,0.22540333075851715,1.7745966692414836,1.7745966692414832,0.22540333075851715,1.,1.7745966692414836,0.22540333075851715,0.22540333075851715],27,3),1e-12))
+ #
+ weights=27*[1]
+ gCoords=refCoo
+ fGauss.setGaussLocalizationOnType(NORM_HEXA27,refCoo,gCoords,weights)
+ arrOfDisc2=fGauss.getLocalizationOfDiscr()
+ self.assertTrue(arrOfDisc2.isEqual(coo,1e-12))
+ pass
+
+ def testSwig2Pyra13GP1(self):
+ coo=DataArrayDouble([[0.,2.,0.],[2.,2.,0.],[2.,0.,0.],[0.,0.,0.],[1.,1.,2.],[1.,2.,0.],[2.,1.,0.],[1.,0.,0.],[0.,1.,0.],[0.5,1.5,1.],[1.5,1.5,1.],[1.5,0.5,1.],[0.5,0.5,1.]])
+ m=MEDCouplingUMesh("mesh",3) ; m.setCoords(coo)
+ m.allocateCells()
+ # the cell description is exactly those described in the description of PYRA13 in MED file 3.0.7 documentation
+ m.insertNextCell(NORM_PYRA13,[0,1,2,3,4,5,6,7,8,9,10,11,12])
+ refCoords=[1.,0.,0.,0.,-1.,0.,-1.,0.,0.,0.,1.,0.,0.,0.,1.,0.5,-0.5,0.,-0.5,-0.5,0.,-0.5,0.5,0.,0.5,0.5,0.,0.5,0.,0.5,0.,-0.5,0.5,-0.5,0.,0.5,0.,0.5,0.5]
+ gaussCoords=[0.,0.,0.5,0.21210450275,0.21210450275,0.5,-0.21210450275,0.21210450275,0.5,-0.21210450275,-0.21210450275,0.5,0.21210450275,-0.21210450275,0.5,0.,0.,0.07579099449999999,0.,0.,0.9242090055000001,0.5394929090572634,0.,0.17359176399999998,0.,0.5394929090572634,0.17359176399999998,-0.5394929090572634,0.,0.17359176399999998,0.,-0.5394929090572634,0.17359176399999998,0.1133235629427366,0.,0.826408236,0.,0.1133235629427366,0.826408236,-0.1133235629427366,0.,0.826408236,0.,-0.1133235629427366,0.826408236,0.5826406005183961,0.5826406005183961,-0.053206449499999975,-0.5826406005183961,0.5826406005183961,-0.053206449499999975,-0.5826406005183961,-0.5826406005183961,-0.053206449499999975,0.5826406005183961,-0.5826406005183961,-0.053206449499999975,0.5532064495,0.,0.5,0.,0.5532064495,0.5,-0.5532064495,0.,0.5,0.,-0.5532064495,0.5,-0.029434151018396033,-0.029434151018396033,1.0532064495,0.029434151018396033,-0.029434151018396033,1.0532064495,0.029434151018396033,0.029434151018396033,1.0532064495,-0.029434151018396033,0.029434151018396033,1.0532064495]
+ weights=[0.0492545926875,0.031210562625,0.031210562625,0.031210562625,0.031210562625,0.10663554205740113,0.0007171281994273535,0.0816994048010844,0.0816994048010844,0.0816994048010844,0.0816994048010844,0.0036048554264914074,0.0036048554264914074,0.0036048554264914074,0.0036048554264914074,0.008958181586640837,0.008958181586640837,0.008958181586640837,0.008958181586640837,0.002018983875,0.002018983875,0.002018983875,0.002018983875,2.286237794882217e-05,2.286237794882217e-05,2.286237794882217e-05,2.286237794882217e-05]
+ fGauss=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fGauss.setName("fGauss")
+ fGauss.setMesh(m)
+ fGauss.setGaussLocalizationOnType(NORM_PYRA13,refCoords,gaussCoords,weights)
+ arr=DataArrayDouble(fGauss.getNumberOfTuplesExpected()) ; arr.iota()
+ fGauss.setArray(arr)
+ arrOfDisc=fGauss.getLocalizationOfDiscr()
+ # the test is here
+ self.assertTrue(arrOfDisc.isEqual(DataArrayDouble([1.,1.,1.,0.5757909945,1.,1.,1.,0.5757909945,1.,1.4242090055,1.,1.,1.,1.4242090055,1.,1.,1.,0.151581989,1.,1.,1.848418011,0.4605070909427367,1.5394929090572635,0.347183528,0.4605070909427367,0.4605070909427367,0.347183528,1.5394929090572638,0.4605070909427366,0.347183528,1.5394929090572635,1.5394929090572638,0.347183528,0.8866764370572636,1.1133235629427367,1.652816472,0.8866764370572636,0.8866764370572636,1.652816472,1.1133235629427367,0.8866764370572636,1.652816472,1.1133235629427365,1.1133235629427367,1.652816472,-0.16528120103679209,1.,-0.106412899,1.,-0.1652812010367921,-0.106412899,2.1652812010367914,1.,-0.106412899,1.,2.165281201036791,-0.106412899,0.4467935505,1.5532064495,1.,0.4467935505,0.4467935505,1.,1.5532064495,0.4467935505,1.,1.5532064495,1.5532064495,1.,1.0588683020367922,1.,2.106412899,1.,1.0588683020367922,2.106412899,0.9411316979632077,1.,2.106412899,1.,0.9411316979632078,2.106412899],27,3),1e-12))
+ #
+ weights=13*[1]
+ gaussCoords=refCoords[:] ; gaussCoords[14]=0.9999999999999 # change z of point #4 0.999... instead of 1. because with shape function it leads to division by 0. !
+ fGauss.setGaussLocalizationOnType(NORM_PYRA13,refCoords,gaussCoords,weights)
+ arrOfDisc2=fGauss.getLocalizationOfDiscr()
+ self.assertTrue(arrOfDisc2.isEqual(coo,1e-10)) # be less exigent 1e-10 instead of 1e-12 due to shape function sensitivity arount 0.,0.,1. !
+ pass
+
+ def testSwig2Tri7GP1(self):
+ coo=DataArrayDouble([[0,0],[0,2],[2,0],[0,1],[1,1],[1,0],[0.6666666666666667,0.6666666666666667]])
+ m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo)
+ m.allocateCells()
+ # the cell description is exactly those described in the description of TRI7 in MED file 3.0.7 documentation
+ m.insertNextCell(NORM_TRI7,range(7))
+ refCoords=[0.,0.,1.,0.,0.,1.,0.5,0.,0.5,0.5,0.,0.5,0.3333333333333333,0.3333333333333333]
+ gaussCoords=[0.3333333333333333,0.3333333333333333,0.470142064105115,0.470142064105115,0.05971587178977,0.470142064105115,0.470142064105115,0.05971587178977,0.101286507323456,0.101286507323456,0.797426985353088,0.101286507323456,0.101286507323456,0.797426985353088]
+ weights=[0.062969590272413,0.062969590272413,0.062969590272413,0.066197076394253,0.066197076394253,0.066197076394253,0.1125]
+ fGauss=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fGauss.setName("fGauss")
+ fGauss.setMesh(m)
+ fGauss.setGaussLocalizationOnType(NORM_TRI7,refCoords,gaussCoords,weights)
+ arr=DataArrayDouble(fGauss.getNumberOfTuplesExpected()) ; arr.iota()
+ fGauss.setArray(arr)
+ arrOfDisc=fGauss.getLocalizationOfDiscr()
+ self.assertTrue(arrOfDisc.isEqual(DataArrayDouble([0.666666666666667,0.666666666666667,0.9402841282102293,0.9402841282102293,0.9402841282102299,0.11943174357954002,0.11943174357953992,0.9402841282102299,0.20257301464691194,0.20257301464691196,0.20257301464691205,1.5948539707061757,1.5948539707061757,0.20257301464691202],7,2),1e-12))
+ #
+ weights=7*[1]
+ gaussCoords=refCoords
+ fGauss.setGaussLocalizationOnType(NORM_TRI7,refCoords,gaussCoords,weights)
+ arrOfDisc2=fGauss.getLocalizationOfDiscr()
+ self.assertTrue(arrOfDisc2.isEqual(coo,1e-12))
+ pass
+
def setUp(self):
pass
pass
%newobject ParaMEDMEM::MEDCouplingUMesh::ComputeSpreadZoneGradually;
%newobject ParaMEDMEM::MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
+%newobject ParaMEDMEM::MEDCouplingUMesh::conformize2D;
%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
%newobject ParaMEDMEM::MEDCouplingUMesh::sortCellsInMEDFileFrmt;
%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForMEDFileFrmt;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildUnionOf3DMesh;
%newobject ParaMEDMEM::MEDCouplingUMesh::getBoundingBoxForBBTreeFast;
%newobject ParaMEDMEM::MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getBoundingBoxForBBTree1DQuadratic;
%newobject ParaMEDMEM::MEDCouplingUMeshCellByTypeEntry::__iter__;
%newobject ParaMEDMEM::MEDCouplingUMeshCellEntry::__iter__;
%newobject ParaMEDMEM::MEDCoupling1GTUMesh::New;
std::string reprConnectivityOfThis() const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *buildSetInstanceFromThis(int spaceDim) const throw(INTERP_KERNEL::Exception);
//tools
+ DataArrayInt *conformize2D(double eps) throw(INTERP_KERNEL::Exception);
void shiftNodeNumbersInConn(int delta) throw(INTERP_KERNEL::Exception);
std::vector<bool> getQuadraticStatus() const throw(INTERP_KERNEL::Exception);
DataArrayInt *findCellIdsOnBoundary() const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildUnionOf3DMesh() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getBoundingBoxForBBTreeFast() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getBoundingBoxForBBTree2DQuadratic(double arcDetEps=1e-12) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getBoundingBoxForBBTree1DQuadratic(double arcDetEps=1e-12) const throw(INTERP_KERNEL::Exception);
+ int split2DCells(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *midOpt=0, const DataArrayInt *midOptI=0) throw(INTERP_KERNEL::Exception);
static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception);
static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
arrIndxIn->checkAllocated();
if(arrIndxIn->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("ExtractFromIndexedArrays2 (wrap) : number of components of last argument must be equal to one !");
- if(PySlice_GetIndices(sliC,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("ExtractFromIndexedArrays2 (wrap) : Invalid slice regarding nb of elements !");
+ GetIndicesOfSlice(sliC,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArrays2 (wrap) : Invalid slice regarding nb of elements !");
DataArrayInt *arrOut=0,*arrIndexOut=0;
MEDCouplingUMesh::ExtractFromIndexedArrays2(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
PyObject *ret=PyTuple_New(2);
#include "InterpKernelAutoPtr.hxx"
+/*!
+ * This method is an extention of PySlice_GetIndices but less
+ * open than PySlice_GetIndicesEx that accepts too many situations.
+ */
+void GetIndicesOfSlice(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
+{
+ int ret(PySlice_GetIndices(slice,length,start,stop,step));
+ if(ret==0)
+ return ;
+ if(*step>0 && *start==*stop && length==*start)
+ return ;
+ throw INTERP_KERNEL::Exception(msgInCaseOfFailure);
+}
+
+/*!
+ * This method allows to retrieve slice info from \a slice.
+ */
+void GetIndicesOfSliceExplicitely(PySliceObject *slice, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
+{
+ int ret(PySlice_GetIndices(slice,std::numeric_limits<int>::max(),start,stop,step));
+ if(ret==0)
+ {
+ if(*start!=std::numeric_limits<int>::max() && *stop!=std::numeric_limits<int>::max())
+ return ;
+ std::ostringstream oss;
+ oss << msgInCaseOfFailure << " The input slice contains some unknowns that can't be determined in static method ! The input slice must be explicit here !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ throw INTERP_KERNEL::Exception(msgInCaseOfFailure);
+}
+
+int InterpreteNegativeInt(int val, int nbelem)
+{
+ if(val<0)
+ {
+ int newVal(nbelem+val);
+ if(newVal<0)
+ {
+ std::ostringstream oss; oss << "interpreteNegativeInt : request for negative int=" << val << " but number of elems is equal to " << nbelem << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return newVal;
+ }
+ else
+ return val;
+}
+
#ifdef WITH_NUMPY
#include <numpy/arrayobject.h>
{
ret->useArray(reinterpret_cast<const T *>(data),true,ParaMEDMEM::C_DEALLOC,sz0,sz1);
PyObject *ref=PyWeakref_NewRef(reinterpret_cast<PyObject *>(eltOwning),NULL);
- void **objs=new void *[2]; objs[0]=ref; objs[1]=(void*) ParaMEDMEM::MemArray<T>::CDeallocator;
+ typename ParaMEDMEM::MemArray<T>::Deallocator tmp(ParaMEDMEM::MemArray<T>::CDeallocator);
+ void **tmp2(reinterpret_cast<void**>(&tmp));
+ void **objs=new void *[2]; objs[0]=ref; objs[1]=*tmp2;
mma.setParameterForDeallocator(objs);
mma.setSpecificDeallocator(numarrdeal);
}
npy_intp dim[2];
dim[0]=(npy_intp)self->getNumberOfTuples(); dim[1]=nbComp;
const T *bg=self->getConstPointer();
- PyObject *ret=PyArray_SimpleNewFromData(nbDims,dim,npyObjectType,const_cast<T *>(bg));
+ PyObject *ret(PyArray_SimpleNewFromData(nbDims,dim,npyObjectType,const_cast<T *>(bg)));
if(mem.isDeallocatorCalled())
{
if(mem.getDeallocator()!=numarrdeal)
{// case for the first call of toNumPyArray
- PyObject *ref=PyWeakref_NewRef(ret,NULL);
- void **objs=new void *[2]; objs[0]=ref; objs[1]=(void*) mem.getDeallocator();
+ PyObject *ref(PyWeakref_NewRef(ret,NULL));
+ typename ParaMEDMEM::MemArray<T>::Deallocator tmp(mem.getDeallocator());
+ void **tmp2(reinterpret_cast<void**>(&tmp));
+ void **objs=new void *[2]; objs[0]=reinterpret_cast<void*>(ref); objs[1]=*tmp2;
mem.setParameterForDeallocator(objs);
mem.setSpecificDeallocator(numarrdeal);
return ret;
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
- if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
- if(nbelem!=0 || strt!=0 || stp!=0)
- {
- std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elements is : " << nbelem;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ GetIndicesOfSlice(oC,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
p.first=strt;
p.second.first=stp;
p.second.second=step;
throw INTERP_KERNEL::Exception(msg);
}
+/*!
+ * Idem than convertObjToPossibleCpp2
+ */
+static void convertObjToPossibleCpp2WithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, ParaMEDMEM::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+{
+ convertObjToPossibleCpp2(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp);
+ if(sw==1)
+ {
+ iTyypp=InterpreteNegativeInt(iTyypp,nbelem);
+ }
+}
+
/*!
* if python int -> cpp int sw=1
* if python tuple[int] -> cpp vector<int> sw=2
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
- if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
- if(nbelem!=0 || strt!=0 || stp!=0)
- {
- std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elements is : " << nbelem;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ GetIndicesOfSlice(oC,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
p.first=strt;
p.second.first=stp;
p.second.second=step;
{
if(!PyTuple_Check(value))
{
- convertObjToPossibleCpp2(value,nbTuple,sw,it,vt,pt,dt);
+ convertObjToPossibleCpp2WithNegIntInterp(value,nbTuple,sw,it,vt,pt,dt);
return ;
}
else
throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
PyObject *ob0=PyTuple_GetItem(value,0);
int sw1,sw2;
- convertObjToPossibleCpp2(ob0,nbTuple,sw1,it,vt,pt,dt);
+ convertObjToPossibleCpp2WithNegIntInterp(ob0,nbTuple,sw1,it,vt,pt,dt);
PyObject *ob1=PyTuple_GetItem(value,1);
- convertObjToPossibleCpp2(ob1,nbCompo,sw2,ic,vc,pc,dc);
+ convertObjToPossibleCpp2WithNegIntInterp(ob1,nbCompo,sw2,ic,vc,pc,dc);
sw=4*sw2+sw1;
}
}
fff.setGaussLocalizationOnCells([6,7],[-1.,-1.,-1.,-1.,1.,-1.,1.,1.,-1.,1.,-1.,-1.,-1.,-1.,1.,-1.,1.,1.,1.,1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,-0.577350269189626,-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,0.577350269189626],[1.,1.,1.,1.,1.,1.,1.,1.])
return MEDCouplingFieldTemplate(fff)
+ def buildCircle(self, center_X, center_Y, radius):
+ from cmath import rect
+ from math import pi
+
+ c = [rect(radius, i*pi/4.0) for i in range(8)]
+ coords = [c[-1].real,c[-1].imag, c[3].real,c[3].imag,
+ c[5].real,c[5].imag, c[1].real,c[1].imag]
+ connec = range(4)
+ baseMesh = MEDCouplingUMesh.New("circle", 2)
+ baseMesh.allocateCells(1)
+ meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+ meshCoords += (center_X, center_Y)
+ baseMesh.setCoords(meshCoords)
+
+ baseMesh.insertNextCell(NORM_QPOLYG, connec)
+ baseMesh.finishInsertingCells()
+ return baseMesh
+
build2DTargetMesh_1=classmethod(build2DTargetMesh_1)
build2DSourceMesh_1=classmethod(build2DSourceMesh_1)
build3DTargetMesh_1=classmethod(build3DTargetMesh_1)
buildFieldOnGauss_2=classmethod(buildFieldOnGauss_2)
buildFieldOnGauss_3=classmethod(buildFieldOnGauss_3)
buildFieldOnGauss_4=classmethod(buildFieldOnGauss_4)
+ buildCircle=classmethod(buildCircle)
pass
+
+
+
throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !");
int a,b;
DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,self->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !");
int a,b;
DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : the input slice contains some unknowns that can't be determined in static method !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
}
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
- if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
- throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice contains some unknowns that can't be determined in static method !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,self->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
}
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,self->getNumberOfTuples(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
}
#endif
else
throw INTERP_KERNEL::Exception(msg.c_str());
+ throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
}
DataArrayDouble(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) throw(INTERP_KERNEL::Exception)
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
const double *pt=self->getConstPointer();
int nbc=self->getNumberOfCompo();
- convertObjToPossibleCpp2(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
std::pair<int, std::pair<int,int> > slic;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
double *pt=self->getPointer();
- convertObjToPossibleCpp2(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
switch(sw2)
{
case 1:
#endif
else
throw INTERP_KERNEL::Exception(msg.c_str());
+ throw INTERP_KERNEL::Exception(msg.c_str());//to make g++ happy
}
DataArrayInt(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception)
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- if(PySlice_GetIndices(sly,std::numeric_limits<int>::max(),&strt,&stp,&step)!=0)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
+ GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step);
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
const int *pt=self->getConstPointer();
int nbc=self->getNumberOfCompo();
- convertObjToPossibleCpp2(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
std::pair<int, std::pair<int,int> > slic;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
int *pt=self->getPointer();
- convertObjToPossibleCpp2(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbc,sw2,singleVal,multiVal,slic,daIntTyypp);
switch(sw2)
{
case 1:
std::vector<int> stdvecTyyppArr;
std::pair<int, std::pair<int,int> > sTyyppArr;
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
- convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
switch(sw)
{
case 1:
ParaMEDMEM::DataArrayInt *daIntTyypp=0;
int nbOfCompo=self->getNumberOfComponents();
int nbOfTuples=self->getNumberOfTuples();
- convertObjToPossibleCpp2(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
+ convertObjToPossibleCpp2WithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
int sw2;
char vc; std::string sc; std::vector<std::string> vsc; DataArrayChar *dacc=0;
convertObjToPossibleCpp6(value,sw2,vc,sc,vsc,dacc);
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-#
from MEDCoupling import *
class MEDCouplingNumPyTest(unittest.TestCase):
- @unittest.skipUnless(MEDCouplingHasNumPyBindings() and architecture()[0]=="64bit","requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test1(self):
sz=20
a=array(0,dtype=int32)
int nullifiedTinyCoeffInCrudeMatrix(double scaleFactor) throw(INTERP_KERNEL::Exception);
double getMaxValueInCrudeMatrix() const throw(INTERP_KERNEL::Exception);
int getNumberOfColsOfMatrix() const throw(INTERP_KERNEL::Exception);
+ static std::string BuildMethodFrom(const std::string& meth1, const std::string& meth2) throw(INTERP_KERNEL::Exception);
%extend
{
PyObject *getCrudeMatrix() const throw(INTERP_KERNEL::Exception)
delta=m0-m1t
self.assertTrue(DataArrayDouble(delta.data).isUniform(0.,1e-17))
pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy")
+ def testNonConformWithRemapper_1(self):
+ coo=DataArrayDouble([-0.396700000780411,-0.134843245350081,-0.0361311386958691,-0.407550009429364,-0.13484324535008,-0.0361311386958923,-0.396700000780411,-0.132191446077668,-0.0448729493559049,-0.407550009429364,-0.132191446077666,-0.0448729493559254,-0.396700000780411,-0.128973582738749,-0.0534226071577727,-0.407550009429364,-0.128973582738747,-0.0534226071577904,-0.396700000780411,-0.128348829636458,-0.0346583696473619,-0.407550009429364,-0.128348829636457,-0.0346583696473822,-0.396700000780411,-0.125874740261886,-0.0430683597970123,-0.407550009429364,-0.125874740261885,-0.0430683597970302,-0.396700000780411,-0.122905344829122,-0.051310216195766,-0.407550009429364,-0.12290534482912,-0.0513102161957814],12,3)
+ conn=DataArrayInt([2,9,3,11,2,3,5,11,2,8,9,11,2,10,8,11,2,5,4,11,2,4,10,11,3,0,1,6,3,1,7,6,3,2,0,6,3,8,2,6,3,7,9,6,3,9,8,6])
+ m=MEDCoupling1SGTUMesh("mesh",NORM_TETRA4)
+ m.setNodalConnectivity(conn)
+ m.setCoords(coo)
+ # m is ready
+ m1,d,di,rd,rdi=m.buildUnstructured().buildDescendingConnectivity()
+ rdi2=rdi.deltaShiftIndex()
+ cellIds=rdi2.getIdsEqual(1)
+ skinAndNonConformCells=m1[cellIds]
+ skinAndNonConformCells.zipCoords() # at this point skinAndNonConformCells contains non conform cells and skin cells. Now trying to split them in two parts.
+ #
+ rem=MEDCouplingRemapper()
+ rem.setMaxDistance3DSurfIntersect(1e-12)
+ rem.setMinDotBtwPlane3DSurfIntersect(0.99)# this line is important it is to tell to remapper to select only cells with very close orientation
+ rem.prepare(skinAndNonConformCells,skinAndNonConformCells,"P0P0")
+ mat=rem.getCrudeCSRMatrix()
+ indptr=DataArrayInt(mat.indptr)
+ indptr2=indptr.deltaShiftIndex()
+ cellIdsOfNonConformCells=indptr2.getIdsNotEqual(1)
+ cellIdsOfSkin=indptr2.getIdsEqual(1)
+ self.assertTrue(cellIdsOfSkin.isEqual(DataArrayInt([1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,23])))
+ self.assertTrue(cellIdsOfNonConformCells.isEqual(DataArrayInt([0,4,18,22])))
+ pass
+
+ def test3D1DOnP1P0_1(self):
+ """ This test focused on P1P0 interpolation with a source with meshDim=1 spaceDim=3 and a target with meshDim=3.
+ This test has revealed a bug in remapper. A reverse matrix is computed so a reverse method should be given in input.
+ """
+ target=MEDCouplingCMesh()
+ arrX=DataArrayDouble([0,1]) ; arrY=DataArrayDouble([0,1]) ; arrZ=DataArrayDouble(11) ; arrZ.iota()
+ target.setCoords(arrX,arrY,arrZ)
+ target=target.buildUnstructured() ; target.setName("TargetSecondaire")
+ #
+ sourceCoo=DataArrayDouble([(0.5,0.5,0.1),(0.5,0.5,1.2),(0.5,0.5,1.6),(0.5,0.5,1.8),(0.5,0.5,2.43),(0.5,0.5,2.55),(0.5,0.5,4.1),(0.5,0.5,4.4),(0.5,0.5,4.9),(0.5,0.5,5.1),(0.5,0.5,7.6),(0.5,0.5,7.7),(0.5,0.5,8.2),(0.5,0.5,8.4),(0.5,0.5,8.6),(0.5,0.5,8.8),(0.5,0.5,9.2),(0.5,0.5,9.6),(0.5,0.5,11.5)])
+ source=MEDCoupling1SGTUMesh("SourcePrimaire",NORM_SEG2)
+ source.setCoords(sourceCoo)
+ source.allocateCells()
+ for i in xrange(len(sourceCoo)-1):
+ source.insertNextCell([i,i+1])
+ pass
+ source=source.buildUnstructured()
+ fsource=MEDCouplingFieldDouble(ON_NODES) ; fsource.setName("field")
+ fsource.setMesh(source)
+ arr=DataArrayDouble(len(sourceCoo)) ; arr.iota(0.7) ; arr*=arr
+ fsource.setArray(arr)
+ fsource.setNature(ConservativeVolumic)
+ #
+ rem=MEDCouplingRemapper()
+ rem.setIntersectionType(PointLocator)
+ rem.prepare(source,target,"P1P0")
+ f2Test=rem.transferField(fsource,-27)
+ self.assertEqual(f2Test.getName(),fsource.getName())
+ self.assertEqual(f2Test.getMesh().getHiddenCppPointer(),target.getHiddenCppPointer())
+ expArr=DataArrayDouble([0.49,7.956666666666667,27.29,-27,59.95666666666667,94.09,-27,125.69,202.89,296.09])
+ self.assertTrue(f2Test.getArray().isEqual(expArr,1e-12))
+ f2Test=rem.reverseTransferField(f2Test,-36)
+ self.assertEqual(f2Test.getName(),fsource.getName())
+ self.assertEqual(f2Test.getMesh().getHiddenCppPointer(),source.getHiddenCppPointer())
+ expArr2=DataArrayDouble([0.49,7.956666666666667,7.956666666666667,7.956666666666667,27.29,27.29,59.95666666666667,59.95666666666667,59.95666666666667,94.09,125.69,125.69,202.89,202.89,202.89,202.89,296.09,296.09,-36.])
+ self.assertTrue(f2Test.getArray().isEqual(expArr2,1e-12))
+ pass
def build2DSourceMesh_1(self):
sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
return contentNotNull()->getFileName();
}
-std::string MEDFileFieldGlobsReal::getFileName2() const
-{
- return contentNotNull()->getFileName2();
-}
-
/*!
* Returns a localization object by its name.
* \param [in] locName - the name of the localization of interest.
/*!
* This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
- * This method does not release arrays set outside the context of a MED file.
+ * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
+ * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
*
- * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
+ * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
*/
void MEDFileAnyTypeField1TS::unloadArrays()
{
contentNotNullBase()->unloadArrays();
}
+/*!
+ * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
+ * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
+ * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
+ *
+ * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
+ */
+void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
+{
+ if(!getFileName().empty())
+ contentNotNullBase()->unloadArrays();
+}
+
void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
{
int nbComp=getNumberOfComponents();
*/
MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
{
- if(getFileName2().empty())
+ if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
*/
MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
{
- if(getFileName2().empty())
+ if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
*/
MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
{
- if(getFileName2().empty())
+ if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
{
- if(getFileName2().empty())
+ if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
*/
MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
{
- if(getFileName2().empty())
+ if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
*/
MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
{
- if(getFileName2().empty())
+ if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
/*!
* This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
- * This method does not release arrays set outside the context of a MED file.
+ * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
+ * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
*
- * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
+ * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
*/
void MEDFileAnyTypeFieldMultiTS::unloadArrays()
{
contentNotNullBase()->unloadArrays();
}
+/*!
+ * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
+ * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
+ * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
+ *
+ * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
+ */
+void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
+{
+ if(!getFileName().empty())
+ contentNotNullBase()->unloadArrays();
+}
+
std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
{
std::ostringstream oss;
/*!
* This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
- * This method does not release arrays set outside the context of a MED file.
+ * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
+ * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
*
- * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
+ * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
*/
void MEDFileFields::unloadArrays()
{
}
}
+/*!
+ * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
+ * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
+ * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
+ *
+ * \sa MEDFileFields::loadArraysIfNecessary
+ */
+void MEDFileFields::unloadArraysWithoutDataLoss()
+{
+ if(!getFileName().empty())
+ unloadArrays();
+}
+
std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
{
std::vector<std::string> ret;
return getFieldAtPos(getPosFromFieldName(fieldName));
}
+/*!
+ * This method removes, if any, fields in \a this having no time steps.
+ * If there is one or more than one such field in \a this true is returned and those fields will not be referenced anymore in \a this.
+ *
+ * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
+ */
+bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
+{
+ std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ {
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
+ if(elt)
+ {
+ if(elt->getNumberOfTS()>0)
+ newFields.push_back(*it);
+ }
+ }
+ if(_fields.size()==newFields.size())
+ return false;
+ _fields=newFields;
+ return true;
+}
+
/*!
* This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
* This method can be seen as a filter applied on \a this, that returns an object containing
int getNbOfGaussPtPerCell(int locId) const;
int getLocalizationId(const std::string& loc) const;
std::string getFileName() const { return _file_name; }
- std::string getFileName2() const { return _file_name; }
const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
const DataArrayInt *getProfileFromId(int pflId) const;
MEDLOADER_EXPORT int getNbOfGaussPtPerCell(int locId) const;
MEDLOADER_EXPORT int getLocalizationId(const std::string& loc) const;
MEDLOADER_EXPORT std::string getFileName() const;
- MEDLOADER_EXPORT std::string getFileName2() const;
MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
MEDLOADER_EXPORT MEDFileFieldLoc& getLocalizationFromId(int locId);
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();
MEDLOADER_EXPORT void unloadArrays();
+ MEDLOADER_EXPORT void unloadArraysWithoutDataLoss();
MEDLOADER_EXPORT std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > splitComponents() const;
MEDLOADER_EXPORT std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > splitDiscretizations() const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TS *deepCpy() const;
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();
MEDLOADER_EXPORT void unloadArrays();
+ MEDLOADER_EXPORT void unloadArraysWithoutDataLoss();
MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
MEDLOADER_EXPORT void writeLL(med_idt fid) const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();
MEDLOADER_EXPORT void unloadArrays();
+ MEDLOADER_EXPORT void unloadArraysWithoutDataLoss();
MEDLOADER_EXPORT int getNumberOfFields() const;
MEDLOADER_EXPORT std::vector< std::pair<int,int> > getCommonIterations(bool& areThereSomeForgottenTS) const;
MEDLOADER_EXPORT std::vector<std::string> getFieldsNames() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const;
MEDLOADER_EXPORT MEDFileFields *buildSubPart(const int *startIds, const int *endIds) const;
+ MEDLOADER_EXPORT bool removeFieldsWithoutAnyTimeStep();
MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const;
MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
MEDLOADER_EXPORT MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
const unsigned char MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH]=
{1,3,21,5,9,7,22,34,23,28,255,255,255,255,10,14,13,255,12,255,24,255,16,27,255,26,255,29,255,255,25,42,36,4};
+const unsigned char MEDMeshMultiLev::HEXA27_PERM_ARRAY[27]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,24,22,21,23,20,25,26};
+
const char MEDFileField1TSStructItem2::NEWLY_CREATED_PFL_NAME[]="???";
MEDFileMeshStruct *MEDFileMeshStruct::New(const MEDFileMesh *mesh)
throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : internal error !");
if(scur)
{
- int nnpc(scur->getNumberOfNodesPerCell());
- for(int i=0;i<curNbCells;i++,connPtr+=nnpc)
+ if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_HEXA27)
+ {
+ int nnpc(scur->getNumberOfNodesPerCell());
+ for(int i=0;i<curNbCells;i++,connPtr+=nnpc)
+ {
+ *dPtr++=nnpc;
+ dPtr=std::copy(connPtr,connPtr+nnpc,dPtr);
+ *cPtr++=k; k+=nnpc+1;
+ }
+ }
+ else
{
- *dPtr++=nnpc;
- dPtr=std::copy(connPtr,connPtr+nnpc,dPtr);
- *cPtr++=k; k+=nnpc+1;
+ for(int i=0;i<curNbCells;i++,connPtr+=27)
+ {
+ *dPtr++=27;
+ for(int j=0;j<27;j++,dPtr++)
+ *dPtr=connPtr[HEXA27_PERM_ARRAY[j]];
+ *cPtr++=k; k+=28;
+ }
}
if(isPolyh)
{ std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; }
public:
static const int PARAMEDMEM_2_VTKTYPE_LGTH=34;
static const unsigned char PARAMEDMEM_2_VTKTYPE[PARAMEDMEM_2_VTKTYPE_LGTH];
+ static const unsigned char HEXA27_PERM_ARRAY[27];
};
class MEDStructuredMeshMultiLev;
{
if(!mrs || mrs->isNodeFamilyFieldReading())
{
+ int nbNodes(getNumberOfNodes());
_fam_nodes=DataArrayInt::New();
- _fam_nodes->alloc(nbOfElt,1);
+ _fam_nodes->alloc(nbNodes,1);//yes nbNodes and not nbOfElt see next line.
+ if(nbNodes!=nbOfElt)//yes it appends some times... It explains surely the mdump implementation. Bug revealed by PARAVIS EDF #2475 on structured.med file where only 12 first nodes are !=0 so nbOfElt=12 and nbOfNodes=378...
+ _fam_nodes->fillWithZero();
MEDmeshEntityFamilyNumberRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,_fam_nodes->getPointer());
}
}
int Mdim;
ParaMEDMEM::MEDCouplingMeshType meshType;
std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim);
+ if(nstep==0)
+ return ;
if(meshType!=UNSTRUCTURED)
throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
_time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
const MEDFileParameter1TS *elt(*it);
if(elt)
{
- if(elt->getIteration()==iteration && elt->getOrder())
+ if(elt->getIteration()==iteration && elt->getOrder()==order)
return ret;
else
oss << "(" << elt->getIteration() << "," << elt->getOrder() << "), ";
_param_per_ts=paramPerTs;
}
+int MEDFileParameterMultiTS::getNumberOfTS() const
+{
+ return (int) getIterations().size();
+}
+
std::vector< std::pair<int,int> > MEDFileParameterMultiTS::getIterations() const
{
std::vector< std::pair<int,int> > ret;
MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const;
MEDLOADER_EXPORT MEDFileParameter1TS *getTimeStepAtPos(int posId) const;
MEDLOADER_EXPORT void eraseTimeStepIds(const int *startIds, const int *endIds);
+ MEDLOADER_EXPORT int getNumberOfTS() const;
MEDLOADER_EXPORT std::vector< std::pair<int,int> > getIterations() const;
MEDLOADER_EXPORT std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const;
MEDLOADER_EXPORT void simpleRepr2(int bkOffset, std::ostream& oss) const;
{
if(PyInt_Check(obj))
{
- MEDFileMesh *ret=self->getMeshAtPos((int)PyInt_AS_LONG(obj));
+ MEDFileMesh *ret=self->getMeshAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfMeshes()));
if(ret)
ret->incrRef();
return ret;
void loadArrays() throw(INTERP_KERNEL::Exception);
void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception);
void unloadArrays() throw(INTERP_KERNEL::Exception);
+ void unloadArraysWithoutDataLoss() throw(INTERP_KERNEL::Exception);
int getDimension() const throw(INTERP_KERNEL::Exception);
int getIteration() const throw(INTERP_KERNEL::Exception);
int getOrder() const throw(INTERP_KERNEL::Exception);
void loadArrays() throw(INTERP_KERNEL::Exception);
void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception);
void unloadArrays() throw(INTERP_KERNEL::Exception);
+ void unloadArraysWithoutDataLoss() throw(INTERP_KERNEL::Exception);
//
virtual MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(elts);
- if(PySlice_GetIndices(oC,self->getNumberOfTS(),&strt,&stp,&step)==0)
- {
- self->eraseTimeStepIds2(strt,stp,step);
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !");
+ GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !");
+ self->eraseTimeStepIds2(strt,stp,step);
}
else
{
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(elt0);
- if(PySlice_GetIndices(oC,self->getNumberOfTS(),&strt,&stp,&step)==0)
- return convertMEDFileFieldMultiTS(self->buildSubPartSlice(strt,stp,step),SWIG_POINTER_OWN | 0);
- else
- throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !");
+ GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !");
+ return convertMEDFileFieldMultiTS(self->buildSubPartSlice(strt,stp,step),SWIG_POINTER_OWN | 0);
}
else
return convertMEDFileField1TS(self->getTimeStepAtPos(MEDFileAnyTypeFieldMultiTSgetitemSingleTS__(self,elt0)),SWIG_POINTER_OWN | 0);
void loadArrays() throw(INTERP_KERNEL::Exception);
void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception);
void unloadArrays() throw(INTERP_KERNEL::Exception);
+ void unloadArraysWithoutDataLoss() throw(INTERP_KERNEL::Exception);
void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const;
std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
+ bool removeFieldsWithoutAnyTimeStep() throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileFields()
{
Py_ssize_t strt=2,stp=2,step=2;
PySliceObject *oC=reinterpret_cast<PySliceObject *>(elts);
- if(PySlice_GetIndices(oC,self->getNumberOfFields(),&strt,&stp,&step)==0)
- self->destroyFieldsAtPos2(strt,stp,step);
- else
- throw INTERP_KERNEL::Exception("MEDFileFields.__delitem__ : error in input slice !");
+ GetIndicesOfSlice(oC,self->getNumberOfFields(),&strt,&stp,&step,"MEDFileFields.__delitem__ : error in input slice !");
+ self->destroyFieldsAtPos2(strt,stp,step);
}
else
{
double getDoubleValue(int iteration, int order) const throw(INTERP_KERNEL::Exception);
int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfTS() const throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileParameterMultiTS()
{
if(elt0 && PyInt_Check(elt0))
{//fmts[3]
- int pos=PyInt_AS_LONG(elt0);
+ int pos=InterpreteNegativeInt(PyInt_AS_LONG(elt0),self->getNumberOfTS());
return pos;
}
else if(elt0 && PyTuple_Check(elt0))
{
if(PyInt_Check(obj))
{
- MEDFileParameterMultiTS *ret=self->getParamAtPos((int)PyInt_AS_LONG(obj));
+ MEDFileParameterMultiTS *ret=self->getParamAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfParams()));
if(ret)
ret->incrRef();
return ret;
self.assertEqual(mm.getMeshAtLevel(0).getName(),"abc")
pass
+ def testMEDFileFieldsUnloadArraysWithoutDataLoss1(self):
+ fileName="Pyfile80.med"
+ m=MEDCouplingCMesh() ; m.setName("cmesh")
+ arr=DataArrayDouble(6) ; arr.iota()
+ m.setCoords(arr,arr)
+ nbCells=m.getNumberOfCells()
+ self.assertEqual(25,nbCells)
+ f=MEDCouplingFieldDouble(ON_CELLS)
+ f.setName("FieldOnCell") ; f.setMesh(m)
+ arr=DataArrayDouble(nbCells) ; arr.iota()
+ mm=MEDFileCMesh()
+ mm.setMesh(m)
+ #
+ fmts=MEDFileFieldMultiTS()
+ #
+ for i in xrange(nbCells):
+ t=(float(i)+0.1,i+1,-i-2)
+ f.setTime(*t)
+ arr2=DataArrayDouble(nbCells)
+ perm=DataArrayInt(nbCells) ; perm.iota(i) ; perm%=nbCells
+ arr2[perm]=arr
+ f.setArray(arr2)
+ f1ts=MEDFileField1TS()
+ f1ts.setFieldNoProfileSBT(f)
+ fmts.pushBackTimeStep(f1ts)
+ pass
+ fmts.unloadArraysWithoutDataLoss()
+ self.assertTrue(fmts[0].getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ fs=MEDFileFields() ; fs.pushField(fmts)
+ self.assertTrue(fs[0][0].getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ fs.unloadArraysWithoutDataLoss()
+ self.assertTrue(fs[0][0].getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ f1ts=fs[0][0]
+ self.assertTrue(f1ts.getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ f1ts.unloadArraysWithoutDataLoss()
+ self.assertTrue(f1ts.getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ mm.write(fileName,2)
+ fs.write(fileName,0)
+ del m,fmts,mm,f,f1ts
+ ##
+ mm=MEDFileMesh.New(fileName)
+ fmts=MEDFileFieldMultiTS(fileName)
+ self.assertTrue(fmts[0].getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ fmts.unloadArraysWithoutDataLoss()
+ self.assertTrue(not fmts[0].getUndergroundDataArray().isAllocated())
+ fmts.loadArraysIfNecessary()
+ self.assertTrue(fmts[0].getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ del mm,fmts
+ fs=MEDFileFields(fileName)
+ self.assertTrue(fs[0][0].getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ fs.unloadArraysWithoutDataLoss()
+ self.assertTrue(not fs[0][0].getUndergroundDataArray().isAllocated())
+ fs.loadArraysIfNecessary()
+ self.assertTrue(fs[0][0].getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ del fs
+ f1ts=MEDFileField1TS(fileName)
+ self.assertTrue(f1ts.getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ f1ts.unloadArraysWithoutDataLoss()
+ self.assertTrue(not f1ts.getUndergroundDataArray().isAllocated())
+ f1ts.loadArraysIfNecessary()
+ self.assertTrue(f1ts.getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
+ pass
+
pass
unittest.main()
########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False) # False is important to not read the values
+ fields.removeFieldsWithoutAnyTimeStep()
refMem=fields.getHeapMemorySize()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False) # false is absolutely necessary for the test
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
self.assertEqual(fields[0].getMeshName(),"mesh")
self.assertEqual(fields[1].getMeshName(),"mesh")
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
ms=MEDFileMeshes(fname)
fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
allFMTSLeavesToDisplay=[]
for fields in fields_per_mesh:
vExp=DataArrayDouble([-1.1,-3.1,5,4,3,2,1,0])
self.assertTrue(v.isEqual(vExp,1e-12))
pass
+
+ def test29(self):
+ """ This test focused on HEXA27 cell for which the MED numbering is not equal to the VTK numbering. So here the HEXA27 cell is those in MED file documentation (reference element).
+ """
+ fname="ForMEDReader29.med"
+ coo=DataArrayDouble([[0.,2.,2.],[0.,0.,2.],[2.,0.,2.],[2.,2.,2.],[0.,2.,0.],[0.,0.,0.],[2.,0.,0.],[2.,2.,0.], [0.,1.,2.],[1.,0.,2.],[2.,1.,2.],[1.,2.,2.], [0.,1.,0.],[1.,0.,0.],[2.,1.,0.],[1.,2.,0.], [0.,2.,1.],[0.,0.,1.],[2.,0.,1.],[2.,2.,1.], [1.,1.,2.], [0.,1.,1.],[1.,0.,1.],[2.,1.,1.],[1.,2.,1.], [1.,1.,0.], [1.,1.,1.]])
+ m=MEDCouplingUMesh("mesh",3) ; m.setCoords(coo)
+ m.allocateCells()
+ # MED = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]
+ # VTK = [0,1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,16,17,18,19,24,22,21,23,20,25,26]
+ m.insertNextCell(NORM_HEXA27,[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])
+ fCell=MEDCouplingFieldDouble(ON_CELLS) ; fCell.setName("fCell")
+ arrCell=DataArrayDouble([7.]) ; arrCell.setInfoOnComponent(0,"smth") ; fCell.setArray(arrCell)
+ fCell.setMesh(m)
+ MEDLoader.WriteField(fname,fCell,True)
+ refCoo=[-1.,-1.,-1.,-1.,1.,-1.,1.,1.,-1.,1.,-1.,-1.,-1.,-1.,1.,-1.,1.,1.,1.,1.,1.,1.,-1.,1.,-1.,0.,-1.,0.,1.,-1.,1.,0.,-1.,0.,-1.,-1.,-1.,0.,1.,0.,1.,1.,1.,0.,1.,0.,-1.,1.,-1.,-1.,0.,-1.,1.,0.,1.,1.,0.,1.,-1.,0.,0.,0.,-1.,-1.,0.,0.,0.,1.,0.,1.,0.,0.,0.,-1.,0.,0.,0.,1.,0.,0.,0.]
+ weights=[0.1714677640603571,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.43895747599451346,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.43895747599451346,0.27434842249657115,0.43895747599451346,0.7023319615912209,0.43895747599451346,0.27434842249657115,0.43895747599451346,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.43895747599451346,0.27434842249657115,0.1714677640603571,0.27434842249657115,0.1714677640603571]
+ gCoords=[-0.774596669241483,-0.774596669241483,-0.774596669241483,-0.774596669241483,-0.774596669241483,0.0,-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.0,-0.774596669241483,-0.774596669241483,0.0,0.0,-0.774596669241483,0.0,0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.774596669241483,0.0,-0.774596669241483,-0.774596669241483,0.0,-0.774596669241483,0.0,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,-0.774596669241483,0.0,0.0,0.0,0.0,0.0,0.774596669241483,0.0,0.774596669241483,-0.774596669241483,0.0,0.774596669241483,0.0,0.0,0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.0,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,0.0,0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,0.0,0.774596669241483,0.774596669241483,0.774596669241483]
+ fGauss=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fGauss.setName("fGauss")
+ fGauss.setMesh(m)
+ fGauss.setGaussLocalizationOnType(NORM_HEXA27,refCoo,gCoords,weights)
+ arrGauss=DataArrayDouble(fGauss.getNumberOfTuplesExpected()) ; arrGauss.setInfoOnComponent(0,"gaussc") ; arrGauss.iota()
+ fGauss.setArray(arrGauss)
+ MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,fGauss)
+ ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
+ ms=MEDFileMeshes(fname)
+ fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ allFMTSLeavesToDisplay=[]
+ for fields in fields_per_mesh:
+ allFMTSLeavesToDisplay2=[]
+ for fmts in fields:
+ allFMTSLeavesToDisplay2+=fmts.splitDiscretizations()
+ pass
+ allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+ pass
+ self.assertEqual(len(allFMTSLeavesToDisplay),1)
+ self.assertEqual(len(allFMTSLeavesToDisplay[0]),2)
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),2)
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),2)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ #
+ fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+ ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+ self.assertTrue(a0.isEqual(coo,1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([29])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0])))
+ # the connectivity must be not a iota as declared in m.insertNextCell
+ self.assertTrue(a3.isEqual(DataArrayInt([27,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,24,22,21,23,20,25,26])))# the test is on this line to check that connectivity has been processed for HEXA27
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+ ffCell.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+ self.assertEqual(ffCell.getName(),"fCell")
+ self.assertTrue(v.isEqual(arrCell,1e-12)) ; self.assertTrue(v.isEqualWithoutConsideringStr(DataArrayDouble([7.]),1e-12)) ; self.assertEqual(v.getInfoOnComponents(),["smth"])
+ del ffCell
+ #
+ ffGauss=allFMTSLeavesPerCommonSupport1[0][0][1][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffGauss,mst)
+ ffGauss.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffGauss.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffGauss.getUndergroundDataArray().getHiddenCppPointer())
+ self.assertEqual(ffGauss.getName(),"fGauss")
+ self.assertTrue(v.isEqual(arrGauss,1e-12)) ; self.assertTrue(v.isEqualWithoutConsideringStr(DataArrayDouble(range(27)),1e-12)) ; self.assertEqual(v.getInfoOnComponents(),["gaussc"])
+ ffGauss=allFMTSLeavesPerCommonSupport1[0][0][1][0]
+ pass
+
pass
unittest.main()
{
if(elt0 && PyInt_Check(elt0))
{//fmts[3]
- return PyInt_AS_LONG(elt0);
+ return InterpreteNegativeInt(PyInt_AS_LONG(elt0),self->getNumberOfTS());
}
else if(elt0 && PyTuple_Check(elt0))
{
{
if(PyInt_Check(obj))
{
- return (int)PyInt_AS_LONG(obj);
+ return InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfFields());
}
else if(PyString_Check(obj))
{
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
+ else if ( distant_support.getMeshDimension() == 3
+ && _source_support->getMeshDimension() == 1
+ && distant_support.getSpaceDimension() == 3 && _source_support->getSpaceDimension() == 3)
+ {
+ MEDCouplingNormalizedUnstructuredMesh<3,3> target_wrapper(distant_supportC);
+ MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(source_supportC);
+ INTERP_KERNEL::Interpolation3D interpolator (*this);
+ interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
+ target_wrapper.releaseTempArrays();
+ source_wrapper.releaseTempArrays();
+ }
else if (distant_support.getMeshDimension() != _source_support->getMeshDimension())
{
throw INTERP_KERNEL::Exception("local and distant meshes do not have the same space and mesh dimensions");
CPPUNIT_TEST(testGauthier1);
CPPUNIT_TEST(testGauthier2);
CPPUNIT_TEST(testGauthier3);
+ CPPUNIT_TEST(testGauthier4);
CPPUNIT_TEST(testFabienAPI1);
CPPUNIT_TEST(testFabienAPI2);
CPPUNIT_TEST(testMEDLoaderRead1);
void testGauthier1();
void testGauthier2();
void testGauthier3();
+ void testGauthier4();
void testFabienAPI1();
void testFabienAPI2();
//
#include "ParaMEDMEMTest.hxx"
#include <cppunit/TestAssert.h>
-#include <string>
#include "CommInterface.hxx"
#include "ProcessorGroup.hxx"
#include "MPIProcessorGroup.hxx"
#include "DEC.hxx"
#include "InterpKernelDEC.hxx"
+#include "ICoCoTrioField.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "ParaMESH.hxx"
+#include "ParaFIELD.hxx"
+#include "ComponentTopology.hxx"
+
#include <set>
#include <time.h>
-#include "ICoCoTrioField.hxx"
#include <iostream>
#include <assert.h>
+#include <string>
#include <math.h>
using namespace std;
}
}
}
+
+/*!
+ * This test is the parallel version of MEDCouplingBasicsTest.test3D1DOnP1P0_1 test.
+ */
+void ParaMEDMEMTest::testGauthier4()
+{
+ //
+ const double sourceCoords[19*3]={0.5,0.5,0.1,0.5,0.5,1.2,0.5,0.5,1.6,0.5,0.5,1.8,0.5,0.5,2.43,0.5,0.5,2.55,0.5,0.5,4.1,0.5,0.5,4.4,0.5,0.5,4.9,0.5,0.5,5.1,0.5,0.5,7.6,0.5,0.5,7.7,0.5,0.5,8.2,0.5,0.5,8.4,0.5,0.5,8.6,0.5,0.5,8.8,0.5,0.5,9.2,0.5,0.5,9.6,0.5,0.5,11.5};
+ const int sourceConn[18*2]={0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18};
+ const double sourceVals[19]={0.49,2.8899999999999997,7.29,13.69,22.09,32.49,44.89,59.29,75.69,94.09, 114.49,136.89,161.29,187.69,216.09,246.49,278.89,313.29,349.69};
+ const double targetCoords0[20*3]={0.,0.,0.,1.,0.,0.,0.,1.,0.,1.,1.,0.,0.,0.,1.,1.,0.,1.,0.,1.,1.,1.,1.,1.,0.,0.,2.,1.,0.,2.,0.,1.,2.,1.,1.,2.,0.,0.,3.,1.,0.,3.,0.,1.,3.,1.,1.,3.,0.,0.,4.,1.,0.,4.,0.,1.,4.,1.,1.,4.};
+ const int targetConn0[8*4]={1,0,2,3,5,4,6,7,5,4,6,7,9,8,10,11,9,8,10,11,13,12,14,15,13,12,14,15,17,16,18,19};
+ const double targetCoords1[28*3]={0.,0.,4.,1.,0.,4.,0.,1.,4.,1.,1.,4.,0.,0.,5.,1.,0.,5.,0.,1.,5.,1.,1.,5.,0.,0.,6.,1.,0.,6.,0.,1.,6.,1.,1.,6.,0.,0.,7.,1.,0.,7.,0.,1.,7.,1.,1.,7.,0.,0.,8.,1.,0.,8.,0.,1.,8.,1.,1.,8.,0.,0.,9.,1.,0.,9.,0.,1.,9.,1.,1.,9.,0.,0.,10.,1.,0.,10.,0.,1.,10.,1.,1.,10.};
+ const int targetConn1[8*6]={1,0,2,3,5,4,6,7,5,4,6,7,9,8,10,11,9,8,10,11,13,12,14,15,13,12,14,15,17,16,18,19,17,16,18,19,21,20,22,23,21,20,22,23,25,24,26,27};
+ //
+ int size;
+ int rank;
+ MPI_Comm_size(MPI_COMM_WORLD,&size);
+ MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ //
+ if(size!=3)
+ return ;
+ int nproc_source = 1;
+ set<int> self_procs;
+ set<int> procs_source;
+ set<int> procs_target;
+
+ for (int i=0; i<nproc_source; i++)
+ procs_source.insert(i);
+ for (int i=nproc_source; i<size; i++)
+ procs_target.insert(i);
+ self_procs.insert(rank);
+ //
+ ParaMEDMEM::MEDCouplingUMesh *mesh=0;
+ ParaMEDMEM::ParaMESH *paramesh=0;
+ ParaMEDMEM::ParaFIELD* parafield=0;
+ //
+ ParaMEDMEM::CommInterface interface;
+ //
+ ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
+ ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
+ ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
+ //
+ MPI_Barrier(MPI_COMM_WORLD);
+ if(source_group->containsMyRank())
+ {
+ std::ostringstream stream; stream << "sourcemesh2D proc " << rank;
+ mesh=MEDCouplingUMesh::New(stream.str().c_str(),1);
+ mesh->allocateCells();
+ for(int i=0;i<18;i++)
+ mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+2*i);
+ mesh->finishInsertingCells();
+ DataArrayDouble *myCoords=DataArrayDouble::New();
+ myCoords->alloc(19,3);
+ std::copy(sourceCoords,sourceCoords+19*3,myCoords->getPointer());
+ mesh->setCoords(myCoords);
+ myCoords->decrRef();
+ paramesh=new ParaMESH(mesh,*source_group,"source mesh");
+ ParaMEDMEM::ComponentTopology comptopo;
+ parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh,comptopo);
+ double *value=parafield->getField()->getArray()->getPointer();
+ std::copy(sourceVals,sourceVals+19,value);
+ }
+ else
+ {
+ if(rank==1)
+ {
+ std::ostringstream stream; stream << "targetmesh2D proc " << rank-nproc_source;
+ mesh=MEDCouplingUMesh::New(stream.str().c_str(),3);
+ mesh->allocateCells();
+ for(int i=0;i<4;i++)
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn0+8*i);
+ mesh->finishInsertingCells();
+ DataArrayDouble *myCoords=DataArrayDouble::New();
+ myCoords->alloc(20,3);
+ std::copy(targetCoords0,targetCoords0+20*3,myCoords->getPointer());
+ mesh->setCoords(myCoords);
+ myCoords->decrRef();
+ paramesh=new ParaMESH (mesh,*target_group,"target mesh");
+ ParaMEDMEM::ComponentTopology comptopo;
+ parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
+ }
+ else if(rank==2)
+ {
+ std::ostringstream stream; stream << "targetmesh2D proc " << rank-nproc_source;
+ mesh=MEDCouplingUMesh::New(stream.str().c_str(),3);
+ mesh->allocateCells();
+ for(int i=0;i<6;i++)
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn1+8*i);
+ mesh->finishInsertingCells();
+ DataArrayDouble *myCoords=DataArrayDouble::New();
+ myCoords->alloc(28,3);
+ std::copy(targetCoords1,targetCoords1+28*3,myCoords->getPointer());
+ mesh->setCoords(myCoords);
+ myCoords->decrRef();
+ paramesh=new ParaMESH (mesh,*target_group,"target mesh");
+ ParaMEDMEM::ComponentTopology comptopo;
+ parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
+ }
+ }
+ //test 1 - primaire -> secondaire
+ ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group);
+ dec.setIntersectionType(INTERP_KERNEL::PointLocator);
+ parafield->getField()->setNature(ConservativeVolumic);//very important
+ if (source_group->containsMyRank())
+ {
+ dec.setMethod("P1");
+ dec.attachLocalField(parafield);
+ dec.synchronize();
+ dec.setForcedRenormalization(false);
+ dec.sendData();
+ }
+ else
+ {
+ dec.setMethod("P0");
+ dec.attachLocalField(parafield);
+ dec.synchronize();
+ dec.setForcedRenormalization(false);
+ dec.recvData();
+ const double *res(parafield->getField()->getArray()->getConstPointer());
+ if(rank==1)
+ {
+ const double expected0[4]={0.49,7.956666666666667,27.29,0.};
+ for(int i=0;i<4;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected0[i],res[i],1e-13);
+ }
+ else
+ {
+ const double expected1[6]={59.95666666666667,94.09,0.,125.69,202.89,296.09};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],res[i],1e-13);
+ }
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (source_group->containsMyRank())
+ {
+ dec.recvData();
+ const double expected2[19]={0.49,7.956666666666667,7.956666666666667,7.956666666666667,27.29,27.29,59.95666666666667,59.95666666666667,59.95666666666667,94.09,125.69,125.69,202.89,202.89,202.89,202.89,296.09,296.09,0.};
+ const double *res(parafield->getField()->getArray()->getConstPointer());
+ for(int i=0;i<19;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],res[i],1e-13);
+ }
+ else
+ {
+ dec.sendData();
+ }
+ delete parafield;
+ mesh->decrRef();
+ delete paramesh;
+ delete self_group;
+ delete target_group;
+ delete source_group;
+ //
+ MPI_Barrier(MPI_COMM_WORLD);
+}