allPillesTest.sauv
BDC-714.sauv
portico_3subs.sauv
+ agitateur.med
)
IF(MED_ENABLE_GUI)
test_2D.sauve \
allPillesTest.sauv \
BDC-714.sauv \
- portico_3subs.sauv
+ portico_3subs.sauv \
+ agitateur.med
if !MED_ENABLE_MICROMED
nodist_salomeres_SCRIPTS = MEDCatalog.xml SalomeApp.xml
--- /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
+//
+// Author : Anthony Geay (CEA/DEN)
+
+#ifndef __BBTREEDST_TXX__
+#define __BBTREEDST_TXX__
+
+#include <vector>
+#include <algorithm>
+
+#include <iostream>
+#include <limits>
+#include <cmath>
+
+template <int dim>
+class BBTreeDst
+{
+private:
+ BBTreeDst* _left;
+ BBTreeDst* _right;
+ int _level;
+ double _max_left;
+ double _min_right;
+ const double *_bb;
+ std::vector<int> _elems;
+ double *_terminal;
+ int _nbelems;
+
+ static const int MIN_NB_ELEMS=15;
+ static const int MAX_LEVEL=20;
+public:
+ BBTreeDst(const double* bbs, int* elems, int level, int nbelems):
+ _left(0),_right(0),_level(level),_bb(bbs),_terminal(0),_nbelems(nbelems)
+ {
+ if((nbelems < MIN_NB_ELEMS || level> MAX_LEVEL))
+ _terminal=new double[2*dim];
+ _elems.resize(nbelems);
+ for (int i=0; i<nbelems; i++)
+ _elems[i]=elems?elems[i]:i;
+ if(_terminal)
+ {
+ fillBBoxTerminal(bbs);
+ return ;
+ }
+ double *nodes=new double[nbelems];
+ for (int i=0; i<nbelems; i++)
+ nodes[i]=bbs[_elems[i]*dim*2+(level%dim)*2];
+ std::nth_element<double*>(nodes, nodes+nbelems/2, nodes+nbelems);
+ double median = *(nodes+nbelems/2);
+ delete [] nodes;
+ std::vector<int> new_elems_left;
+ std::vector<int> new_elems_right;
+
+ new_elems_left.reserve(nbelems/2+1);
+ new_elems_right.reserve(nbelems/2+1);
+ double max_left = -std::numeric_limits<double>::max();
+ double min_right= std::numeric_limits<double>::max();
+ for(int i=0; i<nbelems;i++)
+ {
+ int elem;
+ if (elems!=0)
+ elem= elems[i];
+ else
+ elem=i;
+ double max=bbs[elem*dim*2+(level%dim)*2+1];
+ double min = bbs[elem*dim*2+(level%dim)*2];
+
+ if (min>median)
+ {
+ new_elems_right.push_back(elem);
+ if (min<min_right) min_right = min;
+ }
+ else
+ {
+ new_elems_left.push_back(elem);
+ if (max>max_left) max_left = max;
+ }
+ }
+ _max_left=max_left;
+ _min_right=min_right;
+ int *tmp;
+ tmp=0;
+ if(!new_elems_left.empty())
+ tmp=&(new_elems_left[0]);
+ _left=new BBTreeDst(bbs, tmp, level+1, (int)new_elems_left.size());
+ tmp=0;
+ if(!new_elems_right.empty())
+ tmp=&(new_elems_right[0]);
+ _right=new BBTreeDst(bbs, tmp, level+1, (int)new_elems_right.size());
+ }
+
+ ~BBTreeDst()
+ {
+ delete _left;
+ delete _right;
+ delete [] _terminal;
+ }
+
+ void getElemsWhoseMinDistanceToPtSmallerThan(const double *pt, double minOfMaxDstsSq, std::vector<int>& elems) const
+ {
+ if(_terminal)
+ {
+ for(int i=0; i<_nbelems; i++)
+ {
+ if(GetMinDistanceFromBBoxToPt(_bb+_elems[i]*2*dim,pt)<minOfMaxDstsSq)
+ elems.push_back(_elems[i]);
+ }
+ }
+ else
+ {
+ double minOfMaxDsts=sqrt(minOfMaxDstsSq);
+ if(_min_right-pt[_level%dim]>minOfMaxDsts)
+ { _left->getElemsWhoseMinDistanceToPtSmallerThan(pt,minOfMaxDstsSq,elems); return ; }
+ if(pt[_level%dim]-_max_left>minOfMaxDsts)
+ { _right->getElemsWhoseMinDistanceToPtSmallerThan(pt,minOfMaxDstsSq,elems); return ; }
+ _left->getElemsWhoseMinDistanceToPtSmallerThan(pt,minOfMaxDstsSq,elems);
+ _right->getElemsWhoseMinDistanceToPtSmallerThan(pt,minOfMaxDstsSq,elems);
+ }
+ }
+
+ void getMinDistanceOfMax(const double *pt, double& minOfMaxDstsSq) const
+ {
+ if(_terminal)
+ {
+ if(GetMinDistanceFromBBoxToPt(_terminal,pt)>minOfMaxDstsSq)//min it is not a bug
+ return ;
+ for(int i=0; i<_nbelems; i++)
+ {
+ minOfMaxDstsSq=std::min(minOfMaxDstsSq,GetMaxDistanceFromBBoxToPt(_bb+_elems[i]*2*dim,pt));
+ }
+ }
+ else
+ {
+ double minOfMaxDsts=sqrt(minOfMaxDstsSq);
+ if(_min_right-pt[_level%dim]>minOfMaxDsts)
+ { _left->getMinDistanceOfMax(pt,minOfMaxDstsSq); return ; }
+ if(pt[_level%dim]-_max_left>minOfMaxDsts)
+ { _right->getMinDistanceOfMax(pt,minOfMaxDstsSq); return ; }
+ _left->getMinDistanceOfMax(pt,minOfMaxDstsSq);
+ _right->getMinDistanceOfMax(pt,minOfMaxDstsSq);
+ }
+ }
+
+ void fillBBoxTerminal(const double* bbs)
+ {
+ for(int j=0;j<dim;j++)
+ {
+ _terminal[2*j]=std::numeric_limits<double>::max();
+ _terminal[2*j+1]=-std::numeric_limits<double>::max();
+ }
+ for(int i=0;i<_nbelems;i++)
+ {
+ for(int j=0;j<dim;j++)
+ {
+ _terminal[2*j]=std::min(_terminal[2*j],bbs[2*dim*_elems[i]+2*j]);
+ _terminal[2*j+1]=std::max(_terminal[2*j+1],bbs[2*dim*_elems[i]+2*j+1]);
+ }
+ }
+ }
+
+ static double GetMaxDistanceFromBBoxToPt(const double *bbox, const double *pt)
+ {
+ if(bbox[0]<=bbox[1])
+ {
+ double zeRes=0.;
+ for (int idim=0; idim<dim; idim++)
+ {
+ double val1=pt[idim]-bbox[idim*2],val2=pt[idim]-bbox[idim*2+1];
+ double x=std::max(fabs(val1),fabs(val2));
+ zeRes+=x*x;
+ }
+ return zeRes;
+ }
+ else//min>max -> no cells in this
+ return std::numeric_limits<double>::max();
+
+ }
+
+ static double GetMinDistanceFromBBoxToPt(const double *bbox, const double *pt)
+ {
+ if(bbox[0]<=bbox[1])
+ {
+ double zeRes=0.;
+ for (int idim=0; idim<dim; idim++)
+ {
+ double val1=pt[idim]-bbox[idim*2],val2=pt[idim]-bbox[idim*2+1];
+ char pos=(( (0.<val1)-(val1<0.) )+( (0.<val2)-(val2<0.) ))/2;// sign(val) = (0.<val)-(val<0.)
+ if(pos!=0)
+ {
+ double x=pos==1?val2:val1;
+ zeRes+=x*x;
+ }
+ }
+ return zeRes;
+ }
+ else//min>max -> no cells in this
+ return std::numeric_limits<double>::max();
+ }
+};
+
+#endif
private:
T *_ptr;
};
+
+ template<class T>
+ class AutoCPtr
+ {
+ public:
+ AutoCPtr(T *ptr=0):_ptr(ptr) { }
+ ~AutoCPtr() { destroyPtr(); }
+ AutoCPtr &operator=(T *ptr) { destroyPtr(); _ptr=ptr; return *this; }
+ T *operator->() { return _ptr ; }
+ const T *operator->() const { return _ptr; }
+ T& operator*() { return *_ptr; }
+ const T& operator*() const { return *_ptr; }
+ operator T *() { return _ptr; }
+ operator const T *() const { return _ptr; }
+ private:
+ void destroyPtr() { free(_ptr); }
+ private:
+ T *_ptr;
+ };
}
#endif
break;
case NORM_POLYGON:
{
- _nb_of_pts=0; _nb_of_sons=0; _dim=2; _dyn=true; _extruded_type=NORM_POLYHED; _is_simplex=false;
+ _nb_of_pts=0; _nb_of_sons=0; _dim=2; _dyn=true; _extruded_type=NORM_POLYHED; _is_simplex=false; _quadratic_type=NORM_QPOLYG;
}
break;
case NORM_POLYHED:
break;
case NORM_QPOLYG:
{
- _nb_of_pts=0; _nb_of_sons=0; _dim=2; _dyn=true; _is_simplex=false; _quadratic=true;
+ _nb_of_pts=0; _nb_of_sons=0; _dim=2; _dyn=true; _is_simplex=false; _quadratic=true; _linear_type=NORM_POLYGON;
}
break;
case NORM_POLYL:
else//polyhedron
return (lgth-std::count(conn,conn+lgth,-1))/2;
}
+
+ NormalizedCellType CellModel::getCorrespondingPolyType() const
+ {
+ switch(getDimension())
+ {
+ case 0:
+ return NORM_POINT1;
+ case 1:
+ {
+ if(!isQuadratic())
+ return NORM_POLYL;
+ throw INTERP_KERNEL::Exception("CellModel::getPolyType : no poly type for quadratic 1D !");
+ }
+ case 2:
+ {
+ if(!isQuadratic())
+ return NORM_POLYGON;
+ else
+ return NORM_QPOLYG;
+ }
+ case 3:
+ {
+ if(!isQuadratic())
+ return NORM_POLYHED;
+ throw INTERP_KERNEL::Exception("CellModel::getPolyType : no poly type for quadratic 3D !");
+ }
+ default:
+ throw INTERP_KERNEL::Exception("CellModel::getPolyType : only dimension 0, 1, 2, 3 are supported !");
+ }
+ }
/*!
* Equivalent to getSonType except that this method deals with dynamic type.
INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon(unsigned sonId) const { return _nb_of_sons_con[sonId]; }
INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon2(unsigned sonId, const int *nodalConn, int lgth) const;
INTERPKERNEL_EXPORT NormalizedCellType getExtrudedType() const { return _extruded_type; }
+ INTERPKERNEL_EXPORT NormalizedCellType getCorrespondingPolyType() const;
INTERPKERNEL_EXPORT NormalizedCellType getReverseExtrudedType() const { return _reverse_extruded_type; }
INTERPKERNEL_EXPORT NormalizedCellType getLinearType() const { return _linear_type; }
INTERPKERNEL_EXPORT NormalizedCellType getQuadraticType() const { return _quadratic_type; }
vectOutput[1]=-tmp;
}
+Edge *Edge::BuildEdgeFrom3Points(const double *start, const double *middle, const double *end)
+{
+ Node *b(new Node(start[0],start[1])),*m(new Node(middle[0],middle[1])),*e(new Node(end[0],end[1]));
+ EdgeLin *e1(new EdgeLin(b,m)),*e2(new EdgeLin(m,e));
+ SegSegIntersector inters(*e1,*e2); bool colinearity=inters.areColinears(); delete e1; delete e2;
+ Edge *ret=0;
+ if(colinearity)
+ ret=new EdgeLin(b,e);
+ else
+ ret=new EdgeArcCircle(b,m,e);
+ b->decrRef(); m->decrRef(); e->decrRef();
+ return ret;
+}
+
Edge *Edge::BuildEdgeFrom(Node *start, Node *end)
{
return new EdgeLin(start,end);
static Edge *BuildEdgeFrom(Node *start, Node *end);
template<TypeOfMod4QuadEdge type>
static Edge *BuildEdgeFrom(Node *start, Node *middle, Node *end);
+ static Edge *BuildEdgeFrom3Points(const double *start, const double *middle, const double *end);
virtual void update(Node *m) = 0;
//! returns area between this and axe Ox delimited along Ox by _start and _end.
virtual double getAreaOfZone() const = 0;
salomeinclude_HEADERS = \
BBTree.txx \
BBTreePts.txx \
+BBTreeDst.txx \
BoundingBox.hxx \
CellModel.hxx \
ConvexIntersector.hxx \
#include "InterpolationUtils.hxx"
#include "InterpKernelException.hxx"
+#include "InterpKernelGeo2DEdgeLin.hxx"
+#include "InterpKernelGeo2DEdgeArcCircle.hxx"
#include "InterpKernelGeo2DQuadraticPolygon.hxx"
#include <sstream>
return sqrt(ret);
}
}
+
+ inline double calculateLgthForSeg3(const double *begin, const double *end, const double *middle, int spaceDim)
+ {
+ if(spaceDim==2)
+ {
+ Edge *ed=Edge::BuildEdgeFrom3Points(begin,middle,end);
+ double ret=ed->getCurveLength(); ed->decrRef();
+ return ret;
+ }
+ else
+ return calculateLgthForSeg2(begin,end,spaceDim);
+ }
// ===========================
// Calculate Area for triangle
bary[i]=temp/nbPts;
}
}
-
- template<class ConnType, NumberingPolicy numPol>
- inline void computePolygonBarycenter2D(const ConnType *connec, int lgth, const double *coords, double *res)
+
+ inline void computePolygonBarycenter2DEngine(double **coords, int lgth, double *res)
{
double area=0.;
res[0]=0.; res[1]=0.;
for(int i=0;i<lgth;i++)
{
- double cp=coords[2*OTT<ConnType,numPol>::coo2C(connec[i])]*coords[2*OTT<ConnType,numPol>::coo2C(connec[(i+1)%lgth])+1]-
- coords[2*OTT<ConnType,numPol>::coo2C(connec[i])+1]*coords[2*OTT<ConnType,numPol>::coo2C(connec[(i+1)%lgth])];
+ double cp=coords[i][0]*coords[(i+1)%lgth][1]-coords[i][1]*coords[(i+1)%lgth][0];
area+=cp;
- res[0]+=cp*(coords[2*OTT<ConnType,numPol>::coo2C(connec[i])]+coords[2*OTT<ConnType,numPol>::coo2C(connec[(i+1)%lgth])]);
- res[1]+=cp*(coords[2*OTT<ConnType,numPol>::coo2C(connec[i])+1]+coords[2*OTT<ConnType,numPol>::coo2C(connec[(i+1)%lgth])+1]);
+ res[0]+=cp*(coords[i][0]+coords[(i+1)%lgth][0]);
+ res[1]+=cp*(coords[i][1]+coords[(i+1)%lgth][1]);
}
res[0]/=3.*area;
res[1]/=3.*area;
}
+
+ template<class ConnType, NumberingPolicy numPol>
+ inline void computePolygonBarycenter2D(const ConnType *connec, int lgth, const double *coords, double *res)
+ {
+ double **coords2=new double *[lgth];
+ for(int i=0;i<lgth;i++)
+ coords2[i]=const_cast<double *>(coords+2*OTT<ConnType,numPol>::coo2C(connec[i]));
+ computePolygonBarycenter2DEngine(coords2,lgth,res);
+ delete [] coords2;
+ }
+
+ inline void computeQPolygonBarycenter2D(double **coords, int nbOfPtsInPolygs, int spaceDim, double *res)
+ {
+ if(nbOfPtsInPolygs%2==0)
+ {
+ if(spaceDim==2)
+ {
+ std::vector<Node *> nodes(nbOfPtsInPolygs);
+ for(int i=0;i<nbOfPtsInPolygs;i++)
+ nodes[i]=new Node(coords[i][0],coords[i][1]);
+ QuadraticPolygon *pol=QuadraticPolygon::BuildArcCirclePolygon(nodes);
+ pol->getBarycenter(res);
+ delete pol;
+ }
+ else
+ return computePolygonBarycenter2DEngine(coords,nbOfPtsInPolygs/2,res);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "INTERP_KERNEL::computeQPolygonBarycenter2D : nb of points in quadratic polygon is " << nbOfPtsInPolygs << " should be even !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
}
#endif
namespace INTERP_KERNEL
{
- double SquareDistanceFromPtToSegInSpaceDim2(const double *pt, const double *pt0Seg2, const double *pt1Seg2) throw(INTERP_KERNEL::Exception)
+ double SquareDistanceFromPtToSegInSpaceDim2(const double *pt, const double *pt0Seg2, const double *pt1Seg2, std::size_t &nbOfHint) throw(INTERP_KERNEL::Exception)
{
double dx=pt1Seg2[0]-pt0Seg2[0],dy=pt1Seg2[1]-pt0Seg2[1];
double norm=sqrt(dx*dx+dy*dy);
if(norm==0.)
- return std::numeric_limits<double>::max();
+ return (pt[0]-pt0Seg2[0])*(pt[0]-pt0Seg2[0])+(pt[1]-pt0Seg2[1])*(pt[1]-pt0Seg2[1]);//return std::numeric_limits<double>::max();
dx/=norm; dy/=norm;
double dx2=pt[0]-pt0Seg2[0],dy2=pt[1]-pt0Seg2[1];
double dotP=(dx2*dx+dy2*dy);
if(dotP<0. || dotP>norm)
- return std::numeric_limits<double>::max();
+ return dotP<0.?(pt[0]-pt0Seg2[0])*(pt[0]-pt0Seg2[0])+(pt[1]-pt0Seg2[1])*(pt[1]-pt0Seg2[1]):(pt[0]-pt1Seg2[0])*(pt[0]-pt1Seg2[0])+(pt[1]-pt1Seg2[1])*(pt[1]-pt1Seg2[1]);
+ nbOfHint++;
double x=pt0Seg2[0]+dotP*dx,y=pt0Seg2[1]+dotP*dy;
return (x-pt[0])*(x-pt[0])+(y-pt[1])*(y-pt[1]);
}
xy[1]=matrix[4]*pt[0]+matrix[5]*pt[1]+matrix[6]*pt[2]+matrix[7];
double z=matrix[8]*pt[0]+matrix[9]*pt[1]+matrix[10]*pt[2]+matrix[11];
double ret=std::numeric_limits<double>::max();
- int nbOfHint=0;
+ std::size_t nbOfHint=0;
if(xy[0]>0. && xy[0]<xy1[0])
- { ret=std::min(ret,sqrt(z*z+xy[1]*xy[1])); nbOfHint++; } //distance pt to edge [pt0Tri3,pt1Tri3]
- double tmp=SquareDistanceFromPtToSegInSpaceDim2(xy,xy1,xy2); //distance pt to edge [pt1Tri3,pt2Tri3]
- if(tmp!=std::numeric_limits<double>::max())
- { ret=std::min(ret,sqrt(z*z+tmp)); nbOfHint++; }
- tmp=SquareDistanceFromPtToSegInSpaceDim2(xy,xy2,xy0);//distance pt to edge [pt2Tri3,pt0Tri3]
- if(tmp!=std::numeric_limits<double>::max())
- { ret=std::min(ret,sqrt(z*z+tmp)); nbOfHint++; }
+ { ret=std::min(ret,z*z+xy[1]*xy[1]); nbOfHint++; } //distance pt to edge [pt0Tri3,pt1Tri3]
+ double tmp=SquareDistanceFromPtToSegInSpaceDim2(xy,xy1,xy2,nbOfHint); //distance pt to edge [pt1Tri3,pt2Tri3]
+ ret=std::min(ret,z*z+tmp);
+ tmp=SquareDistanceFromPtToSegInSpaceDim2(xy,xy2,xy0,nbOfHint);//distance pt to edge [pt2Tri3,pt0Tri3]
+ ret=std::min(ret,z*z+tmp);
if(nbOfHint==3)
- ret=std::min(ret,fabs(z));
- return ret;
+ ret=std::min(ret,z*z);
+ return sqrt(ret);
}
double DistanceFromPtToPolygonInSpaceDim3(const double *pt, const int *connOfPolygonBg, const int *connOfPolygonEnd, const double *coords) throw(INTERP_KERNEL::Exception)
std::size_t nbOfHint=0;
for(std::size_t i=0;i<nbOfEdges;i++)
{
- double tmp=SquareDistanceFromPtToSegInSpaceDim2(xy,((double *)ptXY)+2*i,((double *)ptXY)+2*((i+1)%nbOfEdges));
- if(tmp!=std::numeric_limits<double>::max())
- { ret=std::min(ret,sqrt(z*z+tmp)); nbOfHint++; }
+ double tmp=SquareDistanceFromPtToSegInSpaceDim2(xy,((double *)ptXY)+2*i,((double *)ptXY)+2*((i+1)%nbOfEdges),nbOfHint);
+ ret=std::min(ret,z*z+tmp);
}
if(nbOfHint==nbOfEdges)
- ret=std::min(ret,fabs(z));
- return ret;
+ ret=std::min(ret,z*z);
+ return sqrt(ret);
}
/*!
template<class ConnType, NumberingPolicy numPolConn>
void computeBarycenter2(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, int spaceDim, double *res);
- double SquareDistanceFromPtToSegInSpaceDim2(const double *pt, const double *pt0Seg2, const double *pt1Seg2) throw(INTERP_KERNEL::Exception);
+ double SquareDistanceFromPtToSegInSpaceDim2(const double *pt, const double *pt0Seg2, const double *pt1Seg2, std::size_t &nbOfHint) throw(INTERP_KERNEL::Exception);
double DistanceFromPtToTriInSpaceDim3(const double *pt, const double *pt0Tri3, const double *pt1Tri3, const double *pt2Tri3) throw(INTERP_KERNEL::Exception);
switch(type)
{
case INTERP_KERNEL::NORM_SEG2 :
- case INTERP_KERNEL::NORM_SEG3 :
case INTERP_KERNEL::NORM_SEG4 :
{
int N1 = OTT<ConnType,numPol>::coo2C(connec[0]);
int N2 = OTT<ConnType,numPol>::coo2C(connec[1]);
return INTERP_KERNEL::calculateLgthForSeg2(coords+(SPACEDIM*N1),coords+(SPACEDIM*N2),SPACEDIM);
}
+ case INTERP_KERNEL::NORM_SEG3 :
+ {
+ int beginNode = OTT<ConnType,numPol>::coo2C(connec[0]);
+ int endNode = OTT<ConnType,numPol>::coo2C(connec[1]);
+ int middleNode = OTT<ConnType,numPol>::coo2C(connec[2]);
+ return INTERP_KERNEL::calculateLgthForSeg3(coords+(SPACEDIM*beginNode),coords+(SPACEDIM*endNode),coords+(SPACEDIM*middleNode),SPACEDIM);
+ }
case INTERP_KERNEL::NORM_TRI3 :
{
int N1 = OTT<ConnType,numPol>::coo2C(connec[0]);
delete [] pts;
return val;
}
+ break;
case INTERP_KERNEL::NORM_TETRA4 :
case INTERP_KERNEL::NORM_TETRA10 :
{
switch(type)
{
case NORM_SEG2:
- case NORM_SEG3:
case NORM_SEG4:
{
std::copy(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[0]),
std::transform(res,res+SPACEDIM,res,std::bind2nd(std::multiplies<double>(),0.5));
break;
}
+ case NORM_SEG3:
+ {
+ if(SPACEDIM==2)
+ {
+ Edge *ed=Edge::BuildEdgeFrom3Points(coords+2*OTT<ConnType,numPol>::coo2C(connec[0]),coords+2*OTT<ConnType,numPol>::coo2C(connec[2]),coords+2*OTT<ConnType,numPol>::coo2C(connec[1]));
+ ed->getBarycenter(res);
+ ed->decrRef();
+ }
+ else if(SPACEDIM==1)
+ {
+ *res=(coords[OTT<ConnType,numPol>::coo2C(connec[0])]+coords[OTT<ConnType,numPol>::coo2C(connec[1])])/2.;
+ }
+ else if(SPACEDIM==3)
+ {
+ std::copy(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[0]),
+ coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[0]+1),res);
+ std::transform(res,res+SPACEDIM,coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[1]),res,std::plus<double>());
+ std::transform(res,res+SPACEDIM,res,std::bind2nd(std::multiplies<double>(),0.5));
+ }
+ else
+ throw INTERP_KERNEL::Exception("computeBarycenter for SEG3 only SPACEDIM 1,2 or 3 supported !");
+ break;
+ }
case NORM_TRI3:
- case NORM_TRI6:
case NORM_TRI7:
{
std::copy(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[0]),
std::transform(res,res+SPACEDIM,res,std::bind2nd(std::multiplies<double>(),1./3.));
break;
}
+ case NORM_TRI6:
+ {
+ if(SPACEDIM==2)
+ {
+ double *pts[6];
+ pts[0] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[0]));
+ pts[1] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[1]));
+ pts[2] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[2]));
+ pts[3] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[3]));
+ pts[4] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[4]));
+ pts[5] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[5]));
+ computeQPolygonBarycenter2D(pts,6,2,res);
+ }
+ else if(SPACEDIM==3)
+ computePolygonBarycenter3D<ConnType,numPol>(connec,lgth/2,coords,res);
+ else
+ throw INTERP_KERNEL::Exception("Impossible spacedim linked to cell 2D Cell !");
+ break;
+ }
case NORM_QUAD4:
case NORM_POLYGON:
{
case NORM_QUAD8:
{
if(SPACEDIM==2)
- computePolygonBarycenter2D<ConnType,numPol>(connec,lgth/2,coords,res);
+ {
+ double *pts[8];
+ pts[0] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[0]));
+ pts[1] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[1]));
+ pts[2] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[2]));
+ pts[3] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[3]));
+ pts[4] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[4]));
+ pts[5] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[5]));
+ pts[6] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[6]));
+ pts[7] = const_cast<double *>(coords+SPACEDIM*OTT<ConnType,numPol>::coo2C(connec[7]));
+ computeQPolygonBarycenter2D(pts,8,2,res);
+ }
+ else if(SPACEDIM==3)
+ computePolygonBarycenter3D<ConnType,numPol>(connec,lgth/2,coords,res);
+ else
+ throw INTERP_KERNEL::Exception("Impossible spacedim linked to cell 2D Cell !");
+ break;
+ }
+ case INTERP_KERNEL::NORM_QPOLYG :
+ {
+ if(SPACEDIM==2)
+ {
+ double **pts=new double *[lgth];
+ for(int i=0;i<lgth;i++)
+ pts[i]=const_cast<double *>(coords+2*OTT<ConnType,numPol>::coo2C(connec[i]));
+ computeQPolygonBarycenter2D(pts,lgth,2,res);
+ delete [] pts;
+ }
else if(SPACEDIM==3)
computePolygonBarycenter3D<ConnType,numPol>(connec,lgth/2,coords,res);
else
throw INTERP_KERNEL::Exception("Impossible spacedim linked to cell 2D Cell !");
break;
}
+ break;
case NORM_TETRA4:
{
res[0]=coords[3*OTT<ConnType,numPol>::coo2C(connec[0])];
# Author : Anthony Geay (CEA/DEN)
ADD_SUBDIRECTORY(Swig)
-ADD_SUBDIRECTORY(Test)
+
+IF(CPPUNIT_IS_OK)
+ ADD_SUBDIRECTORY(Test)
+ENDIF(CPPUNIT_IS_OK)
INCLUDE_DIRECTORIES(
${MED3_INCLUDE_DIRS}
#
# Author : Anthony Geay (CEA/DEN)
-ADD_SUBDIRECTORY(Test)
+IF(CPPUNIT_STATUS)
+ ADD_SUBDIRECTORY(Test)
+ENDIF(CPPUNIT_STATUS)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}/../..
int *pt=ret3D->getPointer();
for(int i=0;i<nbOfLevs;i++,pt+=nbOfCells2D)
std::copy(ret2D->begin(),ret2D->end(),pt);
+ ret3D->applyLin(2,0,0);
+ return ret3D->renumberR(_mesh3D_ids->begin());
+}
+
+DataArrayInt *MEDCouplingExtrudedMesh::computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2D=_mesh2D->computeNbOfNodesPerCell();
+ int nbOfLevs=_mesh1D->getNumberOfCells();
+ int nbOfCells2D=_mesh2D->getNumberOfCells();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret3D=DataArrayInt::New(); ret3D->alloc(nbOfLevs*nbOfCells2D,1);
+ int *pt=ret3D->getPointer();
+ for(int i=0;i<nbOfLevs;i++,pt+=nbOfCells2D)
+ std::copy(ret2D->begin(),ret2D->end(),pt);
+ ret3D->applyLin(2,2,0);
return ret3D->renumberR(_mesh3D_ids->begin());
}
std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const throw(INTERP_KERNEL::Exception);
return ret;
}
-void MEDCouplingFieldDiscretizationP0::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
+void MEDCouplingFieldDiscretizationP0::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
{
if(!mesh)
const int *array=old2NewBg;
if(check)
array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
- for(std::vector<DataArrayDouble *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
+ for(std::vector<DataArray *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
{
if(*it)
(*it)->renumberInPlace(array);
}
if(check)
- delete [] array;
+ free(const_cast<int *>(array));
}
DataArrayDouble *MEDCouplingFieldDiscretizationP0::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
{
}
-void MEDCouplingFieldDiscretizationP0::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDiscretizationP0::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception)
{
- if(!mesh)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP0::checkCoherencyBetween : NULL input mesh !");
+ if(!mesh || !da)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP0::checkCoherencyBetween : NULL input mesh or DataArray !");
if(mesh->getNumberOfCells()!=da->getNumberOfTuples())
{
std::ostringstream message;
/*!
* Nothing to do here.
*/
-void MEDCouplingFieldDiscretizationOnNodes::renumberArraysForCell(const MEDCouplingMesh *, const std::vector<DataArrayDouble *>& arrays,
+void MEDCouplingFieldDiscretizationOnNodes::renumberArraysForCell(const MEDCouplingMesh *, const std::vector<DataArray *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
{
}
trueTupleRestriction=ret2.retn();
}
-void MEDCouplingFieldDiscretizationOnNodes::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDiscretizationOnNodes::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception)
{
- if(!mesh)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationNodes::checkCoherencyBetween : NULL input mesh !");
+ if(!mesh || !da)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationNodes::checkCoherencyBetween : NULL input mesh or DataArray !");
if(mesh->getNumberOfNodes()!=da->getNumberOfTuples())
{
std::ostringstream message;
return ret;
}
-void MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception)
{
if(!_discr_per_cell)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell has no discretization per cell !");
if(!mesh)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween : NULL input mesh !");
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween : NULL input mesh or DataArray !");
int nbOfTuples=_discr_per_cell->getNumberOfTuples();
if(nbOfTuples!=mesh->getNumberOfCells())
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell has a discretization per cell but it's not matching the underlying mesh !");
_discr_per_cell=dpc;
//
if(check)
- delete [] const_cast<int *>(array);
+ free(const_cast<int *>(array));
}
void MEDCouplingFieldDiscretizationPerCell::buildDiscrPerCellIfNecessary(const MEDCouplingMesh *mesh)
return ret.retn();
}
-void MEDCouplingFieldDiscretizationGauss::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
+void MEDCouplingFieldDiscretizationGauss::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
{
if(!mesh)
array2[j]=array3[array[i]]+k;
}
delete [] array3;
- for(std::vector<DataArrayDouble *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
+ for(std::vector<DataArray *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
if(*it)
(*it)->renumberInPlace(array2);
delete [] array2;
if(check)
- delete [] const_cast<int*>(array);
+ free(const_cast<int*>(array));
}
DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
return da->getIJ(offset+nodeIdInCell,compoId);
}
-void MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception)
{
- if(!mesh)
- throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween : NULL input mesh !");
+ if(!mesh || !da)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween : NULL input mesh or DataArray !");
MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(mesh,da);
for(std::vector<MEDCouplingGaussLocalization>::const_iterator iter=_loc.begin();iter!=_loc.end();iter++)
(*iter).checkCoherency();
return ret;
}
-void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
+void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
{
if(!mesh)
array2[j]=array3[array[i]]+k;
}
delete [] array3;
- for(std::vector<DataArrayDouble *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
+ for(std::vector<DataArray *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
if(*it)
(*it)->renumberInPlace(array2);
delete [] array2;
if(check)
- delete [] const_cast<int *>(array);
+ free(const_cast<int *>(array));
}
DataArrayDouble *MEDCouplingFieldDiscretizationGaussNE::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
return da->getIJ(offset+nodeIdInCell,compoId);
}
-void MEDCouplingFieldDiscretizationGaussNE::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDiscretizationGaussNE::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception)
{
int nbOfTuples=getNumberOfTuples(mesh);
if(nbOfTuples!=da->getNumberOfTuples())
namespace ParaMEDMEM
{
+ class DataArray;
class DataArrayInt;
class MEDCouplingMesh;
class DataArrayDouble;
DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception) = 0;
virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) = 0;
virtual void renumberCells(const int *old2NewBg, bool check=true) throw(INTERP_KERNEL::Exception);
- virtual void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
+ virtual void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0;
virtual double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
- virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0;
virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
- void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
+ void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
- void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
+ void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
- void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
+ void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
- void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
+ void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const int *startCellIds, const int *endCellIds) const;
~MEDCouplingFieldDiscretizationPerCell();
void updateTime() const;
std::size_t getHeapMemorySize() const;
- void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
+ void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
- void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
+ void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
void getSerializationIntArray(DataArrayInt *& arr) const;
void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
- void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
+ void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
- void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
+ void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArray *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception);
DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception);
void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
- void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
+ void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
_type->renumberCells(old2NewBg,check);
std::vector<DataArrayDouble *> arrays;
_time_discr->getArrays(arrays);
- _type->renumberArraysForCell(_mesh,arrays,old2NewBg,check);
+ std::vector<DataArray *> arrays2(arrays.size()); std::copy(arrays.begin(),arrays.end(),arrays2.begin());
+ _type->renumberArraysForCell(_mesh,arrays2,old2NewBg,check);
//
updateTime();
}
}
}
+/*!
+ * Sets information on all components. This method can change number of components
+ * at certain conditions; if the conditions are not respected, an exception is thrown.
+ * The number of components can be changed provided that \a this is not allocated.
+ *
+ * To know more on format of the component information see
+ * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
+ * \param [in] info - a vector of component infos.
+ * \throw If \a this->getNumberOfComponents() != \a info.size() && \a this->isAllocated()
+ */
+void DataArray::setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=(int)info.size())
+ {
+ if(!isAllocated())
+ _info_on_compo=info;
+ else
+ {
+ std::ostringstream oss; oss << "DataArray::setInfoAndChangeNbOfCompo : input is of size " << info.size() << " whereas number of components is equal to " << getNumberOfComponents() << " and this is already allocated !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ _info_on_compo=info;
+}
+
void DataArray::checkNbOfTuples(int nbOfTuples, const char *msg) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfTuples()!=nbOfTuples)
}
}
+/*!
+ * This method is useful to slice work among a pool of threads or processes. \a begin, \a end \a step is the input whole slice of work to perform,
+ * typically it is a whole slice of tuples of DataArray or cells, nodes of a mesh...
+ *
+ * The input \a sliceId should be an id in [0, \a nbOfSlices) that specifies the slice of work.
+ *
+ * \param [in] start - the start of the input slice of the whole work to perform splitted into slices.
+ * \param [in] stop - the stop of the input slice of the whole work to perform splitted into slices.
+ * \param [in] step - the step (that can be <0) of the input slice of the whole work to perform splitted into slices.
+ * \param [in] sliceId - the slice id considered
+ * \param [in] nbOfSlices - the number of slices (typically the number of cores on which the work is expected to be sliced)
+ * \param [out] startSlice - the start of the slice considered
+ * \param [out] stopSlice - the stop of the slice consided
+ *
+ * \throw If \a step == 0
+ * \throw If \a nbOfSlices not > 0
+ * \throw If \a sliceId not in [0,nbOfSlices)
+ */
+void DataArray::GetSlice(int start, int stop, int step, int sliceId, int nbOfSlices, int& startSlice, int& stopSlice) throw(INTERP_KERNEL::Exception)
+{
+ if(nbOfSlices<=0)
+ {
+ std::ostringstream oss; oss << "DataArray::GetSlice : nbOfSlices (" << nbOfSlices << ") must be > 0 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(sliceId<0 || sliceId>=nbOfSlices)
+ {
+ std::ostringstream oss; oss << "DataArray::GetSlice : sliceId (" << nbOfSlices << ") must be in [0 , nbOfSlices (" << nbOfSlices << ") ) !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int nbElems=GetNumberOfItemGivenBESRelative(start,stop,step,"DataArray::GetSlice");
+ int minNbOfElemsPerSlice=nbElems/nbOfSlices;
+ startSlice=start+minNbOfElemsPerSlice*step*sliceId;
+ if(sliceId<nbOfSlices-1)
+ stopSlice=start+minNbOfElemsPerSlice*step*(sliceId+1);
+ else
+ stopSlice=stop;
+}
+
int DataArray::GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception)
{
if(end<begin)
return DataArray::getHeapMemorySize()+sz;
}
-/*!
- * Sets information on all components. This method can change number of components
- * at certain conditions; if the conditions are not respected, an exception is thrown.
- * The number of components can be changed provided that \a this is not allocated.
- *
- * To know more on format of the component information see
- * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
- * \param [in] info - a vector of component infos.
- * \throw If \a this->getNumberOfComponents() != \a info.size() && \a this->isAllocated()
- */
-void DataArrayDouble::setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
-{
- if(getNumberOfComponents()!=(int)info.size())
- {
- if(!isAllocated())
- _info_on_compo=info;
- else
- {
- std::ostringstream oss; oss << "DataArrayDouble::setInfoAndChangeNbOfCompo : input is of size " << info.size() << " whereas number of components is equal to " << getNumberOfComponents() << " and this is already allocated !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- else
- _info_on_compo=info;
-}
-
/*!
* Returns the only one value in \a this, if and only if number of elements
* (nb of tuples * nb of components) is equal to 1, and that \a this is allocated.
throw INTERP_KERNEL::Exception("DataArrayDouble::fromNoInterlace : Not defined array !");
double *tab=_mem.fromNoInterlace(getNumberOfComponents());
DataArrayDouble *ret=DataArrayDouble::New();
- ret->useArray(tab,true,CPP_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
+ ret->useArray(tab,true,C_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
return ret;
}
throw INTERP_KERNEL::Exception("DataArrayDouble::toNoInterlace : Not defined array !");
double *tab=_mem.toNoInterlace(getNumberOfComponents());
DataArrayDouble *ret=DataArrayDouble::New();
- ret->useArray(tab,true,CPP_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
+ ret->useArray(tab,true,C_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
return ret;
}
* \throw If \a end > \a this->getNumberOfTuples().
* \throw If \a this is not allocated.
*/
-DataArrayDouble *DataArrayDouble::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception)
+DataArray *DataArrayDouble::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
int nbOfComp=getNumberOfComponents();
*
* \ref py_mcdataarraydouble_KeepSelectedComponents "Here is a Python example".
*/
-DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
+DataArray *DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
throw INTERP_KERNEL::Exception("DataArrayDouble::meldWith : mismatch of number of tuples !");
int nbOfComp1=getNumberOfComponents();
int nbOfComp2=other->getNumberOfComponents();
- double *newArr=new double[nbOfTuples*(nbOfComp1+nbOfComp2)];
+ double *newArr=(double *)malloc((nbOfTuples*(nbOfComp1+nbOfComp2))*sizeof(double));
double *w=newArr;
const double *inp1=getConstPointer();
const double *inp2=other->getConstPointer();
w=std::copy(inp1,inp1+nbOfComp1,w);
w=std::copy(inp2,inp2+nbOfComp2,w);
}
- useArray(newArr,true,CPP_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+ useArray(newArr,true,C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
std::vector<int> compIds(nbOfComp2);
for(int i=0;i<nbOfComp2;i++)
compIds[i]=nbOfComp1+i;
* \throw If any tuple index given by \a tuplesSelec is out of a valid range for
* \a a array.
*/
-void DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
+void DataArrayDouble::setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
{
- if(!a || !tuplesSelec)
+ if(!aBase || !tuplesSelec)
throw INTERP_KERNEL::Exception("DataArrayDouble::setContigPartOfSelectedValues : input DataArray is NULL !");
+ const DataArrayDouble *a=dynamic_cast<const DataArrayDouble *>(aBase);
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::setContigPartOfSelectedValues : input DataArray aBase is not a DataArrayDouble !");
checkAllocated();
a->checkAllocated();
tuplesSelec->checkAllocated();
* non-empty range of increasing indices or indices are out of a valid range
* for the array \a a.
*/
-void DataArrayDouble::setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayDouble *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
+void DataArrayDouble::setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
{
+ if(!aBase)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::setContigPartOfSelectedValues2 : input DataArray is NULL !");
+ const DataArrayDouble *a=dynamic_cast<const DataArrayDouble *>(aBase);
if(!a)
- throw INTERP_KERNEL::Exception("DataArrayDouble::setContigPartOfSelectedValues2 : input DataArrayDouble is NULL !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::setContigPartOfSelectedValues2 : input DataArray aBase is not a DataArrayDouble !");
checkAllocated();
a->checkAllocated();
int nbOfComp=getNumberOfComponents();
return ret;
}
+/*!
+ * This method returns the number of values in \a this that are equals ( within an absolute precision of \a eps ) to input parameter \a value.
+ * This method only works for single component array.
+ *
+ * \return a value in [ 0, \c this->getNumberOfTuples() )
+ *
+ * \throw If \a this is not allocated
+ *
+ */
+int DataArrayDouble::count(double value, double eps) const throw(INTERP_KERNEL::Exception)
+{
+ int ret=0;
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::count : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
+ const double *vals=begin();
+ int nbOfTuples=getNumberOfTuples();
+ for(int i=0;i<nbOfTuples;i++,vals++)
+ if(fabs(*vals-value)<=eps)
+ ret++;
+ return ret;
+}
+
/*!
* Returns the average value of \a this one-dimensional array.
* \return double - the average value over all values of \a this array.
return ret;
}
+/*!
+ * This method accumulate using addition tuples in \a this using input index array [ \a bgOfIndex, \a endOfIndex ).
+ * The returned array will have same number of components than \a this and number of tuples equal to
+ * \c std::distance(bgOfIndex,endOfIndex) \b minus \b one.
+ *
+ * The input index array is expected to be ascendingly sorted in which the all referenced ids should be in [0, \c this->getNumberOfTuples).
+ * This method is quite useful for users that need to put a field on cells to field on nodes on the same mesh without a need of conservation.
+ *
+ * \param [in] bgOfIndex - begin (included) of the input index array.
+ * \param [in] endOfIndex - end (excluded) of the input index array.
+ * \return DataArrayDouble * - the new instance having the same number of components than \a this.
+ *
+ * \throw If bgOfIndex or end is NULL.
+ * \throw If input index array is not ascendingly sorted.
+ * \throw If there is an id in [ \a bgOfIndex, \a endOfIndex ) not in [0, \c this->getNumberOfTuples).
+ * \throw If std::distance(bgOfIndex,endOfIndex)==0.
+ */
+DataArrayDouble *DataArrayDouble::accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const throw(INTERP_KERNEL::Exception)
+{
+ if(!bgOfIndex || !endOfIndex)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::accumulatePerChunck : input pointer NULL !");
+ checkAllocated();
+ int nbCompo=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ int sz=(int)std::distance(bgOfIndex,endOfIndex);
+ if(sz<1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::accumulatePerChunck : invalid size of input index array !");
+ sz--;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New(); ret->alloc(sz,nbCompo);
+ const int *w=bgOfIndex;
+ if(*w<0 || *w>=nbOfTuples)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::accumulatePerChunck : The first element of the input index not in [0,nbOfTuples) !");
+ const double *srcPt=begin()+(*w)*nbCompo;
+ double *tmp=ret->getPointer();
+ for(int i=0;i<sz;i++,tmp+=nbCompo,w++)
+ {
+ std::fill(tmp,tmp+nbCompo,0.);
+ if(w[1]>=w[0])
+ {
+ for(int j=w[0];j<w[1];j++,srcPt+=nbCompo)
+ {
+ if(j>=0 && j<nbOfTuples)
+ std::transform(srcPt,srcPt+nbCompo,tmp,tmp,std::plus<double>());
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayDouble::accumulatePerChunck : At rank #" << i << " the input index array points to id " << j << " should be in [0," << nbOfTuples << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayDouble::accumulatePerChunck : At rank #" << i << " the input index array is not in ascendingly sorted.";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ ret->copyStringInfoFrom(*this);
+ return ret.retn();
+}
+
/*!
* Converts each 2D point defined by the tuple of \a this array from the Polar to the
* Cartesian coordinate system. The two components of the tuple of \a this array are
* The caller is to delete this result array using decrRef() as it is no more
* needed.
* \throw If \a this is not allocated.
+ * \sa DataArrayDouble::maxPerTupleWithCompoId
*/
DataArrayDouble *DataArrayDouble::maxPerTuple() const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
int nbOfComp=getNumberOfComponents();
- DataArrayDouble *ret=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
int nbOfTuple=getNumberOfTuples();
ret->alloc(nbOfTuple,1);
const double *src=getConstPointer();
double *dest=ret->getPointer();
for(int i=0;i<nbOfTuple;i++,dest++,src+=nbOfComp)
*dest=*std::max_element(src,src+nbOfComp);
- return ret;
+ return ret.retn();
+}
+
+/*!
+ * Computes the maximal value within every tuple of \a this array and it returns the first component
+ * id for each tuple that corresponds to the maximal value within the tuple.
+ *
+ * \param [out] compoIdOfMaxPerTuple - the new new instance of DataArrayInt containing the
+ * same number of tuples and only one component.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble containing the
+ * same number of tuples as \a this array and one component.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If \a this is not allocated.
+ * \sa DataArrayDouble::maxPerTuple
+ */
+DataArrayDouble *DataArrayDouble::maxPerTupleWithCompoId(DataArrayInt* &compoIdOfMaxPerTuple) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int nbOfComp=getNumberOfComponents();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret0=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1=DataArrayInt::New();
+ int nbOfTuple=getNumberOfTuples();
+ ret0->alloc(nbOfTuple,1); ret1->alloc(nbOfTuple,1);
+ const double *src=getConstPointer();
+ double *dest=ret0->getPointer(); int *dest1=ret1->getPointer();
+ for(int i=0;i<nbOfTuple;i++,dest++,dest1++,src+=nbOfComp)
+ {
+ const double *loc=std::max_element(src,src+nbOfComp);
+ *dest=*loc;
+ *dest1=(int)std::distance(src,loc);
+ }
+ compoIdOfMaxPerTuple=ret1.retn();
+ return ret0.retn();
}
/*!
/*!
* Returns a new DataArrayInt contating indices of tuples of \a this one-dimensional
* array whose values are within a given range. Textual data is not copied.
- * \param [in] vmin - a lowest acceptable value.
- * \param [in] vmax - a greatest acceptable value.
+ * \param [in] vmin - a lowest acceptable value (included).
+ * \param [in] vmax - a greatest acceptable value (included).
* \return DataArrayInt * - the new instance of DataArrayInt.
* The caller is to delete this result array using decrRef() as it is no more
* needed.
return DataArray::getHeapMemorySize()+sz;
}
-/*!
- * Sets information on all components. This method can change number of components
- * at certain conditions; if the conditions are not respected, an exception is thrown.
- * The number of components can be changed provided that \a this is not allocated.
- *
- * To know more on format of the component information see
- * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
- * \param [in] info - a vector of component infos.
- * \throw If \a this->getNumberOfComponents() != \a info.size() && \a this->isAllocated()
- */
-void DataArrayInt::setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
-{
- if(getNumberOfComponents()!=(int)info.size())
- {
- if(!isAllocated())
- _info_on_compo=info;
- else
- {
- std::ostringstream oss; oss << "DataArrayInt::setInfoAndChangeNbOfCompo : input is of size " << info.size() << " whereas number of components is equal to " << getNumberOfComponents() << " and this is already allocated !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- else
- _info_on_compo=info;
-}
-
/*!
* Returns the only one value in \a this, if and only if number of elements
* (nb of tuples * nb of components) is equal to 1, and that \a this is allocated.
throw INTERP_KERNEL::Exception("DataArrayInt::fromNoInterlace : Not defined array !");
int *tab=_mem.fromNoInterlace(getNumberOfComponents());
DataArrayInt *ret=DataArrayInt::New();
- ret->useArray(tab,true,CPP_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
+ ret->useArray(tab,true,C_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
return ret;
}
throw INTERP_KERNEL::Exception("DataArrayInt::toNoInterlace : Not defined array !");
int *tab=_mem.toNoInterlace(getNumberOfComponents());
DataArrayInt *ret=DataArrayInt::New();
- ret->useArray(tab,true,CPP_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
+ ret->useArray(tab,true,C_DEALLOC,getNumberOfTuples(),getNumberOfComponents());
return ret;
}
* \throw If \a end > \a this->getNumberOfTuples().
* \throw If \a this is not allocated.
*/
-DataArrayInt *DataArrayInt::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception)
+DataArray *DataArrayInt::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
int nbOfComp=getNumberOfComponents();
const int *pt=getConstPointer();
int *pt2=CheckAndPreparePermutation(pt,pt+nbTuples);
DataArrayInt *ret=DataArrayInt::New();
- ret->useArray(pt2,true,CPP_DEALLOC,nbTuples,1);
+ ret->useArray(pt2,true,C_DEALLOC,nbTuples,1);
return ret;
}
*
* \ref py_mcdataarrayint_keepselectedcomponents "Here is a Python example".
*/
-DataArrayInt *DataArrayInt::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
+DataArray *DataArrayInt::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New());
throw INTERP_KERNEL::Exception("DataArrayInt::meldWith : mismatch of number of tuples !");
int nbOfComp1=getNumberOfComponents();
int nbOfComp2=other->getNumberOfComponents();
- int *newArr=new int[nbOfTuples*(nbOfComp1+nbOfComp2)];
+ int *newArr=(int *)malloc(nbOfTuples*(nbOfComp1+nbOfComp2)*sizeof(int));
int *w=newArr;
const int *inp1=getConstPointer();
const int *inp2=other->getConstPointer();
w=std::copy(inp1,inp1+nbOfComp1,w);
w=std::copy(inp2,inp2+nbOfComp2,w);
}
- useArray(newArr,true,CPP_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+ useArray(newArr,true,C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
std::vector<int> compIds(nbOfComp2);
for(int i=0;i<nbOfComp2;i++)
compIds[i]=nbOfComp1+i;
* \throw If any tuple index given by \a tuplesSelec is out of a valid range for
* \a a array.
*/
-void DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArrayInt*a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
+void DataArrayInt::setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
{
+ if(!aBase || !tuplesSelec)
+ throw INTERP_KERNEL::Exception("DataArrayInt::setContigPartOfSelectedValues : input DataArray is NULL !");
+ const DataArrayInt *a=dynamic_cast<const DataArrayInt *>(aBase);
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayInt::setContigPartOfSelectedValues : input DataArray aBase is not a DataArrayInt !");
checkAllocated();
a->checkAllocated();
tuplesSelec->checkAllocated();
* non-empty range of increasing indices or indices are out of a valid range
* for the array \a a.
*/
-void DataArrayInt::setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayInt *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
+void DataArrayInt::setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
{
+ if(!aBase)
+ throw INTERP_KERNEL::Exception("DataArrayInt::setContigPartOfSelectedValues2 : input DataArray is NULL !");
+ const DataArrayInt *a=dynamic_cast<const DataArrayInt *>(aBase);
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayInt::setContigPartOfSelectedValues2 : input DataArray aBase is not a DataArrayInt !");
checkAllocated();
a->checkAllocated();
int nbOfComp=getNumberOfComponents();
return -1;
}
+/*!
+ * This method returns the number of values in \a this that are equals to input parameter \a value.
+ * This method only works for single component array.
+ *
+ * \return a value in [ 0, \c this->getNumberOfTuples() )
+ *
+ * \throw If \a this is not allocated
+ *
+ */
+int DataArrayInt::count(int value) const throw(INTERP_KERNEL::Exception)
+{
+ int ret=0;
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::count : must be applied on DataArrayInt with only one component, you can call 'rearrange' method before !");
+ const int *vals=begin();
+ int nbOfTuples=getNumberOfTuples();
+ for(int i=0;i<nbOfTuples;i++,vals++)
+ if(*vals==value)
+ ret++;
+ return ret;
+}
+
/*!
* This method is an extension of DataArrayInt::presenceOfValue method because this method works for DataArrayInt with
* any number of components excepted 0 (an INTERP_KERNEL::Exception is thrown in this case).
return ret;
}
+/*!
+ * This method accumulate using addition tuples in \a this using input index array [ \a bgOfIndex, \a endOfIndex ).
+ * The returned array will have same number of components than \a this and number of tuples equal to
+ * \c std::distance(bgOfIndex,endOfIndex) \b minus \b one.
+ *
+ * The input index array is expected to be ascendingly sorted in which the all referenced ids should be in [0, \c this->getNumberOfTuples).
+ *
+ * \param [in] bgOfIndex - begin (included) of the input index array.
+ * \param [in] endOfIndex - end (excluded) of the input index array.
+ * \return DataArrayInt * - the new instance having the same number of components than \a this.
+ *
+ * \throw If bgOfIndex or end is NULL.
+ * \throw If input index array is not ascendingly sorted.
+ * \throw If there is an id in [ \a bgOfIndex, \a endOfIndex ) not in [0, \c this->getNumberOfTuples).
+ * \throw If std::distance(bgOfIndex,endOfIndex)==0.
+ */
+DataArrayInt *DataArrayInt::accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const throw(INTERP_KERNEL::Exception)
+{
+ if(!bgOfIndex || !endOfIndex)
+ throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : input pointer NULL !");
+ checkAllocated();
+ int nbCompo=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ int sz=(int)std::distance(bgOfIndex,endOfIndex);
+ if(sz<1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : invalid size of input index array !");
+ sz--;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New(); ret->alloc(sz,nbCompo);
+ const int *w=bgOfIndex;
+ if(*w<0 || *w>=nbOfTuples)
+ throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : The first element of the input index not in [0,nbOfTuples) !");
+ const int *srcPt=begin()+(*w)*nbCompo;
+ int *tmp=ret->getPointer();
+ for(int i=0;i<sz;i++,tmp+=nbCompo,w++)
+ {
+ std::fill(tmp,tmp+nbCompo,0.);
+ if(w[1]>=w[0])
+ {
+ for(int j=w[0];j<w[1];j++,srcPt+=nbCompo)
+ {
+ if(j>=0 && j<nbOfTuples)
+ std::transform(srcPt,srcPt+nbCompo,tmp,tmp,std::plus<int>());
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::accumulatePerChunck : At rank #" << i << " the input index array points to id " << j << " should be in [0," << nbOfTuples << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::accumulatePerChunck : At rank #" << i << " the input index array is not in ascendingly sorted.";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ ret->copyStringInfoFrom(*this);
+ return ret.retn();
+}
+
/*!
* Returns a new DataArrayInt by concatenating two given arrays, so that (1) the number
* of tuples in the result array is <em> a1->getNumberOfTuples() + a2->getNumberOfTuples() -
/*!
* Returns the maximal value and its location within \a this one-dimensional array.
* \param [out] tupleId - index of the tuple holding the maximal value.
- * \return double - the maximal value among all values of \a this array.
+ * \return int - the maximal value among all values of \a this array.
* \throw If \a this->getNumberOfComponents() != 1
* \throw If \a this->getNumberOfTuples() < 1
*/
* This method returns a newly allocated array storing stored ascendantly tuple ids in \b this so that
* this[*id] in [\b vmin,\b vmax)
*
- * \param [in] vmin begin of range. This value is included in range.
- * \param [out] vmax end of range. This value is \b not included in range.
+ * \param [in] vmin begin of range. This value is included in range (included).
+ * \param [out] vmax end of range. This value is \b not included in range (excluded).
* \return a newly allocated data array that the caller should deal with.
*/
DataArrayInt *DataArrayInt::getIdsInRange(int vmin, int vmax) const throw(INTERP_KERNEL::Exception)
/*!
* Returns a new DataArrayInt which contains all elements of given one-dimensional
- * not negative arrays. The result array does not contain any duplicates and its values
+ * arrays. The result array does not contain any duplicates and its values
* are sorted in ascending order.
* \param [in] arr - sequence of DataArrayInt's to unite.
* \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
* array using decrRef() as it is no more needed.
* \throw If any \a arr[i] is not allocated.
* \throw If \a arr[i]->getNumberOfComponents() != 1.
- * \throw If any value of \a arr[i] is negative.
*/
DataArrayInt *DataArrayInt::BuildUnion(const std::vector<const DataArrayInt *>& arr) throw(INTERP_KERNEL::Exception)
{
for(std::vector<const DataArrayInt *>::const_iterator it4=arr.begin();it4!=arr.end();it4++)
if(*it4)
a.push_back(*it4);
- int valm=std::numeric_limits<int>::max();
for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
{
(*it)->checkAllocated();
if((*it)->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !");
- int tmp1;
- valm=std::min((*it)->getMinValue(tmp1),valm);
}
- if(valm<0)
- throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !");
//
std::set<int> r;
for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
/*!
* Returns a new DataArrayInt which contains elements present in each of given one-dimensional
- * not negative arrays. The result array does not contain any duplicates and its values
+ * arrays. The result array does not contain any duplicates and its values
* are sorted in ascending order.
* \param [in] arr - sequence of DataArrayInt's to intersect.
* \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
* array using decrRef() as it is no more needed.
* \throw If any \a arr[i] is not allocated.
* \throw If \a arr[i]->getNumberOfComponents() != 1.
- * \throw If any value of \a arr[i] < 0.
*/
DataArrayInt *DataArrayInt::BuildIntersection(const std::vector<const DataArrayInt *>& arr) throw(INTERP_KERNEL::Exception)
{
for(std::vector<const DataArrayInt *>::const_iterator it4=arr.begin();it4!=arr.end();it4++)
if(*it4)
a.push_back(*it4);
- int valm=std::numeric_limits<int>::max();
for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
{
(*it)->checkAllocated();
if((*it)->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::BuildIntersection : only single component allowed !");
- int tmp1;
- valm=std::min((*it)->getMinValue(tmp1),valm);
}
- if(valm<0)
- throw INTERP_KERNEL::Exception("DataArrayInt::BuildIntersection : a negative value has been detected !");
//
std::set<int> r;
for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
/*!
* Returns a new DataArrayInt which contains all elements of \a this and a given
- * one-dimensional not negative arrays. The result array does not contain any duplicates
+ * one-dimensional arrays. The result array does not contain any duplicates
* and its values are sorted in ascending order.
* \param [in] other - an array to unite with \a this one.
* \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
* \throw If \a this or \a other is not allocated.
* \throw If \a this->getNumberOfComponents() != 1.
* \throw If \a other->getNumberOfComponents() != 1.
- * \throw If any value of \a this or \a other is negative.
*/
DataArrayInt *DataArrayInt::buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
{
/*!
* Returns a new DataArrayInt which contains elements present in both \a this and a given
- * one-dimensional not negative arrays. The result array does not contain any duplicates
+ * one-dimensional arrays. The result array does not contain any duplicates
* and its values are sorted in ascending order.
* \param [in] other - an array to intersect with \a this one.
* \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
* \throw If \a this or \a other is not allocated.
* \throw If \a this->getNumberOfComponents() != 1.
* \throw If \a other->getNumberOfComponents() != 1.
- * \throw If any value of \a this or \a other is negative.
*/
DataArrayInt *DataArrayInt::buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsets2 : only single component allowed !");
int nbOfTuples=getNumberOfTuples();
- int *ret=new int[nbOfTuples+1];
+ int *ret=(int *)malloc((nbOfTuples+1)*sizeof(int));
if(nbOfTuples==0)
return ;
const int *work=getConstPointer();
ret[0]=0;
for(int i=0;i<nbOfTuples;i++)
ret[i+1]=work[i]+ret[i];
- useArray(ret,true,CPP_DEALLOC,nbOfTuples+1,1);
+ useArray(ret,true,C_DEALLOC,nbOfTuples+1,1);
declareAsNew();
}
int *DataArrayInt::CheckAndPreparePermutation(const int *start, const int *end)
{
std::size_t sz=std::distance(start,end);
- int *ret=new int[sz];
+ int *ret=(int *)malloc(sz*sizeof(int));
int *work=new int[sz];
std::copy(start,end,work);
std::sort(work,work+sz);
if(std::unique(work,work+sz)!=work+sz)
{
delete [] work;
- delete [] ret;
+ free(ret);
throw INTERP_KERNEL::Exception("Some elements are equals in the specified array !");
}
+ std::map<int,int> m;
+ for(int *workPt=work;workPt!=work+sz;workPt++)
+ m[*workPt]=(int)std::distance(work,workPt);
int *iter2=ret;
for(const int *iter=start;iter!=end;iter++,iter2++)
- *iter2=(int)std::distance(work,std::find(work,work+sz,*iter));
+ *iter2=m[*iter];
delete [] work;
return ret;
}
Deallocator getDeallocator() const { return _dealloc; }
void setSpecificDeallocator(Deallocator dealloc) { _dealloc=dealloc; }
void setParameterForDeallocator(void *param) { _param_for_deallocator=param; }
+ void *getParameterForDeallocator() const { return _param_for_deallocator; }
void destroy();
~MemArray() { destroy(); }
public:
void *_param_for_deallocator;
};
+ class DataArrayInt;
+
class DataArray : public RefCountObject, public TimeLabel
{
public:
MEDCOUPLING_EXPORT const std::vector<std::string> &getInfoOnComponents() const { return _info_on_compo; }
MEDCOUPLING_EXPORT std::vector<std::string> &getInfoOnComponents() { return _info_on_compo; }
MEDCOUPLING_EXPORT void setInfoOnComponents(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::vector<std::string> getVarsOnComponent() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::vector<std::string> getUnitsOnComponent() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNumberOfComponents() const { return (int)_info_on_compo.size(); }
+ MEDCOUPLING_EXPORT virtual bool isAllocated() const throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual void checkAllocated() const throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual std::size_t getNbOfElemAllocated() const throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual void alloc(int nbOfTuple, int nbOfCompo=1) throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual void renumberInPlace(const int *old2New) throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual void renumberInPlaceR(const int *new2Old) throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const char *msg) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkNbOfElems(std::size_t nbOfElems, const char *msg) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static void GetSlice(int start, int stop, int step, int sliceId, int nbOfSlices, int& startSlice, int& stopSlice) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
MEDCOUPLING_EXPORT std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) { return _mem.getNbOfElem(); }
MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
- MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double doubleValue() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *deepCpy() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void transpose() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArray *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues4(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesSimple4(double a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayDouble *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const throw(INTERP_KERNEL::Exception) { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
MEDCOUPLING_EXPORT double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
MEDCOUPLING_EXPORT double back() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double getMinValueInArray() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double getMaxValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double getMinValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT int count(double value, double eps) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double getAverageValue() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double norm2() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double normMax() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void accumulate(double *res) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double accumulate(int compId) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayDouble *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double distanceToTuple(const double *tupleBg, const double *tupleEnd, int& tupleId) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *fromPolarToCart() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *fromCylToCart() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *deviator() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayDouble *maxPerTupleWithCompoId(DataArrayInt* &compoIdOfMaxPerTuple) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrix() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *buildEuclidianDistanceDenseMatrixWith(const DataArrayDouble *other) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
MEDCOUPLING_EXPORT std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) { return _mem.getNbOfElem(); }
MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
- MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int intValue() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getHashCode() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT DataArrayInt *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static DataArrayInt *BuildOld2NewArrayFromSurjectiveFormat2(int nbOfOldTuples, const int *arr, const int *arrIBg, const int *arrIEnd, int &newNbOfTuples) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void transpose() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArray *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues4(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesSimple4(int a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArrayInt*a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayInt *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const throw(INTERP_KERNEL::Exception) { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
MEDCOUPLING_EXPORT int getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception) { return _mem[tupleId*_info_on_compo.size()+compoId]; }
MEDCOUPLING_EXPORT int getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool presenceOfTuple(const std::vector<int>& tupl) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool presenceOfValue(int value) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT int count(int value) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void accumulate(int *res) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int accumulate(int compId) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
{
public:
MEDCOUPLING_EXPORT virtual DataArrayChar *buildEmptySpecializedDAChar() const throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual DataArrayChar *deepCpy() const = 0;
MEDCOUPLING_EXPORT bool isAllocated() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
MEDCOUPLING_EXPORT std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) { return _mem.getNbOfElem(); }
MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
- MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getHashCode() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool empty() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void cpyFrom(const DataArrayChar& other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayChar *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayChar *changeNbOfComponents(int newNbOfComp, char dftValue) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArray *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void meldWith(const DataArrayChar *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayChar *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesSimple1(char a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues4(const DataArrayChar *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesSimple4(char a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesAdv(const DataArrayChar *a, const DataArrayChar *tuplesSelec) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArray *selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void getTuple(int tupleId, char *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
MEDCOUPLING_EXPORT char getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
MEDCOUPLING_EXPORT char getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
#include "InterpolationUtils.hxx"
#include <sstream>
+#include <cstdlib>
#include <algorithm>
namespace ParaMEDMEM
if(!other._pointer.isNull())
{
_nb_of_elem_alloc=other._nb_of_elem;
- T *pointer=new T[_nb_of_elem_alloc];
+ T *pointer=(T*)malloc(_nb_of_elem_alloc*sizeof(T));
std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+other._nb_of_elem,pointer);
- useArray(pointer,true,CPP_DEALLOC,other._nb_of_elem);
+ useArray(pointer,true,C_DEALLOC,other._nb_of_elem);
}
}
throw INTERP_KERNEL::Exception("MemArray<T>::fromNoInterlace : number of components must be > 0 !");
const T *pt=_pointer.getConstPointer();
std::size_t nbOfTuples=_nb_of_elem/nbOfComp;
- T *ret=new T[_nb_of_elem];
+ T *ret=(T*)malloc(_nb_of_elem*sizeof(T));
T *w=ret;
for(std::size_t i=0;i<nbOfTuples;i++)
for(int j=0;j<nbOfComp;j++,w++)
throw INTERP_KERNEL::Exception("MemArray<T>::toNoInterlace : number of components must be > 0 !");
const T *pt=_pointer.getConstPointer();
std::size_t nbOfTuples=_nb_of_elem/nbOfComp;
- T *ret=new T[_nb_of_elem];
+ T *ret=(T*)malloc(_nb_of_elem*sizeof(T));
T *w=ret;
for(int i=0;i<nbOfComp;i++)
for(std::size_t j=0;j<nbOfTuples;j++,w++)
throw INTERP_KERNEL::Exception("MemArray::alloc : request for negative length of data !");
_nb_of_elem=nbOfElements;
_nb_of_elem_alloc=nbOfElements;
- _pointer.setInternal(new T[_nb_of_elem_alloc]);
+ _pointer.setInternal((T*)malloc(_nb_of_elem_alloc*sizeof(T)));
_ownership=true;
- _dealloc=CPPDeallocator;
+ _dealloc=CDeallocator;
}
/*!
throw INTERP_KERNEL::Exception("MemArray::reAlloc : request for negative length of data !");
if(_nb_of_elem_alloc==newNbOfElements)
return ;
- T *pointer=new T[newNbOfElements];
+ T *pointer=(T*)malloc(newNbOfElements*sizeof(T));
std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<std::size_t>(_nb_of_elem,newNbOfElements),pointer);
if(_ownership)
destroyPointer(const_cast<T *>(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external
_nb_of_elem=std::min<std::size_t>(_nb_of_elem,newNbOfElements);
_nb_of_elem_alloc=newNbOfElements;
_ownership=true;
- _dealloc=CPPDeallocator;
+ _dealloc=CDeallocator;
_param_for_deallocator=0;
}
throw INTERP_KERNEL::Exception("MemArray::reAlloc : request for negative length of data !");
if(_nb_of_elem==newNbOfElements)
return ;
- T *pointer=new T[newNbOfElements];
+ T *pointer=(T*)malloc(newNbOfElements*sizeof(T));
std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<std::size_t>(_nb_of_elem,newNbOfElements),pointer);
if(_ownership)
destroyPointer(const_cast<T *>(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external
_nb_of_elem=newNbOfElements;
_nb_of_elem_alloc=newNbOfElements;
_ownership=true;
- _dealloc=CPPDeallocator;
+ _dealloc=CDeallocator;
_param_for_deallocator=0;
}
return DataArray::getHeapMemorySize()+sz;
}
-/*!
- * Sets information on all components. This method can change number of components
- * at certain conditions; if the conditions are not respected, an exception is thrown.
- * The number of components can be changed provided that \a this is not allocated.
- *
- * To know more on format of the component information see
- * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos".
- * \param [in] info - a vector of component infos.
- * \throw If \a this->getNumberOfComponents() != \a info.size() && \a this->isAllocated()
- */
-void DataArrayChar::setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
-{
- if(getNumberOfComponents()!=(int)info.size())
- {
- if(!isAllocated())
- _info_on_compo=info;
- else
- {
- std::ostringstream oss; oss << "DataArrayChar::setInfoAndChangeNbOfCompo : input is of size " << info.size() << " whereas number of components is equal to " << getNumberOfComponents() << " and this is already allocated !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- else
- _info_on_compo=info;
-}
-
/*!
* Returns an integer value characterizing \a this array, which is useful for a quick
* comparison of many instances of DataArrayInt.
*
* \ref py_mcdataarrayint_keepselectedcomponents "Here is a Python example".
*/
-DataArrayChar *DataArrayChar::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
+DataArray *DataArrayChar::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayChar> ret(buildEmptySpecializedDAChar());
throw INTERP_KERNEL::Exception("DataArrayChar::meldWith : mismatch of number of tuples !");
int nbOfComp1=getNumberOfComponents();
int nbOfComp2=other->getNumberOfComponents();
- char *newArr=new char[nbOfTuples*(nbOfComp1+nbOfComp2)];
+ char *newArr=(char *)malloc(nbOfTuples*(nbOfComp1+nbOfComp2)*sizeof(char));
char *w=newArr;
const char *inp1=getConstPointer();
const char *inp2=other->getConstPointer();
w=std::copy(inp1,inp1+nbOfComp1,w);
w=std::copy(inp2,inp2+nbOfComp2,w);
}
- useArray(newArr,true,CPP_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+ useArray(newArr,true,C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
std::vector<int> compIds(nbOfComp2);
for(int i=0;i<nbOfComp2;i++)
compIds[i]=nbOfComp1+i;
}
}
+/*!
+ * Copy some tuples from another DataArrayChar (\a a) into contiguous tuples
+ * of \a this array. Textual data is not copied. Both arrays must have equal number of
+ * components.
+ * The tuples to assign to are defined by index of the first tuple, and
+ * their number is defined by \a tuplesSelec->getNumberOfTuples().
+ * The tuples to copy are defined by values of a DataArrayChar.
+ * All components of selected tuples are copied.
+ * \param [in] tupleIdStart - index of the first tuple of \a this array to assign
+ * values to.
+ * \param [in] a - the array to copy values from.
+ * \param [in] tuplesSelec - the array specifying tuples of \a a to copy.
+ * \throw If \a this is not allocated.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If \a tuplesSelec is NULL.
+ * \throw If \a tuplesSelec is not allocated.
+ * \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ * \throw If \a tuplesSelec->getNumberOfComponents() != 1.
+ * \throw If <em>tupleIdStart + tuplesSelec->getNumberOfTuples() > this->getNumberOfTuples().</em>
+ * \throw If any tuple index given by \a tuplesSelec is out of a valid range for
+ * \a a array.
+ */
+void DataArrayChar::setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
+{
+ if(!aBase || !tuplesSelec)
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues : input DataArray is NULL !");
+ const DataArrayChar *a=dynamic_cast<const DataArrayChar *>(aBase);
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues : input DataArray aBase is not a DataArrayChar !");
+ checkAllocated();
+ a->checkAllocated();
+ tuplesSelec->checkAllocated();
+ int nbOfComp=getNumberOfComponents();
+ if(nbOfComp!=a->getNumberOfComponents())
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues : This and a do not have the same number of components !");
+ if(tuplesSelec->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues : Expecting to have a tuple selector DataArrayChar instance with exactly 1 component !");
+ int thisNt=getNumberOfTuples();
+ int aNt=a->getNumberOfTuples();
+ int nbOfTupleToWrite=tuplesSelec->getNumberOfTuples();
+ char *valsToSet=getPointer()+tupleIdStart*nbOfComp;
+ if(tupleIdStart+nbOfTupleToWrite>thisNt)
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues : invalid number range of values to write !");
+ const char *valsSrc=a->getConstPointer();
+ for(const int *tuple=tuplesSelec->begin();tuple!=tuplesSelec->end();tuple++,valsToSet+=nbOfComp)
+ {
+ if(*tuple>=0 && *tuple<aNt)
+ {
+ std::copy(valsSrc+nbOfComp*(*tuple),valsSrc+nbOfComp*(*tuple+1),valsToSet);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayChar::setContigPartOfSelectedValues : Tuple #" << std::distance(tuplesSelec->begin(),tuple);
+ oss << " of 'tuplesSelec' request of tuple id #" << *tuple << " in 'a' ! It should be in [0," << aNt << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+}
+
+/*!
+ * Copy some tuples from another DataArrayChar (\a a) into contiguous tuples
+ * of \a this array. Textual data is not copied. Both arrays must have equal number of
+ * components.
+ * The tuples to copy are defined by three values similar to parameters of
+ * the Python function \c range(\c start,\c stop,\c step).
+ * The tuples to assign to are defined by index of the first tuple, and
+ * their number is defined by number of tuples to copy.
+ * All components of selected tuples are copied.
+ * \param [in] tupleIdStart - index of the first tuple of \a this array to assign
+ * values to.
+ * \param [in] a - the array to copy values from.
+ * \param [in] bg - index of the first tuple to copy of the array \a a.
+ * \param [in] end2 - index of the tuple of \a a before which the tuples to copy
+ * are located.
+ * \param [in] step - index increment to get index of the next tuple to copy.
+ * \throw If \a this is not allocated.
+ * \throw If \a a is NULL.
+ * \throw If \a a is not allocated.
+ * \throw If <em>this->getNumberOfComponents() != a->getNumberOfComponents()</em>.
+ * \throw If <em>tupleIdStart + len(range(bg,end2,step)) > this->getNumberOfTuples().</em>
+ * \throw If parameters specifying tuples to copy, do not give a
+ * non-empty range of increasing indices or indices are out of a valid range
+ * for the array \a a.
+ */
+void DataArrayChar::setContigPartOfSelectedValues2(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
+{
+ if(!aBase)
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues2 : input DataArray is NULL !");
+ const DataArrayChar *a=dynamic_cast<const DataArrayChar *>(aBase);
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues2 : input DataArray aBase is not a DataArrayChar !");
+ checkAllocated();
+ a->checkAllocated();
+ int nbOfComp=getNumberOfComponents();
+ const char msg[]="DataArrayChar::setContigPartOfSelectedValues2";
+ int nbOfTupleToWrite=DataArray::GetNumberOfItemGivenBES(bg,end2,step,msg);
+ if(nbOfComp!=a->getNumberOfComponents())
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues2 : This and a do not have the same number of components !");
+ int thisNt=getNumberOfTuples();
+ int aNt=a->getNumberOfTuples();
+ char *valsToSet=getPointer()+tupleIdStart*nbOfComp;
+ if(tupleIdStart+nbOfTupleToWrite>thisNt)
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues2 : invalid number range of values to write !");
+ if(end2>aNt)
+ throw INTERP_KERNEL::Exception("DataArrayChar::setContigPartOfSelectedValues2 : invalid range of values to read !");
+ const char *valsSrc=a->getConstPointer()+bg*nbOfComp;
+ for(int i=0;i<nbOfTupleToWrite;i++,valsToSet+=nbOfComp,valsSrc+=step*nbOfComp)
+ {
+ std::copy(valsSrc,valsSrc+nbOfComp,valsToSet);
+ }
+}
+
+/*!
+ * Returns a shorten copy of \a this array. The new DataArrayChar contains ranges
+ * of tuples specified by \a ranges parameter.
+ * For more info on renumbering see \ref MEDCouplingArrayRenumbering.
+ * \param [in] ranges - std::vector of std::pair's each of which defines a range
+ * of tuples in [\c begin,\c end) format.
+ * \return DataArrayChar * - the new instance of DataArrayChar that the caller
+ * is to delete using decrRef() as it is no more needed.
+ * \throw If \a end < \a begin.
+ * \throw If \a end > \a this->getNumberOfTuples().
+ * \throw If \a this is not allocated.
+ */
+DataArray *DataArrayChar::selectByTupleRanges(const std::vector<std::pair<int,int> >& ranges) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int nbOfComp=getNumberOfComponents();
+ int nbOfTuplesThis=getNumberOfTuples();
+ if(ranges.empty())
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayChar> ret=buildEmptySpecializedDAChar();
+ ret->alloc(0,nbOfComp);
+ ret->copyStringInfoFrom(*this);
+ return ret.retn();
+ }
+ int ref=ranges.front().first;
+ int nbOfTuples=0;
+ bool isIncreasing=true;
+ for(std::vector<std::pair<int,int> >::const_iterator it=ranges.begin();it!=ranges.end();it++)
+ {
+ if((*it).first<=(*it).second)
+ {
+ if((*it).first>=0 && (*it).second<=nbOfTuplesThis)
+ {
+ nbOfTuples+=(*it).second-(*it).first;
+ if(isIncreasing)
+ isIncreasing=ref<=(*it).first;
+ ref=(*it).second;
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayChar::selectByTupleRanges : on range #" << std::distance(ranges.begin(),it);
+ oss << " (" << (*it).first << "," << (*it).second << ") is greater than number of tuples of this :" << nbOfTuples << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayChar::selectByTupleRanges : on range #" << std::distance(ranges.begin(),it);
+ oss << " (" << (*it).first << "," << (*it).second << ") end is before begin !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ if(isIncreasing && nbOfTuplesThis==nbOfTuples)
+ return deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayChar> ret=buildEmptySpecializedDAChar();
+ ret->alloc(nbOfTuples,nbOfComp);
+ ret->copyStringInfoFrom(*this);
+ const char *src=getConstPointer();
+ char *work=ret->getPointer();
+ for(std::vector<std::pair<int,int> >::const_iterator it=ranges.begin();it!=ranges.end();it++)
+ work=std::copy(src+(*it).first*nbOfComp,src+(*it).second*nbOfComp,work);
+ return ret.retn();
+}
+
/*!
* Returns a value located at specified tuple and component.
* This method is equivalent to DataArrayChar::getIJ() except that validity of
}
/*!
- * This method checks geo equivalence between two meshes : 'this' and 'other'.
- * If no exception is throw 'this' and 'other' are geometrically equivalent regarding 'levOfCheck' level.
- * This method is typically used to change the mesh of a field "safely" depending the 'levOfCheck' level considered.
- * So in case of success cell \c other[i] is equal to cell \c this[cellCor[i]]. If \a cellCor is null it means that for all i cell \c other[i] is equal to cell \c this[i].
+ * This method checks geo equivalence between two meshes : \a this and \a other.
+ * If no exception is thrown \a this and \a other are geometrically equivalent regarding \a levOfCheck level.
+ * This method is typically used to change the mesh of a field "safely" depending the \a levOfCheck level considered.
*
- * @param levOfCheck input that specifies the level of check specified. The possible values are listed below.
- * @param prec input that specifies precision for double float data used for comparison in meshes.
- * @param cellCor output array not always informed (depending 'levOfCheck' param) that gives the corresponding array for cells from 'other' to 'this'.
- * @param nodeCor output array not always informed (depending 'levOfCheck' param) that gives the corresponding array for nodes from 'other' to 'this'.
+ * In case of success cell \c other[i] is equal to the cell \c this[cellCor[i]].
+ * In case of success node \c other->getCoords()[i] is equal to the node \c this->getCoords()[nodeCor[i]].
+ *
+ * If \a cellCor is null (or Py_None) it means that for all #i cell in \a other is equal to cell # i in \a this.
+ *
+ * If \a nodeCor is null (or Py_None) it means that for all #i node in \a other is equal to node # i in \a this.
+ *
+ * So null (or Py_None) returned in \a cellCor and/or \a nodeCor means identity array. This is for optimization reason to avoid to build useless arrays
+ * for some \a levOfCheck (for example 0).
+ *
+ * **Warning a not null output does not mean that it is not identity !**
+ *
+ * \param [in] other - the mesh to be compared with \a this.
+ * \param [in] levOfCheck - input that specifies the level of check specified. The possible values are listed below.
+ * \param [in] prec - input that specifies precision for double float data used for comparison in meshes.
+ * \param [out] cellCor - output array not always informed (depending \a levOfCheck param) that gives the corresponding array for cells from \a other to \a this.
+ * \param [out] nodeCor - output array not always informed (depending \a levOfCheck param) that gives the corresponding array for nodes from \a other to \a this.
*
* Possible values for levOfCheck :
- * - 0 for strict equality. This is the strongest level. 'cellCor' and 'nodeCor' params are never informed.
- * - 10,11,12 for less strict equality. Two meshes are compared geometrically. In case of success 'cellCor' and 'nodeCor' are informed. Warning ! These equivalences are CPU/Mem costly. The 3 values correspond respectively to policy used for cell comparison (see MEDCouplingUMesh::zipConnectivityTraducer to have more details)
- * - 20,21,22, for less strict equality. Two meshes are compared geometrically. The difference with the previous version is that nodes(coordinates) are expected to be the same between this and other. In case of success 'cellCor' is informed. Warning ! These equivalences are CPU/Mem costly. The 3 values correspond respectively to policy used for cell comparison (see MEDCouplingUMesh::zipConnectivityTraducer to have more details)
+ * - 0 for strict equality. This is the strongest level. \a cellCor and \a nodeCor params are never informed.
+ * - 10,11,12 (10+x) for less strict equality. Two meshes are compared geometrically. In case of success \a cellCor and \a nodeCor are informed. Warning ! These equivalences are CPU/Mem costly. The 3 values correspond respectively to policy used for cell comparison (see MEDCouplingUMesh::zipConnectivityTraducer to have more details)
+ * - 20,21,22 (20+x), for less strict equality. Two meshes are compared geometrically. The difference with the previous version is that nodes(coordinates) are expected to be the same between this and other. In case of success \a cellCor is informed. Warning ! These equivalences are CPU/Mem costly. The 3 values correspond respectively to policy used for cell comparison (see MEDCouplingUMesh::zipConnectivityTraducer to have more details)
* - 1 for fast 'equality'. This is a lazy level. Just number of cells and number of nodes are considered here and 3 cells (begin,middle,end)
* - 2 for deep 'equality' as 0 option except that no control is done on all strings in mesh.
+ *
+ * So the most strict level of check is 0 (equality). The least strict is 12. If the level of check 12 throws, the 2 meshes \a this and \a other are not similar enough
+ * to be compared. An interpolation using MEDCouplingRemapper class should be then used.
*/
void MEDCouplingMesh::checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec,
DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception)
}
/*!
- * This method checks fastly that 'this' and 'other' are equal. All common checks are done here.
+ * This method checks fastly that \a this and \a other are equal. All common checks are done here.
*/
void MEDCouplingMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception)
{
}
/*!
- * This method is very poor and looks only if 'this' and 'other' are candidate for merge of fields lying repectively on them.
+ * This method is very poor and looks only if \a this and \a other are candidate for merge of fields lying repectively on them.
*/
bool MEDCouplingMesh::areCompatibleForMerge(const MEDCouplingMesh *other) const
{
}
/*!
- * This method builds a field lying on 'this' with 'nbOfComp' components.
+ * This method builds a field lying on \a this with 'nbOfComp' components.
* 'func' is a pointer that points to a function that takes 2 arrays in parameter and returns a boolean.
* The first array is a in-param of size this->getSpaceDimension and the second an out param of size 'nbOfComp'.
* The return field will have type specified by 't'. 't' is also used to determine where values of field will be
* The 'func' is a callback that takes as first parameter an input array of size 'this->getSpaceDimension()',
* the second parameter is a pointer on a valid zone of size at least equal to 'nbOfComp' values. And too finish
* the returned value is a boolean that is equal to False in case of invalid evaluation (log(0) for example...)
- * @param t type of field returned and specifies where the evaluation of func will be done.
- * @param nbOfComp number of components of returned field.
- * @param func pointer to a function that should return false if the evaluation failed. (division by 0. for example)
- * @return field with counter = 1.
+ *
+ * \param t type of field returned and specifies where the evaluation of func will be done.
+ * \param nbOfComp number of components of returned field.
+ * \param func pointer to a function that should return false if the evaluation failed. (division by 0. for example)
+ * \return field with counter = 1.
*/
MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const
{
/*!
* This method copies all attributes that are \b NOT arrays in this.
- * All tiny attributes not usefully for state of 'this' are ignored.
+ * All tiny attributes not usefully for state of \a this are ignored.
*/
void MEDCouplingMesh::copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception)
{
return MEDCouplingUMesh::MergeUMeshes(ms2);
}
+/*!
+ * For example if \a type is INTERP_KERNEL::NORM_TRI3 , INTERP_KERNEL::NORM_POLYGON is returned.
+ * If \a type is INTERP_KERNEL::NORM_HEXA8 , INTERP_KERNEL::NORM_POLYHED is returned.
+ *
+ * \param [in] type the geometric type for which the corresponding dynamic type, is asked.
+ * \return the corresponding dynamic type, able to store the input \a type.
+ *
+ * \throw if type is equal to \c INTERP_KERNEL::NORM_ERROR or to an unexisting geometric type.
+ */
+INTERP_KERNEL::NormalizedCellType MEDCouplingMesh::GetCorrespondingPolyType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
+{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ return cm.getCorrespondingPolyType();
+}
+
+/*!
+ * \param [in] type the geometric type for which the number of nodes consituting it, is asked.
+ * \return number of nodes consituting the input geometric type \a type.
+ *
+ * \throw if type is dynamic as \c INTERP_KERNEL::NORM_POLYHED , \c INTERP_KERNEL::NORM_POLYGON , \c INTERP_KERNEL::NORM_QPOLYG
+ * \throw if type is equal to \c INTERP_KERNEL::NORM_ERROR or to an unexisting geometric type.
+ */
+int MEDCouplingMesh::GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
+{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ if(cm.isDynamic())
+ throw INTERP_KERNEL::Exception("MEDCouplingMesh::GetNumberOfNodesOfGeometricType : the input geometric type is dynamic ! Impossible to return a fixed number of nodes constituting it !");
+ return (int) cm.getNumberOfNodes();
+}
+
+/*!
+ * \param [in] type the geometric type for which the status static/dynamic is asked.
+ * \return true for static geometric type, false for dynamic geometric type.
+ *
+ * \throw if type is equal to \c INTERP_KERNEL::NORM_ERROR or to an unexisting geometric type.
+ */
+bool MEDCouplingMesh::IsStaticGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
+{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ return !cm.isDynamic();
+}
+
+bool MEDCouplingMesh::IsLinearGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
+{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ return !cm.isQuadratic();
+}
+
/*!
* \param [in] type the geometric type for which the dimension is asked.
* \return the dimension associated to the input geometric type \a type.
virtual DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const throw(INTERP_KERNEL::Exception) = 0;
virtual DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) = 0;
virtual DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception) = 0;
virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const = 0;
virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0;
virtual std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const = 0;
virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const;
static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) throw(INTERP_KERNEL::Exception);
static MEDCouplingMesh *MergeMeshes(std::vector<const MEDCouplingMesh *>& meshes) throw(INTERP_KERNEL::Exception);
+ static bool IsStaticGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
+ static bool IsLinearGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
+ static INTERP_KERNEL::NormalizedCellType GetCorrespondingPolyType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
+ static int GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
static int GetDimensionOfGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
static const char *GetReprOfGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
//serialisation-unserialization
return ret.retn();
}
+DataArrayInt *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+ int nbCells=getNumberOfCells();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbCells,1);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0));
+ ret->fillWithValue((int)cm.getNumberOfSons());
+ return ret.retn();
+}
+
void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
{
int meshDim=getMeshDimension();
int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
static void GetPosFromId(int nodeId, int meshDim, const int *split, int *res);
void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
std::size_t getHeapMemorySize() const;
const char MEDCouplingLinearTime::REPR[]="Linear time between 2 time steps.";
-MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type)
+MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type) throw(INTERP_KERNEL::Exception)
{
switch(type)
{
_time_unit=other._time_unit;
}
-void MEDCouplingTimeDiscretization::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
+void MEDCouplingTimeDiscretization::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
{
_time_unit=other._time_unit;
if(_array && other._array)
return ret;
}
-bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
return false;
return true;
}
-bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
+bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
std::ostringstream oss; oss.precision(15);
if(_time_unit!=other->_time_unit)
return true;
}
-bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
return false;
return true;
}
-bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
return false;
return true;
}
-bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
return false;
return true;
}
-bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
if(!areStrictlyCompatible(other,reason))
return false;
return _array->isEqualIfNotWhy(*other->_array,prec,reason);
}
-bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception)
{
std::string reason;
return isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception)
{
std::string tmp;
if(!areStrictlyCompatible(other,tmp))
return _array->isEqualWithoutConsideringStr(*other->_array,prec);
}
-MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const
+MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type);
ret->setTimeUnit(getTimeUnit());
return ret;
}
-void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
if(_array)
{
}
}
-void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
+void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays) throw(INTERP_KERNEL::Exception)
{
arrays.resize(1);
if(_array!=0)
arrays[0]=arr;
}
-void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS) throw(INTERP_KERNEL::Exception)
{
_time_tolerance=tinyInfoD[0];
int nbOfCompo=_array->getNumberOfComponents();
_array->setInfoOnComponent(i,tinyInfoS[i].c_str());
}
-void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
tinyInfo.push_back(_time_tolerance);
}
-void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
int nbOfCompo=_array->getNumberOfComponents();
for(int i=0;i<nbOfCompo;i++)
_array->decrRef();
}
-void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel *owner)
+void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel *owner) throw(INTERP_KERNEL::Exception)
{
if(array!=_array)
{
}
}
-const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const
+const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const throw(INTERP_KERNEL::Exception)
{
throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
}
-DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray()
+DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() throw(INTERP_KERNEL::Exception)
{
throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
}
-void MEDCouplingTimeDiscretization::setEndArray(DataArrayDouble *array, TimeLabel *owner)
+void MEDCouplingTimeDiscretization::setEndArray(DataArrayDouble *array, TimeLabel *owner) throw(INTERP_KERNEL::Exception)
{
throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !");
}
setArray(arrays.back(),owner);
}
-void MEDCouplingTimeDiscretization::getArrays(std::vector<DataArrayDouble *>& arrays) const
+void MEDCouplingTimeDiscretization::getArrays(std::vector<DataArrayDouble *>& arrays) const throw(INTERP_KERNEL::Exception)
{
arrays.resize(1);
arrays[0]=_array;
for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
- arrays2[j]=arrays[j]->keepSelectedComponents(compoIds);
+ arrays2[j]=static_cast<DataArrayDouble *>(arrays[j]->keepSelectedComponents(compoIds));
else
arrays2[j]=0;
}
}
}
-void MEDCouplingTimeDiscretization::setUniformValue(int nbOfTuple, int nbOfCompo, double value)
+void MEDCouplingTimeDiscretization::setUniformValue(int nbOfTuple, int nbOfCompo, double value) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value)
+void MEDCouplingTimeDiscretization::setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
}
}
-void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
+void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
}
}
-void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func)
+void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func)
+void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const char *func)
+void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func)
+void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFunc(const char *func)
+void MEDCouplingTimeDiscretization::applyFunc(const char *func) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFuncFast32(const char *func)
+void MEDCouplingTimeDiscretization::applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
}
}
-void MEDCouplingTimeDiscretization::applyFuncFast64(const char *func)
+void MEDCouplingTimeDiscretization::applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
{
}
-std::string MEDCouplingNoTimeLabel::getStringRepr() const
+std::string MEDCouplingNoTimeLabel::getStringRepr() const throw(INTERP_KERNEL::Exception)
{
std::ostringstream stream;
stream << REPR;
throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !");
}
-bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
return otherC!=0;
}
-bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
+bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
return ret;
}
-bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
return otherC!=0;
}
-bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
return otherC!=0;
}
-bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
return false;
return otherC!=0;
}
-bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> a(other.size());
int i=0;
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
getArray()->addEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
getArray()->substractEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
getArray()->multiplyEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
getArray()->divideEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
getArray()->powEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const throw(INTERP_KERNEL::Exception)
{
return new MEDCouplingNoTimeLabel(*this,deepCpy);
}
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
}
-void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const
+void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const throw(INTERP_KERNEL::Exception)
{
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
}
/*!
* idem getTinySerializationIntInformation except that it is for multi field fetch
*/
-void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
+void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
tinyInfo.clear();
}
/*!
* idem getTinySerializationDbleInformation except that it is for multi field fetch
*/
-void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
+void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
tinyInfo.resize(1);
tinyInfo[0]=_time_tolerance;
/*!
* idem finishUnserialization except that it is for multi field fetch
*/
-void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) throw(INTERP_KERNEL::Exception)
{
_time_tolerance=tinyInfoD[0];
}
{
}
-std::string MEDCouplingWithTimeStep::getStringRepr() const
+std::string MEDCouplingWithTimeStep::getStringRepr() const throw(INTERP_KERNEL::Exception)
{
std::ostringstream stream;
stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << ".";
_time_unit=tUnit;
}
-void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
tinyInfo.push_back(_iteration);
tinyInfo.push_back(_order);
}
-void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
tinyInfo.push_back(_time);
}
-void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS) throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
_time=tinyInfoD[1];
/*!
* idem getTinySerializationIntInformation except that it is for multi field fetch
*/
-void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
+void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
tinyInfo.resize(2);
tinyInfo[0]=_iteration;
/*!
* idem getTinySerializationDbleInformation except that it is for multi field fetch
*/
-void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
+void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
tinyInfo.resize(2);
tinyInfo[0]=_time_tolerance;
/*!
* idem finishUnserialization except that it is for multi field fetch
*/
-void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) throw(INTERP_KERNEL::Exception)
{
_iteration=tinyInfoI[0];
_order=tinyInfoI[1];
_time=tinyInfoD[1];
}
-bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
return otherC!=0;
}
-bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
+bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
return ret;
}
-bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
return otherC!=0;
}
-bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
return otherC!=0;
}
-bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
return false;
return otherC!=0;
}
-bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
std::ostringstream oss; oss.precision(15);
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
_order=otherC->_order;
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> a(other.size());
int i=0;
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
getArray()->addEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
getArray()->substractEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
getArray()->multiplyEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
getArray()->divideEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
getArray()->powEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const throw(INTERP_KERNEL::Exception)
{
return new MEDCouplingWithTimeStep(*this,deepCpy);
}
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
}
-void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const
+void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const throw(INTERP_KERNEL::Exception)
{
std::copy(vals.begin(),vals.end(),res);
}
_end_order=otherC->_end_order;
}
-void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
tinyInfo.push_back(_start_iteration);
tinyInfo.push_back(_end_order);
}
-void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
tinyInfo.push_back(_start_time);
tinyInfo.push_back(_end_time);
}
-void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS) throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
_start_time=tinyInfoD[1];
/*!
* idem getTinySerializationIntInformation except that it is for multi field fetch
*/
-void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
+void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
tinyInfo.resize(4);
tinyInfo[0]=_start_iteration;
/*!
* idem getTinySerializationDbleInformation except that it is for multi field fetch
*/
-void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
+void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
tinyInfo.resize(3);
tinyInfo[0]=_time_tolerance;
/*!
* idem finishUnserialization except that it is for multi field fetch
*/
-void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) throw(INTERP_KERNEL::Exception)
{
_start_iteration=tinyInfoI[0];
_start_order=tinyInfoI[1];
{
}
-std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
+std::string MEDCouplingConstOnTimeInterval::getStringRepr() const throw(INTERP_KERNEL::Exception)
{
std::ostringstream stream;
stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
_time_unit=tUnit;
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCpy(bool deepCpy) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCpy(bool deepCpy) const throw(INTERP_KERNEL::Exception)
{
return new MEDCouplingConstOnTimeInterval(*this,deepCpy);
}
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
}
-void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const
+void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const throw(INTERP_KERNEL::Exception)
{
std::copy(vals.begin(),vals.end(),res);
}
-bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
return otherC!=0;
}
-bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
return ret;
}
-bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
return otherC!=0;
}
-bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
return otherC!=0;
}
-bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
return false;
return otherC!=0;
}
-bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
std::ostringstream oss; oss.precision(15);
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
}
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> a(other.size());
int i=0;
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
getArray()->addEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
getArray()->substractEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
getArray()->multiplyEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
getArray()->divideEqual(other->getArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
_end_order=otherC->_end_order;
}
-void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
+void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
_end_array->copyStringInfoFrom(*otherC->_end_array);
}
-const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
+const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const throw(INTERP_KERNEL::Exception)
{
return _end_array;
}
-DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
+DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() throw(INTERP_KERNEL::Exception)
{
return _end_array;
}
throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
}
-bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
+bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
std::ostringstream oss;
const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
-bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
if(!otherC)
}
}
-void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
+void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const throw(INTERP_KERNEL::Exception)
{
arrays.resize(2);
arrays[0]=_array;
arrays[1]=_end_array;
}
-void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner)
+void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner) throw(INTERP_KERNEL::Exception)
{
if(array!=_end_array)
{
}
}
-void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
tinyInfo.push_back(_start_iteration);
}
}
-void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
tinyInfo.push_back(_start_time);
tinyInfo.push_back(_end_time);
}
-void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
int nbOfCompo=_array->getNumberOfComponents();
for(int i=0;i<nbOfCompo;i++)
tinyInfo.push_back(_end_array->getInfoOnComponent(i));
}
-void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
+void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays) throw(INTERP_KERNEL::Exception)
{
arrays.resize(2);
if(_array!=0)
arrays[1]=arr;
}
-void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS) throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
_start_time=tinyInfoD[1];
/*!
* idem getTinySerializationIntInformation except that it is for multi field fetch
*/
-void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
+void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
tinyInfo.resize(4);
tinyInfo[0]=_start_iteration;
/*!
* idem getTinySerializationDbleInformation except that it is for multi field fetch
*/
-void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
+void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception)
{
tinyInfo.resize(3);
tinyInfo[0]=_time_tolerance;
/*!
* idem finishUnserialization except that it is for multi field fetch
*/
-void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) throw(INTERP_KERNEL::Exception)
{
_start_iteration=tinyInfoI[0];
_start_order=tinyInfoI[1];
{
}
-std::string MEDCouplingLinearTime::getStringRepr() const
+std::string MEDCouplingLinearTime::getStringRepr() const throw(INTERP_KERNEL::Exception)
{
std::ostringstream stream;
stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCpy(bool deepCpy) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCpy(bool deepCpy) const throw(INTERP_KERNEL::Exception)
{
return new MEDCouplingLinearTime(*this,deepCpy);
}
-bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
return true;
}
-bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
+bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
return ret;
}
-bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
return otherC!=0;
}
-bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
return true;
}
-bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
return false;
/*!
* vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
*/
-void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
+void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const throw(INTERP_KERNEL::Exception)
{
double alpha=(_end_time-time)/(_end_time-_start_time);
std::size_t nbComp=vals.size()/2;
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> a(other.size());
std::vector<const DataArrayDouble *> b(other.size());
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
getEndArray()->addEqual(other->getEndArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
getEndArray()->substractEqual(other->getEndArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
getEndArray()->multiplyEqual(other->getEndArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
getEndArray()->divideEqual(other->getEndArray());
}
-MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
return ret;
}
-void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other)
+void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
public:
void updateTime() const;
virtual std::size_t getHeapMemorySize() const;
- static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
+ static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type) throw(INTERP_KERNEL::Exception);
void setTimeUnit(const char *unit) { _time_unit=unit; }
const char *getTimeUnit() const { return _time_unit.c_str(); }
virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
- virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
+ virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
- virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
- virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
- virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
- virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
- virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
- virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const;
- virtual std::string getStringRepr() const = 0;
- virtual TypeOfTimeDiscretization getEnum() const = 0;
+ virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception);
+ virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const throw(INTERP_KERNEL::Exception);
+ virtual std::string getStringRepr() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual TypeOfTimeDiscretization getEnum() const throw(INTERP_KERNEL::Exception) = 0;
virtual void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception) = 0;
- virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const = 0;
- virtual MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual void addEqual(const MEDCouplingTimeDiscretization *other) = 0;
- virtual MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual void substractEqual(const MEDCouplingTimeDiscretization *other) = 0;
- virtual MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual void multiplyEqual(const MEDCouplingTimeDiscretization *other) = 0;
- virtual MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual void divideEqual(const MEDCouplingTimeDiscretization *other) = 0;
- virtual MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const = 0;
- virtual void powEqual(const MEDCouplingTimeDiscretization *other) = 0;
- virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
- virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
- virtual void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
- virtual void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
- virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
- virtual void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const = 0;
- virtual void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const = 0;
- virtual void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) = 0;
- virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const = 0;
+ virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void addEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void substractEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void multiplyEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void divideEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void powEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ virtual void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ virtual void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays) throw(INTERP_KERNEL::Exception);
+ virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS) throw(INTERP_KERNEL::Exception);
+ virtual void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const throw(INTERP_KERNEL::Exception) = 0;
void setTimeTolerance(double val) { _time_tolerance=val; }
double getTimeTolerance() const { return _time_tolerance; }
virtual void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) = 0;
virtual void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception) = 0;
- virtual void setArray(DataArrayDouble *array, TimeLabel *owner);
- virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner);
+ virtual void setArray(DataArrayDouble *array, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
+ virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
virtual void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getArray() { return _array; }
- const DataArrayDouble *getArray() const { return _array; }
- virtual const DataArrayDouble *getEndArray() const;
- virtual DataArrayDouble *getEndArray();
+ DataArrayDouble *getArray() throw(INTERP_KERNEL::Exception) { return _array; }
+ const DataArrayDouble *getArray() const throw(INTERP_KERNEL::Exception) { return _array; }
+ virtual const DataArrayDouble *getEndArray() const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayDouble *getEndArray() throw(INTERP_KERNEL::Exception);
virtual std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) = 0;
- virtual void getValueForTime(double time, const std::vector<double>& vals, double *res) const = 0;
- virtual void getArrays(std::vector<DataArrayDouble *>& arrays) const;
+ virtual void getValueForTime(double time, const std::vector<double>& vals, double *res) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void getArrays(std::vector<DataArrayDouble *>& arrays) const throw(INTERP_KERNEL::Exception);
virtual bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
virtual bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
double getTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { return getStartTime(iteration,order); }
virtual void setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
virtual void changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception);
virtual void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
- virtual void setUniformValue(int nbOfTuple, int nbOfCompo, double value);
- virtual void setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value);
- virtual void applyLin(double a, double b, int compoId);
- virtual void applyFunc(int nbOfComp, FunctionToEvaluate func);
- virtual void applyFunc(int nbOfComp, const char *func);
- virtual void applyFunc2(int nbOfComp, const char *func);
- virtual void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func);
- virtual void applyFunc(const char *func);
- virtual void applyFuncFast32(const char *func);
- virtual void applyFuncFast64(const char *func);
+ virtual void setUniformValue(int nbOfTuple, int nbOfCompo, double value) throw(INTERP_KERNEL::Exception);
+ virtual void setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value) throw(INTERP_KERNEL::Exception);
+ virtual void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception);
+ virtual void applyFunc(int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception);
+ virtual void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ virtual void applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ virtual void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
+ virtual void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
+ virtual void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
+ virtual void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception);
virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
virtual void fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
public:
MEDCouplingNoTimeLabel();
MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy);
- std::string getStringRepr() const;
- TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
+ std::string getStringRepr() const throw(INTERP_KERNEL::Exception);
+ TypeOfTimeDiscretization getEnum() const throw(INTERP_KERNEL::Exception) { return DISCRETIZATION; }
void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
- MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
- MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
- void addEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
- void substractEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
- void multiplyEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
- void divideEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const;
- void powEqual(const MEDCouplingTimeDiscretization *other);
- bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
- bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
- bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
- bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
+ MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void addEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void substractEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void multiplyEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void divideEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void powEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception);
+ bool areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const throw(INTERP_KERNEL::Exception);
void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) { }
void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
- void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
+ void getValueForTime(double time, const std::vector<double>& vals, double *res) const throw(INTERP_KERNEL::Exception);
bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception);
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception);
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
- void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
- void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
- void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) throw(INTERP_KERNEL::Exception);
public:
static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME;
static const char REPR[];
MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy);
public:
MEDCouplingWithTimeStep();
- std::string getStringRepr() const;
+ std::string getStringRepr() const throw(INTERP_KERNEL::Exception);
void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
- TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
+ TypeOfTimeDiscretization getEnum() const throw(INTERP_KERNEL::Exception) { return DISCRETIZATION; }
void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
- MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
- MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
- void addEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
- void substractEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
- void multiplyEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
- void divideEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const;
- void powEqual(const MEDCouplingTimeDiscretization *other);
- bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
- bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
- bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
- bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
- void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
- void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
- void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
- void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
- void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
- void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
- MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
+ MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void addEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void substractEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void multiplyEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void divideEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void powEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception);
+ bool areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS) throw(INTERP_KERNEL::Exception);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const throw(INTERP_KERNEL::Exception);
void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; }
void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
- void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
+ void getValueForTime(double time, const std::vector<double>& vals, double *res) const throw(INTERP_KERNEL::Exception);
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
public:
public:
MEDCouplingConstOnTimeInterval();
void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
- void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
- void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
- void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
- void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
- void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
- void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
- MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
- bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
- bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
- bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
- bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
+ void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS) throw(INTERP_KERNEL::Exception);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const throw(INTERP_KERNEL::Exception);
+ bool areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception);
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
- void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
+ void getValueForTime(double time, const std::vector<double>& vals, double *res) const throw(INTERP_KERNEL::Exception);
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
- TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
+ TypeOfTimeDiscretization getEnum() const throw(INTERP_KERNEL::Exception) { return DISCRETIZATION; }
void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
- std::string getStringRepr() const;
- MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
- MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
- void addEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
- void substractEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
- void multiplyEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
- void divideEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const;
- void powEqual(const MEDCouplingTimeDiscretization *other);
+ std::string getStringRepr() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void addEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void substractEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void multiplyEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void divideEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void powEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_iteration=iteration; _start_order=order; }
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
std::size_t getHeapMemorySize() const;
void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
- void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
- const DataArrayDouble *getEndArray() const;
- DataArrayDouble *getEndArray();
+ void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
+ const DataArrayDouble *getEndArray() const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getEndArray() throw(INTERP_KERNEL::Exception);
void checkCoherency() const throw(INTERP_KERNEL::Exception);
- bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
- bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const throw(INTERP_KERNEL::Exception);
void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
- void getArrays(std::vector<DataArrayDouble *>& arrays) const;
- void setEndArray(DataArrayDouble *array, TimeLabel *owner);
+ void getArrays(std::vector<DataArrayDouble *>& arrays) const throw(INTERP_KERNEL::Exception);
+ void setEndArray(DataArrayDouble *array, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_iteration=iteration; _start_order=order; }
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; }
void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; }
void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; }
- void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
- void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
- void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
- void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
- void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
- void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
- void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
- void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
+ void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays) throw(INTERP_KERNEL::Exception);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS) throw(INTERP_KERNEL::Exception);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const throw(INTERP_KERNEL::Exception);
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) throw(INTERP_KERNEL::Exception);
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
protected:
MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy);
public:
MEDCouplingLinearTime();
- std::string getStringRepr() const;
- TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
+ std::string getStringRepr() const throw(INTERP_KERNEL::Exception);
+ TypeOfTimeDiscretization getEnum() const throw(INTERP_KERNEL::Exception) { return DISCRETIZATION; }
void checkCoherency() const throw(INTERP_KERNEL::Exception);
- MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
- bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
- bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
- void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
+ MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const throw(INTERP_KERNEL::Exception);
+ bool areCompatible(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void getValueForTime(double time, const std::vector<double>& vals, double *res) const throw(INTERP_KERNEL::Exception);
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
- MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
- MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
- MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
- void addEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
- void substractEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
- void multiplyEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
- void divideEqual(const MEDCouplingTimeDiscretization *other);
- MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const;
- void powEqual(const MEDCouplingTimeDiscretization *other);
+ MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void addEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void substractEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void multiplyEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void divideEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
+ void powEqual(const MEDCouplingTimeDiscretization *other) throw(INTERP_KERNEL::Exception);
public:
static const TypeOfTimeDiscretization DISCRETIZATION=LINEAR_TIME;
static const char REPR[];
#include "InterpolationUtils.hxx"
#include "PointLocatorAlgos.txx"
#include "BBTree.txx"
+#include "BBTreeDst.txx"
#include "SplitterTetra.hxx"
#include "DirectedBoundingBox.hxx"
#include "InterpKernelMeshQuality.hxx"
{
checkFullyDefined();
int nbOfNodes=getNumberOfNodes();
- int *revNodalIndxPtr=new int[nbOfNodes+1];
- revNodalIndx->useArray(revNodalIndxPtr,true,CPP_DEALLOC,nbOfNodes+1,1);
+ int *revNodalIndxPtr=(int *)malloc((nbOfNodes+1)*sizeof(int));
+ revNodalIndx->useArray(revNodalIndxPtr,true,C_DEALLOC,nbOfNodes+1,1);
std::fill(revNodalIndxPtr,revNodalIndxPtr+nbOfNodes+1,0);
const int *conn=_nodal_connec->getConstPointer();
const int *connIndex=_nodal_connec_index->getConstPointer();
}
}
std::transform(revNodalIndxPtr+1,revNodalIndxPtr+nbOfNodes+1,revNodalIndxPtr,revNodalIndxPtr+1,std::plus<int>());
- int *revNodalPtr=new int[nbOfEltsInRevNodal];
- revNodal->useArray(revNodalPtr,true,CPP_DEALLOC,nbOfEltsInRevNodal,1);
+ int *revNodalPtr=(int *)malloc((nbOfEltsInRevNodal)*sizeof(int));
+ revNodal->useArray(revNodalPtr,true,C_DEALLOC,nbOfEltsInRevNodal,1);
std::fill(revNodalPtr,revNodalPtr+nbOfEltsInRevNodal,-1);
for(int eltId=0;eltId<nbOfCells;eltId++)
{
if(*iter>=0 && *iter<nbOfCells)
{
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*iter]]);
- if(!cm.isDynamic())
+ if(!cm.isQuadratic())
conn[connIndex[*iter]]=INTERP_KERNEL::NORM_POLYGON;
else
conn[connIndex[*iter]]=INTERP_KERNEL::NORM_QPOLYG;
/*!
* This method returns a newly allocated array containing this->getNumberOfCells() tuples and 1 component.
* For each cell in \b this the number of nodes constituting cell is computed.
- * Excepted for poyhedrons, the result can be deduced by performing a deltaShiftIndex on the nodal connectivity index in \b this minus 1.
- * For polyhedrons, the face separation (-1) are excluded from the couting.
+ * For each polyhedron cell, the sum of the number of nodes of each face constituting polyhedron cell is returned.
+ * So for pohyhedrons some nodes can be counted several times in the returned result.
*
* \return a newly allocated array
*/
return ret.retn();
}
+/*!
+ * This method returns a newly allocated array containing this->getNumberOfCells() tuples and 1 component.
+ * For each cell in \b this the number of faces constituting (entity of dimension this->getMeshDimension()-1) cell is computed.
+ *
+ * \return a newly allocated array
+ */
+DataArrayInt *MEDCouplingUMesh::computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+ checkConnectivityFullyDefined();
+ int nbOfCells=getNumberOfCells();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbOfCells,1);
+ int *retPtr=ret->getPointer();
+ const int *conn=getNodalConnectivity()->getConstPointer();
+ const int *connI=getNodalConnectivityIndex()->getConstPointer();
+ for(int i=0;i<nbOfCells;i++,retPtr++,connI++)
+ {
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*connI]);
+ *retPtr=cm.getNumberOfSons2(conn+connI[0]+1,connI[1]-connI[0]-1);
+ }
+ return ret.retn();
+}
+
/*!
* Removes unused nodes (the node coordinates array is shorten) and returns an array
* mapping between new and old node ids in "Old to New" mode. -1 values in the returned
//
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=DataArrayInt::New(); o2n->useArray(array,false,C_DEALLOC,nbCells,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o=o2n->invertArrayO2N2N2O(nbCells);
+ const int *n2oPtr=n2o->begin();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn=DataArrayInt::New();
newConn->alloc(_nodal_connec->getNumberOfTuples(),_nodal_connec->getNumberOfComponents());
newConn->copyStringInfoFrom(*_nodal_connec);
newCI[0]=loc;
for(int i=0;i<nbCells;i++)
{
- std::size_t pos=std::distance(array,std::find(array,array+nbCells,i));
+ int pos=n2oPtr[i];
int nbOfElts=connI[pos+1]-connI[pos];
newC=std::copy(conn+connI[pos],conn+connI[pos+1],newC);
loc+=nbOfElts;
//
setConnectivity(newConn,newConnI);
if(check)
- delete [] const_cast<int *>(array);
+ free(const_cast<int *>(array));
}
/*!
ret->_mesh_dim=_mesh_dim;
ret->setCoords(_coords);
std::size_t nbOfElemsRet=std::distance(begin,end);
- int *connIndexRet=new int[nbOfElemsRet+1];
+ int *connIndexRet=(int *)malloc((nbOfElemsRet+1)*sizeof(int));
connIndexRet[0]=0;
const int *conn=_nodal_connec->getConstPointer();
const int *connIndex=_nodal_connec_index->getConstPointer();
connIndexRet[newNbring+1]=connIndexRet[newNbring]+connIndex[*work+1]-connIndex[*work];
else
{
- delete [] connIndexRet;
+ free(connIndexRet);
std::ostringstream oss; oss << "MEDCouplingUMesh::buildPartOfMySelfKeepCoords : On pos #" << std::distance(begin,work) << " input cell id =" << *work << " should be in [0," << ncell << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
- int *connRet=new int[connIndexRet[nbOfElemsRet]];
+ int *connRet=(int *)malloc(connIndexRet[nbOfElemsRet]*sizeof(int));
int *connRetWork=connRet;
std::set<INTERP_KERNEL::NormalizedCellType> types;
for(const int *work=begin;work!=end;work++)
connRetWork=std::copy(conn+connIndex[*work],conn+connIndex[*work+1],connRetWork);
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> connRetArr=DataArrayInt::New();
- connRetArr->useArray(connRet,true,CPP_DEALLOC,connIndexRet[nbOfElemsRet],1);
+ connRetArr->useArray(connRet,true,C_DEALLOC,connIndexRet[nbOfElemsRet],1);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> connIndexRetArr=DataArrayInt::New();
- connIndexRetArr->useArray(connIndexRet,true,CPP_DEALLOC,(int)nbOfElemsRet+1,1);
+ connIndexRetArr->useArray(connIndexRet,true,C_DEALLOC,(int)nbOfElemsRet+1,1);
ret->setConnectivity(connRetArr,connIndexRetArr,false);
ret->_types=types;
ret->copyTinyInfoFrom(this);
}
/*!
- * This method computes the distance from a point \a pt to \a this and the first \a cellId and \a nodeId in \a this corresponding to the returned distance.
+ * This method computes the distance from a point \a pt to \a this and the first \a cellId in \a this corresponding to the returned distance.
* \a this is expected to be a mesh so that its space dimension is equal to its
* mesh dimension + 1. Furthermore only mesh dimension 1 and 2 are supported for the moment.
* Distance from \a ptBg to \a ptEnd is expected to be equal to the space dimension. \a this is also expected to be fully defined (connectivity and coordinates).
- *
- * This method firstly find the closer node in \a this to the requested point whose coordinates are defined by [ \a ptBg, \a ptEnd ). Then for this node found
- * the cells sharing this node (if any) are considered to find if the distance to these cell are smaller than the result found previously. If no cells are linked
- * to the node that minimizes distance with the input point then -1 is returned in cellId.
+
+ * WARNING, if there is some orphan nodes in \a this (nodes not fetched by any cells in \a this ( see MEDCouplingUMesh::zipCoords ) ) these nodes will ** not ** been taken
+ * into account in this method. Only cells and nodes lying on them are considered in the algorithm (even if one of these orphan nodes is closer than returned distance).
+ * A user that needs to consider orphan nodes should invoke DataArrayDouble::minimalDistanceTo method on the coordinates array of \a this.
*
* So this method is more accurate (so, more costly) than simply searching for the closest point in \a this.
* If only this information is enough for you simply call \c getCoords()->distanceToTuple on \a this.
* \return the positive value of the distance.
* \throw if distance from \a ptBg to \a ptEnd is not equal to the space dimension. An exception is also thrown if mesh dimension of \a this is not equal to space
* dimension - 1.
- * \sa DataArrayDouble::distanceToTuple
+ * \sa DataArrayDouble::distanceToTuple, MEDCouplingUMesh::distanceToPoints
*/
-double MEDCouplingUMesh::distanceToPoint(const double *ptBg, const double *ptEnd, int& cellId, int& nodeId) const throw(INTERP_KERNEL::Exception)
+double MEDCouplingUMesh::distanceToPoint(const double *ptBg, const double *ptEnd, int& cellId) const throw(INTERP_KERNEL::Exception)
{
int meshDim=getMeshDimension(),spaceDim=getSpaceDimension();
if(meshDim!=spaceDim-1)
checkFullyDefined();
if((int)std::distance(ptBg,ptEnd)!=spaceDim)
{ std::ostringstream oss; oss << "MEDCouplingUMesh::distanceToPoint : input point has to have dimension equal to the space dimension of this (" << spaceDim << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
- nodeId=-1;
- double ret0=_coords->distanceToTuple(ptBg,ptEnd,nodeId);
- if(nodeId==-1)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoint : something wrong with nodes in this !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=getCellIdsLyingOnNodes(&nodeId,&nodeId+1,false);
- switch(meshDim)
+ DataArrayInt *ret1=0;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> pts=DataArrayDouble::New(); pts->useArray(ptBg,false,C_DEALLOC,1,spaceDim);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret0=distanceToPoints(pts,ret1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1Safe(ret1);
+ cellId=*ret1Safe->begin();
+ return *ret0->begin();
+}
+
+/*!
+ * This method computes the distance from each point of points serie \a pts (stored in a DataArrayDouble in which each tuple represents a point)
+ * to \a this and the first \a cellId in \a this corresponding to the returned distance.
+ * WARNING, if there is some orphan nodes in \a this (nodes not fetched by any cells in \a this ( see MEDCouplingUMesh::zipCoords ) ) these nodes will ** not ** been taken
+ * into account in this method. Only cells and nodes lying on them are considered in the algorithm (even if one of these orphan nodes is closer than returned distance).
+ * A user that needs to consider orphan nodes should invoke DataArrayDouble::minimalDistanceTo method on the coordinates array of \a this.
+ *
+ * \a this is expected to be a mesh so that its space dimension is equal to its
+ * mesh dimension + 1. Furthermore only mesh dimension 1 and 2 are supported for the moment.
+ * Number of components of \a pts is expected to be equal to the space dimension. \a this is also expected to be fully defined (connectivity and coordinates).
+ *
+ * So this method is more accurate (so, more costly) than simply searching for each point in \a pts the closest point in \a this.
+ * If only this information is enough for you simply call \c getCoords()->distanceToTuple on \a this.
+ *
+ * \param [in] pts the list of points in which each tuple represents a point
+ * \param [out] cellIds a newly allocated object that tells for each point in \a pts the first cell id in \a this that minimizes the distance.
+ * \return a newly allocated object to be dealed by the caller that tells for each point in \a pts the distance to \a this.
+ * \throw if number of components of \a pts is not equal to the space dimension.
+ * \throw if mesh dimension of \a this is not equal to space dimension - 1.
+ * \sa DataArrayDouble::distanceToTuple, MEDCouplingUMesh::distanceToPoint
+ */
+DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, DataArrayInt *& cellIds) const throw(INTERP_KERNEL::Exception)
+{
+ if(!pts)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : input points pointer is NULL !");
+ pts->checkAllocated();
+ int meshDim=getMeshDimension(),spaceDim=getSpaceDimension();
+ if(meshDim!=spaceDim-1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints works only for spaceDim=meshDim+1 !");
+ if(meshDim!=2 && meshDim!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : only mesh dimension 2 and 1 are implemented !");
+ if(pts->getNumberOfComponents()!=spaceDim)
{
- case 2:
+ std::ostringstream oss; oss << "MEDCouplingUMesh::distanceToPoints : input pts DataArrayDouble has " << pts->getNumberOfComponents() << " components whereas it should be equal to " << spaceDim << " (mesh spaceDimension) !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ checkFullyDefined();
+ int nbCells=getNumberOfCells();
+ if(nbCells==0)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : no cells in this !");
+ int nbOfPts=pts->getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret0=DataArrayDouble::New(); ret0->alloc(nbOfPts,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1=DataArrayInt::New(); ret1->alloc(nbOfPts,1);
+ const int *nc=_nodal_connec->begin(),*ncI=_nodal_connec_index->begin(); const double *coords=_coords->begin();
+ double *ret0Ptr=ret0->getPointer(); int *ret1Ptr=ret1->getPointer(); const double *ptsPtr=pts->begin();
+ std::vector<double> bbox;
+ getBoundingBoxForBBTree(bbox);
+ switch(spaceDim)
+ {
+ case 3:
{
- distanceToPoint3DSurfAlg(ptBg,cellIds,ret0,cellId);
- return ret0;
+ BBTreeDst<3> myTree(&bbox[0],0,0,nbCells);
+ for(int i=0;i<nbOfPts;i++,ret0Ptr++,ret1Ptr++,ptsPtr+=3)
+ {
+ double x=std::numeric_limits<double>::max();
+ std::vector<int> elems;
+ myTree.getMinDistanceOfMax(ptsPtr,x);
+ myTree.getElemsWhoseMinDistanceToPtSmallerThan(ptsPtr,x,elems);
+ DistanceToPoint3DSurfAlg(ptsPtr,&elems[0],&elems[0]+elems.size(),coords,nc,ncI,*ret0Ptr,*ret1Ptr);
+ }
+ break;
}
- case 1:
+ case 2:
{
- distanceToPoint2DCurveAlg(ptBg,cellIds,ret0,cellId);
- return ret0;
+ BBTreeDst<2> myTree(&bbox[0],0,0,nbCells);
+ for(int i=0;i<nbOfPts;i++,ret0Ptr++,ret1Ptr++,ptsPtr+=2)
+ {
+ double x=std::numeric_limits<double>::max();
+ std::vector<int> elems;
+ myTree.getMinDistanceOfMax(ptsPtr,x);
+ myTree.getElemsWhoseMinDistanceToPtSmallerThan(ptsPtr,x,elems);
+ DistanceToPoint2DCurveAlg(ptsPtr,&elems[0],&elems[0]+elems.size(),coords,nc,ncI,*ret0Ptr,*ret1Ptr);
+ }
+ break;
}
default:
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoint : only mesh dimension 2 and 1 are implemented !");
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : only spacedim 2 and 3 supported !");
}
-
- return ret0;
+ cellIds=ret1.retn();
+ return ret0.retn();
}
-
/*!
* \param [in] pt the start pointer (included) of the coordinates of the point
- * \param [in] cellIds
+ * \param [in] cellIdsBg the start pointer (included) of cellIds
+ * \param [in] cellIdsEnd the end pointer (excluded) of cellIds
+ * \param [in] nc nodal connectivity
+ * \param [in] ncI nodal connectivity index
* \param [in,out] ret0 the min distance between \a this and the external input point
* \param [out] cellId that corresponds to minimal distance. If the closer node is not linked to any cell in \a this -1 is returned.
- * \sa MEDCouplingUMesh::distanceToPoint
+ * \sa MEDCouplingUMesh::distanceToPoint, MEDCouplingUMesh::distanceToPoints
*/
-void MEDCouplingUMesh::distanceToPoint3DSurfAlg(const double *pt, const DataArrayInt *cellIds, double& ret0, int& cellId) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::DistanceToPoint3DSurfAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId) throw(INTERP_KERNEL::Exception)
{
- const double *coords=_coords->getConstPointer();
- cellId=-1;
- if(cellIds->empty())
- return;
- const int *ptr=_nodal_connec->getConstPointer();
- const int *ptrI=_nodal_connec_index->getConstPointer();
- for(const int *zeCell=cellIds->begin();zeCell!=cellIds->end();zeCell++)
+ cellId=-1;
+ ret0=std::numeric_limits<double>::max();
+ for(const int *zeCell=cellIdsBg;zeCell!=cellIdsEnd;zeCell++)
{
- switch((INTERP_KERNEL::NormalizedCellType)ptr[ptrI[*zeCell]])
+ switch((INTERP_KERNEL::NormalizedCellType)nc[ncI[*zeCell]])
{
case INTERP_KERNEL::NORM_TRI3:
{
- double tmp=INTERP_KERNEL::DistanceFromPtToTriInSpaceDim3(pt,coords+3*ptr[ptrI[*zeCell]+1],coords+3*ptr[ptrI[*zeCell]+2],coords+3*ptr[ptrI[*zeCell]+3]);
+ double tmp=INTERP_KERNEL::DistanceFromPtToTriInSpaceDim3(pt,coords+3*nc[ncI[*zeCell]+1],coords+3*nc[ncI[*zeCell]+2],coords+3*nc[ncI[*zeCell]+3]);
if(tmp<ret0)
{ ret0=tmp; cellId=*zeCell; }
break;
case INTERP_KERNEL::NORM_QUAD4:
case INTERP_KERNEL::NORM_POLYGON:
{
- double tmp=INTERP_KERNEL::DistanceFromPtToPolygonInSpaceDim3(pt,ptr+ptrI[*zeCell]+1,ptr+ptrI[*zeCell+1],coords);
+ double tmp=INTERP_KERNEL::DistanceFromPtToPolygonInSpaceDim3(pt,nc+ncI[*zeCell]+1,nc+ncI[*zeCell+1],coords);
if(tmp<ret0)
{ ret0=tmp; cellId=*zeCell; }
break;
/*!
* \param [in] pt the start pointer (included) of the coordinates of the point
- * \param [in] cellIds
+ * \param [in] cellIdsBg the start pointer (included) of cellIds
+ * \param [in] cellIdsEnd the end pointer (excluded) of cellIds
+ * \param [in] nc nodal connectivity
+ * \param [in] ncI nodal connectivity index
* \param [in,out] ret0 the min distance between \a this and the external input point
* \param [out] cellId that corresponds to minimal distance. If the closer node is not linked to any cell in \a this -1 is returned.
- * \sa MEDCouplingUMesh::distanceToPoint
+ * \sa MEDCouplingUMesh::distanceToPoint, MEDCouplingUMesh::distanceToPoints
*/
-void MEDCouplingUMesh::distanceToPoint2DCurveAlg(const double *pt, const DataArrayInt *cellIds, double& ret0, int& cellId) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::DistanceToPoint2DCurveAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId) throw(INTERP_KERNEL::Exception)
{
- const double *coords=_coords->getConstPointer();
- if(cellIds->empty())
- { cellId=-1; return; }
- const int *ptr=_nodal_connec->getConstPointer();
- const int *ptrI=_nodal_connec_index->getConstPointer();
- for(const int *zeCell=cellIds->begin();zeCell!=cellIds->end();zeCell++)
+ cellId=-1;
+ ret0=std::numeric_limits<double>::max();
+ for(const int *zeCell=cellIdsBg;zeCell!=cellIdsEnd;zeCell++)
{
- switch((INTERP_KERNEL::NormalizedCellType)ptr[ptrI[*zeCell]])
+ switch((INTERP_KERNEL::NormalizedCellType)nc[ncI[*zeCell]])
{
case INTERP_KERNEL::NORM_SEG2:
{
- double tmp=INTERP_KERNEL::SquareDistanceFromPtToSegInSpaceDim2(pt,coords+2*ptr[ptrI[*zeCell]+1],coords+2*ptr[ptrI[*zeCell]+2]);
- if(tmp!=std::numeric_limits<double>::max()) tmp=sqrt(tmp);
+ std::size_t uselessEntry=0;
+ double tmp=INTERP_KERNEL::SquareDistanceFromPtToSegInSpaceDim2(pt,coords+2*nc[ncI[*zeCell]+1],coords+2*nc[ncI[*zeCell]+2],uselessEntry);
+ tmp=sqrt(tmp);
if(tmp<ret0)
{ ret0=tmp; cellId=*zeCell; }
break;
checkFullyDefined();
int nbOfCells=getNumberOfCells();
int delta=0;
+ const int *iciptr=_nodal_connec_index->getConstPointer();
for(int i=0;i<nbOfCells;i++)
{
INTERP_KERNEL::NormalizedCellType type=getTypeOfCell(i);
{
INTERP_KERNEL::NormalizedCellType typel=cm.getLinearType();
const INTERP_KERNEL::CellModel& cml=INTERP_KERNEL::CellModel::GetCellModel(typel);
- delta+=cm.getNumberOfNodes()-cml.getNumberOfNodes();
+ if(!cml.isDynamic())
+ delta+=cm.getNumberOfNodes()-cml.getNumberOfNodes();
+ else
+ delta+=(iciptr[i+1]-iciptr[i]-1)/2;
}
}
if(delta==0)
return ;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn=DataArrayInt::New();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConnI=DataArrayInt::New();
+ const int *icptr=_nodal_connec->getConstPointer();
newConn->alloc(getMeshLength()-delta,1);
newConnI->alloc(nbOfCells+1,1);
- const int *icptr=_nodal_connec->getConstPointer();
- const int *iciptr=_nodal_connec_index->getConstPointer();
int *ocptr=newConn->getPointer();
int *ociptr=newConnI->getPointer();
*ociptr=0;
_types.insert(typel);
const INTERP_KERNEL::CellModel& cml=INTERP_KERNEL::CellModel::GetCellModel(typel);
int newNbOfNodes=cml.getNumberOfNodes();
+ if(cml.isDynamic())
+ newNbOfNodes=(iciptr[i+1]-iciptr[i]-1)/2;
*ocptr++=(int)typel;
ocptr=std::copy(icptr+iciptr[i]+1,icptr+iciptr[i]+newNbOfNodes+1,ocptr);
ociptr[1]=ociptr[0]+newNbOfNodes+1;
DataArrayInt *MEDCouplingUMesh::sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception)
{
checkConnectivityFullyDefined();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=getRenumArrForConsecutiveCellTypesSpec(MEDMEM_ORDER,MEDMEM_ORDER+N_MEDMEM_ORDER);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=getRenumArrForMEDFileFrmt();
renumberCells(ret->getConstPointer(),false);
return ret.retn();
}
return tmpa.retn();
}
+/*!
+ * This method behaves exactly as MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec but the order is those defined in MED file spec.
+ *
+ * \return a new object containing the old to new correspondance.
+ *
+ * \sa MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec, MEDCouplingUMesh::sortCellsInMEDFileFrmt.
+ */
+DataArrayInt *MEDCouplingUMesh::getRenumArrForMEDFileFrmt() const throw(INTERP_KERNEL::Exception)
+{
+ return getRenumArrForConsecutiveCellTypesSpec(MEDMEM_ORDER,MEDMEM_ORDER+N_MEDMEM_ORDER);
+}
+
/*!
* This method is similar to method MEDCouplingUMesh::rearrange2ConsecutiveCellTypes except that the type order is specfied by [orderBg,orderEnd) (as MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder method) and that this method is \b const and performs \b NO permutation in 'this'.
* This method returns an array of size getNumberOfCells() that gives a renumber array old2New that can be used as input of MEDCouplingMesh::renumberCells.
std::size_t nbPoints=std::distance(begin,end);
if(nbPoints<3)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeVecAndPtOfFace : < of 3 points in face ! not able to find a plane on that face !");
- double vec[3];
+ double vec[3]={0.,0.,0.};
std::size_t j=0;
bool refFound=false;
for(;j<nbPoints-1 && !refFound;j++)
int nextNode=-1;
int prevNode=-1;
double resRef;
- double angleNext;
+ double angleNext=0.;
while(nextNode!=startNode)
{
nextNode=-1;
MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType, int startCellId=0) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void findCommonCells(int compType, int startCellId, DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getCellIdsCrossingPlane(const double *origin, const double *vec, double eps) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isContiguous1D() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void project1D(const double *pt, const double *v, double eps, double *res) const;
- MEDCOUPLING_EXPORT double distanceToPoint(const double *ptBg, const double *ptEnd, int& cellId, int& nodeId) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT double distanceToPoint(const double *ptBg, const double *ptEnd, int& cellId) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayDouble *distanceToPoints(const DataArrayDouble *pts, DataArrayInt *& cellIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
MEDCOUPLING_EXPORT bool checkConsecutiveCellTypesForMEDFileFrmt() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const;
MEDCOUPLING_EXPORT DataArrayInt *getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayInt *&nbPerType) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForMEDFileFrmt() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *rearrange2ConsecutiveCellTypes();
MEDCOUPLING_EXPORT std::vector<MEDCouplingUMesh *> splitByType() const;
MEDCouplingUMesh *buildDescendingConnectivityGen(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx, DimM1DescNbrer nbrer) const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildUnionOf2DMesh() const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildUnionOf3DMesh() const throw(INTERP_KERNEL::Exception);
- void distanceToPoint3DSurfAlg(const double *pt, const DataArrayInt *cellIds, double& ret0, int& cellId) const throw(INTERP_KERNEL::Exception);
- void distanceToPoint2DCurveAlg(const double *pt, const DataArrayInt *cellIds, double& ret0, int& cellId) const throw(INTERP_KERNEL::Exception);
+ static void DistanceToPoint3DSurfAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId) throw(INTERP_KERNEL::Exception);
+ static void DistanceToPoint2DCurveAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId) throw(INTERP_KERNEL::Exception);
static DataArrayInt *ComputeSpreadZoneGraduallyFromSeedAlg(std::vector<bool>& fetched, const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed) throw(INTERP_KERNEL::Exception);
static void FillInCompact3DMode(int spaceDim, int nbOfNodesInCell, const int *conn, const double *coo, double *zipFrmt) throw(INTERP_KERNEL::Exception);
static void AppendExtrudedCell(const int *connBg, const int *connEnd, int nbOfNodesPerLev, bool isQuad, std::vector<int>& ret);
throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::computeNbOfNodesPerCell : not implemented yet !");
}
+DataArrayInt *MEDCouplingUMeshDesc::computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::computeNbOfFacesPerCell : not implemented yet !");
+}
+
int MEDCouplingUMeshDesc::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
{
const int *desc_connec=_desc_connec->getConstPointer();
MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
MEDCOUPLING_EXPORT DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
MEDCOUPLING_EXPORT std::string simpleRepr() const;
int tab4[4*nbOfCells]={
1, 2, 8, 7, 2, 3, 9, 8, 3, 4, 10, 9, 4, 5, 11, 10, 5, 0, 6, 11,
0, 1, 7, 6, };
-
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NORM_TRI3),3);
+ CPPUNIT_ASSERT(MEDCouplingMesh::IsStaticGeometricType(INTERP_KERNEL::NORM_TRI3));
+ CPPUNIT_ASSERT(MEDCouplingMesh::IsLinearGeometricType(INTERP_KERNEL::NORM_TRI3));
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetDimensionOfGeometricType(INTERP_KERNEL::NORM_TRI3),2);
+ CPPUNIT_ASSERT_EQUAL(std::string(MEDCouplingMesh::GetReprOfGeometricType(INTERP_KERNEL::NORM_TRI3)),std::string("NORM_TRI3"));
+ CPPUNIT_ASSERT_THROW(MEDCouplingMesh::GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NORM_POLYGON),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT(not MEDCouplingMesh::IsStaticGeometricType(INTERP_KERNEL::NORM_POLYGON));
+ CPPUNIT_ASSERT(MEDCouplingMesh::IsLinearGeometricType(INTERP_KERNEL::NORM_POLYGON));
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetDimensionOfGeometricType(INTERP_KERNEL::NORM_POLYGON),2);
+ CPPUNIT_ASSERT_EQUAL(std::string(MEDCouplingMesh::GetReprOfGeometricType(INTERP_KERNEL::NORM_POLYGON)),std::string("NORM_POLYGON"));
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NORM_TRI6),6);
+ CPPUNIT_ASSERT(MEDCouplingMesh::IsStaticGeometricType(INTERP_KERNEL::NORM_TRI6));
+ CPPUNIT_ASSERT(!MEDCouplingMesh::IsLinearGeometricType(INTERP_KERNEL::NORM_TRI6));
+ CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetDimensionOfGeometricType(INTERP_KERNEL::NORM_TRI6),2);
+ CPPUNIT_ASSERT_EQUAL(std::string(MEDCouplingMesh::GetReprOfGeometricType(INTERP_KERNEL::NORM_TRI6)),std::string("NORM_TRI6"));
MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(8);
CPPUNIT_ASSERT_DOUBLES_EQUAL(5.6,f2->getIJ(i,0),1e-13);
f2->decrRef();
//
+ DataArrayInt *d2I=0;
+ DataArrayDouble *d2=array->maxPerTupleWithCompoId(d2I);
+ CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,d2->getNumberOfTuples());
+ const int expected2[5]={4,3,2,0,1};
+ for(int i=0;i<5;i++)
+ {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5.6,d2->getIJ(i,0),1e-13);
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d2I->getIJ(i,0));
+ }
+ d2->decrRef(); d2I->decrRef();
+ //
mesh1->decrRef();
f1->decrRef();
}
a1->setInfoOnComponent(3,"dddd");
const int arr2[6]={1,2,1,2,0,0};
std::vector<int> arr2V(arr2,arr2+6);
- DataArrayDouble *a2=a1->keepSelectedComponents(arr2V);
+ DataArrayDouble *a2=static_cast<DataArrayDouble *>(a1->keepSelectedComponents(arr2V));
CPPUNIT_ASSERT_EQUAL(6,a2->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(5,a2->getNumberOfTuples());
CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb");
for(int i=0;i<30;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14);
DataArrayInt *a3=a1->convertToIntArr();
- DataArrayInt *a4=a3->keepSelectedComponents(arr2V);
+ DataArrayInt *a4=static_cast<DataArrayInt *>(a3->keepSelectedComponents(arr2V));
CPPUNIT_ASSERT_EQUAL(6,a4->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(5,a4->getNumberOfTuples());
CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb");
// setSelectedComponents
const int arr3[2]={3,2};
std::vector<int> arr3V(arr3,arr3+2);
- DataArrayDouble *a5=a1->keepSelectedComponents(arr3V);
+ DataArrayDouble *a5=static_cast<DataArrayDouble *>(a1->keepSelectedComponents(arr3V));
a5->setInfoOnComponent(0,"eeee");
a5->setInfoOnComponent(1,"ffff");
const int arr4[2]={1,2};
//
std::vector<std::pair<int,int> > p(3);
p[0].first=0; p[0].second=3; p[1].first=3; p[1].second=5; p[2].first=5; p[2].second=7;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayDouble *>(da->selectByTupleRanges(p));
CPPUNIT_ASSERT(tmp->isEqual(*da,1e-14));
tmp->decrRef();
p[0].first=0; p[0].second=2; p[1].first=3; p[1].second=4; p[2].first=5; p[2].second=7;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayDouble *>(da->selectByTupleRanges(p));
const double expected1[10]={1.,11.,2.,12.,4.,14.,6.,16.,7.,17.};
CPPUNIT_ASSERT_EQUAL(5,tmp->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfComponents());
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],tmp->getIJ(0,i),1e-14);
tmp->decrRef();
p[0].first=0; p[0].second=2; p[1].first=0; p[1].second=2; p[2].first=5; p[2].second=6;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayDouble *>(da->selectByTupleRanges(p));
const double expected2[10]={1.,11.,2.,12.,1.,11.,2.,12.,6.,16.};
CPPUNIT_ASSERT_EQUAL(5,tmp->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfComponents());
//
std::vector<std::pair<int,int> > p(3);
p[0].first=0; p[0].second=3; p[1].first=3; p[1].second=5; p[2].first=5; p[2].second=7;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayInt *>(da->selectByTupleRanges(p));
CPPUNIT_ASSERT(tmp->isEqual(*da));
tmp->decrRef();
p[0].first=0; p[0].second=2; p[1].first=3; p[1].second=4; p[2].first=5; p[2].second=7;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayInt *>(da->selectByTupleRanges(p));
const int expected1[10]={1,11,2,12,4,14,6,16,7,17};
CPPUNIT_ASSERT_EQUAL(5,tmp->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(expected1[i],tmp->getIJ(0,i));
tmp->decrRef();
p[0].first=0; p[0].second=2; p[1].first=0; p[1].second=2; p[2].first=5; p[2].second=6;
- tmp=da->selectByTupleRanges(p);
+ tmp=dynamic_cast<DataArrayInt *>(da->selectByTupleRanges(p));
const int expected2[10]={1,11,2,12,1,11,2,12,6,16};
CPPUNIT_ASSERT_EQUAL(5,tmp->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfComponents());
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2 =
field1->cloneWithMesh( true );
double vec[1] = { 5. };
- ((ParaMEDMEM::MEDCouplingMesh *)field2->getMesh())->translate(vec); // translate mesh2
+ (const_cast<ParaMEDMEM::MEDCouplingMesh *>(field2->getMesh()))->translate(vec); // translate mesh2
field2->applyFunc("x + 5"); // "translate" field2
// concatenate field1 and field2
field->renumberNodes(renumber,false);
const MEDCouplingMesh* mesh2 = field->getMesh(); // field now refers to another mesh
values = field->getArray();
- nodeCoords = ((MEDCouplingUMesh*)mesh2)->getCoords();
+ nodeCoords = (static_cast<const MEDCouplingUMesh*>(mesh2))->getCoords();
CPPUNIT_ASSERT( values->isEqualWithoutConsideringStr( *nodeCoords, 1e-13 ));
//! [CppSnippet_MEDCouplingFieldDouble_renumberNodes_3]
}
INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${MED_salomescript_PYTHON})
INSTALL(FILES MEDCoupling.i MEDCouplingCommon.i MEDCouplingMemArray.i MEDCouplingFinalize.i MEDCouplingRemapper.i MEDCouplingTypemaps.i DESTINATION ${MED_salomeinclude_HEADERS})
-INSTALL(FILES MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCouplingDataForTest.py MEDCouplingNumpyTest.py DESTINATION ${MED_salomescript_PYTHON})
+INSTALL(FILES MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCouplingDataForTest.py MEDCouplingNumPyTest.py DESTINATION ${MED_salomescript_PYTHON})
ADD_TEST(MEDCouplingBasicsTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingBasicsTest.py)
ADD_TEST(MEDCouplingExamplesTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingExamplesTest.py)
ADD_TEST(MEDCouplingRemapperTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingRemapperTest.py)
IF(NUMPY_STATUS)
- ADD_TEST(MEDCouplingNumpyTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingNumpyTest.py)
+ ADD_TEST(MEDCouplingNumPyTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingNumPyTest.py)
ENDIF(NUMPY_STATUS)
from MEDCoupling import *
import unittest
from math import pi,e,sqrt,cos,sin
+from datetime import datetime
from MEDCouplingDataForTest import MEDCouplingDataForTest
+import rlcompleter,readline # this line has to be here, ot ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr
class MEDCouplingBasicsTest(unittest.TestCase):
def testArray2(self):
-0.305, 0.024155, 0.04183768725682622, -0.2863, 0.04831000000000001, -1.015761910347357e-17, -0.2863,
0.09662000000000001, -1.832979297858306e-18, -0.2863, 0.120775, 0.04183768725682623, -0.2863, 0.09662000000000001,
0.08367537451365245, -0.2863, 0.04831000000000001, 0.08367537451365246, -0.2863 ]
+ self.assertEqual(MEDCouplingMesh.GetNumberOfNodesOfGeometricType(NORM_TRI3),3)
+ self.assertTrue(MEDCouplingMesh.IsStaticGeometricType(NORM_TRI3))
+ self.assertTrue(MEDCouplingMesh.IsLinearGeometricType(NORM_TRI3))
+ self.assertEqual(MEDCouplingMesh.GetDimensionOfGeometricType(NORM_TRI3),2)
+ self.assertEqual(MEDCouplingMesh.GetReprOfGeometricType(NORM_TRI3),"NORM_TRI3")
+ self.assertRaises(InterpKernelException,MEDCouplingMesh.GetNumberOfNodesOfGeometricType,NORM_POLYGON)
+ self.assertTrue(not MEDCouplingMesh.IsStaticGeometricType(NORM_POLYGON))
+ self.assertTrue(MEDCouplingMesh.IsLinearGeometricType(NORM_POLYGON))
+ self.assertEqual(MEDCouplingMesh.GetDimensionOfGeometricType(NORM_POLYGON),2)
+ self.assertEqual(MEDCouplingMesh.GetReprOfGeometricType(NORM_POLYGON),"NORM_POLYGON")
+ self.assertEqual(MEDCouplingMesh.GetNumberOfNodesOfGeometricType(NORM_TRI6),6)
+ self.assertTrue(MEDCouplingMesh.IsStaticGeometricType(NORM_TRI6))
+ self.assertTrue(not MEDCouplingMesh.IsLinearGeometricType(NORM_TRI6))
+ self.assertEqual(MEDCouplingMesh.GetDimensionOfGeometricType(NORM_TRI6),2)
+ self.assertEqual(MEDCouplingMesh.GetReprOfGeometricType(NORM_TRI6),"NORM_TRI6")
mesh=MEDCouplingUMesh.New()
mesh.setMeshDimension(2)
mesh.allocateCells(8);
self.assertTrue(not fieldOnNodes1.isEqual(fieldOnCells1,1e-12,1e-15));
#
fieldOnCells2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ self.assertEqual(fieldOnCells2.getMesh(),None) # to check that convertMesh wrapping do not raise but return Py_None
self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
fieldOnCells1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
self.assertAlmostEqual(5.6,f2.getIJ(i,0),13);
pass
#
+ d2,d2I=array.maxPerTupleWithCompoId()
+ self.assertEqual(1,d2.getNumberOfComponents());
+ self.assertEqual(5,d2.getNumberOfTuples());
+ for i in xrange(5):
+ self.assertAlmostEqual(5.6,d2.getIJ(i,0),13);
+ pass
+ self.assertTrue(d2I.isEqual(DataArrayInt([4,3,2,0,1])))
pass
def testChangeNbOfComponents(self):
m.setCoords(coords)
m.allocateCells(0)
m.insertNextCell(NORM_TRI3,[0,1,2])
- a,b,c=m.distanceToPoint([-0.335,2.27,1.21])
- self.assertEqual(0,b) ; self.assertEqual(0,c)
+ a,b=m.distanceToPoint([-0.335,2.27,1.21])
+ self.assertEqual(0,b)
self.assertAlmostEqual(0.022360988100374124,a,14);
- a,b,c=m.distanceToPoint(DataArrayDouble([-0.335,2.27,1.21],1,3))
- self.assertEqual(0,b) ; self.assertEqual(0,c)
+ a,b=m.distanceToPoint(DataArrayDouble([-0.335,2.27,1.21],1,3))
+ self.assertEqual(0,b)
self.assertAlmostEqual(0.022360988100374124,a,14);
a,b=coords.distanceToTuple([-0.335,2.27,1.21])
self.assertAlmostEqual(5.243302871282566,a,14)
m.insertNextCell(NORM_QUAD4,[0,1,2,3])
m.checkCoherency2()
self.assertEqual([4,0,1,2,3],m.getNodalConnectivity().getValues())
- a,b,c=m.distanceToPoint([5.,2.,0.1])
- self.assertAlmostEqual(0.1,a,14) ; self.assertEqual(0,b) ; self.assertEqual(1,c)
- a,b,c=m.distanceToPoint([5.,-2.,4.])
- self.assertAlmostEqual(sqrt(2*2+4*4),a,14) ; self.assertEqual(0,b) ; self.assertEqual(1,c)
+ a,b=m.distanceToPoint([5.,2.,0.1])
+ self.assertAlmostEqual(0.1,a,14) ; self.assertEqual(0,b)
+ a,b=m.distanceToPoint([5.,-2.,4.])
+ self.assertAlmostEqual(sqrt(2*2+4*4),a,14) ; self.assertEqual(0,b)
m.allocateCells(0)
m.insertNextCell(NORM_POLYGON,[0,1,2,3])
m.checkCoherency2()
self.assertEqual([5,0,1,2,3],m.getNodalConnectivity().getValues())
- a,b,c=m.distanceToPoint([11.,3.,4.])
- self.assertAlmostEqual(sqrt(3*3+4*4),a,14) ; self.assertEqual(0,b) ; self.assertEqual(1,c)
- a,b,c=m.distanceToPoint([4.,12.,5.])
- self.assertAlmostEqual(sqrt(4*4+5*5),a,14) ; self.assertEqual(0,b) ; self.assertEqual(2,c)
+ a,b=m.distanceToPoint([11.,3.,4.])
+ self.assertAlmostEqual(sqrt(3*3+4*4),a,14) ; self.assertEqual(0,b)
+ a,b=m.distanceToPoint([4.,12.,5.])
+ self.assertAlmostEqual(sqrt(4*4+5*5),a,14) ; self.assertEqual(0,b)
d=DataArrayDouble([-1.2,3.,2.],1,3)
for elt in d:
- a,b,c=m.distanceToPoint(d)
- self.assertAlmostEqual(sqrt(1.2*1.2+2*2),a,14) ; self.assertEqual(0,b) ; self.assertEqual(0,c)
+ a,b=m.distanceToPoint(d)
+ self.assertAlmostEqual(sqrt(1.2*1.2+2*2),a,14) ; self.assertEqual(0,b)
pass
#
m=MEDCouplingUMesh("toto",1)
coords=DataArrayDouble([0.,0.,4.,0.,0.,4.],3,2) ; m.setCoords(coords)
m.allocateCells(0) ; m.insertNextCell(NORM_SEG2,[0,1]) ; m.insertNextCell(NORM_SEG2,[1,2])
- a,b,c=m.distanceToPoint([-0.1,4.1])
- self.assertAlmostEqual(0.14142135623730925,a,14) ; self.assertEqual(-1,b) ; self.assertEqual(2,c)
- a,b,c=m.distanceToPoint([0.,3.9])
- self.assertAlmostEqual(0.07071067811865482,a,14) ; self.assertEqual(1,b) ; self.assertEqual(2,c)
+ a,b=m.distanceToPoint([-0.1,4.1])
+ self.assertAlmostEqual(0.14142135623730925,a,14) # b==1 self.assertEqual(2,c)
+ a,b=m.distanceToPoint([0.,3.9])
+ self.assertAlmostEqual(0.07071067811865482,a,14) ; self.assertEqual(1,b) # self.assertEqual(2,c)
pass
def testSwig2NonRegressionPartitionBySpreadZone1(self):
self.assertTrue( field.getArray().getValues() == coords2 )
pass
+ def testSwig2UMeshDistanceToMesh2(self):
+ sz=5
+ m=MEDCouplingCMesh()
+ arr=DataArrayDouble(sz+1) ; arr.iota() ; arr/=sz
+ m.setCoords(arr,arr,arr)
+ m=m.buildUnstructured()
+ m1=m.computeSkin()
+ m1.zipCoords()
+ c=m1.getCoords()[:]
+ d=2*(c-[0.5,0.5,0.5])+[0.5,0.5,0.5]
+ time_deb = datetime.now()
+ #print "go.."
+ a,b=m1.distanceToPoints(d)
+ #print 'time spent in distanceToPoints %s ' %str(datetime.now() - time_deb)
+ time_deb = datetime.now()
+ a1=DataArrayDouble(len(d))
+ b1=DataArrayInt(len(d))
+ m1s=[m1[i] for i in xrange(m1.getNumberOfCells())]
+ for j,pt in enumerate(d):
+ eter=1e308
+ fter=-1
+ for i,miter in enumerate(m1s):
+ e,f=miter.distanceToPoint(pt)
+ self.assertEqual(0,f)
+ if e<eter:
+ eter=e ; fter=i
+ pass
+ pass
+ a1[j]=eter
+ b1[j]=fter
+ pass
+ #print 'time spent in naive distanceToPoints %s ' %str(datetime.now() - time_deb)
+ self.assertTrue(a.isEqual(a1,1e-12))
+ self.assertTrue(b.isEqual(b1))
+ self.assertTrue(a.isEqual(DataArrayDouble([0.8660254037844386,0.714142842854285,0.7071067811865476,0.7071067811865476,0.714142842854285,0.8660254037844386,0.714142842854285,0.5196152422706632,0.5099019513592785,0.5099019513592785,0.5196152422706632,0.714142842854285,0.7071067811865475,0.5099019513592785,0.5,0.5,0.5099019513592785,0.7071067811865476,0.7071067811865475,0.5099019513592785,0.5,0.5,0.5099019513592785,0.7071067811865476,0.714142842854285,0.5196152422706632,0.5099019513592785,0.5099019513592785,0.5196152422706632,0.714142842854285,0.8660254037844386,0.714142842854285,0.7071067811865476,0.7071067811865476,0.714142842854285,0.8660254037844386,0.714142842854285,0.5196152422706632,0.5099019513592785,0.5099019513592785,0.5196152422706631,0.714142842854285,0.5196152422706631,0.5196152422706632,0.5099019513592784,0.5099019513592785,0.5099019513592784,0.5099019513592785,0.5196152422706631,0.5196152422706632,0.714142842854285,0.5196152422706632,0.5099019513592785,0.5099019513592785,0.5196152422706632,0.714142842854285,0.7071067811865475,0.5099019513592785,0.5,0.5,0.5099019513592784,0.7071067811865475,0.5099019513592784,0.5099019513592785,0.5,0.5,0.5,0.5,0.5099019513592785,0.5099019513592785,0.7071067811865476,0.5099019513592785,0.5,0.5,0.5099019513592785,0.7071067811865476,0.7071067811865475,0.5099019513592785,0.5,0.5,0.5099019513592784,0.7071067811865475,0.5099019513592784,0.5099019513592785,0.5,0.5,0.5,0.5,0.5099019513592785,0.5099019513592785,0.7071067811865476,0.5099019513592785,0.5,0.5,0.5099019513592785,0.7071067811865476,0.714142842854285,0.5196152422706632,0.5099019513592785,0.5099019513592785,0.5196152422706631,0.714142842854285,0.5196152422706631,0.5196152422706632,0.5099019513592784,0.5099019513592785,0.5099019513592784,0.5099019513592785,0.5196152422706631,0.5196152422706632,0.714142842854285,0.5196152422706632,0.5099019513592785,0.5099019513592785,0.5196152422706632,0.714142842854285,0.8660254037844386,0.714142842854285,0.7071067811865476,0.7071067811865476,0.714142842854285,0.8660254037844386,0.714142842854285,0.5196152422706632,0.5099019513592785,0.5099019513592785,0.5196152422706632,0.714142842854285,0.7071067811865475,0.5099019513592785,0.5,0.5,0.5099019513592785,0.7071067811865476,0.7071067811865475,0.5099019513592785,0.5,0.5,0.5099019513592785,0.7071067811865476,0.714142842854285,0.5196152422706632,0.5099019513592785,0.5099019513592785,0.5196152422706632,0.714142842854285,0.8660254037844386,0.714142842854285,0.7071067811865476,0.7071067811865476,0.714142842854285,0.8660254037844386]),1e-12))
+ self.assertTrue(b.isEqual(DataArrayInt([0,0,3,7,9,9,0,0,3,7,9,9,12,12,14,16,17,17,26,26,28,30,31,31,33,33,36,40,42,42,33,33,36,40,42,42,0,0,3,7,11,9,0,9,12,17,26,31,33,42,33,33,36,40,42,42,45,45,47,49,51,51,45,50,52,53,56,57,58,63,58,58,60,62,63,63,85,85,87,89,91,91,85,90,92,93,96,97,98,103,98,98,100,102,103,103,105,105,108,112,116,114,105,114,117,122,131,136,138,147,138,138,141,145,147,147,105,105,108,112,114,114,105,105,108,112,114,114,117,117,119,121,122,122,131,131,133,135,136,136,138,138,141,145,147,147,138,138,141,145,147,147])))
+ pass
+
+ def testSwig2NonRegressionBugDistance1(self):
+ pt=DataArrayDouble([(8.8452994616207476,3.1547005383792515,3.1547005383792515)])
+ coo=DataArrayDouble([(8,0,0),(8,0,8),(8,8,8),(8,8,0),(16,0,0),(16,0,8),(16,8,8),(16,8,0),(8,0,4),(8,4,8),(8,8,4),(8,4,0),(16,0,4),(16,4,8),(16,8,4),(16,4,0),(12,0,0),(12,0,8),(12,8,8),(12,8,0),(8,4,4),(16,4,4),(12,0,4),(12,4,8),(12,8,4),(12,4,0)])
+ conn=DataArrayInt([4,15,21,12,4,16,25,15,12,22,16,4,0,8,20,11,16,0,11,25,22,8,0,16,15,7,14,21,15,25,19,7,7,19,24,14,11,20,10,3,25,11,3,19,19,3,10,24,12,21,13,5,13,23,17,5,5,17,22,12,8,1,9,20,23,9,1,17,17,1,8,22,21,14,6,13,14,24,18,6 ,6,18,23,13,20,9,2,10,24,10,2,18,18,2,9,23])
+ m=MEDCouplingUMesh("mesh",2)
+ m.setCoords(coo)
+ m.allocateCells()
+ for i in xrange(24):
+ m.insertNextCell(NORM_QUAD4,conn[4*i:4*i+4])
+ pass
+ m.checkCoherency2()
+ m0=m[3] ; m0.zipCoords()
+ expectedDist=0.8452994616207476
+ a,b=m0.distanceToPoint(pt)
+ self.assertAlmostEqual(expectedDist,a,14)
+ self.assertEqual(0,b)
+ #
+ a,b=m.distanceToPoint(pt)
+ self.assertAlmostEqual(expectedDist,a,14)
+ self.assertEqual(3,b)
+ #
+ fd=MEDCouplingFieldDiscretization.New(ON_CELLS)
+ self.assertEqual(24,fd.getNumberOfTuples(m))
+ fd=MEDCouplingFieldDiscretization.New(ON_NODES)
+ self.assertEqual(26,fd.getNumberOfTuples(m))
+ pass
+
+ def testSwig2AreaBarySeg3Quad8Tri6QPolyg(self):
+ #QUAD8 representing a circle of center zeBary and radius zeRadius
+ zeBary=[5,6]
+ zeRadius=3
+ d=DataArrayDouble(8,2)
+ d[:,0]=zeRadius
+ d[:,1]=[87,-100,-170,110,5,-130,175,95] # angle in degree
+ d[:,1]*=pi/180. # angle in radian
+ d=d.fromPolarToCart()
+ d+=zeBary
+ m=MEDCouplingUMesh("quad8",2) ; m.allocateCells() ; m.insertNextCell(NORM_QUAD8,range(8)) ; m.setCoords(d)
+ self.assertTrue(m.getBarycenterAndOwner().isEqual(DataArrayDouble(zeBary,1,2),1e-13))
+ self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),pi*zeRadius*zeRadius,12)
+ tri32D=m.buildDescendingConnectivity()[0][0] ; tri32D.zipCoords()
+ # spaceDim=3 QUAD8 becomes QUAD4 ... for the moment
+ m.setCoords(m.getCoords().changeNbOfComponents(3,0.))
+ m2=m.deepCpy()
+ m2.convertQuadraticCellsToLinear()
+ self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),float(m2.getMeasureField(False).getArray()),12)
+ self.assertTrue(m.getBarycenterAndOwner().isEqual(m2.getBarycenterAndOwner(),1e-13))
+ #TRI6 representing a circle of center zeBary and radius zeRadius
+ zeBary=[5,6]
+ zeRadius=3
+ d=DataArrayDouble(6,2)
+ d[:,0]=zeRadius
+ d[:,1]=[87,-100,110,5,175,95] # angle in degree
+ d[:,1]*=pi/180. # angle in radian
+ d=d.fromPolarToCart()
+ d+=zeBary
+ m=MEDCouplingUMesh("tri6",2) ; m.allocateCells() ; m.insertNextCell(NORM_TRI6,range(6)) ; m.setCoords(d)
+ self.assertTrue(m.getBarycenterAndOwner().isEqual(DataArrayDouble(zeBary,1,2),1e-13))
+ self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),pi*zeRadius*zeRadius,12)
+ # spaceDim=3 TRI6 becomes TRI3 ... for the moment
+ m.setCoords(m.getCoords().changeNbOfComponents(3,0.))
+ m2=m.deepCpy()
+ m2.convertQuadraticCellsToLinear()
+ self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),float(m2.getMeasureField(False).getArray()),12)
+ self.assertTrue(m.getBarycenterAndOwner().isEqual(m2.getBarycenterAndOwner(),1e-13))
+ # QPOLYG representing a circle of center zeBary and radius zeRadius
+ zeBary=[5,6]
+ zeRadius=3
+ d=DataArrayDouble(10,2)
+ d[:,0]=zeRadius
+ d[:,1]=[87,-80,-100,-170,110,5,-90,-130,175,95] # angle in degree
+ d[:,1]*=pi/180. # angle in radian
+ d=d.fromPolarToCart()
+ d+=zeBary
+ m=MEDCouplingUMesh("qpolyg",2) ; m.allocateCells() ; m.insertNextCell(NORM_QPOLYG,range(10)) ; m.setCoords(d)
+ self.assertTrue(m.getBarycenterAndOwner().isEqual(DataArrayDouble(zeBary,1,2),1e-13))
+ self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),pi*zeRadius*zeRadius,12)
+ # spaceDim=3 QPOLYG becomes POLYG ... for the moment
+ m.setCoords(m.getCoords().changeNbOfComponents(3,0.))
+ m2=m.deepCpy()
+ m2.convertQuadraticCellsToLinear() ; m2.checkCoherency2()
+ self.assertTrue(m2.getAllGeoTypes()==[NORM_POLYGON] and m2.getNodalConnectivity().getValues()==[5,0,1,2,3,4])
+ self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),float(m2.getMeasureField(False).getArray()),12)
+ self.assertTrue(m.getBarycenterAndOwner().isEqual(m2.getBarycenterAndOwner(),1e-13))
+ # TRI3
+ self.assertAlmostEqual(float(tri32D.getMeasureField(False).getArray()),(87+100)*pi/180*zeRadius,13)
+ exp=DataArrayDouble(1,2) ; exp[:,0]=3 ; exp[:,1]=(87-100)/2. ; exp[:,1]*=pi/180. ; exp=exp.fromPolarToCart() ; exp+=DataArrayDouble([5,6],1,2)
+ self.assertTrue(tri32D.getBarycenterAndOwner().isEqual(exp,1e-12))
+ # spaceDim=3 TRI3 becomes TRI2 ... for the moment
+ tri32D.changeSpaceDimension(3)
+ tri2=tri32D.deepCpy() ; tri2.convertQuadraticCellsToLinear()
+ self.assertAlmostEqual(float(tri32D.getMeasureField(False).getArray()),float(tri2.getMeasureField(False).getArray()),13)
+ self.assertTrue(tri32D.getBarycenterAndOwner().isEqual(tri2.getBarycenterAndOwner(),1e-12))
+ tri32D.changeSpaceDimension(1)
+ self.assertAlmostEqual(float(tri32D.getMeasureField(False).getArray()),-0.67795240172962323,12)
+ pass
+
+ # this bug 5/6/2013 is swig specific
+ def testSwigNonRegressionBugRotate3D1(self):
+ m=MEDCouplingUMesh.New()
+ dataArray=DataArrayDouble.New(100,3)
+ dataArray[:]=0.
+ dataArray[0]=[0.,1,3]
+ m.setCoords(dataArray[0])
+ m1=m.deepCpy()
+ m.rotate([0.,0.,3.],[1.,0.,0.],0.5*pi)
+ self.assertTrue(m.getCoords().isEqual(DataArrayDouble([0.,0.,4.],1,3),1e-15))
+ #
+ d1=DataArrayDouble([0.,0.,3.],1,3) ; d2=DataArrayDouble([1.,0.,0.],1,3)
+ pts=[[0.,0.,3.],[(0.,0.,3.)],DataArrayDouble([0.,0.,3.],1,3),list(d1)[0]]
+ vec=[[1.,0.,0.],[(1.,0.,0.)],DataArrayDouble([1.,0.,0.],1,3),list(d2)[0]]
+ for p in pts:
+ for v in vec:
+ m2=m1.deepCpy()
+ m2.rotate(p,v,0.5*pi)
+ self.assertTrue(m2.getCoords().isEqual(DataArrayDouble([0.,0.,4.],1,3),1e-15))
+ pass
+ pass
+
+ def testSwig2DataArrayCount1(self):
+ d=DataArrayInt([])
+ self.assertEqual(0,d.getNumberOfTuples())
+ self.assertEqual(1,d.getNumberOfComponents())
+ self.assertEqual(0,d.count(0))
+ self.assertEqual(0,d.count(1))
+ self.assertEqual(0,d.count(-1))
+ d=DataArrayInt([2,1,-2,-3,2,0,0,7,2,-2,3,0])
+ self.assertEqual(12,d.getNumberOfTuples())
+ self.assertEqual(1,d.getNumberOfComponents())
+ self.assertEqual(3,d.count(0))
+ self.assertEqual(1,d.count(1))
+ self.assertEqual(0,d.count(-1))
+ self.assertEqual(2,d.count(-2))
+ self.assertEqual(3,d.count(2))
+ e=d.getDifferentValues()
+ f=DataArrayInt()
+ for it in e:
+ f.pushBackSilent(d.count(int(it)))
+ pass
+ self.assertEqual(12,f.accumulate()[0])
+ #
+ eps=1e-12
+ d=DataArrayDouble([])
+ self.assertEqual(0,d.getNumberOfTuples())
+ self.assertEqual(1,d.getNumberOfComponents())
+ self.assertEqual(0,d.count(0,eps))
+ self.assertEqual(0,d.count(1,eps))
+ self.assertEqual(0,d.count(-1,eps))
+ d=DataArrayDouble([2,1,-2,-3,2,0,eps/10,7,2+eps/10,-2,3,0])
+ self.assertEqual(12,d.getNumberOfTuples())
+ self.assertEqual(1,d.getNumberOfComponents())
+ self.assertEqual(3,d.count(0,eps))
+ self.assertEqual(1,d.count(1,eps))
+ self.assertEqual(0,d.count(-1,eps))
+ self.assertEqual(2,d.count(-2,eps))
+ self.assertEqual(3,d.count(2,eps))
+ self.assertEqual(3,d.count(2,eps))
+ self.assertEqual(2,d.count(2,eps/100))
+ e=d.getDifferentValues(eps)
+ f=DataArrayInt()
+ for it in e:
+ f.pushBackSilent(d.count(float(it),eps))
+ pass
+ self.assertEqual(12,f.accumulate()[0])
+ pass
+
+ def testSwig2DataArrayGetSlice1(self):
+ s=slice(2,18,1)
+ self.assertEqual(DataArray.GetNumberOfItemGivenBESRelative(s),16)
+ self.assertEqual(DataArray.GetNumberOfItemGivenBES(s),16)
+ self.assertEqual(DataArray.GetSlice(s,0,4),slice(2,6,1))
+ self.assertEqual(DataArray.GetSlice(s,1,4),slice(6,10,1))
+ self.assertEqual(DataArray.GetSlice(s,2,4),slice(10,14,1))
+ self.assertEqual(DataArray.GetSlice(s,3,4),slice(14,18,1))
+ #
+ s=slice(2,18,2)
+ self.assertEqual(DataArray.GetNumberOfItemGivenBESRelative(s),8)
+ self.assertEqual(DataArray.GetNumberOfItemGivenBES(s),8)
+ self.assertEqual(DataArray.GetSlice(s,0,4),slice(2,6,2))
+ self.assertEqual(DataArray.GetSlice(s,1,4),slice(6,10,2))
+ self.assertEqual(DataArray.GetSlice(s,2,4),slice(10,14,2))
+ self.assertEqual(DataArray.GetSlice(s,3,4),slice(14,18,2))
+ #
+ s=slice(1,18,1)
+ self.assertEqual(DataArray.GetSlice(s,0,4),slice(1,5,1))
+ self.assertEqual(DataArray.GetSlice(s,1,4),slice(5,9,1))
+ self.assertEqual(DataArray.GetSlice(s,2,4),slice(9,13,1))
+ self.assertEqual(DataArray.GetSlice(s,3,4),slice(13,18,1))# 18 not 17
+ #
+ s=slice(1,18,2)
+ self.assertEqual(DataArray.GetNumberOfItemGivenBESRelative(s),9)
+ self.assertEqual(DataArray.GetNumberOfItemGivenBES(s),9)
+ self.assertEqual(DataArray.GetSlice(s,0,4),slice(1,5,2))
+ self.assertEqual(DataArray.GetSlice(s,1,4),slice(5,9,2))
+ self.assertEqual(DataArray.GetSlice(s,2,4),slice(9,13,2))
+ self.assertEqual(DataArray.GetSlice(s,3,4),slice(13,18,2))# 18 not 17
+ #
+ s=slice(18,2,-1)
+ self.assertEqual(DataArray.GetSlice(s,0,4),slice(18,14,-1))
+ self.assertEqual(DataArray.GetSlice(s,1,4),slice(14,10,-1))
+ self.assertEqual(DataArray.GetSlice(s,2,4),slice(10,6,-1))
+ self.assertEqual(DataArray.GetSlice(s,3,4),slice(6,2,-1))
+ #
+ s=slice(18,2,-2)
+ self.assertEqual(DataArray.GetSlice(s,0,4),slice(18,14,-2))
+ self.assertEqual(DataArray.GetSlice(s,1,4),slice(14,10,-2))
+ self.assertEqual(DataArray.GetSlice(s,2,4),slice(10,6,-2))
+ self.assertEqual(DataArray.GetSlice(s,3,4),slice(6,2,-2))
+ #
+ s=slice(18,1,-1)
+ self.assertEqual(DataArray.GetSlice(s,0,4),slice(18,14,-1))
+ self.assertEqual(DataArray.GetSlice(s,1,4),slice(14,10,-1))
+ self.assertEqual(DataArray.GetSlice(s,2,4),slice(10,6,-1))
+ self.assertEqual(DataArray.GetSlice(s,3,4),slice(6,1,-1))# 1 not 2
+ #
+ s=slice(18,1,-2)
+ self.assertEqual(DataArray.GetNumberOfItemGivenBESRelative(s),9)
+ self.assertRaises(InterpKernelException,DataArray.GetNumberOfItemGivenBES,s)
+ self.assertEqual(sum([DataArray.GetNumberOfItemGivenBESRelative(DataArray.GetSlice(s,i,4)) for i in xrange(4)]),DataArray.GetNumberOfItemGivenBESRelative(s))
+ self.assertEqual(DataArray.GetSlice(s,0,4),slice(18,14,-2))
+ self.assertEqual(DataArray.GetSlice(s,1,4),slice(14,10,-2))
+ self.assertEqual(DataArray.GetSlice(s,2,4),slice(10,6,-2))
+ self.assertEqual(DataArray.GetSlice(s,3,4),slice(6,1,-2))# 1 not 2
+ self.assertRaises(InterpKernelException,DataArray.GetSlice,slice(0,None,2),0,4)
+ #
+ d=DataArrayInt.Range(0,18,1)
+ s=slice(2,None,1)
+ self.assertEqual(d.getNumberOfItemGivenBES(s),16)
+ self.assertEqual(d.getNumberOfItemGivenBESRelative(s),16)
+ self.assertEqual(d.getSlice(s,0,4),slice(2,6,1))
+ self.assertEqual(d.getSlice(s,1,4),slice(6,10,1))
+ self.assertEqual(d.getSlice(s,2,4),slice(10,14,1))
+ self.assertEqual(d.getSlice(s,3,4),slice(14,18,1))
+ #
+ d=DataArrayInt.Range(0,18,1)
+ s=slice(2,-2,1)
+ self.assertEqual(d.getSlice(s,0,4),slice(2,5,1))
+ self.assertEqual(d.getSlice(s,1,4),slice(5,8,1))
+ self.assertEqual(d.getSlice(s,2,4),slice(8,11,1))
+ self.assertEqual(d.getSlice(s,3,4),slice(11,16,1))
+ #
+ d=DataArrayInt.Range(0,18,1)
+ s=slice(None,None,1)
+ self.assertEqual(d.getSlice(s,0,4),slice(0,4,1))
+ self.assertEqual(d.getSlice(s,1,4),slice(4,8,1))
+ self.assertEqual(d.getSlice(s,2,4),slice(8,12,1))
+ self.assertEqual(d.getSlice(s,3,4),slice(12,18,1))
+ #
+ d=DataArrayInt.Range(0,18,1)
+ s=slice(None,2,-2)
+ self.assertRaises(InterpKernelException,d.getNumberOfItemGivenBES,s)
+ self.assertEqual(d.getNumberOfItemGivenBESRelative(s),8)
+ self.assertEqual(d.getSlice(s,0,4),slice(17,13,-2))
+ self.assertEqual(d.getSlice(s,1,4),slice(13,9,-2))
+ self.assertEqual(d.getSlice(s,2,4),slice(9,5,-2))
+ self.assertEqual(d.getSlice(s,3,4),slice(5,2,-2))
+ pass
+
+ def testSwig2AccumulatePerChunk1(self):
+ arr=DataArrayDouble(11) ; arr.iota()
+ m=MEDCouplingCMesh() ; m.setCoords(arr,arr)
+ m=m.buildUnstructured()
+ m0=m[::2] ; ids0=m0.simplexize(0) ; m1=m[1::2]
+ m=MEDCouplingUMesh.MergeUMeshesOnSameCoords(m0,m1) ; m.setName("mesh")
+ m.checkConsecutiveCellTypesForMEDFileFrmt()
+ #
+ formula="7-sqrt((x-5.)*(x-5.)+(y-5.)*(y-5.))"
+ f=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f.setMesh(m)
+ f.fillFromAnalytic(1,formula)
+ f.setName("Field1") ; f.setTime(1.1,1,-1)
+ f.checkCoherency()
+ #
+ arr=f.getArray()
+ arr2=DataArrayDouble(len(arr),2) ; arr2[:,0]=arr
+ arr2=DataArrayDouble(len(arr),2) ; arr2[:,0]=arr ; arr2[:,1]=2*arr
+ f.setArray(arr2)
+ f.checkCoherency()
+ # here the compact code to obviously put field on cell to nodes
+ rn,rni=f.getMesh().getReverseNodalConnectivity()
+ arr2=f.getArray()[rn]
+ arr4=arr2.accumulatePerChunck(rni)
+ nbOfCellsSharingNodes=rni.deltaShiftIndex()
+ arr4/=nbOfCellsSharingNodes.convertToDblArr()
+ #
+ maxNbCSN=nbOfCellsSharingNodes.getMaxValue()[0]
+ arr3=DataArrayDouble(f.getMesh().getNumberOfNodes(),f.getArray().getNumberOfComponents()) ; arr3[:]=0.
+ for i in xrange(1,maxNbCSN+1):
+ ids=nbOfCellsSharingNodes.getIdsEqual(i)
+ if len(ids)==0:
+ continue
+ for j in range(i):
+ rni2=rni[ids] ; rni2+=j
+ arr3[ids]+=arr2[rni2]
+ pass
+ arr3[ids]/=i
+ pass
+ fNode=MEDCouplingFieldDouble(ON_NODES,ONE_TIME) ; fNode.setMesh(m)
+ fNode.setName("Field1Node") ; fNode.setTime(1.1,1,-1)
+ fNode.setArray(arr3) ; fNode.checkCoherency()
+ self.assertTrue(arr3.isEqual(arr4,1e-12))
+ #
+ d=DataArrayInt.Range(0,20,1)
+ self.assertTrue(d.accumulatePerChunck([2,4,12]).isEqual(DataArrayInt([5,60])))
+ #
+ a=DataArrayDouble(12) ; a.iota() ; a.rearrange(3)
+ b=DataArrayDouble(12) ; b.iota(20) ; b.rearrange(3)
+ ids=DataArrayInt([])
+ self.assertEqual(len(a[ids]),0)
+ self.assertEqual(len(b[ids]),0)
+ a2=a.deepCpy() ; a2[ids]+=b[ids] ; self.assertTrue(a2.isEqual(a,1e-15))
+ a2=a.deepCpy() ; a2[ids]*=b[ids] ; self.assertTrue(a2.isEqual(a,1e-15))
+ a2=a.deepCpy() ; a2[ids]/=b[ids] ; self.assertTrue(a2.isEqual(a,1e-15))
+ a2=a.deepCpy() ; a2[ids]-=b[ids] ; self.assertTrue(a2.isEqual(a,1e-15))
+ pass
+
def setUp(self):
pass
pass
$result=convertMultiFields($1,$owner);
}
+%typemap(out) ParaMEDMEM::DataArray*
+{
+ $result=convertDataArray($1,$owner);
+}
+
%typemap(out) ParaMEDMEM::DataArrayChar*
{
$result=convertDataArrayChar($1,$owner);
%feature("autodoc", "1");
%feature("docstring");
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::New;
%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr;
%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::deepCpy;
%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clone;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti;
%newobject ParaMEDMEM::MEDCouplingFieldTemplate::New;
+%newobject ParaMEDMEM::DataArray::selectByTupleRanges;
%newobject ParaMEDMEM::DataArrayInt::New;
%newobject ParaMEDMEM::DataArrayInt::__iter__;
%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
%newobject ParaMEDMEM::DataArrayInt::performCpy;
%newobject ParaMEDMEM::DataArrayInt::substr;
%newobject ParaMEDMEM::DataArrayInt::changeNbOfComponents;
-%newobject ParaMEDMEM::DataArrayInt::keepSelectedComponents;
+%newobject ParaMEDMEM::DataArrayInt::accumulatePerChunck;
%newobject ParaMEDMEM::DataArrayInt::selectByTupleId;
%newobject ParaMEDMEM::DataArrayInt::selectByTupleIdSafe;
%newobject ParaMEDMEM::DataArrayInt::selectByTupleId2;
-%newobject ParaMEDMEM::DataArrayInt::selectByTupleRanges;
%newobject ParaMEDMEM::DataArrayInt::checkAndPreparePermutation;
%newobject ParaMEDMEM::DataArrayInt::transformWithIndArrR;
%newobject ParaMEDMEM::DataArrayInt::renumber;
%newobject ParaMEDMEM::DataArrayInt::__pow__;
%newobject ParaMEDMEM::DataArrayInt::__rpow__;
%newobject ParaMEDMEM::DataArrayIntTuple::buildDAInt;
+%newobject ParaMEDMEM::DataArrayChar::deepCpy;
%newobject ParaMEDMEM::DataArrayChar::convertToIntArr;
%newobject ParaMEDMEM::DataArrayChar::renumber;
%newobject ParaMEDMEM::DataArrayChar::renumberR;
%newobject ParaMEDMEM::DataArrayChar::selectByTupleIdSafe;
%newobject ParaMEDMEM::DataArrayChar::selectByTupleId2;
%newobject ParaMEDMEM::DataArrayChar::changeNbOfComponents;
-%newobject ParaMEDMEM::DataArrayChar::keepSelectedComponents;
%newobject ParaMEDMEM::DataArrayChar::getIdsEqual;
%newobject ParaMEDMEM::DataArrayChar::getIdsNotEqual;
%newobject ParaMEDMEM::DataArrayChar::Aggregate;
%newobject ParaMEDMEM::DataArrayChar::Meld;
%newobject ParaMEDMEM::DataArrayByte::New;
%newobject ParaMEDMEM::DataArrayByte::__iter__;
-%newobject ParaMEDMEM::DataArrayByte::deepCpy;
%newobject ParaMEDMEM::DataArrayByte::performCpy;
%newobject ParaMEDMEM::DataArrayByteTuple::buildDAByte;
%newobject ParaMEDMEM::DataArrayChar::substr;
%newobject ParaMEDMEM::DataArrayAsciiChar::New;
%newobject ParaMEDMEM::DataArrayAsciiChar::__iter__;
-%newobject ParaMEDMEM::DataArrayAsciiChar::deepCpy;
%newobject ParaMEDMEM::DataArrayAsciiChar::performCpy;
%newobject ParaMEDMEM::DataArrayAsciiCharTuple::buildDAAsciiChar;
%newobject ParaMEDMEM::DataArrayDouble::New;
%newobject ParaMEDMEM::DataArrayDouble::Pow;
%newobject ParaMEDMEM::DataArrayDouble::substr;
%newobject ParaMEDMEM::DataArrayDouble::changeNbOfComponents;
-%newobject ParaMEDMEM::DataArrayDouble::keepSelectedComponents;
+%newobject ParaMEDMEM::DataArrayDouble::accumulatePerChunck;
%newobject ParaMEDMEM::DataArrayDouble::getIdsInRange;
%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId;
%newobject ParaMEDMEM::DataArrayDouble::selectByTupleIdSafe;
%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId2;
-%newobject ParaMEDMEM::DataArrayDouble::selectByTupleRanges;
%newobject ParaMEDMEM::DataArrayDouble::negate;
%newobject ParaMEDMEM::DataArrayDouble::applyFunc;
%newobject ParaMEDMEM::DataArrayDouble::applyFunc2;
%newobject ParaMEDMEM::MEDCouplingMesh::checkDeepEquivalOnSameNodesWith;
%newobject ParaMEDMEM::MEDCouplingMesh::checkTypeConsistencyAndContig;
%newobject ParaMEDMEM::MEDCouplingMesh::computeNbOfNodesPerCell;
+%newobject ParaMEDMEM::MEDCouplingMesh::computeNbOfFacesPerCell;
%newobject ParaMEDMEM::MEDCouplingMesh::buildPartRange;
%newobject ParaMEDMEM::MEDCouplingMesh::giveCellsWithType;
%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
%newobject ParaMEDMEM::MEDCouplingUMesh::sortCellsInMEDFileFrmt;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForMEDFileFrmt;
%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType;
%newobject ParaMEDMEM::MEDCouplingUMesh::computeFetchedNodeIds;
%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec;
%feature("unref") MEDCouplingExtrudedMesh "$this->decrRef();"
%feature("unref") MEDCouplingCMesh "$this->decrRef();"
%feature("unref") DataArrayInt "$this->decrRef();"
+%feature("unref") DataArrayChar "$this->decrRef();"
%feature("unref") DataArrayAsciiChar "$this->decrRef();"
%feature("unref") DataArrayByte "$this->decrRef();"
%feature("unref") MEDCouplingField "$this->decrRef();"
%inline
{
- bool MEDCouplingHasNumpyBindings()
+ bool MEDCouplingHasNumPyBindings()
{
#ifdef WITH_NUMPY
return true;
return false;
#endif
}
+
+ std::string MEDCouplingCompletionScript() throw(INTERP_KERNEL::Exception)
+ {
+ static const char script[]="import rlcompleter,readline\nreadline.parse_and_bind('tab:complete')";
+ std::ostringstream oss; oss << "MEDCouplingCompletionScript : error when trying to activate completion ! readline not present ?\nScript is :\n" << script;
+ if(PyRun_SimpleString(script)!=0)
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ return std::string(script);
+ }
}
%include "MEDCouplingMemArray.i"
virtual DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
virtual DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
virtual DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
virtual MEDCouplingMesh *buildPartRange(int beginCellIds, int endCellIds, int stepCellIds) const throw(INTERP_KERNEL::Exception);
virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception);
virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ static bool IsStaticGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
+ static bool IsLinearGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
+ static INTERP_KERNEL::NormalizedCellType GetCorrespondingPolyType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
+ static int GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
static int GetDimensionOfGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
static const char *GetReprOfGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
%extend
if (!SWIG_IsOK(res1))
{
int size;
- INTERP_KERNEL::AutoPtr<double> tmp=convertPyToNewDblArr2(p,&size);
+ INTERP_KERNEL::AutoCPtr<double> tmp=convertPyToNewDblArr2(p,&size);
int nbOfPoints=size/spaceDim;
if(size%spaceDim!=0)
{
void rotate(PyObject *center, PyObject *vector, double alpha) throw(INTERP_KERNEL::Exception)
{
const char msg[]="Python wrap of MEDCouplingPointSet::rotate : ";
- double val;
- DataArrayDouble *a;
- DataArrayDoubleTuple *aa;
- std::vector<double> bb;
+ double val,val2;
+ DataArrayDouble *a,*a2;
+ DataArrayDoubleTuple *aa,*aa2;
+ std::vector<double> bb,bb2;
int sw;
int spaceDim=self->getSpaceDimension();
const double *centerPtr=convertObjToPossibleCpp5_Safe(center,sw,val,a,aa,bb,msg,1,spaceDim,true);
- const double *vectorPtr=convertObjToPossibleCpp5_Safe(vector,sw,val,a,aa,bb,msg,1,spaceDim,false);
+ const double *vectorPtr=convertObjToPossibleCpp5_Safe(vector,sw,val2,a2,aa2,bb2,msg,1,spaceDim,false);//vectorPtr can be null in case of space dim 2
self->rotate(centerPtr,vectorPtr,alpha);
}
static void Rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
{
int sz;
- INTERP_KERNEL::AutoPtr<double> c=convertPyToNewDblArr2(center,&sz);
- INTERP_KERNEL::AutoPtr<double> coo=convertPyToNewDblArr2(coords,&sz);
+ INTERP_KERNEL::AutoCPtr<double> c=convertPyToNewDblArr2(center,&sz);
+ INTERP_KERNEL::AutoCPtr<double> coo=convertPyToNewDblArr2(coords,&sz);
ParaMEDMEM::MEDCouplingPointSet::Rotate2DAlg(c,angle,nbNodes,coo);
for(int i=0;i<sz;i++)
PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
static void Rotate2DAlg(PyObject *center, double angle, PyObject *coords) throw(INTERP_KERNEL::Exception)
{
int sz;
- INTERP_KERNEL::AutoPtr<double> c=convertPyToNewDblArr2(center,&sz);
+ INTERP_KERNEL::AutoCPtr<double> c=convertPyToNewDblArr2(center,&sz);
int sw,nbNodes=0;
double val0; ParaMEDMEM::DataArrayDouble *val1=0; ParaMEDMEM::DataArrayDoubleTuple *val2=0;
std::vector<double> val3;
static void Rotate3DAlg(PyObject *center, PyObject *vect, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
{
int sz,sz2;
- INTERP_KERNEL::AutoPtr<double> c=convertPyToNewDblArr2(center,&sz);
- INTERP_KERNEL::AutoPtr<double> coo=convertPyToNewDblArr2(coords,&sz);
- INTERP_KERNEL::AutoPtr<double> v=convertPyToNewDblArr2(vect,&sz2);
+ INTERP_KERNEL::AutoCPtr<double> c=convertPyToNewDblArr2(center,&sz);
+ INTERP_KERNEL::AutoCPtr<double> coo=convertPyToNewDblArr2(coords,&sz);
+ INTERP_KERNEL::AutoCPtr<double> v=convertPyToNewDblArr2(vect,&sz2);
ParaMEDMEM::MEDCouplingPointSet::Rotate3DAlg(c,v,angle,nbNodes,coo);
for(int i=0;i<sz;i++)
PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
static void Rotate3DAlg(PyObject *center, PyObject *vect, double angle, PyObject *coords) throw(INTERP_KERNEL::Exception)
{
int sz,sz2;
- INTERP_KERNEL::AutoPtr<double> c=convertPyToNewDblArr2(center,&sz);
+ INTERP_KERNEL::AutoCPtr<double> c=convertPyToNewDblArr2(center,&sz);
int sw,nbNodes=0;
double val0; ParaMEDMEM::DataArrayDouble *val1=0; ParaMEDMEM::DataArrayDoubleTuple *val2=0;
std::vector<double> val3;
"Rotate3DAlg",3,true,nbNodes);
if(sw!=2 && sw!=3)
throw INTERP_KERNEL::Exception("Invalid call to MEDCouplingPointSet::Rotate3DAlg : try another overload method !");
- INTERP_KERNEL::AutoPtr<double> v=convertPyToNewDblArr2(vect,&sz2);
+ INTERP_KERNEL::AutoCPtr<double> v=convertPyToNewDblArr2(vect,&sz2);
ParaMEDMEM::MEDCouplingPointSet::Rotate3DAlg(c,v,angle,nbNodes,const_cast<double *>(coo));
}
}
bool checkConsecutiveCellTypesForMEDFileFrmt() const throw(INTERP_KERNEL::Exception);
DataArrayInt *rearrange2ConsecutiveCellTypes() throw(INTERP_KERNEL::Exception);
DataArrayInt *sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getRenumArrForMEDFileFrmt() const throw(INTERP_KERNEL::Exception);
DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
DataArrayInt *computeFetchedNodeIds() const throw(INTERP_KERNEL::Exception);
DataArrayInt *zipConnectivityTraducer(int compType, int startCellId=0) throw(INTERP_KERNEL::Exception);
int nbOfCompo=self->getSpaceDimension();
const double *pt=convertObjToPossibleCpp5_Safe(point,sw,val,a,aa,bb,"Python wrap of MEDCouplingUMesh::distanceToPoint",1,nbOfCompo,true);
//
- int cellId=-1,nodeId=-1;
- double ret0=self->distanceToPoint(pt,pt+nbOfCompo,cellId,nodeId);
- PyObject *ret=PyTuple_New(3);
+ int cellId=-1;
+ double ret0=self->distanceToPoint(pt,pt+nbOfCompo,cellId);
+ PyObject *ret=PyTuple_New(2);
PyTuple_SetItem(ret,0,PyFloat_FromDouble(ret0));
PyTuple_SetItem(ret,1,PyInt_FromLong(cellId));
- PyTuple_SetItem(ret,2,PyInt_FromLong(nodeId));
+ return ret;
+ }
+
+ PyObject *distanceToPoints(const DataArrayDouble *pts) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ DataArrayDouble *ret0=self->distanceToPoints(pts,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
if (!SWIG_IsOK(res1))
{
int size;
- INTERP_KERNEL::AutoPtr<double> tmp=convertPyToNewDblArr2(li,&size);
+ INTERP_KERNEL::AutoCPtr<double> tmp=convertPyToNewDblArr2(li,&size);
const MEDCouplingMesh *mesh=self->getMesh();
if(!mesh)
throw INTERP_KERNEL::Exception("Python wrap MEDCouplingFieldDouble::getValueOnMulti : lying on a null mesh !");
return convertDblArrToPyList(res,sz);
}
- void setValues(PyObject *li) throw(INTERP_KERNEL::Exception)
+ void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception)
{
if(self->getArray()!=0)
+ ParaMEDMEM_DataArrayDouble_setValues__SWIG_0(self->getArray(),li,nbOfTuples,nbOfComp);
+ else
{
- int sz;
- double *tmp=convertPyToNewDblArr2(li,&sz);
- int nbTuples=self->getArray()->getNumberOfTuples();
- int nbOfCompo=self->getArray()->getNumberOfComponents();
- self->getArray()->useArray(tmp,true,CPP_DEALLOC,nbTuples,nbOfCompo);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New();
+ ParaMEDMEM_DataArrayDouble_setValues__SWIG_0(arr,li,nbOfTuples,nbOfComp);
+ self->setArray(arr);
}
- else
- throw INTERP_KERNEL::Exception("setValuesCpy : field must contain an array behind");
}
PyObject *getTime() throw(INTERP_KERNEL::Exception)
case 1:
{
std::vector<int> v2(1,singleVal);
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> aarr=ret0Arr->keepSelectedComponents(v2);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> aarr=static_cast<DataArrayDouble *>(ret0Arr->keepSelectedComponents(v2));
ret0->setArray(aarr);
return ret0.retn();
}
case 2:
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> aarr=ret0Arr->keepSelectedComponents(multiVal);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> aarr=static_cast<DataArrayDouble *>(ret0Arr->keepSelectedComponents(multiVal));
ret0->setArray(aarr);
return ret0.retn();
}
std::vector<int> v2(nbOfComp);
for(int i=0;i<nbOfComp;i++)
v2[i]=slic.first+i*slic.second.second;
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> aarr=ret0Arr->keepSelectedComponents(v2);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> aarr=static_cast<DataArrayDouble *>(ret0Arr->keepSelectedComponents(v2));
ret0->setArray(aarr);
return ret0.retn();
}
#! [PySnippet_MEDCouplingFieldDouble_getValueOnMulti_1]
#! [PySnippet_MEDCouplingFieldDouble_getValueOnMulti_2]
bc = mesh.getBarycenterAndOwner() # field values are located at cell barycenters
- valArray = field.getValueOnMulti( bc.getValues() )
+ valArray = field.getValueOnMulti( bc )
self.assertTrue( valArray.isEqual( field.getArray(), 1e-13 ))
#! [PySnippet_MEDCouplingFieldDouble_getValueOnMulti_2]
return
#! [PySnippet_MEDCouplingFieldDouble_getValueOn_2]
bc = mesh.getBarycenterAndOwner() # field values are located at cell barycenters
vals = [] # array to collect values returned by getValueOn()
- for i in range( bc.getNumberOfTuples() ):
- vals.extend( field.getValueOn( bc.getTuple( i )))
+ for i,tupl in enumerate( bc ):
+ vals.extend( field.getValueOn( tupl ) )
self.assertTrue( vals == field.getArray().getValues() )
#! [PySnippet_MEDCouplingFieldDouble_getValueOn_2]
return
#! [PySnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_1]
#! [PySnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_2]
fixedCells = mesh.findAndCorrectBadOriented3DExtrudedCells()
- assert len( fixedCells.getValues() ) == 2 # 2 cells fixed
+ assert len( fixedCells ) == 2 # 2 cells fixed
fixedCells = mesh.findAndCorrectBadOriented3DExtrudedCells()
- assert len( fixedCells.getValues() ) == 0 # no bad cells
+ assert len( fixedCells ) == 0 # no bad cells
#! [PySnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_2]
return
#! [PySnippet_MEDCouplingUMesh_arePolyhedronsNotCorrectlyOriented_1]
#! [PySnippet_MEDCouplingUMesh_arePolyhedronsNotCorrectlyOriented_2]
badCells = mesh.arePolyhedronsNotCorrectlyOriented()
- assert len( badCells.getValues() ) == 1 # one polyhedron is KO
+ assert len( badCells ) == 1 # one polyhedron is KO
# fix invalid rolyherdons
mesh.orientCorrectlyPolyhedrons()
# re-check the orientation
badCells = mesh.arePolyhedronsNotCorrectlyOriented()
- assert len( badCells.getValues() ) == 0 # connectivity is OK
+ assert len( badCells ) == 0 # connectivity is OK
#! [PySnippet_MEDCouplingUMesh_arePolyhedronsNotCorrectlyOriented_2]
return
#! [PySnippet_MEDCouplingPointSet_rotate_3]
#! [PySnippet_MEDCouplingPointSet_rotate_4]
mesh.changeSpaceDimension(2)
- coords2 = mesh.getCoords().getValues()
+ coords2 = mesh.getCoords()
for i,c in enumerate( coords ):
- self.assertAlmostEqual( c, coords2[i], 13 )
+ self.assertAlmostEqual( c, coords2.getIJ(0,i), 13 )
#! [PySnippet_MEDCouplingPointSet_rotate_4]
return
for i in xrange(8):#8 is not an error
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12)
pass
- self.assertEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:])
- self.assertEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4])
- self.assertEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues()))
+ self.assertEqual(expected3[:4],[int(i) for i in m2C.getNodalConnectivity()][4:])
+ self.assertEqual(expected3[4:8],[int(i) for i in m2C.getNodalConnectivity()][:4])
+ self.assertEqual(expected4[:3],[int(i) for i in m2C.getNodalConnectivityIndex()])
#idem previous because nodes of cell#4 are not fully present in part3
part3=[1,2]
arrr=DataArrayInt.New()
for i in xrange(8):#8 is not an error
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12)
pass
- self.assertEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:8])
- self.assertEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4])
- self.assertEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues()))
+ self.assertEqual(expected3[:4],[int(i) for i in m2C.getNodalConnectivity()][4:8])
+ self.assertEqual(expected3[4:8],[int(i) for i in m2C.getNodalConnectivity()][:4])
+ self.assertEqual(expected4[:3],m2C.getNodalConnectivityIndex().getValues())
part4=[1,2,4]
f2=f1.buildSubPart(part4)
self.assertEqual(6,f2.getNumberOfTuples())
for i in xrange(12):
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12)
pass
- self.assertEqual(expected3[0:4],list(m2C.getNodalConnectivity().getValues())[4:8])
- self.assertEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[0:4])
- self.assertEqual(expected3[8:13],list(m2C.getNodalConnectivity().getValues())[8:13])
- self.assertEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues()))
+ self.assertEqual(expected3[0:4],m2C.getNodalConnectivity().getValues()[4:8])
+ self.assertEqual(expected3[4:8],m2C.getNodalConnectivity().getValues()[0:4])
+ self.assertEqual(expected3[8:13],m2C.getNodalConnectivity().getValues()[8:13])
+ self.assertEqual(expected4,m2C.getNodalConnectivityIndex().getValues())
+ # previous line equivalent to
+ self.assertEqual(expected4,[int(i) for i in m2C.getNodalConnectivityIndex()])
return
def testExampleUMeshStdBuild1(self):
std::string cppRepr(const char *varName) const throw(INTERP_KERNEL::Exception);
std::string getName() const;
void setInfoOnComponents(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
+ void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
std::vector<std::string> getVarsOnComponent() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getUnitsOnComponent() const throw(INTERP_KERNEL::Exception);
std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
std::string getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception);
void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
int getNumberOfComponents() const;
+ virtual void alloc(int nbOfTuple, int nbOfCompo=1) throw(INTERP_KERNEL::Exception);
+ virtual bool isAllocated() const throw(INTERP_KERNEL::Exception);
+ virtual void checkAllocated() const throw(INTERP_KERNEL::Exception);
virtual int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
virtual std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception);
virtual std::size_t getNbOfElemAllocated() const throw(INTERP_KERNEL::Exception);
convertPyToNewIntArr3(li,tmp);
self->copyPartOfStringInfoFrom2(tmp,other);
}
+
+ virtual void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(da2->getConstPointer());
+ }
+ }
+
+ virtual void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(da2->getConstPointer());
+ }
+ }
+
+ //tuplesSelec in PyObject * because DataArrayInt is not already existing !
+ virtual void setContigPartOfSelectedValues(int tupleIdStart, PyObject *aBase, PyObject *tuplesSelec) throw(INTERP_KERNEL::Exception)
+ {
+ static const char msg[]="DataArray::setContigPartOfSelectedValues2 : 4th parameter \"tuplesSelec\" should be of type DataArrayInt";
+ DataArray *a=CheckAndRetrieveDataArrayInstance(aBase,"DataArray::setContigPartOfSelectedValues2 : 3rd parameter \"aBase\" should be of type DataArray");
+ DataArray *tuplesSelecPtr=CheckAndRetrieveDataArrayInstance(tuplesSelec,msg);
+ DataArrayInt *tuplesSelecPtr2=0;
+ if(tuplesSelecPtr)
+ {
+ tuplesSelecPtr2=dynamic_cast<DataArrayInt *>(tuplesSelecPtr);
+ if(!tuplesSelecPtr2)
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ self->setContigPartOfSelectedValues(tupleIdStart,a,tuplesSelecPtr2);
+ }
+
+ virtual void setContigPartOfSelectedValues2(int tupleIdStart, PyObject *aBase, int bg, int end2, int step) throw(INTERP_KERNEL::Exception)
+ {
+ DataArray *a=CheckAndRetrieveDataArrayInstance(aBase,"DataArray::setContigPartOfSelectedValues2 : 2nd parameter \"aBase\" should be of type DataArray");
+ self->setContigPartOfSelectedValues2(tupleIdStart,a,bg,end2,step);
+ }
+
+ virtual DataArray *selectByTupleRanges(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<std::pair<int,int> > ranges;
+ convertPyToVectorPairInt(li,ranges);
+ return self->selectByTupleRanges(ranges);
+ }
+
+ virtual PyObject *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ DataArray *ret=self->keepSelectedComponents(tmp);
+ return convertDataArray(ret,SWIG_POINTER_OWN | 0 );
+ }
+
+ static PyObject *GetSlice(PyObject *slic, int sliceId, int nbOfSlices) throw(INTERP_KERNEL::Exception)
+ {
+ if(!PySlice_Check(slic))
+ 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 !");
+ int a,b;
+ DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
+ return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
+ }
+
+ PyObject *getSlice(PyObject *slic, int sliceId, int nbOfSlices) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!PySlice_Check(slic))
+ 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 !");
+ int a,b;
+ DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
+ return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
+ }
+
+ static int GetNumberOfItemGivenBES(PyObject *slic) throw(INTERP_KERNEL::Exception)
+ {
+ if(!PySlice_Check(slic))
+ 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 !");
+ return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
+ }
+
+ static int GetNumberOfItemGivenBESRelative(PyObject *slic) throw(INTERP_KERNEL::Exception)
+ {
+ if(!PySlice_Check(slic))
+ 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 !");
+ return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
+ }
+
+ int getNumberOfItemGivenBES(PyObject *slic) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!PySlice_Check(slic))
+ 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 !");
+ return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
+ }
+
+ int getNumberOfItemGivenBESRelative(PyObject *slic) throw(INTERP_KERNEL::Exception)
+ {
+ if(!PySlice_Check(slic))
+ 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 !");
+ return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
+ }
}
};
{
public:
static DataArrayDouble *New();
- bool isAllocated() const throw(INTERP_KERNEL::Exception);
- void checkAllocated() const throw(INTERP_KERNEL::Exception);
- void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
double doubleValue() const throw(INTERP_KERNEL::Exception);
bool empty() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *deepCpy() const throw(INTERP_KERNEL::Exception);
void pushBackValsSilent(const double *valsBg, const double *valsEnd) throw(INTERP_KERNEL::Exception);
double popBackSilent() throw(INTERP_KERNEL::Exception);
void pack() const throw(INTERP_KERNEL::Exception);
- void alloc(int nbOfTuple, int nbOfCompo=1) throw(INTERP_KERNEL::Exception);
void allocIfNecessary(int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception);
void fillWithZero() throw(INTERP_KERNEL::Exception);
void fillWithValue(double val) throw(INTERP_KERNEL::Exception);
void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
- void setContigPartOfSelectedValues(int tupleIdStart, const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
- void setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayDouble *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
double getIJ(int tupleId, int compoId) const;
double back() const throw(INTERP_KERNEL::Exception);
double getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
double getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
double getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
double getMinValueInArray() const throw(INTERP_KERNEL::Exception);
+ int count(double value, double eps) const throw(INTERP_KERNEL::Exception);
double getAverageValue() const throw(INTERP_KERNEL::Exception);
double norm2() const throw(INTERP_KERNEL::Exception);
double normMax() const throw(INTERP_KERNEL::Exception);
- void accumulate(double *res) const throw(INTERP_KERNEL::Exception);
double accumulate(int compId) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *fromPolarToCart() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *fromCylToCart() const throw(INTERP_KERNEL::Exception);
static DataArrayDouble *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) throw(INTERP_KERNEL::Exception)
{
- const char *msg="ParaMEDMEM::DataArrayDouble::New : Available API are : \n-DataArrayDouble.New()\n-DataArrayDouble.New([1.,3.,4.])\n-DataArrayDouble.New([1.,3.,4.],3)\n-DataArrayDouble.New([1.,3.,4.,5.],2,2)\n-DataArrayDouble.New([1.,3.,4.,5.,7,8.],3,2)\n-DataArrayDouble.New(5)\n-DataArrayDouble.New(5,2) !";
+ const char *msgBase="ParaMEDMEM::DataArrayDouble::New : Available API are : \n-DataArrayDouble.New()\n-DataArrayDouble.New([1.,3.,4.])\n-DataArrayDouble.New([1.,3.,4.],3)\n-DataArrayDouble.New([1.,3.,4.,5.],2,2)\n-DataArrayDouble.New([1.,3.,4.,5.,7,8.],3,2)\n-DataArrayDouble.New([(1.,3.),(4.,5.),(7,8.)])\n-DataArrayDouble.New(5)\n-DataArrayDouble.New(5,2)";
+ std::string msg(msgBase);
+#ifdef WITH_NUMPY
+ msg+="\n-DataArrayDouble.New(numpy array with dtype=float64)";
+#endif
+ msg+=" !";
if(PyList_Check(elt0) || PyTuple_Check(elt0))
{
if(nbOfTuples)
return ret.retn();
}
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
else
{//DataArrayDouble.New([1.,3.,4.],3)
}
}
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
else
{// DataArrayDouble.New([1.,3.,4.])
return ret.retn();
}
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
else
{//DataArrayDouble.New(5)
}
}
#ifdef WITH_NUMPY
- else if(PyArray_Check(elt0))
+ else if(PyArray_Check(elt0) && nbOfTuples==NULL && elt2==NULL)
{//DataArrayDouble.New(numpyArray)
return BuildNewInstance<DataArrayDouble,double>(elt0,NPY_DOUBLE,&PyCallBackDataArrayDouble_RefType,"FLOAT64");
}
#endif
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
DataArrayDouble(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *elt2=0) throw(INTERP_KERNEL::Exception)
}
}
- void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- void *da=0;
- int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
- if (!SWIG_IsOK(res1))
- {
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlace(tmp);
- }
- else
- {
- DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
- if(!da2)
- throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
- da2->checkAllocated();
- int size=self->getNumberOfTuples();
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlace(da2->getConstPointer());
- }
- }
-
- void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- void *da=0;
- int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
- if (!SWIG_IsOK(res1))
- {
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlaceR(tmp);
- }
- else
- {
- DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
- if(!da2)
- throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
- da2->checkAllocated();
- int size=self->getNumberOfTuples();
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlaceR(da2->getConstPointer());
- }
- }
-
DataArrayDouble *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
void *da=0;
self->accumulate(tmp);
return convertDblArrToPyList(tmp,sz);
}
-
- DataArrayDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+
+ DataArrayDouble *accumulatePerChunck(PyObject *indexArr) const throw(INTERP_KERNEL::Exception)
{
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
+ int sw,sz,val;
+ std::vector<int> val2;
+ const int *bg=convertObjToPossibleCpp1_Safe(indexArr,sw,sz,val,val2);
+ return self->accumulatePerChunck(bg,bg+sz);
}
PyObject *findCommonTuples(double prec, int limitNodeId=-1) const throw(INTERP_KERNEL::Exception)
return DataArrayDouble::Meld(tmp);
}
- DataArrayDouble *selectByTupleRanges(PyObject *li) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<std::pair<int,int> > ranges;
- convertPyToVectorPairInt(li,ranges);
- return self->selectByTupleRanges(ranges);
- }
-
PyObject *computeTupleIdsNearTuples(PyObject *pt, double eps) const throw(INTERP_KERNEL::Exception)
{
double val;
PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(cI),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
+
+ PyObject *maxPerTupleWithCompoId() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ DataArrayDouble *ret0=self->maxPerTupleWithCompoId(ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
}
};
{
public:
static DataArrayInt *New();
- bool isAllocated() const throw(INTERP_KERNEL::Exception);
- void checkAllocated() const throw(INTERP_KERNEL::Exception);
- void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
int intValue() const throw(INTERP_KERNEL::Exception);
int getHashCode() const throw(INTERP_KERNEL::Exception);
bool empty() const throw(INTERP_KERNEL::Exception);
void pushBackSilent(int val) throw(INTERP_KERNEL::Exception);
int popBackSilent() throw(INTERP_KERNEL::Exception);
void pack() const throw(INTERP_KERNEL::Exception);
- void alloc(int nbOfTuple, int nbOfCompo=1) throw(INTERP_KERNEL::Exception);
void allocIfNecessary(int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception);
bool isEqual(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
void setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
void setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
void setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
- void setContigPartOfSelectedValues(int tupleIdStart, const DataArrayInt*a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
- void setContigPartOfSelectedValues2(int tupleIdStart, const DataArrayInt *a, int bg, int end2, int step) throw(INTERP_KERNEL::Exception);
void getTuple(int tupleId, int *res) const throw(INTERP_KERNEL::Exception);
int getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
int getIJSafe(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
bool presenceOfTuple(const std::vector<int>& tupl) const throw(INTERP_KERNEL::Exception);
bool presenceOfValue(int value) const throw(INTERP_KERNEL::Exception);
bool presenceOfValue(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
- void accumulate(int *res) const throw(INTERP_KERNEL::Exception);
+ int count(int value) const throw(INTERP_KERNEL::Exception);
int accumulate(int compId) const throw(INTERP_KERNEL::Exception);
int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
int getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
static DataArrayInt *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception)
{
- const char *msg="ParaMEDMEM::DataArrayInt::New : Available API are : \n-DataArrayInt.New()\n-DataArrayInt.New([1,3,4])\n-DataArrayInt.New([1,3,4],3)\n-DataArrayInt.New([1,3,4,5],2,2)\n-DataArrayInt.New([1,3,4,5,7,8],3,2)\n-DataArrayInt.New(5)\n-DataArrayInt.New(5,2) !";
+ const char *msgBase="ParaMEDMEM::DataArrayInt::New : Available API are : \n-DataArrayInt.New()\n-DataArrayInt.New([1,3,4])\n-DataArrayInt.New([1,3,4],3)\n-DataArrayInt.New([1,3,4,5],2,2)\n-DataArrayInt.New([1,3,4,5,7,8],3,2)\n-DataArrayInt.New([(1,3),(4,5),(7,8)])\n-DataArrayInt.New(5)\n-DataArrayInt.New(5,2)";
+ std::string msg(msgBase);
+#ifdef WITH_NUMPY
+ msg+="\n-DataArrayInt.New(numpy array with dtype=int32)";
+#endif
+ msg+=" !";
if(PyList_Check(elt0) || PyTuple_Check(elt0))
{
if(nbOfTuples)
return ret.retn();
}
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
else
{//DataArrayInt.New([1,3,4],3)
}
}
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
else
{// DataArrayInt.New([1,3,4])
return ret.retn();
}
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
else
{//DataArrayInt.New(5)
}
}
#ifdef WITH_NUMPY
- else if(PyArray_Check(elt0))
+ else if(PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
{//DataArrayInt.New(numpyArray)
return BuildNewInstance<DataArrayInt,int>(elt0,NPY_INT,&PyCallBackDataArrayInt_RefType,"INT32");
}
#endif
else
- throw INTERP_KERNEL::Exception(msg);
+ throw INTERP_KERNEL::Exception(msg.c_str());
}
DataArrayInt(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception)
self->accumulate(tmp);
return convertIntArrToPyList(tmp,sz);
}
+
+ DataArrayInt *accumulatePerChunck(PyObject *indexArr) const throw(INTERP_KERNEL::Exception)
+ {
+ int sw,sz,val;
+ std::vector<int> val2;
+ const int *bg=convertObjToPossibleCpp1_Safe(indexArr,sw,sz,val,val2);
+ return self->accumulatePerChunck(bg,bg+sz);
+ }
static PyObject *BuildOld2NewArrayFromSurjectiveFormat2(int nbOfOldTuples, PyObject *arr, PyObject *arrI) throw(INTERP_KERNEL::Exception)
{
return ret;
}
- DataArrayInt *transformWithIndArrR(PyObject *li) const
+ DataArrayInt *transformWithIndArrR(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
void *da=0;
int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
}
}
- void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- void *da=0;
- int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
- if (!SWIG_IsOK(res1))
- {
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlace(tmp);
- }
- else
- {
- DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
- if(!da2)
- throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
- da2->checkAllocated();
- int size=self->getNumberOfTuples();
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlace(da2->getConstPointer());
- }
- }
-
- void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- void *da=0;
- int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
- if (!SWIG_IsOK(res1))
- {
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlaceR(tmp);
- }
- else
- {
- DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
- if(!da2)
- throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
- da2->checkAllocated();
- int size=self->getNumberOfTuples();
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlaceR(da2->getConstPointer());
- }
- }
-
DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
{
void *da=0;
}
}
- DataArrayInt *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
- }
-
void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception)
{
std::vector<int> tmp;
return res;
}
- DataArrayInt *selectByTupleRanges(PyObject *li) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<std::pair<int,int> > ranges;
- convertPyToVectorPairInt(li,ranges);
- return self->selectByTupleRanges(ranges);
- }
-
static DataArrayInt *Meld(PyObject *li) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *> tmp;
{
public:
virtual DataArrayChar *buildEmptySpecializedDAChar() const throw(INTERP_KERNEL::Exception) = 0;
- bool isAllocated() const throw(INTERP_KERNEL::Exception);
- void checkAllocated() const throw(INTERP_KERNEL::Exception);
- void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
+ virtual DataArrayChar *deepCpy() const throw(INTERP_KERNEL::Exception);
int getHashCode() const throw(INTERP_KERNEL::Exception);
bool empty() const throw(INTERP_KERNEL::Exception);
void cpyFrom(const DataArrayChar& other) throw(INTERP_KERNEL::Exception);
void pushBackValsSilent(const char *valsBg, const char *valsEnd) throw(INTERP_KERNEL::Exception);
char popBackSilent() throw(INTERP_KERNEL::Exception);
void pack() const throw(INTERP_KERNEL::Exception);
- void alloc(int nbOfTuple, int nbOfCompo=1) throw(INTERP_KERNEL::Exception);
void allocIfNecessary(int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception);
bool isEqual(const DataArrayChar& other) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const DataArrayChar& other) const throw(INTERP_KERNEL::Exception);
std::string reprZip() const throw(INTERP_KERNEL::Exception);
void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception);
DataArrayInt *convertToIntArr() const throw(INTERP_KERNEL::Exception);
- void renumberInPlace(const int *old2New) throw(INTERP_KERNEL::Exception);
- void renumberInPlaceR(const int *new2Old) throw(INTERP_KERNEL::Exception);
DataArrayChar *renumber(const int *old2New) const throw(INTERP_KERNEL::Exception);
DataArrayChar *renumberR(const int *new2Old) const throw(INTERP_KERNEL::Exception);
DataArrayChar *renumberAndReduce(const int *old2NewBg, int newNbOfTuple) const throw(INTERP_KERNEL::Exception);
return ret;
}
- void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- void *da=0;
- int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
- if (!SWIG_IsOK(res1))
- {
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlace(tmp);
- }
- else
- {
- DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
- if(!da2)
- throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
- da2->checkAllocated();
- int size=self->getNumberOfTuples();
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlace(da2->getConstPointer());
- }
- }
-
- void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- void *da=0;
- int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
- if (!SWIG_IsOK(res1))
- {
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlaceR(tmp);
- }
- else
- {
- DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
- if(!da2)
- throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
- da2->checkAllocated();
- int size=self->getNumberOfTuples();
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- }
- self->renumberInPlaceR(da2->getConstPointer());
- }
- }
-
DataArrayChar *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
{
void *da=0;
}
}
- DataArrayChar *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
- }
-
static DataArrayChar *Aggregate(PyObject *dachs) throw(INTERP_KERNEL::Exception)
{
std::vector<const ParaMEDMEM::DataArrayChar *> tmp;
static DataArrayByte *New();
DataArrayChar *buildEmptySpecializedDAChar() const throw(INTERP_KERNEL::Exception);
DataArrayByteIterator *iterator();
- DataArrayByte *deepCpy() const;
DataArrayByte *performCpy(bool deepCpy) const;
char byteValue() const throw(INTERP_KERNEL::Exception);
%extend
static DataArrayAsciiChar *New();
DataArrayChar *buildEmptySpecializedDAChar() const throw(INTERP_KERNEL::Exception);
DataArrayAsciiCharIterator *iterator();
- DataArrayAsciiChar *deepCpy() const;
DataArrayAsciiChar *performCpy(bool deepCpy) const;
char asciiCharValue() const throw(INTERP_KERNEL::Exception);
%extend
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# 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
+#
+#
+
+from MEDCoupling import *
+
+if MEDCouplingHasNumPyBindings():
+ from numpy import *
+ pass
+
+from sys import getrefcount
+
+import os,gc,weakref,unittest
+
+class MEDCouplingNumPyTest(unittest.TestCase):
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test1(self):
+ sz=20
+ a=array(0,dtype=int32)
+ a.resize(sz)
+ a[:]=4
+ self.assertEqual(getrefcount(a),2)
+ a=a.cumsum(dtype=int32)
+ self.assertEqual(getrefcount(a),2)
+ d=DataArrayInt(a)
+ d[:]=2
+ #
+ e=DataArrayInt(sz) ; e.fillWithValue(2)
+ self.assertTrue(d.isEqual(e))
+ #
+ a[:]=4 ; e.fillWithValue(4)
+ self.assertTrue(d.isEqual(e))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test2(self):
+ sz=20
+ a=array(0,dtype=int32)
+ a.resize(sz,2)
+ self.assertEqual(getrefcount(a),2)
+ b=a.reshape(2*sz)
+ self.assertEqual(getrefcount(a),3)
+ self.assertEqual(getrefcount(b),2)
+ b[:]=5
+ d=DataArrayInt(b)
+ #
+ e=DataArrayInt(sz*2) ; e.fillWithValue(5)
+ self.assertTrue(d.isEqual(e))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test3(self):
+ sz=10
+ a=array(0,dtype=int32)
+ a.resize(sz,2)
+ b=a.reshape(2*sz)
+ c=a.reshape(2,sz)
+ b[:]=6
+ b[7:17]=7
+ d=DataArrayInt(b)
+ self.assertTrue(d.isEqual(DataArrayInt([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6])))
+ #
+ a=zeros((10,2),dtype=int32)
+ b=a.T
+ c=b.view()
+ a.shape=20
+ a[3:]=10.
+ d=DataArrayInt(a)
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10])))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test4(self):
+ a=zeros(20,dtype=int32)
+ b = a[::-1]
+ self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b is not contiguous in memory
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test5(self):
+ a=arange(20,dtype=int32)
+ self.assertEqual(weakref.getweakrefcount(a),0)
+ d=DataArrayInt(a)
+ self.assertEqual(weakref.getweakrefcount(a),1)
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(d.isIdentity())
+ self.assertEqual(len(d),20)
+ a[:]=2 # modifying a and d because a and d share the same chunk of data
+ self.assertTrue(d.isUniform(2))
+ del d # d is destroyed, a retrieves its ownership of its initial chunk of data
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ import gc
+ gc.collect()
+ self.assertTrue(a.flags["OWNDATA"])
+ a[:]=4 # a can be used has usual
+ self.assertTrue(DataArrayInt(a).isUniform(4))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test6(self):
+ a=arange(20,dtype=int32)
+ d=DataArrayInt(a) # d owns data of a
+ e=DataArrayInt(a) # a not owned -> e only an access to chunk of a
+ self.assertTrue(d.isIdentity())
+ self.assertTrue(e.isIdentity())
+ a[:]=6
+ self.assertTrue(d.isUniform(6))
+ self.assertTrue(e.isUniform(6))
+ del a # a destroyed -> d no change because owned and e array is has no more data set
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ import gc
+ gc.collect()
+ self.assertTrue(d.isUniform(6))
+ self.assertTrue(not e.isAllocated())
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test7(self):
+ a=array(0,dtype=int32) ; a.resize(10,2)
+ b=a.reshape(20)
+ c=a.reshape(2,10)
+ d=DataArrayInt(b) # d owns data of a
+ e=DataArrayInt(b) # a not owned -> e only an access to chunk of a
+ f=DataArrayInt(b) # a not owned -> e only an access to chunk of a
+ del d # d removed -> a ownes again data
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ import gc
+ gc.collect()
+ self.assertTrue(e.isUniform(0))
+ e[:]=6
+ self.assertTrue(e.isUniform(6))
+ self.assertTrue(f.isUniform(6))
+ self.assertEqual(b.tolist(),[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6])
+ self.assertEqual(a.tolist(),[[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6]])
+ b[:]=arange(20)
+ del b # no impact on e and f because a is the base of a.
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ gc.collect()
+ self.assertTrue(f.isIdentity())
+ self.assertTrue(e.isIdentity())
+ del a # a destroyed, but as c has its base set to a, a exists -> e and f not allocated
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ gc.collect()
+ self.assertTrue(f.isIdentity())
+ self.assertTrue(e.isIdentity())
+ del c # c killed -> a killed -> e and d are put into not allocated state
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ gc.collect()
+ self.assertTrue(not e.isAllocated())
+ self.assertTrue(not f.isAllocated())
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test8(self):
+ a=arange(20,dtype=int32)
+ self.assertTrue(a.flags["OWNDATA"])
+ d=DataArrayInt(a) # d owns data of a
+ self.assertTrue(not a.flags["OWNDATA"])
+ d.pushBackSilent(20)# d pushBack so release of chunk of data -> a becomes owner of its data again
+ self.assertTrue(a.flags["OWNDATA"])
+ self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])))
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test9(self):
+ sz=20
+ a=array(0,dtype=float64)
+ a.resize(sz)
+ a[:]=4
+ self.assertEqual(getrefcount(a),2)
+ a=a.cumsum(dtype=float64)
+ self.assertEqual(getrefcount(a),2)
+ d=DataArrayDouble(a)
+ d[:]=2
+ #
+ e=DataArrayDouble(sz) ; e.fillWithValue(2)
+ self.assertTrue(d.isEqual(e,1e-14))
+ #
+ a[:]=4 ; e.fillWithValue(4)
+ self.assertTrue(d.isEqual(e,1e-14))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test10(self):
+ sz=20
+ a=array(0,dtype=float64)
+ a.resize(sz,2)
+ self.assertEqual(getrefcount(a),2)
+ b=a.reshape(2*sz)
+ self.assertEqual(getrefcount(a),3)
+ self.assertEqual(getrefcount(b),2)
+ b[:]=5
+ d=DataArrayDouble(b)
+ #
+ e=DataArrayDouble(sz*2) ; e.fillWithValue(5)
+ self.assertTrue(d.isEqual(e,1e-14))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test11(self):
+ sz=10
+ a=array(0,dtype=float64)
+ a.resize(sz,2)
+ b=a.reshape(2*sz)
+ c=a.reshape(2,sz)
+ b[:]=6
+ b[7:17]=7
+ d=DataArrayDouble(b)
+ self.assertTrue(d.isEqual(DataArrayDouble([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6]),1e-14))
+ #
+ a=zeros((10,2),dtype=float64)
+ b=a.T
+ c=b.view()
+ a.shape=20
+ a[3:]=10.
+ d=DataArrayDouble(a)
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]),1e-14))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test12(self):
+ a=zeros(20,dtype=float64)
+ b = a[::-1]
+ self.assertRaises(InterpKernelException,DataArrayDouble.New,b) # b is not contiguous in memory
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test13(self):
+ a=arange(20,dtype=float64)
+ self.assertEqual(weakref.getweakrefcount(a),0)
+ d=DataArrayDouble(a)
+ self.assertEqual(weakref.getweakrefcount(a),1)
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+ self.assertEqual(len(d),20)
+ a[:]=2 # modifying a and d because a and d share the same chunk of data
+ self.assertTrue(d.isUniform(2,1e-14))
+ del d # d is destroyed, a retrieves its ownership of its initial chunk of data
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ import gc
+ gc.collect()
+ self.assertTrue(a.flags["OWNDATA"])
+ a[:]=4 # a can be used has usual
+ self.assertTrue(DataArrayDouble(a).isUniform(4,1e-14))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test14(self):
+ a=arange(20,dtype=float64)
+ d=DataArrayDouble(a) # d owns data of a
+ e=DataArrayDouble(a) # a not owned -> e only an access to chunk of a
+ self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+ self.assertTrue(e.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+ a[:]=6
+ self.assertTrue(d.isUniform(6,1e-14))
+ self.assertTrue(e.isUniform(6,1e-14))
+ del a # a destroyed -> d no change because owned and e array is has no more data set
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ import gc
+ gc.collect()
+ self.assertTrue(d.isUniform(6,1e-14))
+ self.assertTrue(not e.isAllocated())
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test15(self):
+ a=array(0,dtype=float64) ; a.resize(10,2)
+ b=a.reshape(20)
+ c=a.reshape(2,10)
+ d=DataArrayDouble(b) # d owns data of a
+ e=DataArrayDouble(b) # a not owned -> e only an access to chunk of a
+ f=DataArrayDouble(b) # a not owned -> e only an access to chunk of a
+ del d # d removed -> a ownes again data
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ import gc
+ gc.collect()
+ self.assertTrue(e.isUniform(0,1e-14))
+ e[:]=6
+ self.assertTrue(e.isUniform(6,1e-14))
+ self.assertTrue(f.isUniform(6,1e-14))
+ self.assertEqual(b.tolist(),[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6])
+ self.assertEqual(a.tolist(),[[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6]])
+ b[:]=arange(20)
+ del b # no impact on e and f because a is the base of a.
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ gc.collect()
+ self.assertTrue(f.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+ self.assertTrue(e.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+ del a # a destroyed, but as c has its base set to a, a exists -> e and f not allocated
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ gc.collect()
+ self.assertTrue(f.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+ self.assertTrue(e.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
+ del c # c killed -> a killed -> e and d are put into not allocated state
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ gc.collect()
+ self.assertTrue(not e.isAllocated())
+ self.assertTrue(not f.isAllocated())
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test16(self):
+ a=arange(20,dtype=float64)
+ self.assertTrue(a.flags["OWNDATA"])
+ d=DataArrayDouble(a) # d owns data of a
+ self.assertTrue(not a.flags["OWNDATA"])
+ d.pushBackSilent(20)# d pushBack so release of chunk of data -> a becomes owner of its data again
+ self.assertTrue(a.flags["OWNDATA"])
+ self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),1e-14))
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test17(self):
+ d=DataArrayInt.Range(0,20,1)
+ a=d.toNumPyArray()
+ self.assertTrue(not a.flags["OWNDATA"])
+ a[-2:]=100
+ self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100])))
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100])
+ del a
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ import gc
+ gc.collect()
+ self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100])))
+ #
+ d.rearrange(2)
+ a=d.toNumPyArray()
+ self.assertTrue(not a.flags["OWNDATA"])
+ a[-2:]=200
+ self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2)))
+ self.assertEqual(a.tolist(),[[0,1],[2,3],[4,5],[6,7],[8,9],[10,11],[12,13],[14,15],[200,200],[200,200]])
+ del a
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ gc.collect()
+ self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2)))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test18(self):
+ d=DataArrayInt.Range(0,20,1)
+ d=d.convertToDblArr()
+ a=d.toNumPyArray()
+ self.assertTrue(not a.flags["OWNDATA"])
+ a[-2:]=100
+ self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100]),1e-14))
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100])
+ del a
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ import gc
+ gc.collect()
+ self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100]),1e-14))
+ #
+ d.rearrange(2)
+ a=d.toNumPyArray()
+ self.assertTrue(not a.flags["OWNDATA"])
+ a[-2:]=200
+ self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2),1e-14))
+ self.assertEqual(a.tolist(),[[0,1],[2,3],[4,5],[6,7],[8,9],[10,11],[12,13],[14,15],[200,200],[200,200]])
+ del a
+ ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
+ gc.collect()
+ self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2),1e-14))
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test19(self):
+ sz=20
+ a=array(0,dtype=int32)
+ a.resize(sz/2,2)
+ a[:]=4
+ self.assertEqual(getrefcount(a),2)
+ d=DataArrayInt(a)
+ self.assertEqual(10,d.getNumberOfTuples())
+ self.assertEqual(2,d.getNumberOfComponents())
+ self.assertEqual(sz,d.getNbOfElems())
+ self.assertTrue(d.isEqual(DataArrayInt([(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4)])))
+ a[:]=7
+ self.assertTrue(d.isEqual(DataArrayInt([(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7)])))
+ #
+ b=a.reshape((2,5,2))
+ self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b has not dimension in [0,1] !
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test20(self):
+ sz=20
+ a=array(0,dtype=float64)
+ a.resize(sz/2,2)
+ a[:]=4
+ self.assertEqual(getrefcount(a),2)
+ d=DataArrayDouble(a)
+ self.assertEqual(10,d.getNumberOfTuples())
+ self.assertEqual(2,d.getNumberOfComponents())
+ self.assertEqual(sz,d.getNbOfElems())
+ self.assertTrue(d.isEqual(DataArrayDouble([(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.),(4.,4.)]),1e-14))
+ a[:]=7
+ self.assertTrue(d.isEqual(DataArrayDouble([(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.),(7.,7.)]),1e-14))
+ #
+ b=a.reshape((2,5,2))
+ self.assertRaises(InterpKernelException,DataArrayDouble.New,b) # b has not dimension in [0,1] !
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test21(self):
+ #tests that only DataArray*(npArray) contructor is available
+ a=array(0,dtype=int32)
+ a.resize(20)
+ DataArrayInt(a)
+ self.assertRaises(InterpKernelException,DataArrayInt.New,a,20)
+ self.assertRaises(InterpKernelException,DataArrayInt.New,a,20,1)
+ a=array(0,dtype=float64)
+ a.resize(20)
+ DataArrayDouble(a)
+ self.assertRaises(InterpKernelException,DataArrayDouble.New,a,20)
+ self.assertRaises(InterpKernelException,DataArrayDouble.New,a,20,1)
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test22(self):
+ d=DataArrayDouble(10)
+ d.iota()
+ a=d.toNumPyArray()
+ self.assertTrue(not a.flags["OWNDATA"])
+ del d
+ gc.collect()
+ self.assertTrue(a.flags["OWNDATA"])
+ self.assertEqual(a.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ #
+ d=DataArrayInt(10)
+ d.iota()
+ a=d.toNumPyArray()
+ self.assertTrue(not a.flags["OWNDATA"])
+ del d
+ gc.collect()
+ self.assertTrue(a.flags["OWNDATA"])
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test23(self):
+ d=DataArrayDouble(10)
+ d.iota()
+ a=d.toNumPyArray()
+ b=d.toNumPyArray()
+ c=d.toNumPyArray()
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(not b.flags["OWNDATA"])
+ self.assertTrue(not c.flags["OWNDATA"])
+ self.assertEqual(a.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertEqual(b.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertEqual(c.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ del d
+ gc.collect()
+ self.assertTrue(a.flags["OWNDATA"])
+ self.assertTrue(not b.flags["OWNDATA"])
+ self.assertTrue(not c.flags["OWNDATA"])
+ self.assertEqual(a.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertEqual(b.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertEqual(c.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ #
+ d=DataArrayInt(10)
+ d.iota()
+ a=d.toNumPyArray()
+ b=d.toNumPyArray()
+ c=d.toNumPyArray()
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(not b.flags["OWNDATA"])
+ self.assertTrue(not c.flags["OWNDATA"])
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ self.assertEqual(b.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ self.assertEqual(c.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ del d
+ gc.collect()
+ self.assertTrue(a.flags["OWNDATA"])
+ self.assertTrue(not b.flags["OWNDATA"])
+ self.assertTrue(not c.flags["OWNDATA"])
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ self.assertEqual(b.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ self.assertEqual(c.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test24(self):
+ d=DataArrayDouble(10)
+ d.iota()
+ a=d.toNumPyArray()
+ self.assertEqual(a.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(a.base is None)
+ del a
+ gc.collect()
+ a=d.toNumPyArray()
+ self.assertEqual(a.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(a.base is None)
+ b=d.toNumPyArray()
+ self.assertEqual(a.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertEqual(b.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(not b.flags["OWNDATA"])
+ self.assertTrue(b.base is a)
+ del a
+ gc.collect()
+ self.assertEqual(b.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertTrue(not b.flags["OWNDATA"])
+ del d
+ gc.collect()
+ self.assertEqual(b.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertTrue(not b.flags["OWNDATA"])
+ #
+ d=DataArrayInt(10)
+ d.iota()
+ a=d.toNumPyArray()
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(a.base is None)
+ del a
+ gc.collect()
+ a=d.toNumPyArray()
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(a.base is None)
+ b=d.toNumPyArray()
+ self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ self.assertEqual(b.tolist(),[0,1,2,3,4,5,6,7,8,9])
+ self.assertTrue(not a.flags["OWNDATA"])
+ self.assertTrue(not b.flags["OWNDATA"])
+ self.assertTrue(b.base is a)
+ del a
+ gc.collect()
+ self.assertEqual(b.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertTrue(not b.flags["OWNDATA"])
+ del d
+ gc.collect()
+ self.assertEqual(b.tolist(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.])
+ self.assertTrue(not b.flags["OWNDATA"])
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test25(self):
+ a=arange(10,dtype=int32)
+ b=DataArrayInt(a)
+ c=DataArrayInt(a)
+ d=DataArrayInt(a)
+ self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),10)
+ self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),10)
+ self.assertTrue(d.isIdentity()) ; self.assertEqual(len(d),10)
+ c.pushBackSilent(10) # c and a,b are dissociated
+ self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),10)
+ self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),11)
+ self.assertTrue(d.isIdentity()) ; self.assertEqual(len(d),10)
+ del a
+ gc.collect()
+ self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),10)
+ self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),11)
+ self.assertTrue(not d.isAllocated())
+ del b
+ gc.collect()
+ self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),11)
+ #
+ a=arange(10,dtype=int32)
+ b=DataArrayInt(a)
+ c=DataArrayInt(a)
+ self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),10)
+ self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),10)
+ b.pushBackSilent(10) # c and a,b are dissociated
+ self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),11)
+ self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),10)
+ del a
+ gc.collect()
+ self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),11)
+ self.assertTrue(not c.isAllocated())
+ del b
+ gc.collect()
+ self.assertTrue(not c.isAllocated())
+ #
+ a=float64(arange(5,dtype=int32))
+ b=DataArrayDouble(a)
+ c=DataArrayDouble(a)
+ d=DataArrayDouble(a)
+ self.assertTrue(b.isEqual(DataArrayDouble([0.,1.,2.,3.,4.]),1e-12))
+ self.assertTrue(c.isEqual(DataArrayDouble([0.,1.,2.,3.,4.]),1e-12))
+ self.assertTrue(d.isEqual(DataArrayDouble([0.,1.,2.,3.,4.]),1e-12))
+ c.pushBackSilent(10.) # c and a,b are dissociated
+ self.assertTrue(b.isEqual(DataArrayDouble([0.,1.,2.,3.,4.]),1e-12))
+ self.assertTrue(c.isEqual(DataArrayDouble([0.,1.,2.,3.,4.,10.]),1e-12))
+ self.assertTrue(d.isEqual(DataArrayDouble([0.,1.,2.,3.,4.]),1e-12))
+ del a
+ gc.collect()
+ self.assertTrue(b.isEqual(DataArrayDouble([0.,1.,2.,3.,4.]),1e-12))
+ self.assertTrue(c.isEqual(DataArrayDouble([0.,1.,2.,3.,4.,10.]),1e-12))
+ self.assertTrue(not d.isAllocated())
+ del b
+ gc.collect()
+ self.assertTrue(c.isEqual(DataArrayDouble([0.,1.,2.,3.,4.,10.]),1e-12))
+ #
+ a=float64(arange(5,dtype=int32))
+ b=DataArrayDouble(a)
+ c=DataArrayDouble(a)
+ self.assertTrue(b.isEqual(DataArrayDouble([0.,1.,2.,3.,4.]),1e-12))
+ self.assertTrue(c.isEqual(DataArrayDouble([0.,1.,2.,3.,4.]),1e-12))
+ b.pushBackSilent(10.) # c and a,b are dissociated
+ self.assertTrue(b.isEqual(DataArrayDouble([0.,1.,2.,3.,4.,10.]),1e-12))
+ self.assertTrue(c.isEqual(DataArrayDouble([0.,1.,2.,3.,4.]),1e-12))
+ del a
+ gc.collect()
+ self.assertTrue(b.isEqual(DataArrayDouble([0.,1.,2.,3.,4.,10.]),1e-12))
+ self.assertTrue(not c.isAllocated())
+ del b
+ gc.collect()
+ self.assertTrue(not c.isAllocated())
+ pass
+
+ # @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test26(self):
+ d=DataArrayInt(15) ; d.iota()
+ d.rearrange(3)
+ a=d.toNumPyArray()
+ self.assertEqual(a.ndim,2)
+ self.assertEqual(a.size,15)
+ self.assertEqual(a.shape,(5,3))
+ self.assertEqual(a.strides,(12,4))
+ self.assertEqual(a.nbytes,60)
+ self.assertEqual(a.itemsize,4)
+ self.assertEqual(a.tolist(),[[0,1,2],[3,4,5],[6,7,8],[9,10,11],[12,13,14]])
+ #
+ d2=d.convertToDblArr()
+ a2=d2.toNumPyArray()
+ self.assertEqual(a2.ndim,2)
+ self.assertEqual(a2.size,15)
+ self.assertEqual(a2.shape,(5,3))
+ self.assertEqual(a2.strides,(24,8))
+ self.assertEqual(a2.nbytes,120)
+ self.assertEqual(a2.itemsize,8)
+ self.assertEqual(a2.tolist(),[[0.,1.,2.],[3.,4.,5.],[6.,7.,8.],[9.,10.,11.],[12.,13.,14.]])
+ pass
+
+ def setUp(self):
+ pass
+ pass
+
+#gc.set_debug(gc.DEBUG_LEAK)
+unittest.main()
+++ /dev/null
-# -*- coding: iso-8859-1 -*-
-# 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
-#
-#
-
-from MEDCoupling import *
-
-if MEDCouplingHasNumpyBindings():
- from numpy import *
- pass
-
-from sys import getrefcount
-
-import os,gc,weakref,unittest
-
-class MEDCouplingNumpyTest(unittest.TestCase):
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test1(self):
- sz=20
- a=array(0,dtype=int32)
- a.resize(sz)
- a[:]=4
- self.assertEqual(getrefcount(a),2)
- a=a.cumsum(dtype=int32)
- self.assertEqual(getrefcount(a),2)
- d=DataArrayInt(a)
- d[:]=2
- #
- e=DataArrayInt(sz) ; e.fillWithValue(2)
- self.assertTrue(d.isEqual(e))
- #
- a[:]=4 ; e.fillWithValue(4)
- self.assertTrue(d.isEqual(e))
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test2(self):
- sz=20
- a=array(0,dtype=int32)
- a.resize(sz,2)
- self.assertEqual(getrefcount(a),2)
- b=a.reshape(2*sz)
- self.assertEqual(getrefcount(a),3)
- self.assertEqual(getrefcount(b),2)
- b[:]=5
- d=DataArrayInt(b)
- #
- e=DataArrayInt(sz*2) ; e.fillWithValue(5)
- self.assertTrue(d.isEqual(e))
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test3(self):
- sz=10
- a=array(0,dtype=int32)
- a.resize(sz,2)
- b=a.reshape(2*sz)
- c=a.reshape(2,sz)
- b[:]=6
- b[7:17]=7
- d=DataArrayInt(b)
- self.assertTrue(d.isEqual(DataArrayInt([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6])))
- #
- a=zeros((10,2),dtype=int32)
- b=a.T
- c=b.view()
- a.shape=20
- a[3:]=10.
- d=DataArrayInt(a)
- self.assertTrue(d.isEqual(DataArrayInt([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10])))
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test4(self):
- a=zeros(20,dtype=int32)
- b = a[::-1]
- self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b is not contiguous in memory
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test5(self):
- a=arange(20,dtype=int32)
- self.assertEqual(weakref.getweakrefcount(a),0)
- d=DataArrayInt(a)
- self.assertEqual(weakref.getweakrefcount(a),1)
- self.assertTrue(not a.flags["OWNDATA"])
- self.assertTrue(d.isIdentity())
- self.assertEqual(len(d),20)
- a[:]=2 # modifying a and d because a and d share the same chunk of data
- self.assertTrue(d.isUniform(2))
- del d # d is destroyed, a retrieves its ownership of its initial chunk of data
- self.assertTrue(a.flags["OWNDATA"])
- a[:]=4 # a can be used has usual
- self.assertTrue(DataArrayInt(a).isUniform(4))
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test6(self):
- a=arange(20,dtype=int32)
- d=DataArrayInt(a) # d owns data of a
- e=DataArrayInt(a) # a not owned -> e only an access to chunk of a
- self.assertTrue(d.isIdentity())
- self.assertTrue(e.isIdentity())
- a[:]=6
- self.assertTrue(d.isUniform(6))
- self.assertTrue(e.isUniform(6))
- del a # a destroyed -> d no change because owned and e array is has no more data set
- self.assertTrue(d.isUniform(6))
- self.assertTrue(not e.isAllocated())
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test7(self):
- a=array(0,dtype=int32) ; a.resize(10,2)
- b=a.reshape(20)
- c=a.reshape(2,10)
- d=DataArrayInt(b) # d owns data of a
- e=DataArrayInt(b) # a not owned -> e only an access to chunk of a
- f=DataArrayInt(b) # a not owned -> e only an access to chunk of a
- del d # d removed -> a ownes again data
- self.assertTrue(e.isUniform(0))
- e[:]=6
- self.assertTrue(e.isUniform(6))
- self.assertTrue(f.isUniform(6))
- self.assertEqual(b.tolist(),[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6])
- self.assertEqual(a.tolist(),[[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6]])
- b[:]=arange(20)
- del b # no impact on e and f because a is the base of a.
- self.assertTrue(f.isIdentity())
- self.assertTrue(e.isIdentity())
- del a # a destroyed, but as c has its base set to a, a exists -> e and f not allocated
- self.assertTrue(f.isIdentity())
- self.assertTrue(e.isIdentity())
- del c # c killed -> a killed -> e and d are put into not allocated state
- self.assertTrue(not e.isAllocated())
- self.assertTrue(not f.isAllocated())
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test8(self):
- a=arange(20,dtype=int32)
- self.assertTrue(a.flags["OWNDATA"])
- d=DataArrayInt(a) # d owns data of a
- self.assertTrue(not a.flags["OWNDATA"])
- d.pushBackSilent(20)# d pushBack so release of chunk of data -> a becomes owner of its data again
- self.assertTrue(a.flags["OWNDATA"])
- self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])))
- self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test9(self):
- sz=20
- a=array(0,dtype=float64)
- a.resize(sz)
- a[:]=4
- self.assertEqual(getrefcount(a),2)
- a=a.cumsum(dtype=float64)
- self.assertEqual(getrefcount(a),2)
- d=DataArrayDouble(a)
- d[:]=2
- #
- e=DataArrayDouble(sz) ; e.fillWithValue(2)
- self.assertTrue(d.isEqual(e,1e-14))
- #
- a[:]=4 ; e.fillWithValue(4)
- self.assertTrue(d.isEqual(e,1e-14))
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test10(self):
- sz=20
- a=array(0,dtype=float64)
- a.resize(sz,2)
- self.assertEqual(getrefcount(a),2)
- b=a.reshape(2*sz)
- self.assertEqual(getrefcount(a),3)
- self.assertEqual(getrefcount(b),2)
- b[:]=5
- d=DataArrayDouble(b)
- #
- e=DataArrayDouble(sz*2) ; e.fillWithValue(5)
- self.assertTrue(d.isEqual(e,1e-14))
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test11(self):
- sz=10
- a=array(0,dtype=float64)
- a.resize(sz,2)
- b=a.reshape(2*sz)
- c=a.reshape(2,sz)
- b[:]=6
- b[7:17]=7
- d=DataArrayDouble(b)
- self.assertTrue(d.isEqual(DataArrayDouble([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6]),1e-14))
- #
- a=zeros((10,2),dtype=float64)
- b=a.T
- c=b.view()
- a.shape=20
- a[3:]=10.
- d=DataArrayDouble(a)
- self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]),1e-14))
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test12(self):
- a=zeros(20,dtype=float64)
- b = a[::-1]
- self.assertRaises(InterpKernelException,DataArrayDouble.New,b) # b is not contiguous in memory
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test13(self):
- a=arange(20,dtype=float64)
- self.assertEqual(weakref.getweakrefcount(a),0)
- d=DataArrayDouble(a)
- self.assertEqual(weakref.getweakrefcount(a),1)
- self.assertTrue(not a.flags["OWNDATA"])
- self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
- self.assertEqual(len(d),20)
- a[:]=2 # modifying a and d because a and d share the same chunk of data
- self.assertTrue(d.isUniform(2,1e-14))
- del d # d is destroyed, a retrieves its ownership of its initial chunk of data
- self.assertTrue(a.flags["OWNDATA"])
- a[:]=4 # a can be used has usual
- self.assertTrue(DataArrayDouble(a).isUniform(4,1e-14))
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test14(self):
- a=arange(20,dtype=float64)
- d=DataArrayDouble(a) # d owns data of a
- e=DataArrayDouble(a) # a not owned -> e only an access to chunk of a
- self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
- self.assertTrue(e.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
- a[:]=6
- self.assertTrue(d.isUniform(6,1e-14))
- self.assertTrue(e.isUniform(6,1e-14))
- del a # a destroyed -> d no change because owned and e array is has no more data set
- self.assertTrue(d.isUniform(6,1e-14))
- self.assertTrue(not e.isAllocated())
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test15(self):
- a=array(0,dtype=float64) ; a.resize(10,2)
- b=a.reshape(20)
- c=a.reshape(2,10)
- d=DataArrayDouble(b) # d owns data of a
- e=DataArrayDouble(b) # a not owned -> e only an access to chunk of a
- f=DataArrayDouble(b) # a not owned -> e only an access to chunk of a
- del d # d removed -> a ownes again data
- self.assertTrue(e.isUniform(0,1e-14))
- e[:]=6
- self.assertTrue(e.isUniform(6,1e-14))
- self.assertTrue(f.isUniform(6,1e-14))
- self.assertEqual(b.tolist(),[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6])
- self.assertEqual(a.tolist(),[[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6],[6,6]])
- b[:]=arange(20)
- del b # no impact on e and f because a is the base of a.
- self.assertTrue(f.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
- self.assertTrue(e.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
- del a # a destroyed, but as c has its base set to a, a exists -> e and f not allocated
- self.assertTrue(f.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
- self.assertTrue(e.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),1e-14))
- del c # c killed -> a killed -> e and d are put into not allocated state
- self.assertTrue(not e.isAllocated())
- self.assertTrue(not f.isAllocated())
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test16(self):
- a=arange(20,dtype=float64)
- self.assertTrue(a.flags["OWNDATA"])
- d=DataArrayDouble(a) # d owns data of a
- self.assertTrue(not a.flags["OWNDATA"])
- d.pushBackSilent(20)# d pushBack so release of chunk of data -> a becomes owner of its data again
- self.assertTrue(a.flags["OWNDATA"])
- self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),1e-14))
- self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test17(self):
- d=DataArrayInt.Range(0,20,1)
- d.rearrange(10)
- self.assertRaises(InterpKernelException,d.toNumPyArray)# forbidden one or two components of d is accepted
- d.rearrange(1)
- a=d.toNumPyArray()
- self.assertTrue(not a.flags["OWNDATA"])
- a[-2:]=100
- self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100])))
- self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100])
- del a
- self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100])))
- #
- d.rearrange(2)
- a=d.toNumPyArray()
- self.assertTrue(not a.flags["OWNDATA"])
- a[-2:]=200
- self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2)))
- self.assertEqual(a.tolist(),[[0,1],[2,3],[4,5],[6,7],[8,9],[10,11],[12,13],[14,15],[200,200],[200,200]])
- del a
- self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2)))
- pass
-
- @unittest.skipUnless(MEDCouplingHasNumpyBindings(),"requires numpy")
- def test18(self):
- d=DataArrayInt.Range(0,20,1)
- d=d.convertToDblArr()
- d.rearrange(10)
- self.assertRaises(InterpKernelException,d.toNumPyArray)# forbidden one or two components of d is accepted
- d.rearrange(1)
- a=d.toNumPyArray()
- self.assertTrue(not a.flags["OWNDATA"])
- a[-2:]=100
- self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100]),1e-14))
- self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100])
- del a
- self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,100,100]),1e-14))
- #
- d.rearrange(2)
- a=d.toNumPyArray()
- self.assertTrue(not a.flags["OWNDATA"])
- a[-2:]=200
- self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2),1e-14))
- self.assertEqual(a.tolist(),[[0,1],[2,3],[4,5],[6,7],[8,9],[10,11],[12,13],[14,15],[200,200],[200,200]])
- del a
- self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2),1e-14))
- pass
-
- def setUp(self):
- pass
- pass
-
-#gc.set_debug(gc.DEBUG_LEAK)
-unittest.main()
#ifdef WITH_NUMPY
#include <numpy/arrayobject.h>
+// specific DataArray deallocator callback. This deallocator is used both in the constructor of DataArray and in the toNumPyArr
+// method. This dellocator uses weakref to determine if the linked numArr is still alive or not. If alive the ownership is given to it.
+// if no more alive the "standart" DataArray deallocator is called.
void numarrdeal(void *pt, void *wron)
{
void **wronc=(void **)wron;
typedef void (*MyDeallocator)(void *,void *);
MyDeallocator deall=(MyDeallocator)wronc[1];
deall(pt,NULL);
+ Py_XDECREF(weakRefOnOwner);
}
delete [] wronc;
}
Py_TYPE(self)->tp_free(self);
}
+ // real callback called when a numpy arr having more than one DataArray instance client on it is destroyed.
+ // In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients.
static PyObject *callbackmcdataarrayint_call(PyCallBackDataArrayInt *self, PyObject *args, PyObject *kw)
{
if(self->_pt_mc)
Py_XINCREF(Py_None);
return Py_None;
}
-
+
+ // real callback called when a numpy arr having more than one DataArray instance client on it is destroyed.
+ // In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients.
static PyObject *callbackmcdataarraydouble_call(PyCallBackDataArrayDouble *self, PyObject *args, PyObject *kw)
{
if(self->_pt_mc)
PyObject_GC_Del, /*tp_free*/
};
+// this is the second type of specific deallocator, only valid for the constructor of DataArrays taking numpy array
+// in input when an another DataArray is already client of this.
template<class MCData>
void numarrdeal2(void *pt, void *obj)
{
MCData *BuildNewInstance(PyObject *elt0, int npyObjectType, PyTypeObject *pytype, const char *msg)
{
int ndim=PyArray_NDIM(elt0);
- if(ndim!=1)
- throw INTERP_KERNEL::Exception("Input numpy array has not 1 dimension !");//to do 1 or 2.
+ if(ndim!=1 && ndim!=2)
+ throw INTERP_KERNEL::Exception("Input numpy array should have dimension equal to 1 or 2 !");
if(PyArray_ObjectType(elt0,0)!=npyObjectType)
{
- std::ostringstream oss; oss << "Input numpy array has not of type " << msg << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());//to do 1 or 2.
+ std::ostringstream oss; oss << "Input numpy array has not of type " << msg << " at component #0 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- npy_intp stride=PyArray_STRIDE(elt0,0);
+ if(ndim==2)
+ if(PyArray_ObjectType(elt0,1)!=npyObjectType)
+ {
+ std::ostringstream oss; oss << "Input numpy array has not of type " << msg << " at component #1 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ npy_intp sz0=PyArray_DIM(elt0,0);
+ npy_intp sz1=ndim==2?PyArray_DIM(elt0,1):1;
+ //
int itemSize=PyArray_ITEMSIZE(elt0);
- if(itemSize<stride)
- throw INTERP_KERNEL::Exception("Input numpy array has item size < stride !");
- if(stride!=sizeof(T))
+ if(itemSize!=sizeof(T))
{
- std::ostringstream oss; oss << "Input numpy array has not stride set to " << sizeof(T) << " !";
+ std::ostringstream oss; oss << "Input numpy array has not itemSize set to " << sizeof(T) << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- npy_intp sz=PyArray_DIM(elt0,0);
+ if(itemSize*sz1!=PyArray_STRIDE(elt0,0))
+ throw INTERP_KERNEL::Exception("Input numpy array has stride that mismatches the item size ! Data are not packed in the right way for DataArrays !");
+ if(ndim==2)
+ if(itemSize!=PyArray_STRIDE(elt0,1))
+ throw INTERP_KERNEL::Exception("Input numpy array has stride that mismatches the item size ! Data are not packed in the right way for DataArrays for component #1 !");
const char *data=PyArray_BYTES(elt0);
typename ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<MCData> ret=MCData::New();
if(PyArray_ISBEHAVED(elt0))//aligned and writeable and in machine byte-order
{
PyCallBackDataArraySt<MCData> *cb=PyObject_GC_New(PyCallBackDataArraySt<MCData>,pytype);
cb->_pt_mc=ret;
- ret->useArray(reinterpret_cast<const T *>(data),true,ParaMEDMEM::C_DEALLOC,sz,1);
+ ret->useArray(reinterpret_cast<const T *>(data),true,ParaMEDMEM::C_DEALLOC,sz0,sz1);
PyObject *ref=PyWeakref_NewRef(deepestObj,(PyObject *)cb);
void **objs=new void *[2]; objs[0]=cb; objs[1]=ref;
mma.setParameterForDeallocator(objs);
}
else
{
- ret->useArray(reinterpret_cast<const T *>(data),true,ParaMEDMEM::C_DEALLOC,sz,1);
+ 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;
mma.setParameterForDeallocator(objs);
}
}
else if(PyArray_ISBEHAVED_RO(elt0))
- ret->useArray(reinterpret_cast<const T *>(data),false,ParaMEDMEM::CPP_DEALLOC,sz,1);
+ ret->useArray(reinterpret_cast<const T *>(data),false,ParaMEDMEM::CPP_DEALLOC,sz0,sz1);
return ret.retn();
}
+
+int NumpyArrSetBaseObjectExt(PyArrayObject *arr, PyObject *obj)
+{
+ if (obj == NULL) {
+ PyErr_SetString(PyExc_ValueError,
+ "Cannot set the NumPy array 'base' "
+ "dependency to NULL after initialization");
+ return -1;
+ }
+ /*
+ * Allow the base to be set only once. Once the object which
+ * owns the data is set, it doesn't make sense to change it.
+ */
+ if (PyArray_BASE(arr) != NULL) {
+ Py_DECREF(obj);
+ PyErr_SetString(PyExc_ValueError,
+ "Cannot set the NumPy array 'base' "
+ "dependency more than once");
+ return -1;
+ }
+
+ /*
+ * Don't allow infinite chains of views, always set the base
+ * to the first owner of the data.
+ * That is, either the first object which isn't an array,
+ * or the first object which owns its own data.
+ */
+
+ while (PyArray_Check(obj) && (PyObject *)arr != obj) {
+ PyArrayObject *obj_arr = (PyArrayObject *)obj;
+ PyObject *tmp;
+
+
+ /* If this array owns its own data, stop collapsing */
+ if (PyArray_CHKFLAGS(obj_arr, NPY_OWNDATA)) {
+ break;
+ }
+
+ tmp = PyArray_BASE(obj_arr);
+ /* If there's no base, stop collapsing */
+ if (tmp == NULL) {
+ break;
+ }
+ /* Stop the collapse new base when the would not be of the same
+ * type (i.e. different subclass).
+ */
+ if (Py_TYPE(tmp) != Py_TYPE(arr)) {
+ break;
+ }
+
+
+ Py_INCREF(tmp);
+ Py_DECREF(obj);
+ obj = tmp;
+ }
+
+ /* Disallow circular references */
+ if ((PyObject *)arr == obj) {
+ Py_DECREF(obj);
+ PyErr_SetString(PyExc_ValueError,
+ "Cannot create a circular NumPy array 'base' dependency");
+ return -1;
+ }
+
+ arr->base = obj;
+
+ return 0;
+}
+
template<class MCData, class T>
PyObject *ToNumPyArray(MCData *self, int npyObjectType, const char *MCDataStr)
{
}
ParaMEDMEM::MemArray<T>& mem=self->accessToMemArray();
int nbComp=self->getNumberOfComponents();
- if(nbComp!=1 && nbComp!=2)
+ if(nbComp==0)
{
- std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : number of components of this is " << nbComp << " ! Should 1 or 2 !";
+ std::ostringstream oss; oss << MCDataStr << "::toNumPyArray : number of components of this is 0 ! Should be > 0 !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- std::size_t sz=self->getNbOfElems();
+ int nbDims=nbComp==1?1:2;
npy_intp dim[2];
- dim[0]=(npy_intp)self->getNumberOfTuples(); dim[1]=2;
+ dim[0]=(npy_intp)self->getNumberOfTuples(); dim[1]=nbComp;
const T *bg=self->getConstPointer();
- PyObject *ret=PyArray_SimpleNewFromData(nbComp,dim,npyObjectType,const_cast<T *>(bg));
+ PyObject *ret=PyArray_SimpleNewFromData(nbDims,dim,npyObjectType,const_cast<T *>(bg));
if(mem.isDeallocatorCalled())
{
- if(mem.getDeallocator()!=ParaMEDMEM::MemArray<T>::CDeallocator)
- {
- int mask=NPY_OWNDATA; mask=~mask;
- (reinterpret_cast<PyArrayObject *>(ret))->flags&=mask;
- return ret;
- }
- else
- {
+ 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*) ParaMEDMEM::MemArray<T>::CDeallocator;
+ void **objs=new void *[2]; objs[0]=ref; objs[1]=(void*) mem.getDeallocator();
mem.setParameterForDeallocator(objs);
mem.setSpecificDeallocator(numarrdeal);
return ret;
}
+ else
+ {// case for the second and other call of toNumPyArray
+ void **objs=(void **)mem.getParameterForDeallocator();
+ PyObject *weakRefOnOwner=(PyObject *)objs[0];
+ PyObject *obj=PyWeakref_GetObject(weakRefOnOwner);
+ if(obj!=Py_None)
+ {//the previous numArray exists let numpy deals the numpy array each other by declaring the still alive instance as base
+ Py_XINCREF(obj);
+ NumpyArrSetBaseObjectExt((PyArrayObject*)ret,obj);
+ }
+ else
+ {//the previous numArray no more exists -> declare the newly created numpy array as the first one.
+ Py_XDECREF(weakRefOnOwner);
+ PyObject *ref=PyWeakref_NewRef(ret,NULL);
+ objs[0]=ref;
+ }
+ }
}
return ret;
}
static PyObject *convertMesh(ParaMEDMEM::MEDCouplingMesh *mesh, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!mesh)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::MEDCouplingUMesh *>(mesh))
ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,owner);
if(dynamic_cast<ParaMEDMEM::MEDCouplingExtrudedMesh *>(mesh))
static PyObject *convertFieldDiscretization(ParaMEDMEM::MEDCouplingFieldDiscretization *fd, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!fd)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationP0 *>(fd))
ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationP0,owner);
if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationP1 *>(fd))
static PyObject *convertDataArrayChar(ParaMEDMEM::DataArrayChar *dac, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!dac)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::DataArrayByte *>(dac))
ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayByte,owner);
if(dynamic_cast<ParaMEDMEM::DataArrayAsciiChar *>(dac))
return ret;
}
+static PyObject *convertDataArray(ParaMEDMEM::DataArray *dac, int owner) throw(INTERP_KERNEL::Exception)
+{
+ PyObject *ret=0;
+ if(!dac)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
+ if(dynamic_cast<ParaMEDMEM::DataArrayDouble *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,owner);
+ if(dynamic_cast<ParaMEDMEM::DataArrayInt *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,owner);
+ if(dynamic_cast<ParaMEDMEM::DataArrayByte *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayByte,owner);
+ if(dynamic_cast<ParaMEDMEM::DataArrayAsciiChar *>(dac))
+ ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayAsciiChar,owner);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("Not recognized type of DataArray on downcast !");
+ return ret;
+}
+
static PyObject* convertMultiFields(ParaMEDMEM::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!mfs)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldOverTime *>(mfs))
ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldOverTime,owner);
else
if(PyList_Check(pyLi))
{
*size=PyList_Size(pyLi);
- double *tmp=new double[*size];
+ double *tmp=(double *)malloc((*size)*sizeof(double));
for(int i=0;i<*size;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
}
else
{
- delete [] tmp;
+ free(tmp);
throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : list must contain floats/integers only");
}
}
else if(PyTuple_Check(pyLi))
{
*size=PyTuple_Size(pyLi);
- double *tmp=new double[*size];
+ double *tmp=(double *)malloc((*size)*sizeof(double));
for(int i=0;i<*size;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
}
else
{
- delete [] tmp;
+ free(tmp);
throw INTERP_KERNEL::Exception("convertPyToNewDblArr2 : tuple must contain floats/integers only");
}
}
{ throw INTERP_KERNEL::Exception(msg); }
}
}
+
+static ParaMEDMEM::DataArray *CheckAndRetrieveDataArrayInstance(PyObject *obj, const char *msg)
+{
+ void *aBasePtrVS=0;
+ int status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArray,0|0);
+ if(!SWIG_IsOK(status))
+ {
+ status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ if(!SWIG_IsOK(status))
+ {
+ status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
+ if(!SWIG_IsOK(status))
+ {
+ status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArrayAsciiChar,0|0);
+ if(!SWIG_IsOK(status))
+ {
+ status=SWIG_ConvertPtr(obj,&aBasePtrVS,SWIGTYPE_p_ParaMEDMEM__DataArrayByte,0|0);
+ std::ostringstream oss; oss << msg << " ! Accepted instances are DataArrayDouble, DataArrayInt, DataArrayAsciiChar, DataArrayByte !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ }
+ return reinterpret_cast< ParaMEDMEM::DataArray * >(aBasePtrVS);
+}
CLEANFILES = MEDCouplingWRAP.cxx MEDCoupling.py MEDCouplingRemapperWRAP.cxx MEDCouplingRemapper.py
-dist_salomescript_DATA= MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCoupling.py MEDCouplingRemapper.py MEDCouplingDataForTest.py MEDCouplingNumpyTest.py libMEDCoupling_Swig.py
+dist_salomescript_DATA= MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCoupling.py MEDCouplingRemapper.py MEDCouplingDataForTest.py MEDCouplingNumPyTest.py libMEDCoupling_Swig.py
UNIT_TEST_PROG = MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py
# Author : Anthony Geay (CEA/DEN)
ADD_SUBDIRECTORY(Swig)
-ADD_SUBDIRECTORY(Test)
+IF(CPPUNIT_STATUS)
+ ADD_SUBDIRECTORY(Test)
+ENDIF(CPPUNIT_STATUS)
INCLUDE_DIRECTORIES(
${MED3_INCLUDE_DIRS}
tmp3->simpleReprWithoutHeader(oss);
}
else
- oss << "params set !!!\n";
+ oss << "No params set !!!\n";
return oss.str();
}
using namespace ParaMEDMEM;
+const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
+const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
+
MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
{
return new MEDFileFieldLoc(fid,locName);
return oss.str();
}
-void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
_type=field->getTypeOfField();
- const DataArrayDouble *da=field->getArray();
_start=start;
switch(_type)
{
case ON_CELLS:
{
- getArray()->setContigPartOfSelectedValues2(_start,da,offset,offset+nbOfCells,1);
+ getArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
_end=_start+nbOfCells;
_nval=nbOfCells;
break;
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
const int *arrPtr=arr->getConstPointer();
- getArray()->setContigPartOfSelectedValues2(_start,da,arrPtr[offset],arrPtr[offset+nbOfCells],1);
+ getArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
_end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
_nval=nbOfCells;
break;
const int *da3Ptr=da3->getConstPointer();
if(da3->getNumberOfTuples()!=nbOfCells)
{//profile : for gauss even in NoProfile !!!
- std::ostringstream oss; oss << "Pfl_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
+ std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
_profile=oss.str();
da3->setName(_profile.c_str());
glob.appendProfile(da3);
for(int j=0;j<nbi;j++)
*da4Ptr++=ref+j;
}
- std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
+ std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
_localization=oss2.str();
- getArray()->setContigPartOfSelectedValues(_start,da,da4);
+ getArray()->setContigPartOfSelectedValues(_start,arrr,da4);
_end=_start+_nval*nbi;
glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
break;
* \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
* \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
*/
-void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
_profile.clear();
_type=field->getTypeOfField();
_profile=oss.str();
}
}
- const DataArrayDouble *da=field->getArray();
_start=start;
switch(_type)
{
case ON_NODES:
{
_nval=idsInPfl->getNumberOfTuples();
- getArray()->setContigPartOfSelectedValues2(_start,da,0,da->getNumberOfTuples(),1);
+ getArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
_end=_start+_nval;
break;
}
case ON_CELLS:
{
_nval=idsInPfl->getNumberOfTuples();
- getArray()->setContigPartOfSelectedValues(_start,da,idsInPfl);
+ getArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
_end=_start+_nval;
break;
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
int trueNval=tmp->getNumberOfTuples();
_nval=idsInPfl->getNumberOfTuples();
- getArray()->setContigPartOfSelectedValues(_start,da,tmp);
+ getArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
_end=_start+trueNval;
break;
}
*tmpPtr++=j;
//
_nval=da4->getNumberOfTuples();
- getArray()->setContigPartOfSelectedValues(_start,da,tmp);
+ getArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
_end=_start+trueNval;
oss << "_loc_" << _loc_id;
if(locIds)
_profile=oss.str();
}
}
- std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
+ std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
_localization=oss2.str();
glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
break;
start=_end;
}
-void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
_start=start;
- _nval=field->getArray()->getNumberOfTuples();
- getArray()->setContigPartOfSelectedValues2(_start,field->getArray(),0,_nval,1);
+ _nval=arrr->getNumberOfTuples();
+ getArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
_end=_start+_nval;
start=_end;
}
return _father;
}
-void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- std::string fieldName=getName();
+ std::string fieldName=nasc.getName();
std::string meshName=getMeshName();
int iteration=getIteration();
int order=getOrder();
}
}
-void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, int ft) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
- std::string fieldName=getName();
+ std::string fieldName=nasc.getName();
std::string meshName=getMeshName();
int iteration=getIteration();
int order=getOrder();
INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
med_geometry_type mgeoti;
med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
- DataArrayDouble *arr=getArray();
- double *startFeeding=arr->getPointer()+_start*arr->getNumberOfComponents();
- switch(ft)
+ DataArray *arr=getArray();
+ DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
+ if(arrD)
{
- case 0:
- {
- MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
- _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
- break;
- }
- case 1:
- {
- INTERP_KERNEL::AutoPtr<int> tmpp=new int[(_end-_start)*arr->getNumberOfComponents()];
- MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
- _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>((int *)tmpp));
- std::copy((const int *)tmpp,(const int *)tmpp+(_end-_start)*arr->getNumberOfComponents(),startFeeding);
- break;
- }
- default:
- throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
+ double *startFeeding=arrD->getPointer()+_start*arrD->getNumberOfComponents();
+ MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
+ _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
+ return ;
+ }
+ DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
+ if(arrI)
+ {
+ int *startFeeding=arrI->getPointer()+_start*arrI->getNumberOfComponents();
+ MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
+ _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
+ return ;
}
+ throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
}
/*!
return _father->getTime();
}
-std::string MEDFileFieldPerMeshPerTypePerDisc::getName() const
-{
- return _father->getName();
-}
-
std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
{
return _father->getMeshName();
return _end-_start;
}
-DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray()
+DataArray *MEDFileFieldPerMeshPerTypePerDisc::getArray()
{
return _father->getArray();
}
-const DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
+const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
{
const MEDFileFieldPerMeshPerType *fath=_father;
return fath->getArray();
}
+DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArrayDouble()
+{
+ return _father->getArrayDouble();
+}
+
+const DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArrayDouble() const
+{
+ const MEDFileFieldPerMeshPerType *fath=_father;
+ return fath->getArrayDouble();
+}
+
const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
{
return _father->getInfo();
startEntryId++;
}
-void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
TypeOfField type=getType();
INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
med_geometry_type mgeoti;
med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
- const DataArrayDouble *arr=getArray();
- const double *locToWrite=arr->getConstPointer()+_start*arr->getNumberOfComponents();
- MEDfieldValueWithProfileWr(fid,getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
+ const DataArray *arr=getArray();
+ if(!arr)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
+ const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
+ const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
+ const unsigned char *locToWrite=0;
+ if(arrD)
+ locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
+ else if(arrI)
+ locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
+ else
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
+ MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
- reinterpret_cast<const unsigned char*>(locToWrite));
+ locToWrite);
}
void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
}
-MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
+MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
- return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType);
+ return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
}
MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
return ret.retn();
}
-void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
- _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
+ _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
}
/*!
* \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
* \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
*/
-void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
- _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,mesh,glob);
+ _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
}
-void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
_field_pm_pt_pd.resize(1);
_field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
- _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,glob);
+ _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
}
-void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
//
_field_pm_pt_pd.resize(1);
_field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
- _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,0,glob);//mesh is not requested so 0 is send.
+ _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
}
std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
return _father->getTime();
}
-std::string MEDFileFieldPerMeshPerType::getName() const
-{
- return _father->getName();
-}
-
std::string MEDFileFieldPerMeshPerType::getMeshName() const
{
return _father->getMeshName();
return _father->getNumberOfComponents();
}
-DataArrayDouble *MEDFileFieldPerMeshPerType::getArray()
+DataArray *MEDFileFieldPerMeshPerType::getArray()
{
return _father->getArray();
}
-const DataArrayDouble *MEDFileFieldPerMeshPerType::getArray() const
+const DataArray *MEDFileFieldPerMeshPerType::getArray() const
{
const MEDFileFieldPerMesh *fath=_father;
return fath->getArray();
}
+DataArrayDouble *MEDFileFieldPerMeshPerType::getArrayDouble()
+{
+ return _father->getArrayDouble();
+}
+
+const DataArrayDouble *MEDFileFieldPerMeshPerType::getArrayDouble() const
+{
+ const MEDFileFieldPerMesh *fath=_father;
+ return fath->getArrayDouble();
+}
+
const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
{
return _father->getInfo();
{
}
-MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
+MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
{
INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
med_geometry_type mgeoti;
med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
- int nbProfiles=MEDfieldnProfile(fid,getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
+ int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
_field_pm_pt_pd.resize(nbProfiles);
for(int i=0;i<nbProfiles;i++)
{
}
}
-void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
int pflId=0;
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
{
- (*it)->prepareLoading(fid,pflId+1,start);
+ (*it)->prepareLoading(fid,pflId+1,start,nasc);//tony
}
}
-void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
int pflId=0;
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
{
- (*it)->finishLoading(fid,pflId+1,ft);
+ (*it)->finishLoading(fid,pflId+1,nasc);//tony
}
}
-void MEDFileFieldPerMeshPerType::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
{
(*it)->copyOptionsFrom(*this);
- (*it)->writeLL(fid);
+ (*it)->writeLL(fid,nasc);
}
}
return MED_UNDEF_ENTITY_TYPE;
}
-MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception)
+MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
- return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder);
+ return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
}
-MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
+MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
{
return new MEDFileFieldPerMesh(fath,mesh);
}
return ret;
}
-MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
+MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
ret->_father=father;
mesh->getTime(_mesh_iteration,_mesh_order);
}
-void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
int nbOfTypes=code.size()/3;
int offset=0;
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
int nbOfCells=code[3*i+1];
int pos=addNewEntryIfNecessary(type);
- _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
+ _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
offset+=nbOfCells;
}
}
* \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
* \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
*/
-void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
int nbOfTypes=code.size()/3;
for(int i=0;i<nbOfTypes;i++)
break;
if(found==nbOfTupes2)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
- _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,mesh,glob);
+ _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
}
}
-void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
- _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,glob);
+ _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
}
-void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
- _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,glob);
+ _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
}
-void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
- (*it)->prepareLoading(fid,start);
+ (*it)->prepareLoading(fid,start,nasc);
}
-void MEDFileFieldPerMesh::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
- (*it)->finishLoading(fid,ft);
+ (*it)->finishLoading(fid,nasc);
}
-void MEDFileFieldPerMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
int nbOfTypes=_field_pm_pt.size();
for(int i=0;i<nbOfTypes;i++)
{
_field_pm_pt[i]->copyOptionsFrom(*this);
- _field_pm_pt[i]->writeLL(fid);
+ _field_pm_pt[i]->writeLL(fid,nasc);
}
}
return _father->getIteration();
}
-const std::string& MEDFileFieldPerMesh::getDtUnit() const
-{
- return _father->getDtUnit();
-}
-
int MEDFileFieldPerMesh::getOrder() const
{
return _father->getOrder();
}
-std::string MEDFileFieldPerMesh::getName() const
+int MEDFileFieldPerMesh::getNumberOfComponents() const
{
- return _father->getName();
+ return _father->getNumberOfComponents();
}
-int MEDFileFieldPerMesh::getNumberOfComponents() const
+DataArray *MEDFileFieldPerMesh::getArray()
{
- return _father->getNumberOfComponents();
+ if(!_father)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
+ return _father->getOrCreateAndGetArray();
}
-DataArrayDouble *MEDFileFieldPerMesh::getArray()
+const DataArray *MEDFileFieldPerMesh::getArray() const
{
+ if(!_father)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
return _father->getOrCreateAndGetArray();
}
-const DataArrayDouble *MEDFileFieldPerMesh::getArray() const
+DataArrayDouble *MEDFileFieldPerMesh::getArrayDouble()
+{
+ MEDFileField1TSWithoutSDA *fatherC=dynamic_cast<MEDFileField1TSWithoutSDA *>(_father);
+ if(!fatherC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArrayDouble : Expected to be called on double array !");
+ return fatherC->getOrCreateAndGetArrayDouble();
+}
+
+const DataArrayDouble *MEDFileFieldPerMesh::getArrayDouble() const
{
- const MEDFileField1TSWithoutSDA *fath=_father;
- return fath->getOrCreateAndGetArray();
+ const MEDFileField1TSWithoutSDA *fatherC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(_father);
+ if(!fatherC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArrayDouble : Expected to be called on double array !");
+ return fatherC->getOrCreateAndGetArrayDouble();
}
const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
- DataArrayDouble *arr=getUndergroundDataArrayExt(entries);
+ getUndergroundDataArrayExt(entries);
+ DataArrayDouble *arr=getArrayDouble();
int sz=0;
if(!arr)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
/*!
* \param [in] mesh is the whole mesh
*/
-MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
if(_field_pm_pt.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
if(code.empty())
{
- std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
+ std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
//
{
DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
if(!arr)
- return finishField(type,glob,dads,locs,mesh,isPfl);
+ return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
else
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
- return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl);
+ return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
}
}
else
oss << " nodes in mesh !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- return finishField(type,glob,dads,locs,mesh,isPfl);
+ return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
}
else
- return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl);
+ return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
}
}
-DataArrayDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
+DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
if(_field_pm_pt.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
if(code.empty())
{
- std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
+ std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
return 0;
}
-DataArrayDouble *MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
{
int globalSz=0;
int nbOfEntries=0;
{
(*it)->fillValues(nbOfEntries,entries);
}
- return _father->getUndergroundDataArray();
}
MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
*/
MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
- const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
+ const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
isPfl=false;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
- ret->setMesh(mesh); ret->setName(getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(getDtUnit().c_str());
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
+ ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
+ MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
const std::vector<std::string>& infos=getInfo();
da->setInfoOnComponents(infos);
da->setName("");
- ret->setArray(da);
if(type==ON_GAUSS_PT)
{
int offset=0;
offset+=nbOfElems;
}
}
- //
+ arrOut=da;
return ret.retn();
}
MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
- const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
+ const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
if(da->isIdentity())
{
int nbOfTuples=da->getNumberOfTuples();
if(nbOfTuples==mesh->getNumberOfCells())
- return finishField(type,glob,dads,locs,mesh,isPfl);
+ return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
}
MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
m2->setName(mesh->getName());
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
isPfl=true;
return ret.retn();
}
*/
MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
- const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
+ const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
if(da->isIdentity())
{
int nbOfTuples=da->getNumberOfTuples();
if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
- return finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
+ return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
}
// Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
{
if(meshu->getNodalConnectivity()==0)
{
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
int nb=da->getNbOfElems();
const int *ptr=da->getConstPointer();
MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
meshuc->finishInsertingCells();
ret->setMesh(meshuc);
- ret->checkCoherency();
+ const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
+ if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
+ disc->checkCoherencyBetween(meshuc,arrOut);
return ret.retn();
}
}
//
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
isPfl=true;
DataArrayInt *arr2=0;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
if(nnodes==(int)da->getNbOfElems())
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
- ret->getArray()->renumberInPlace(da3->getConstPointer());
+ arrOut->renumberInPlace(da3->getConstPointer());
mesh2->setName(mesh->getName());
ret->setMesh(mesh2);
return ret.retn();
/*!
* This method is the most light method of field retrieving.
*/
-DataArrayDouble *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
+DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
{
if(!pflIn)
{
pflOut->incrRef();
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
+ MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
const std::vector<std::string>& infos=getInfo();
int nbOfComp=infos.size();
for(int i=0;i<nbOfComp;i++)
return da.retn();
}
-MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
- _mesh_csit(meshCsit),_father(fath)
+MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
+ _mesh_csit(meshCsit),_father(fath)
{
INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
{
- int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
+ int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
if(nbProfile>0)
{
- _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i]));
+ _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
_mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
}
- nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
+ nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
if(nbProfile>0)
{
- _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i]));
+ _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
_mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
}
}
- int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
+ int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
if(nbProfile>0)
{
- _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR));
+ _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
_mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
}
}
-MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
+MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
{
copyTinyInfoFrom(mesh);
}
}
}
+void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
+ getProfile((*it).c_str());
+}
+
+void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
+ getLocalization((*it).c_str());
+}
+
void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
{
std::vector<std::string> profiles=real.getPflsReallyUsed();
return ret.retn();
}
+/*!
+ * \throw if a profile in \a pfls in not in \a this.
+ * \throw if a localization in \a locs in not in \a this.
+ * \sa MEDFileFieldGlobs::deepCpyPart
+ */
+MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
+ for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
+ {
+ DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
+ if(!pfl)
+ throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
+ pfl->incrRef();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
+ ret->_pfls.push_back(pfl2);
+ }
+ for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
+ {
+ MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
+ if(!loc)
+ throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
+ loc->incrRef();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
+ ret->_locs.push_back(loc2);
+ }
+ ret->setFileName(getFileName());
+ return ret.retn();
+}
+
+/*!
+ * \throw if a profile in \a pfls in not in \a this.
+ * \throw if a localization in \a locs in not in \a this.
+ * \sa MEDFileFieldGlobs::shallowCpyPart
+ */
+MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
+ for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
+ {
+ DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
+ if(!pfl)
+ throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
+ ret->_pfls.push_back(pfl->deepCpy());
+ }
+ for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
+ {
+ MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
+ if(!loc)
+ throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
+ ret->_locs.push_back(loc->deepCpy());
+ }
+ ret->setFileName(getFileName());
+ return ret.retn();
+}
+
MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
{
}
return std::distance(_locs.begin(),it);
}
+/*!
+ * The returned value is never null.
+ */
const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
{
std::string pflNameCpp(pflName);
return getLocalizationFromId(getLocalizationId(locName));
}
+/*!
+ * The returned value is never null.
+ */
DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
{
std::string pflNameCpp(pflName);
* Returns a string describing profiles and Gauss points held in \a this.
* \return std::string - the description string.
*/
-void MEDFileFieldGlobsReal::simpleRepr(std::ostream& oss) const
+void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
{
- oss << "Globals information on fields :" << "\n*******************************\n\n";
const MEDFileFieldGlobs *glob=_globals;
+ std::ostringstream oss2; oss2 << glob;
+ std::string stars(oss2.str().length(),'*');
+ oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
if(glob)
glob->simpleRepr(oss);
else
oss << "NO GLOBAL INFORMATION !\n";
}
+void MEDFileFieldGlobsReal::resetContent()
+{
+ _globals=MEDFileFieldGlobs::New();
+}
+
MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
{
}
_globals=other._globals;
}
+/*!
+ * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
+ * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
+ */
+void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileFieldGlobs *otherg(other._globals);
+ if(!otherg)
+ return ;
+ _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
+}
+
+/*!
+ * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
+ * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
+ */
+void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileFieldGlobs *otherg(other._globals);
+ if(!otherg)
+ return ;
+ _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
+}
+
void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
{
_globals=other._globals;
*/
void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
{
+ const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
+ if(thisGlobals==otherGlobals)
+ return ;
+ if(!thisGlobals)
+ {
+ _globals=other._globals;
+ return ;
+ }
_globals->appendGlobs(*other._globals,eps);
}
+void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ checkGlobsPflsPartCoherency();
+ checkGlobsLocsPartCoherency();
+}
+
+void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
+}
+
+void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
+}
+
void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
{
- _globals->loadProfileInFile(fid,id,pflName);
+ contentNotNull()->loadProfileInFile(fid,id,pflName);
}
void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
{
- _globals->loadProfileInFile(fid,id);
+ contentNotNull()->loadProfileInFile(fid,id);
}
void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
{
- _globals->loadGlobals(fid,*this);
+ contentNotNull()->loadGlobals(fid,*this);
}
void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
{
- _globals->loadAllGlobals(fid);
+ contentNotNull()->loadAllGlobals(fid);
}
void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
{
- _globals->writeGlobals(fid,opt);
+ contentNotNull()->writeGlobals(fid,opt);
}
/*!
*/
std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
{
- return _globals->getPfls();
+ return contentNotNull()->getPfls();
}
/*!
*/
std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
{
- return _globals->getLocs();
+ return contentNotNull()->getLocs();
}
/*!
*/
bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
{
- return _globals->existsPfl(pflName);
+ return contentNotNull()->existsPfl(pflName);
}
/*!
*/
bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
{
- return _globals->existsLoc(locName);
+ return contentNotNull()->existsLoc(locName);
}
std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
{
- return _globals->createNewNameOfPfl();
+ return contentNotNull()->createNewNameOfPfl();
}
std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
{
- return _globals->createNewNameOfLoc();
+ return contentNotNull()->createNewNameOfLoc();
}
/*!
*/
void MEDFileFieldGlobsReal::setFileName(const char *fileName)
{
- _globals->setFileName(fileName);
+ contentNotNull()->setFileName(fileName);
}
/*!
*/
std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
{
- return _globals->whichAreEqualProfiles();
+ return contentNotNull()->whichAreEqualProfiles();
}
/*!
*/
std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
{
- return _globals->whichAreEqualLocs(eps);
+ return contentNotNull()->whichAreEqualLocs(eps);
}
/*!
*/
void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
{
- _globals->changePflsNamesInStruct(mapOfModif);
+ contentNotNull()->changePflsNamesInStruct(mapOfModif);
}
/*!
*/
void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
{
- _globals->changeLocsNamesInStruct(mapOfModif);
+ contentNotNull()->changeLocsNamesInStruct(mapOfModif);
}
/*!
*/
int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
{
- return _globals->getNbOfGaussPtPerCell(locId);
+ return contentNotNull()->getNbOfGaussPtPerCell(locId);
}
/*!
*/
int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
{
- return _globals->getLocalizationId(loc);
+ return contentNotNull()->getLocalizationId(loc);
}
/*!
*/
const char *MEDFileFieldGlobsReal::getFileName() const
{
- return _globals->getFileName();
+ return contentNotNull()->getFileName();
}
std::string MEDFileFieldGlobsReal::getFileName2() const
{
- return _globals->getFileName2();
+ return contentNotNull()->getFileName2();
}
/*!
*/
const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
{
- return _globals->getLocalization(locName);
+ return contentNotNull()->getLocalization(locName);
}
/*!
*/
const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
{
- return _globals->getLocalizationFromId(locId);
+ return contentNotNull()->getLocalizationFromId(locId);
}
/*!
*/
const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
{
- return _globals->getProfile(pflName);
+ return contentNotNull()->getProfile(pflName);
}
/*!
*/
const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
{
- return _globals->getProfileFromId(pflId);
+ return contentNotNull()->getProfileFromId(pflId);
}
/*!
*/
MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
{
- return _globals->getLocalizationFromId(locId);
+ return contentNotNull()->getLocalizationFromId(locId);
}
/*!
*/
MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
{
- return _globals->getLocalization(locName);
+ return contentNotNull()->getLocalization(locName);
}
/*!
*/
DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
{
- return _globals->getProfile(pflName);
+ return contentNotNull()->getProfile(pflName);
}
/*!
*/
DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
{
- return _globals->getProfileFromId(pflId);
+ return contentNotNull()->getProfileFromId(pflId);
}
/*!
*/
void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
{
- _globals->killProfileIds(pflIds);
+ contentNotNull()->killProfileIds(pflIds);
}
/*!
*/
void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
{
- _globals->killLocalizationIds(locIds);
+ contentNotNull()->killLocalizationIds(locIds);
}
/*!
*/
void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
{
- _globals->appendProfile(pfl);
+ contentNotNull()->appendProfile(pfl);
}
/*!
*/
void MEDFileFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
{
- _globals->appendLoc(locName,geoType,refCoo,gsCoo,w);
+ contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
}
-/*!
- * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
- * empty. Returns -1 if this in on nodes.
- * \return int - the dimension of \a this.
- */
-int MEDFileField1TSWithoutSDA::getDimension() const
+MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
{
- int ret=-2;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
- (*it)->getDimension(ret);
- return ret;
+ MEDFileFieldGlobs *g(_globals);
+ if(!g)
+ throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
+ return g;
}
-/*!
- * Throws if a given value is not a valid (non-extended) relative dimension.
- * \param [in] meshDimRelToMax - the relative dimension value.
- * \throw If \a meshDimRelToMax > 0.
- */
-void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
+const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMax>0)
- throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
+ const MEDFileFieldGlobs *g(_globals);
+ if(!g)
+ throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
+ return g;
}
-/*!
- * Checks if elements of a given mesh are in the order suitable for writing
- * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
- * vector describing types of elements and their number.
- * \param [in] mesh - the mesh to check.
- * \return std::vector<int> - a vector holding for each element type (1) item of
- * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
- * These values are in full-interlace mode.
- * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
- */
-std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
-{
- //
- std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
- int nbOfTypes=geoTypes.size();
- std::vector<int> code(3*nbOfTypes);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
- arr1->alloc(nbOfTypes,1);
- int *arrPtr=arr1->getPointer();
- std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
- for(int i=0;i<nbOfTypes;i++,it++)
- arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
- const int *arrPtr2=arr2->getConstPointer();
- int i=0;
- for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
- {
- int pos=arrPtr2[i];
- int nbCells=mesh->getNumberOfCellsWithType(*it);
- code[3*pos]=(int)(*it);
- code[3*pos+1]=nbCells;
- code[3*pos+2]=-1;//no profiles
- }
- std::vector<const DataArrayInt *> idsPerType;//no profiles
- DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
- if(da)
- {
- da->decrRef();
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
- }
- return code;
-}
+//= MEDFileFieldNameScope
-MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos)
+MEDFileFieldNameScope::MEDFileFieldNameScope()
{
- return new MEDFileField1TSWithoutSDA(fieldName,csit,fieldtype,iteration,order,infos);
}
-/*!
- * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
- * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
- * larger by the size of \a field. Returns an id of the first not filled
- * tuple of \a this->_arr.
- * \param [in] field - the field to copy the info on components and the name from.
- * \return int - the id of first not initialized tuple of \a this->_arr.
- * \throw If the name of \a field is empty.
- * \throw If the data array of \a field is not set.
- * \throw If \a this->_arr is already allocated but has different number of components
- * than \a field.
- */
-int MEDFileField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
+MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
{
- std::string name(field->getName());
- getOrCreateAndGetArray()->setName(name.c_str());
- if(name.empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
- const DataArrayDouble *arr=field->getArray();
- if(!arr)
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
- _dt=field->getTime(_iteration,_order);
- int nbOfComponents=arr->getNumberOfComponents();
- getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
- if(!getOrCreateAndGetArray()->isAllocated())
- {
- _arr->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
- return 0;
- }
- else
- {
- int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
- int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=DataArrayDouble::New();
- tmp->alloc(newNbOfTuples,nbOfComponents);
- tmp->copyStringInfoFrom(*_arr);
- std::copy(_arr->begin(),_arr->end(),tmp->getPointer());
- _arr=tmp;
- return oldNbOfTuples;
- }
}
/*!
* Returns the name of \a this field.
* \return std::string - a string containing the field name.
*/
-std::string MEDFileField1TSWithoutSDA::getName() const
+std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
{
- const DataArrayDouble *arr=getOrCreateAndGetArray();
- return arr->getName();
+ return _name;
}
/*!
* Sets name of \a this field
* \param [in] name - the new field name.
*/
-void MEDFileField1TSWithoutSDA::setName(const char *name)
+void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
+{
+ _name=fieldName;
+}
+
+std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
+{
+ return _dt_unit;
+}
+
+void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
+{
+ _dt_unit=dtUnit;
+}
+
+void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
{
- DataArrayDouble *arr=getOrCreateAndGetArray();
- arr->setName(name);
+ _name=other._name;
+ _dt_unit=other._dt_unit;
}
+//= MEDFileAnyTypeField1TSWithoutSDA
+
/*!
* Prints a string describing \a this field into a stream. This string is outputted
* by \c print Python command.
* \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
* info id printed, else, not.
*/
-void MEDFileField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
+void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
{
std::string startOfLine(bkOffset,' ');
- oss << startOfLine << "Field on One time Step ";
+ oss << startOfLine << "Field ";
+ if(bkOffset==0)
+ oss << "[Type=" << getTypeStr() << "] ";
+ oss << "on One time Step ";
if(f1tsId>=0)
oss << "(" << f1tsId << ") ";
oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
- const DataArrayDouble *arr=_arr;
+ const DataArray *arr=getUndergroundDataArray();
if(arr)
{
const std::vector<std::string> &comps=arr->getInfoOnComponents();
oss << startOfLine << "----------------------" << std::endl;
}
+std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
+{
+ const DataArray *arr(getUndergroundDataArray());
+ if(!arr)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
+ int nbOfCompo=arr->getNumberOfComponents();
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
+ for(int i=0;i<nbOfCompo;i++)
+ {
+ ret[i]=deepCpy();
+ std::vector<int> v(1,i);
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
+ ret[i]->setArray(arr2);
+ }
+ return ret;
+}
+
+MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit)
+{
+}
+
+MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1)
+{
+}
+
+/*!
+ * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
+ * empty. Returns -1 if this in on nodes.
+ * \return int - the dimension of \a this.
+ */
+int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
+{
+ int ret=-2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ (*it)->getDimension(ret);
+ return ret;
+}
+
/*!
* Returns the mesh name.
* \return std::string - a string holding the mesh name.
* \throw If \c _field_per_mesh.empty()
*/
-std::string MEDFileField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
+std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
{
if(_field_per_mesh.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
return _field_per_mesh[0]->getMeshName();
}
-void MEDFileField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
+void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
{
std::string oldName(getMeshName());
std::vector< std::pair<std::string,std::string> > v(1);
changeMeshNames(v);
}
-bool MEDFileField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
{
bool ret=false;
for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
return ret;
}
-bool MEDFileField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
- MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
-{
- bool ret=false;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
- {
- MEDFileFieldPerMesh *fpm(*it);
- if(fpm)
- ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
- }
- return ret;
-}
-
/*!
* Returns the number of iteration of the state of underlying mesh.
* \return int - the iteration number.
* \throw If \c _field_per_mesh.empty()
*/
-int MEDFileField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
{
if(_field_per_mesh.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
* \return int - the order number.
* \throw If \c _field_per_mesh.empty()
*/
-int MEDFileField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
{
if(_field_per_mesh.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
return _field_per_mesh[0]->getMeshOrder();
}
-/*!
- * Returns number of components in \a this field
- * \return int - the number of components.
- */
-int MEDFileField1TSWithoutSDA::getNumberOfComponents() const
-{
- return getOrCreateAndGetArray()->getNumberOfComponents();
-}
-
/*!
* Checks if \a this field is tagged by a given iteration number and a given
* iteration order number.
* \return bool - \c true if \a this->getIteration() == \a iteration &&
* \a this->getOrder() == \a order.
*/
-bool MEDFileField1TSWithoutSDA::isDealingTS(int iteration, int order) const
+bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
{
return iteration==_iteration && order==_order;
}
* \return std::pair<int,int> - a pair of the iteration number and the iteration
* order number.
*/
-std::pair<int,int> MEDFileField1TSWithoutSDA::getDtIt() const
+std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
{
std::pair<int,int> p;
fillIteration(p);
* \param [in,out] p - a pair returning the iteration number and the iteration
* order number.
*/
-void MEDFileField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
+void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
{
p.first=_iteration;
p.second=_order;
* Returns all types of spatial discretization of \a this field.
* \param [in,out] types - a sequence of types of \a this field.
*/
-void MEDFileField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
+void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
{
std::set<TypeOfField> types2;
for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
}
/*!
- * Returns info on components of \a this field.
- * \return const std::vector<std::string>& - a sequence of strings each being an
- * information on _i_-th component.
- */
-const std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo() const
-{
- const DataArrayDouble *arr=getOrCreateAndGetArray();
- return arr->getInfoOnComponents();
+ * Returns all types of spatial discretization of \a this field.
+ * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
+ * of \a this field.
+ */
+std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<TypeOfField> ret;
+ fillTypesOfFieldAvailable(ret);
+ return ret;
+}
+
+std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
+{
+ std::vector<std::string> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
+ ret.insert(ret.end(),tmp.begin(),tmp.end());
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
+ ret.insert(ret.end(),tmp.begin(),tmp.end());
+ }
+ return ret;
+}
+
+void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ (*it)->changePflsRefsNamesGen(mapOfModif);
+}
+
+void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ (*it)->changeLocsRefsNamesGen(mapOfModif);
}
/*!
- * Returns a mutable info on components of \a this field.
- * \return std::vector<std::string>& - a sequence of strings each being an
- * information on _i_-th component.
+ * Returns all attributes of parts of \a this field lying on a given mesh.
+ * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
+ * item of every of returned sequences refers to the _i_-th part of \a this field.
+ * Thus all sequences returned by this method are of the same length equal to number
+ * of different types of supporting entities.<br>
+ * A field part can include sub-parts with several different spatial discretizations,
+ * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
+ * for example. Hence, some of the returned sequences contains nested sequences, and an item
+ * of a nested sequence corresponds to a type of spatial discretization.<br>
+ * This method allows for iteration over MEDFile DataStructure without any overhead.
+ * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
+ * for the case with only one underlying mesh. (Actually, the number of meshes is
+ * not checked if \a mname == \c NULL).
+ * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
+ * a field part is returned.
+ * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
+ * This sequence is of the same length as \a types.
+ * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
+ * discretization. A profile name can be empty.
+ * Length of this and of nested sequences is the same as that of \a typesF.
+ * \param [in,out] locs - a sequence returning a localization name per each type of spatial
+ * discretization. A localization name can be empty.
+ * Length of this and of nested sequences is the same as that of \a typesF.
+ * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
+ * of ids of tuples within the data array, per each type of spatial
+ * discretization within one mesh entity type.
+ * Length of this and of nested sequences is the same as that of \a typesF.
+ * \throw If no field is lying on \a mname.
*/
-std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo()
+std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
{
- DataArrayDouble *arr=getOrCreateAndGetArray();
- return arr->getInfoOnComponents();
+ int meshId=0;
+ if(mname)
+ meshId=getMeshIdFromMeshName(mname);
+ else
+ if(_field_per_mesh.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
+ return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
}
/*!
* \return int - the maximal absolute dimension of elements \a this fields lies on.
* \throw If no field is lying on \a mname.
*/
-int MEDFileField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
{
levs.clear();
int meshId=getMeshIdFromMeshName(mname);
}
/*!
- * Returns all types of spatial discretization of \a this field.
- * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
- * of \a this field.
+ * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
+ * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
+ * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
+ * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
*/
-std::vector<TypeOfField> MEDFileField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
{
- std::vector<TypeOfField> ret;
- fillTypesOfFieldAvailable(ret);
- return ret;
+ int mid=getMeshIdFromMeshName(mName);
+ return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
}
/*!
- * Returns all attributes of parts of \a this field lying on a given mesh.
- * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
- * item of every of returned sequences refers to the _i_-th part of \a this field.
- * Thus all sequences returned by this method are of the same length equal to number
- * of different types of supporting entities.<br>
- * A field part can include sub-parts with several different spatial discretizations,
- * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
- * for example. Hence, some of the returned sequences contains nested sequences, and an item
- * of a nested sequence corresponds to a type of spatial discretization.<br>
- * This method allows for iteration over MEDFile DataStructure without any overhead.
- * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
- * for the case with only one underlying mesh. (Actually, the number of meshes is
- * not checked if \a mname == \c NULL).
- * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
- * a field part is returned.
- * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
- * This sequence is of the same length as \a types.
- * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
- * discretization. A profile name can be empty.
- * Length of this and of nested sequences is the same as that of \a typesF.
- * \param [in,out] locs - a sequence returning a localization name per each type of spatial
- * discretization. A localization name can be empty.
- * Length of this and of nested sequences is the same as that of \a typesF.
- * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
- * of ids of tuples within the data array, per each type of spatial
- * discretization within one mesh entity type.
- * Length of this and of nested sequences is the same as that of \a typesF.
- * \throw If no field is lying on \a mname.
+ * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
+ * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
+ * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
+ * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
*/
-std::vector< std::vector< std::pair<int,int> > > MEDFileField1TSWithoutSDA::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
+const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
{
- int meshId=0;
- if(mname)
- meshId=getMeshIdFromMeshName(mname);
- else
- if(_field_per_mesh.empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
- return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
+ int mid=getMeshIdFromMeshName(mName);
+ return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
}
/*!
- * Returns all attributes and values of parts of \a this field lying on a given mesh.
- * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
- * item of every of returned sequences refers to the _i_-th part of \a this field.
- * Thus all sequences returned by this method are of the same length equal to number
- * of different types of supporting entities.<br>
- * A field part can include sub-parts with several different spatial discretizations,
- * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
- * for example. Hence, some of the returned sequences contains nested sequences, and an item
- * of a nested sequence corresponds to a type of spatial discretization.<br>
- * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
- * The overhead is due to selecting values into new instances of DataArrayDouble.
- * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
- * for the case with only one underlying mesh. (Actually, the number of meshes is
- * not checked if \a mname == \c NULL).
- * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
- * a field part is returned.
- * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
- * A field part can include sub-parts with several different spatial discretizations,
- * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
- * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
- * This sequence is of the same length as \a types.
- * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
- * discretization. A profile name can be empty.
- * Length of this and of nested sequences is the same as that of \a typesF.
- * \param [in,out] locs - a sequence returning a localization name per each type of spatial
- * discretization. A localization name can be empty.
- * Length of this and of nested sequences is the same as that of \a typesF.
- * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
- * per each type of spatial discretization within one mesh entity type.
- * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
- * Length of this and of nested sequences is the same as that of \a typesF.
- * \throw If no field is lying on \a mname.
+ * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
*/
-std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
{
- int meshId=0;
- if(mname)
- meshId=getMeshIdFromMeshName(mname);
- else
- if(_field_per_mesh.empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
- std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
- int nbOfRet=ret0.size();
- std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
- for(int i=0;i<nbOfRet;i++)
- {
- const std::vector< std::pair<int,int> >& p=ret0[i];
- int nbOfRet1=p.size();
- ret[i].resize(nbOfRet1);
- for(int j=0;j<nbOfRet1;j++)
- {
- DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
- ret[i][j]=tmp;
- }
- }
- return ret;
+ if(_field_per_mesh.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
+ if(mName==0)
+ return 0;
+ std::string mName2(mName);
+ int ret=0;
+ std::vector<std::string> msg;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
+ if(mName2==(*it)->getMeshName())
+ return ret;
+ else
+ msg.push_back((*it)->getMeshName());
+ std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
+ oss << "Possible meshes are : ";
+ for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
+ oss << "\"" << (*it2) << "\" ";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
-void MEDFileField1TSWithoutSDA::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
{
- med_int numdt,numit;
- med_float dt;
- med_int nmesh;
- med_bool localMesh;
- med_int meshnumdt,meshnumit;
- INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- MEDfieldComputingStepInfo(fid,getName().c_str(),_csit,&numdt,&numit,&_dt);
- MEDfield23ComputingStepMeshInfo(fid,getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
- if(_iteration!=numdt || _order!=numit)
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
- _field_per_mesh.resize(nmesh);
- for(int i=0;i<nmesh;i++)
- _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit);
- int start=0;
- for(int i=0;i<nmesh;i++)
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
+ std::string tmp(mesh->getName());
+ if(tmp.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
+ int i=0;
+ for(;it!=_field_per_mesh.end();it++,i++)
{
- _field_per_mesh[i]->prepareLoading(fid,start);
- }
- getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
- for(int i=0;i<nmesh;i++)
- {
- _field_per_mesh[i]->finishLoading(fid,_field_type);
+ if((*it)->getMeshName()==tmp)
+ return i;
}
+ int sz=_field_per_mesh.size();
+ _field_per_mesh.resize(sz+1);
+ _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
+ return sz;
}
-std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsed2() const
+bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
+ MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
- std::vector<std::string> ret;
- std::set<std::string> ret2;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ bool ret=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
{
- std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
- for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
- if(ret2.find(*it2)==ret2.end())
- {
- ret.push_back(*it2);
- ret2.insert(*it2);
- }
+ MEDFileFieldPerMesh *fpm(*it);
+ if(fpm)
+ ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
}
return ret;
}
-std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsed2() const
+void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
- std::vector<std::string> ret;
- std::set<std::string> ret2;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
- {
- std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
- for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
- if(ret2.find(*it2)==ret2.end())
- {
- ret.push_back(*it2);
- ret2.insert(*it2);
- }
- }
- return ret;
+ if(_field_per_mesh.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
+ if(_field_per_mesh.size()>1)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
+ _field_per_mesh[0]->copyOptionsFrom(opts);
+ _field_per_mesh[0]->writeLL(fid,nasc);
}
-std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsedMulti2() const
+void MEDFileAnyTypeField1TSWithoutSDA::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
- std::vector<std::string> ret;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ med_int numdt,numit;
+ med_float dt;
+ med_int nmesh;
+ med_bool localMesh;
+ med_int meshnumdt,meshnumit;
+ INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
+ MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
+ if(_iteration!=numdt || _order!=numit)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
+ _field_per_mesh.resize(nmesh);
+ for(int i=0;i<nmesh;i++)
+ _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
+ int start=0;
+ for(int i=0;i<nmesh;i++)
{
- std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
- ret.insert(ret.end(),tmp.begin(),tmp.end());
+ _field_per_mesh[i]->prepareLoading(fid,start,nasc);
}
- return ret;
-}
-
-std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsedMulti2() const
-{
- std::vector<std::string> ret;
- std::set<std::string> ret2;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
+ for(int i=0;i<nmesh;i++)
{
- std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
- ret.insert(ret.end(),tmp.begin(),tmp.end());
+ _field_per_mesh[i]->finishLoading(fid,nasc);
}
- return ret;
-}
-
-void MEDFileField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
-{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
- (*it)->changePflsRefsNamesGen(mapOfModif);
-}
-
-void MEDFileField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
-{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
- (*it)->changeLocsRefsNamesGen(mapOfModif);
}
-void MEDFileField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
+std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
{
- if(_field_per_mesh.empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
- if(_field_per_mesh.size()>1)
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
- _field_per_mesh[0]->copyOptionsFrom(opts);
- _field_per_mesh[0]->writeLL(fid);
+ std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
+ if(getUndergroundDataArray())
+ ret+=getUndergroundDataArray()->getHeapMemorySize();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ ret+=(*it)->getHeapMemorySize();
+ return ret;
}
/*!
* Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
* checked if its elements are sorted suitable for writing to MED file ("STB" stands for
* "Sort By Type"), if not, an exception is thrown.
- * \param [in] field - the field to add to \a this.
+ * \param [in] field - the field to add to \a this. The array of field \a field is ignored
+ * \param [in] arr - the array of values.
* \param [in,out] glob - the global data where profiles and localization present in
* \a field, if any, are added.
* \throw If the name of \a field is empty.
* \throw If the underlying mesh of \a field has no name.
* \throw If elements in the mesh are not in the order suitable for writing to the MED file.
*/
-void MEDFileField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingMesh *mesh=field->getMesh();
//
TypeOfField type=field->getTypeOfField();
std::vector<DataArrayInt *> dummy;
- int start=copyTinyInfoFrom(field);
+ int start=copyTinyInfoFrom(field,arr);
int pos=addNewEntryIfNecessary(mesh);
if(type!=ON_NODES)
{
std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
- _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,glob);
+ _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
}
else
- _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,glob);
+ _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
}
/*!
* is not prescribed; this method permutes field values to have them sorted by element
* type as required for writing to MED file. A new profile is added only if no equal
* profile is missing.
- * \param [in] field - the field to add to \a this.
+ * \param [in] field - the field to add to \a this. The field double values are ignored.
+ * \param [in] arrOfVals - the values of the field \a field used.
* \param [in] mesh - the supporting mesh of \a field.
* \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
* \param [in] profile - ids of mesh entities on which corresponding field values lie.
* \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
* \sa setFieldNoProfileSBT()
*/
-void MEDFileField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
{
TypeOfField type=field->getTypeOfField();
- int start=copyTinyInfoFrom(field);
+ int start=copyTinyInfoFrom(field,arrOfVals);
std::vector<DataArrayInt *> idsInPflPerType;
std::vector<DataArrayInt *> idsPerType;
std::vector<int> code,code2;
idsPerType2[i]=idsPerType[i];
//
int pos=addNewEntryIfNecessary(m);
- _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,m,glob);
+ _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
}
else
{
int pos=addNewEntryIfNecessary(m);
- _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,glob);
+ _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
+ }
+}
+
+/*!
+ * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
+ * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
+ * larger by the size of \a field. Returns an id of the first not filled
+ * tuple of \a this->_arr.
+ * \param [in] field - the field to copy the info on components and the name from.
+ * \return int - the id of first not initialized tuple of \a this->_arr.
+ * \throw If the name of \a field is empty.
+ * \throw If the data array of \a field is not set.
+ * \throw If \a this->_arr is already allocated but has different number of components
+ * than \a field.
+ */
+int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
+{
+ if(!field)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
+ std::string name(field->getName());
+ setName(name.c_str());
+ setDtUnit(field->getTimeUnit());
+ if(name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
+ if(!arr)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
+ _dt=field->getTime(_iteration,_order);
+ int nbOfComponents=arr->getNumberOfComponents();
+ getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
+ if(!getOrCreateAndGetArray()->isAllocated())
+ {
+ getOrCreateAndGetArray()->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
+ return 0;
+ }
+ else
+ {
+ int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
+ int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArray> tmp=createNewEmptyDataArrayInstance();
+ tmp->alloc(newNbOfTuples,nbOfComponents);
+ tmp->copyStringInfoFrom(*getOrCreateAndGetArray());
+ DataArray *arrr=getOrCreateAndGetArray();
+ tmp->setContigPartOfSelectedValues2(0,arrr,0,oldNbOfTuples,1);
+ setArray(tmp);
+ return oldNbOfTuples;
}
}
+/*!
+ * Returns number of components in \a this field
+ * \return int - the number of components.
+ */
+int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
+{
+ return getOrCreateAndGetArray()->getNumberOfComponents();
+}
+
+/*!
+ * Change info on components in \a this.
+ * \throw If size of \a infos is not equal to the number of components already in \a this.
+ */
+void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
+{
+ DataArray *arr=getOrCreateAndGetArray();
+ arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
+}
+
+/*!
+ * Returns info on components of \a this field.
+ * \return const std::vector<std::string>& - a sequence of strings each being an
+ * information on _i_-th component.
+ */
+const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
+{
+ const DataArray *arr=getOrCreateAndGetArray();
+ return arr->getInfoOnComponents();
+}
+
+/*!
+ * Returns a mutable info on components of \a this field.
+ * \return std::vector<std::string>& - a sequence of strings each being an
+ * information on _i_-th component.
+ */
+std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
+{
+ DataArray *arr=getOrCreateAndGetArray();
+ return arr->getInfoOnComponents();
+}
+
/*!
* Returns a new MEDCouplingFieldDouble of given type lying on a given support.
* \param [in] type - a spatial discretization of the new field.
* \throw If no field of \a this is lying on the mesh \a mName.
* \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
*/
-MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
if(mName==0)
mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
else
mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
- return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
+ return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
}
/*!
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
* \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
*/
-MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
if(meshDimRelToMax==1)
(static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
- return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e);
+ return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
}
/*!
* \throw If there are no mesh entities in the mesh.
* \throw If no field values of the given \a type are available.
*/
-MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
if(mName==0)
mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
int absDim=getDimension();
int meshDimRelToMax=absDim-mm->getMeshDimension();
- return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
+ return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
}
/*!
* \throw If no field of \a this is lying on \a mesh.
* \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
*/
-MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
int meshId=getMeshIdFromMeshName(mesh->getName());
bool isPfl=false;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
switch(renumPol)
{
case 0:
oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- ret->renumberCells(cellRenum->getConstPointer(),true);
+ MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
+ if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
+ std::vector<DataArray *> arrOut2(1,arrOut);
+ // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
+ disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
+ (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
}
if(renumPol==1)
return ret.retn();
if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
{
std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
- oss << "\"" << getName() << "\" not defined on all nodes !";
+ oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
+ if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
ret->renumberNodes(nodeRenumSafe->getConstPointer());
}
return ret.retn();
* \throw If no field of \a this is lying on \a mesh.
* \throw If no field values of the given \a type are available.
*/
-DataArrayDouble *MEDFileField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
+DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
int meshId=getMeshIdFromMeshName(mesh->getName());
- return _field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob);
+ MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
+ ret->setName(nasc.getName().c_str());
+ return ret.retn();
}
+//= MEDFileField1TSWithoutSDA
+
/*!
- * Returns a pointer to the underground DataArrayDouble instance. So the
- * caller should not decrRef() it. This method allows for a direct access to the field
- * values. This method is quite unusable if there is more than a nodal field or a cell
- * field on single geometric cell type.
- * \return DataArrayDouble * - the pointer to the field values array.
+ * Throws if a given value is not a valid (non-extended) relative dimension.
+ * \param [in] meshDimRelToMax - the relative dimension value.
+ * \throw If \a meshDimRelToMax > 0.
*/
-DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
+void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
{
- const DataArrayDouble *ret=_arr;
- if(ret)
- return const_cast<DataArrayDouble *>(ret);
- else
- return 0;
+ if(meshDimRelToMax>0)
+ throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
}
/*!
- * Returns a pointer to the underground DataArrayDouble instance and a
- * sequence describing parameters of a support of each part of \a this field. The
- * caller should not decrRef() the returned DataArrayDouble. This method allows for a
- * direct access to the field values. This method is intended for the field lying on one
- * mesh only.
- * \param [in,out] entries - the sequence describing parameters of a support of each
- * part of \a this field. Each item of this sequence consists of two parts. The
- * first part describes a type of mesh entity and an id of discretization of a
- * current field part. The second part describes a range of values [begin,end)
- * within the returned array relating to the current field part.
- * \return DataArrayDouble * - the pointer to the field values array.
- * \throw If the number of underlying meshes is not equal to 1.
- * \throw If no field values are available.
- * \sa getUndergroundDataArray()
+ * Checks if elements of a given mesh are in the order suitable for writing
+ * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
+ * vector describing types of elements and their number.
+ * \param [in] mesh - the mesh to check.
+ * \return std::vector<int> - a vector holding for each element type (1) item of
+ * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
+ * These values are in full-interlace mode.
+ * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
*/
-DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
-{
- if(_field_per_mesh.size()!=1)
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
- if(_field_per_mesh[0]==0)
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
- return _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
-}
-
-MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int fieldtype, int iteration, int order,
- const std::vector<std::string>& infos):_iteration(iteration),_order(order),_csit(csit),_field_type(fieldtype)
-{
- DataArrayDouble *arr=getOrCreateAndGetArray();
- arr->setName(fieldName);
- arr->setInfoAndChangeNbOfCompo(infos);
-}
-
-MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():_csit(-1),_field_type(-1)
-{
-}
-
-int MEDFileField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
+std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
{
- std::string tmp(mesh->getName());
- if(tmp.empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
- std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
+ std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
+ int nbOfTypes=geoTypes.size();
+ std::vector<int> code(3*nbOfTypes);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
+ arr1->alloc(nbOfTypes,1);
+ int *arrPtr=arr1->getPointer();
+ std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
+ for(int i=0;i<nbOfTypes;i++,it++)
+ arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
+ const int *arrPtr2=arr2->getConstPointer();
int i=0;
- for(;it!=_field_per_mesh.end();it++,i++)
+ for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
{
- if((*it)->getMeshName()==tmp)
- return i;
+ int pos=arrPtr2[i];
+ int nbCells=mesh->getNumberOfCellsWithType(*it);
+ code[3*pos]=(int)(*it);
+ code[3*pos+1]=nbCells;
+ code[3*pos+2]=-1;//no profiles
}
- int sz=_field_per_mesh.size();
- _field_per_mesh.resize(sz+1);
- _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
- return sz;
+ std::vector<const DataArrayInt *> idsPerType;//no profiles
+ DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
+ if(da)
+ {
+ da->decrRef();
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
+ }
+ return code;
}
-/*!
- * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
- */
-int MEDFileField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
+MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
{
- if(_field_per_mesh.empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
- if(mName==0)
- return 0;
- std::string mName2(mName);
- int ret=0;
- std::vector<std::string> msg;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
- if(mName2==(*it)->getMeshName())
- return ret;
- else
- msg.push_back((*it)->getMeshName());
- std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
- oss << "Possible meshes are : ";
- for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
- oss << "\"" << (*it2) << "\" ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
}
/*!
- * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
- * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
- * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
- * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
+ * Returns all attributes and values of parts of \a this field lying on a given mesh.
+ * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
+ * item of every of returned sequences refers to the _i_-th part of \a this field.
+ * Thus all sequences returned by this method are of the same length equal to number
+ * of different types of supporting entities.<br>
+ * A field part can include sub-parts with several different spatial discretizations,
+ * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
+ * for example. Hence, some of the returned sequences contains nested sequences, and an item
+ * of a nested sequence corresponds to a type of spatial discretization.<br>
+ * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
+ * The overhead is due to selecting values into new instances of DataArrayDouble.
+ * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
+ * for the case with only one underlying mesh. (Actually, the number of meshes is
+ * not checked if \a mname == \c NULL).
+ * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
+ * a field part is returned.
+ * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
+ * A field part can include sub-parts with several different spatial discretizations,
+ * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
+ * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
+ * This sequence is of the same length as \a types.
+ * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
+ * discretization. A profile name can be empty.
+ * Length of this and of nested sequences is the same as that of \a typesF.
+ * \param [in,out] locs - a sequence returning a localization name per each type of spatial
+ * discretization. A localization name can be empty.
+ * Length of this and of nested sequences is the same as that of \a typesF.
+ * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
+ * per each type of spatial discretization within one mesh entity type.
+ * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
+ * Length of this and of nested sequences is the same as that of \a typesF.
+ * \throw If no field is lying on \a mname.
*/
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
+std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
{
- int mid=getMeshIdFromMeshName(mName);
- return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
+ int meshId=0;
+ if(mname)
+ meshId=getMeshIdFromMeshName(mname);
+ else
+ if(_field_per_mesh.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
+ std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
+ int nbOfRet=ret0.size();
+ std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
+ for(int i=0;i<nbOfRet;i++)
+ {
+ const std::vector< std::pair<int,int> >& p=ret0[i];
+ int nbOfRet1=p.size();
+ ret[i].resize(nbOfRet1);
+ for(int j=0;j<nbOfRet1;j++)
+ {
+ DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
+ ret[i][j]=tmp;
+ }
+ }
+ return ret;
}
/*!
- * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
- * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
- * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
- * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
+ * Returns a pointer to the underground DataArrayDouble instance. So the
+ * caller should not decrRef() it. This method allows for a direct access to the field
+ * values. This method is quite unusable if there is more than a nodal field or a cell
+ * field on single geometric cell type.
+ * \return DataArrayDouble * - the pointer to the field values array.
*/
-const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
{
- int mid=getMeshIdFromMeshName(mName);
- return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
+ const DataArrayDouble *ret=_arr;
+ if(ret)
+ return const_cast<DataArrayDouble *>(ret);
+ else
+ return 0;
}
-std::size_t MEDFileField1TSWithoutSDA::getHeapMemorySize() const
+const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
{
- std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
- if((const DataArrayDouble *)_arr)
- ret+=_arr->getHeapMemorySize();
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
- ret+=(*it)->getHeapMemorySize();
- return ret;
+ return TYPE_STR;
+}
+
+/*!
+ * Returns a pointer to the underground DataArrayDouble instance. So the
+ * caller should not decrRef() it. This method allows for a direct access to the field
+ * values. This method is quite unusable if there is more than a nodal field or a cell
+ * field on single geometric cell type.
+ * \return DataArrayDouble * - the pointer to the field values array.
+ */
+DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
+{
+ return getUndergroundDataArrayDouble();
+}
+
+/*!
+ * Returns a pointer to the underground DataArrayDouble instance and a
+ * sequence describing parameters of a support of each part of \a this field. The
+ * caller should not decrRef() the returned DataArrayDouble. This method allows for a
+ * direct access to the field values. This method is intended for the field lying on one
+ * mesh only.
+ * \param [in,out] entries - the sequence describing parameters of a support of each
+ * part of \a this field. Each item of this sequence consists of two parts. The
+ * first part describes a type of mesh entity and an id of discretization of a
+ * current field part. The second part describes a range of values [begin,end)
+ * within the returned array relating to the current field part.
+ * \return DataArrayDouble * - the pointer to the field values array.
+ * \throw If the number of underlying meshes is not equal to 1.
+ * \throw If no field values are available.
+ * \sa getUndergroundDataArray()
+ */
+DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+{
+ if(_field_per_mesh.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
+ if(_field_per_mesh[0]==0)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
+ _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
+ return getUndergroundDataArrayDouble();
+}
+
+/*!
+ * Returns a pointer to the underground DataArrayDouble instance and a
+ * sequence describing parameters of a support of each part of \a this field. The
+ * caller should not decrRef() the returned DataArrayDouble. This method allows for a
+ * direct access to the field values. This method is intended for the field lying on one
+ * mesh only.
+ * \param [in,out] entries - the sequence describing parameters of a support of each
+ * part of \a this field. Each item of this sequence consists of two parts. The
+ * first part describes a type of mesh entity and an id of discretization of a
+ * current field part. The second part describes a range of values [begin,end)
+ * within the returned array relating to the current field part.
+ * \return DataArrayDouble * - the pointer to the field values array.
+ * \throw If the number of underlying meshes is not equal to 1.
+ * \throw If no field values are available.
+ * \sa getUndergroundDataArray()
+ */
+DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+{
+ return getUndergroundDataArrayDoubleExt(entries);
+}
+
+MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
+ const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
+{
+ DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
+ arr->setInfoAndChangeNbOfCompo(infos);
+}
+
+MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
+{
+}
+
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileField1TSWithoutSDA(*this);
}
-MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=new MEDFileField1TSWithoutSDA(*this);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
if((const DataArrayDouble *)_arr)
ret->_arr=_arr->deepCpy();
std::size_t i=0;
return ret.retn();
}
-DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
+void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
+{
+ if(!arr)
+ _arr=0;
+ DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
+ if(!arrC)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
+ arrC->incrRef();
+ _arr=arrC;
+}
+
+DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
+{
+ return DataArrayDouble::New();
+}
+
+DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
{
DataArrayDouble *ret=_arr;
if(ret)
return _arr;
}
-const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
+DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
+{
+ return getOrCreateAndGetArrayDouble();
+}
+
+const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
{
const DataArrayDouble *ret=_arr;
if(ret)
return ret2;
}
-/*!
- * Returns a new instance of MEDFileField1TS holding data of the first time step of
- * the first field that has been read from a specified MED file.
- * \param [in] fileName - the name of the MED file to read.
- * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
- * is to delete this field using decrRef() as it is no more needed.
- * \throw If reading the file fails.
- */
-MEDFileField1TS *MEDFileField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
{
- return new MEDFileField1TS(fileName);
+ return getOrCreateAndGetArrayDouble();
}
-/*!
- * Returns a new instance of MEDFileField1TS holding data of the first time step of
- * a given field that has been read from a specified MED file.
- * \param [in] fileName - the name of the MED file to read.
- * \param [in] fieldName - the name of the field to read.
- * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
- * is to delete this field using decrRef() as it is no more needed.
- * \throw If reading the file fails.
- * \throw If there is no field named \a fieldName in the file.
- */
-MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+//= MEDFileIntField1TSWithoutSDA
+
+MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
+ const std::vector<std::string>& infos)
+{
+ return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
+}
+
+MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
+{
+}
+
+MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
+ const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
+{
+ DataArrayInt *arr=getOrCreateAndGetArrayInt();
+ arr->setInfoAndChangeNbOfCompo(infos);
+}
+
+const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
{
- return new MEDFileField1TS(fileName,fieldName);
+ return TYPE_STR;
}
/*!
- * Returns a new instance of MEDFileField1TS holding data of a given time step of
- * a given field that has been read from a specified MED file.
- * \param [in] fileName - the name of the MED file to read.
- * \param [in] fieldName - the name of the field to read.
- * \param [in] iteration - the iteration number of a required time step.
- * \param [in] order - the iteration order number of required time step.
- * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
- * is to delete this field using decrRef() as it is no more needed.
- * \throw If reading the file fails.
- * \throw If there is no field named \a fieldName in the file.
- * \throw If the required time step is missing from the file.
+ * Returns a pointer to the underground DataArrayInt instance. So the
+ * caller should not decrRef() it. This method allows for a direct access to the field
+ * values. This method is quite unusable if there is more than a nodal field or a cell
+ * field on single geometric cell type.
+ * \return DataArrayInt * - the pointer to the field values array.
*/
-MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
{
- return new MEDFileField1TS(fileName,fieldName,iteration,order);
+ return getUndergroundDataArrayInt();
}
/*!
- * Returns a new instance of MEDFileField1TS holding either deep or shallow copy
- * of a given MEDFileField1TSWithoutSDA.
- * \warning this is a shallow copy constructor
- * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
- * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
- * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
- * is to delete this field using decrRef() as it is no more needed.
+ * Returns a pointer to the underground DataArrayInt instance. So the
+ * caller should not decrRef() it. This method allows for a direct access to the field
+ * values. This method is quite unusable if there is more than a nodal field or a cell
+ * field on single geometric cell type.
+ * \return DataArrayInt * - the pointer to the field values array.
*/
-MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
+DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
{
- return new MEDFileField1TS(other,shallowCopyOfContent);
+ const DataArrayInt *ret=_arr;
+ if(ret)
+ return const_cast<DataArrayInt *>(ret);
+ else
+ return 0;
}
/*!
- * Returns a new empty instance of MEDFileField1TS.
- * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
- * is to delete this field using decrRef() as it is no more needed.
+ * Returns a pointer to the underground DataArrayInt instance and a
+ * sequence describing parameters of a support of each part of \a this field. The
+ * caller should not decrRef() the returned DataArrayInt. This method allows for a
+ * direct access to the field values. This method is intended for the field lying on one
+ * mesh only.
+ * \param [in,out] entries - the sequence describing parameters of a support of each
+ * part of \a this field. Each item of this sequence consists of two parts. The
+ * first part describes a type of mesh entity and an id of discretization of a
+ * current field part. The second part describes a range of values [begin,end)
+ * within the returned array relating to the current field part.
+ * \return DataArrayInt * - the pointer to the field values array.
+ * \throw If the number of underlying meshes is not equal to 1.
+ * \throw If no field values are available.
+ * \sa getUndergroundDataArray()
*/
-MEDFileField1TS *MEDFileField1TS::New()
+DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
{
- return new MEDFileField1TS;
+ return getUndergroundDataArrayIntExt(entries);
}
/*!
- * Returns a string describing \a this field. This string is outputted
- * by \c print Python command.
+ * Returns a pointer to the underground DataArrayInt instance and a
+ * sequence describing parameters of a support of each part of \a this field. The
+ * caller should not decrRef() the returned DataArrayInt. This method allows for a
+ * direct access to the field values. This method is intended for the field lying on one
+ * mesh only.
+ * \param [in,out] entries - the sequence describing parameters of a support of each
+ * part of \a this field. Each item of this sequence consists of two parts. The
+ * first part describes a type of mesh entity and an id of discretization of a
+ * current field part. The second part describes a range of values [begin,end)
+ * within the returned array relating to the current field part.
+ * \return DataArrayInt * - the pointer to the field values array.
+ * \throw If the number of underlying meshes is not equal to 1.
+ * \throw If no field values are available.
+ * \sa getUndergroundDataArray()
*/
-std::string MEDFileField1TS::simpleRepr() const
+DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
{
- std::ostringstream oss;
- _content->simpleRepr(0,oss,-1);
- MEDFileFieldGlobsReal::simpleRepr(oss);
- return oss.str();
+ if(_field_per_mesh.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
+ if(_field_per_mesh[0]==0)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
+ _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
+ return getUndergroundDataArrayInt();
}
-void MEDFileField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
{
- int nbComp=getNumberOfComponents();
- INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
- for(int i=0;i<nbComp;i++)
+ return new MEDFileIntField1TSWithoutSDA(*this);
+}
+
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
+ if((const DataArrayInt *)_arr)
+ ret->_arr=_arr->deepCpy();
+ std::size_t i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,i++)
{
- std::string info=getInfo()[i];
- std::string c,u;
- MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
- MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
- MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
+ if((const MEDFileFieldPerMesh *)*it)
+ ret->_field_per_mesh[i]=(*it)->deepCpy((MEDFileIntField1TSWithoutSDA *)ret);
}
- if(getName().empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
- MEDfieldCr(fid,getName().c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
- writeGlobals(fid,*this);
- _content->writeLL(fid,*this);
+ return ret.retn();
}
-/*!
- * Writes \a this field into a MED file specified by its name.
- * \param [in] fileName - the MED file name.
- * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
- * - 2 - erase; an existing file is removed.
- * - 1 - append; same data should not be present in an existing file.
- * - 0 - overwrite; same data present in an existing file is overwritten.
- * \throw If the field name is not set.
- * \throw If no field data is set.
- * \throw If \a mode == 1 and the same data is present in an existing file.
- */
-void MEDFileField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
{
- med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
- writeLL(fid);
+ if(!arr)
+ _arr=0;
+ DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
+ if(!arrC)
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
+ _arr=arrC;
}
-MEDFileField1TS::MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
-try:MEDFileFieldGlobsReal(fileName)
+DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
+{
+ return DataArrayInt::New();
+}
+
+DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
+{
+ DataArrayInt *ret=_arr;
+ if(ret)
+ return ret;
+ _arr=DataArrayInt::New();
+ return _arr;
+}
+
+DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
+{
+ return getOrCreateAndGetArrayInt();
+}
+
+const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
+{
+ const DataArrayInt *ret=_arr;
+ if(ret)
+ return ret;
+ DataArrayInt *ret2=DataArrayInt::New();
+ const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
+ return ret2;
+}
+
+const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
+{
+ return getOrCreateAndGetArrayInt();
+}
+
+MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
+{
+}
+
+//= MEDFileAnyTypeField1TS
+
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
med_field_type typcha;
//
- int nbFields=MEDnField(fid);
- if(nbFields<1)
+ std::vector<std::string> infos;
+ std::string dtunit,fieldName;
+ LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
+ switch(typcha)
{
- std::ostringstream oss; oss << "MEDFileField1TS(fileName) : no field present in file \'" << fileName << "\' !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- int ncomp=MEDfieldnComponent(fid,1);
- INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- med_bool localMesh;
- int nbOfStep;
- MEDfieldInfo(fid,1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
- std::string fieldName(nomcha);
- if(nbOfStep<1)
- {
- std::ostringstream oss; oss << "MEDFileField1TS(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ case MED_FLOAT64:
+ {
+ ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
+ break;
+ }
+ case MED_INT32:
+ {
+ ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
+ break;
+ }
+ default:
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
- std::vector<std::string> infos(ncomp);
- for(int j=0;j<ncomp;j++)
- infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
- _content=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
- _content->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
+ ret->setDtUnit(dtunit.c_str());
+ ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
//
med_int numdt,numit;
med_float dt;
MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
- _content->setTime(numdt,numit,dt);
- _content->_csit=1;
- _content->_field_type=MEDFileUtilities::TraduceFieldType(typcha);
- _content->finishLoading(fid);
- //
+ ret->setTime(numdt,numit,dt);
+ ret->_csit=1;
+ ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
+ return ret.retn();
+}
+
+MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
+try:MEDFileFieldGlobsReal(fileName)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ _content=BuildContentFrom(fid,fileName);
loadGlobals(fid);
}
catch(INTERP_KERNEL::Exception& e)
throw e;
}
-MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
-try:MEDFileFieldGlobsReal(fileName),_content(MEDFileField1TSWithoutSDA::New(fieldName,-1,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>()))
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
med_field_type typcha;
- int nbSteps=locateField(fid,fileName,fieldName,typcha);
+ std::vector<std::string> infos;
+ std::string dtunit;
+ int iii=-1;
+ int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
+ switch(typcha)
+ {
+ case MED_FLOAT64:
+ {
+ ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
+ break;
+ }
+ case MED_INT32:
+ {
+ ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
+ break;
+ }
+ default:
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ ret->setDtUnit(dtunit.c_str());
+ ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
+ //
if(nbSteps<1)
{
std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
med_int numdt,numit;
med_float dt;
MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
- _content->setTime(numdt,numit,dt);
- _content->_csit=1;
- _content->_field_type=MEDFileUtilities::TraduceFieldType(typcha);
- _content->finishLoading(fid);
- //
+ ret->setTime(numdt,numit,dt);
+ ret->_csit=1;
+ ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
+ return ret.retn();
+}
+
+MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+try:MEDFileFieldGlobsReal(fileName)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ _content=BuildContentFrom(fid,fileName,fieldName);
loadGlobals(fid);
}
catch(INTERP_KERNEL::Exception& e)
throw e;
}
-MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
-try:MEDFileFieldGlobsReal(fileName),_content(MEDFileField1TSWithoutSDA::New(fieldName,-1,-1,iteration,order,std::vector<std::string>()))
+MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ if(!c)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
+ if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
+ ret->setFileName(fileName);
+ ret->_content=c; c->incrRef();
+ return ret.retn();
+ }
+ if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
+ ret->setFileName(fileName);
+ ret->_content=c; c->incrRef();
+ return ret.retn();
+ }
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
+}
+
+MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
+ ret->loadGlobals(fid);
+ return ret.retn();
+}
+
+MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
+ ret->loadGlobals(fid);
+ return ret.retn();
+}
+
+MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
MEDFileUtilities::CheckFileForRead(fileName);
MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
+ ret->loadGlobals(fid);
+ return ret.retn();
+}
+
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+{
med_field_type typcha;
- int nbOfStep2=locateField(fid,fileName,fieldName,typcha);
+ std::vector<std::string> infos;
+ std::string dtunit;
+ int iii=-1;
+ int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
+ switch(typcha)
+ {
+ case MED_FLOAT64:
+ {
+ ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
+ break;
+ }
+ case MED_INT32:
+ {
+ ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
+ break;
+ }
+ default:
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName,iteration,order) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ ret->setDtUnit(dtunit.c_str());
+ ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
+ //
bool found=false;
std::vector< std::pair<int,int> > dtits(nbOfStep2);
for(int i=0;i<nbOfStep2 && !found;i++)
if(numdt==iteration && numit==order)
{
found=true;
- _content->_csit=i+1;
- _content->_field_type=MEDFileUtilities::TraduceFieldType(typcha);
+ ret->_csit=i+1;
}
else
dtits[i]=std::pair<int,int>(numdt,numit);
oss << "(" << (*iter).first << "," << (*iter).second << "), ";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- _content->finishLoading(fid);
- //
+ ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
+ return ret.retn();
+}
+
+MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+try:MEDFileFieldGlobsReal(fileName)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ _content=BuildContentFrom(fid,fileName,fieldName,iteration,order);
loadGlobals(fid);
}
catch(INTERP_KERNEL::Exception& e)
}
/*!
+ * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
+ * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
+ *
* \warning this is a shallow copy constructor
*/
-MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
+MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
{
if(!shallowCopyOfContent)
{
- const MEDFileField1TSWithoutSDA *otherPtr(&other);
+ const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
otherPtr->incrRef();
- _content=const_cast<MEDFileField1TSWithoutSDA *>(otherPtr);
+ _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
}
else
{
- _content=new MEDFileField1TSWithoutSDA(other);
+ _content=other.shallowCpy();
}
}
-MEDFileField1TS::MEDFileField1TS():_content(new MEDFileField1TSWithoutSDA)
+int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
{
+ if(checkFieldId)
+ {
+ int nbFields=MEDnField(fid);
+ if(fieldIdCFormat>=nbFields)
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
+ INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ med_bool localMesh;
+ int nbOfStep;
+ MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
+ fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
+ dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
+ infos.clear(); infos.resize(ncomp);
+ for(int j=0;j<ncomp;j++)
+ infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
+ return nbOfStep;
}
/*!
* \param [out]
* \return in case of success the number of time steps available for the field with name \a fieldName.
*/
-int MEDFileField1TS::locateField(med_idt fid, const char *fileName, const char *fieldName, med_field_type& typcha) throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
{
int nbFields=MEDnField(fid);
bool found=false;
int nbOfStep2=-1;
for(int i=0;i<nbFields && !found;i++)
{
- int ncomp=MEDfieldnComponent(fid,i+1);
- INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- med_bool localMesh;
- int nbOfStep;
- MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
- std::string tmp(nomcha);
+ std::string tmp;
+ nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
fns[i]=tmp;
found=(tmp==fieldName);
if(found)
- {
- nbOfStep2=nbOfStep;
- std::string mname=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
- std::vector<std::string> infos(ncomp);
- for(int j=0;j<ncomp;j++)
- infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
- _content->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
- }
+ posCFormat=i;
}
if(!found)
{
}
/*!
- * This method returns all profiles whose name is non empty used.
- * \b WARNING If profile is used several times it will be reported \b only \b once.
- * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
+ * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
+ * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
+ * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
+ * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
+ * to keep a valid instance.
+ * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
+ * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
+ * If \b newPflName already exists and that \b forceRenameOnGlob is false (the default) an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newPflName.
+ *
+ * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
+ * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
+ * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
+ * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
+ * \param [in] newLocName is the new localization name.
+ * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newPflName already exists. If true, the renaming is done without check. It can lead to major bug.
+ * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
*/
-std::vector<std::string> MEDFileField1TS::getPflsReallyUsed() const
+void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
{
- return _content->getPflsReallyUsed2();
+ MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
+ std::string oldPflName=disc->getProfile();
+ std::vector<std::string> vv=getPflsReallyUsedMulti();
+ int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
+ if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
+ {
+ disc->setProfile(newPflName);
+ DataArrayInt *pfl=getProfile(oldPflName.c_str());
+ pfl->setName(newPflName);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
/*!
- * This method returns all localizations whose name is non empty used.
- * \b WARNING If localization is used several times it will be reported \b only \b once.
+ * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
+ * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
+ * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
+ * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
+ * to keep a valid instance.
+ * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
+ * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
+ * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
+ * If \b newLocName already exists an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newLocName.
+ *
+ * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
+ * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
+ * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
+ * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
+ * \param [in] newLocName is the new localization name.
+ * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newLocName already exists. If true, the renaming is done without check. It can lead to major bug.
+ * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
*/
-std::vector<std::string> MEDFileField1TS::getLocsReallyUsed() const
+void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
{
- return _content->getLocsReallyUsed2();
+ MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
+ std::string oldLocName=disc->getLocalization();
+ std::vector<std::string> vv=getLocsReallyUsedMulti();
+ int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
+ if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
+ {
+ disc->setLocalization(newLocName);
+ MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
+ loc.setName(newLocName);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
-/*!
- * This method returns all profiles whose name is non empty used.
- * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
- */
-std::vector<std::string> MEDFileField1TS::getPflsReallyUsedMulti() const
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
{
- return _content->getPflsReallyUsedMulti2();
+ MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
+ return ret;
}
-/*!
- * This method returns all localizations whose name is non empty used.
- * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
+const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
+ return ret;
+}
+
+/*!
+ * Writes \a this field into a MED file specified by its name.
+ * \param [in] fileName - the MED file name.
+ * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
+ * - 2 - erase; an existing file is removed.
+ * - 1 - append; same data should not be present in an existing file.
+ * - 0 - overwrite; same data present in an existing file is overwritten.
+ * \throw If the field name is not set.
+ * \throw If no field data is set.
+ * \throw If \a mode == 1 and the same data is present in an existing file.
*/
-std::vector<std::string> MEDFileField1TS::getLocsReallyUsedMulti() const
+void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
{
- return _content->getLocsReallyUsedMulti2();
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ writeLL(fid);
}
-void MEDFileField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
- _content->changePflsRefsNamesGen2(mapOfModif);
+ int nbComp=getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
+ for(int i=0;i<nbComp;i++)
+ {
+ std::string info=getInfo()[i];
+ std::string c,u;
+ MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
+ MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
+ MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
+ }
+ if(getName().empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
+ MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
+ writeGlobals(fid,*this);
+ contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
}
-void MEDFileField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
{
- _content->changeLocsRefsNamesGen2(mapOfModif);
+ std::size_t ret=0;
+ if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
+ ret+=_content->getHeapMemorySize();
+ return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on
- * mesh entities of a given dimension of the first mesh in MED file. If \a this field
- * has not been constructed via file reading, an exception is thrown.
- * For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] type - a spatial discretization of interest.
- * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \param [in] renumPol - specifies how to permute values of the result field according to
- * the optional numbers of cells and nodes, if any. The valid values are
- * - 0 - do not permute.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
- * caller is to delete this field using decrRef() as it is no more needed.
- * \throw If \a this field has not been constructed via file reading.
- * \throw If the MED file is not readable.
- * \throw If there is no mesh in the MED file.
- * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
- * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
- * \sa getFieldOnMeshAtLevel()
+ * Returns a string describing \a this field. This string is outputted
+ * by \c print Python command.
*/
-MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
+std::string MEDFileAnyTypeField1TS::simpleRepr() const
{
- if(getFileName2().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 !");
- return _content->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
+ std::ostringstream oss;
+ contentNotNullBase()->simpleRepr(0,oss,-1);
+ simpleReprGlobs(oss);
+ return oss.str();
}
+
/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on
- * the top level cells of the first mesh in MED file. If \a this field
- * has not been constructed via file reading, an exception is thrown.
- * For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] type - a spatial discretization of interest.
- * \param [in] renumPol - specifies how to permute values of the result field according to
- * the optional numbers of cells and nodes, if any. The valid values are
- * - 0 - do not permute.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
- * caller is to delete this field using decrRef() as it is no more needed.
- * \throw If \a this field has not been constructed via file reading.
- * \throw If the MED file is not readable.
- * \throw If there is no mesh in the MED file.
- * \throw If no field values of the given \a type.
- * \throw If no field values lying on the top level support.
- * \sa getFieldAtLevel()
+ * This method returns all profiles whose name is non empty used.
+ * \b WARNING If profile is used several times it will be reported \b only \b once.
+ * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
*/
-MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
+std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
{
- if(getFileName2().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 !");
- return _content->getFieldAtTopLevel(type,0,renumPol,this);
+ return contentNotNullBase()->getPflsReallyUsed2();
}
-
/*!
- * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
- * For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] type - a spatial discretization of the new field.
- * \param [in] mesh - the supporting mesh.
- * \param [in] renumPol - specifies how to permute values of the result field according to
- * the optional numbers of cells and nodes, if any. The valid values are
- * - 0 - do not permute.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
- * caller is to delete this field using decrRef() as it is no more needed.
- * \throw If no field of \a this is lying on \a mesh.
- * \throw If the mesh is empty.
- * \throw If no field values of the given \a type are available.
- * \sa getFieldAtLevel()
- * \sa getFieldOnMeshAtLevel()
+ * This method returns all localizations whose name is non empty used.
+ * \b WARNING If localization is used several times it will be reported \b only \b once.
*/
-MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
+std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
{
- return _content->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
+ return contentNotNullBase()->getLocsReallyUsed2();
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
- * For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] type - a spatial discretization of interest.
- * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \param [in] mesh - the supporting mesh.
- * \param [in] renumPol - specifies how to permute values of the result field according to
- * the optional numbers of cells and nodes, if any. The valid values are
- * - 0 - do not permute.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
- * caller is to delete this field using decrRef() as it is no more needed.
- * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
- * \throw If no field of \a this is lying on \a mesh.
- * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
- * \sa getFieldAtLevel()
- * \sa getFieldOnMeshAtLevel()
+ * This method returns all profiles whose name is non empty used.
+ * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
*/
-MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
+std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
{
- return _content->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
+ return contentNotNullBase()->getPflsReallyUsedMulti2();
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
- * This method is called "Old" because in MED3 norm a field has only one meshName
- * attached, so this method is for readers of MED2 files. If \a this field
- * has not been constructed via file reading, an exception is thrown.
- * For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] type - a spatial discretization of interest.
- * \param [in] mName - a name of the supporting mesh.
- * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \param [in] renumPol - specifies how to permute values of the result field according to
- * the optional numbers of cells and nodes, if any. The valid values are
- * - 0 - do not permute.
- * - 1 - permute cells.
- * - 2 - permute nodes.
- * - 3 - permute cells and nodes.
- *
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
- * caller is to delete this field using decrRef() as it is no more needed.
- * \throw If the MED file is not readable.
- * \throw If there is no mesh named \a mName in the MED file.
- * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
- * \throw If \a this field has not been constructed via file reading.
- * \throw If no field of \a this is lying on the mesh named \a mName.
- * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
- * \sa getFieldAtLevel()
+ * This method returns all localizations whose name is non empty used.
+ * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
*/
-MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
+std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
{
- if(getFileName2().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 !");
- return _content->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
+ return contentNotNullBase()->getLocsReallyUsedMulti2();
}
+void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+{
+ contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
+}
-/*!
- * Returns values and a profile of the field of a given type lying on a given support.
- * For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] type - a spatial discretization of the field.
- * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \param [in] mesh - the supporting mesh.
- * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
- * field of interest lies on. If the field lies on all entities of the given
- * dimension, all ids in \a pfl are zero. The caller is to delete this array
- * using decrRef() as it is no more needed.
- * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
- * field. The caller is to delete this array using decrRef() as it is no more needed.
- * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
- * \throw If no field of \a this is lying on \a mesh.
- * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
- */
-DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
+void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
{
- return _content->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
+ contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
}
-/*!
- * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
- * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
- * "Sort By Type"), if not, an exception is thrown.
- * For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] field - the field to add to \a this.
- * \throw If the name of \a field is empty.
- * \throw If the data array of \a field is not set.
- * \throw If the data array is already allocated but has different number of components
- * than \a field.
- * \throw If the underlying mesh of \a field has no name.
- * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
- */
-void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TS::getDimension() const
{
- setFileName("");
- _content->setFieldNoProfileSBT(field,*this);
+ return contentNotNullBase()->getDimension();
}
-/*!
- * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
- * of a given mesh are used as the support of the given field (a real support is not used).
- * Elements of the given mesh must be sorted suitable for writing to MED file.
- * Order of underlying mesh entities of the given field specified by \a profile parameter
- * is not prescribed; this method permutes field values to have them sorted by element
- * type as required for writing to MED file. A new profile is added only if no equal
- * profile is missing.
- * For more info, see \ref AdvMEDLoaderAPIFieldRW
- * \param [in] field - the field to add to \a this.
- * \param [in] mesh - the supporting mesh of \a field.
- * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
- * \param [in] profile - ids of mesh entities on which corresponding field values lie.
- * \throw If either \a field or \a mesh or \a profile has an empty name.
- * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
- * \throw If the data array of \a field is not set.
- * \throw If the data array of \a this is already allocated but has different number of
- * components than \a field.
- * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
- * \sa setFieldNoProfileSBT()
- */
-void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TS::getIteration() const
{
- setFileName("");
- _content->setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
+ return contentNotNullBase()->getIteration();
}
-/*!
- * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
- * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
- * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
- * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
- * to keep a valid instance.
- * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
- * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
- * If \b newPflName already exists and that \b forceRenameOnGlob is false (the default) an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newPflName.
- *
- * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
- * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
- * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
- * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
- * \param [in] newLocName is the new localization name.
- * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newPflName already exists. If true, the renaming is done without check. It can lead to major bug.
- * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
- */
-void MEDFileField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TS::getOrder() const
{
- MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
- std::string oldPflName=disc->getProfile();
- std::vector<std::string> vv=getPflsReallyUsedMulti();
- int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
- if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
- {
- disc->setProfile(newPflName);
- DataArrayInt *pfl=getProfile(oldPflName.c_str());
- pfl->setName(newPflName);
- }
- else
- {
- std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ return contentNotNullBase()->getOrder();
}
-/*!
- * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
- * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
- * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
- * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
- * to keep a valid instance.
- * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
- * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
- * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
- * If \b newLocName already exists an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newLocName.
- *
- * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
- * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
- * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
- * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
- * \param [in] newLocName is the new localization name.
- * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newLocName already exists. If true, the renaming is done without check. It can lead to major bug.
- * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
- */
-void MEDFileField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
-{
- MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
- std::string oldLocName=disc->getLocalization();
- std::vector<std::string> vv=getLocsReallyUsedMulti();
- int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
- if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
- {
- disc->setLocalization(newLocName);
- MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
- loc.setName(newLocName);
- }
- else
- {
- std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
-}
-
-std::size_t MEDFileField1TS::getHeapMemorySize() const
-{
- std::size_t ret=0;
- if((const MEDFileField1TSWithoutSDA *)_content)
- ret+=_content->getHeapMemorySize();
- return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
-}
-
-MEDFileField1TS *MEDFileField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
-{
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(*this);
- if((const MEDFileField1TSWithoutSDA *)_content)
- ret->_content=_content->deepCpy();
- ret->deepCpyGlobs(*this);
- return ret.retn();
-}
-
-int MEDFileField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
-{
- return _content->copyTinyInfoFrom(field);
-}
-
-int MEDFileField1TS::getDimension() const
-{
- return _content->getDimension();
-}
-
-int MEDFileField1TS::getIteration() const
+double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
{
- return _content->getIteration();
+ return contentNotNullBase()->getTime(iteration,order);
}
-int MEDFileField1TS::getOrder() const
+void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
{
- return _content->getOrder();
+ contentNotNullBase()->setTime(iteration,order,val);
}
-double MEDFileField1TS::getTime(int& iteration, int& order) const
+std::string MEDFileAnyTypeField1TS::getName() const
{
- return _content->getTime(iteration,order);
+ return contentNotNullBase()->getName();
}
-void MEDFileField1TS::setTime(int iteration, int order, double val)
+void MEDFileAnyTypeField1TS::setName(const char *name)
{
- _content->setTime(iteration,order,val);
+ contentNotNullBase()->setName(name);
}
-std::string MEDFileField1TS::getName() const
+void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
{
- return _content->getName();
+ contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
}
-void MEDFileField1TS::setName(const char *name)
+std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
{
- _content->setName(name);
+ return contentNotNullBase()->getDtUnit();
}
-void MEDFileField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
+void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
{
- _content->simpleRepr(bkOffset,oss,f1tsId);
+ contentNotNullBase()->setDtUnit(dtUnit);
}
-const std::string& MEDFileField1TS::getDtUnit() const
+std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
{
- return _content->getDtUnit();
+ return contentNotNullBase()->getMeshName();
}
-std::string MEDFileField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
+void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
{
- return _content->getMeshName();
+ contentNotNullBase()->setMeshName(newMeshName);
}
-void MEDFileField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
+bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
{
- _content->setMeshName(newMeshName);
+ return contentNotNullBase()->changeMeshNames(modifTab);
}
-bool MEDFileField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
{
- return _content->changeMeshNames(modifTab);
+ return contentNotNullBase()->getMeshIteration();
}
-int MEDFileField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
{
- return _content->getMeshIteration();
+ return contentNotNullBase()->getMeshOrder();
}
-int MEDFileField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TS::getNumberOfComponents() const
{
- return _content->getMeshOrder();
+ return contentNotNullBase()->getNumberOfComponents();
}
-int MEDFileField1TS::getNumberOfComponents() const
+bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
{
- return _content->getNumberOfComponents();
+ return contentNotNullBase()->isDealingTS(iteration,order);
}
-bool MEDFileField1TS::isDealingTS(int iteration, int order) const
+std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
{
- return _content->isDealingTS(iteration,order);
+ return contentNotNullBase()->getDtIt();
}
-std::pair<int,int> MEDFileField1TS::getDtIt() const
+void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
{
- return _content->getDtIt();
+ contentNotNullBase()->fillIteration(p);
}
-void MEDFileField1TS::fillIteration(std::pair<int,int>& p) const
+void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
{
- _content->fillIteration(p);
-}
-void MEDFileField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
-{
- _content->fillTypesOfFieldAvailable(types);
+ contentNotNullBase()->fillTypesOfFieldAvailable(types);
}
-const std::vector<std::string>& MEDFileField1TS::getInfo() const
-{
- return _content->getInfo();
-}
-std::vector<std::string>& MEDFileField1TS::getInfo()
+void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
{
- return _content->getInfo();
+ contentNotNullBase()->setInfo(infos);
}
-DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
+const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
{
- return _content->getUndergroundDataArray();
+ return contentNotNullBase()->getInfo();
}
-
-DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
{
- return _content->getUndergroundDataArrayExt(entries);
+ return contentNotNullBase()->getInfo();
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
{
- return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
+ return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
}
-const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
+const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
{
- return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
+ return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
}
-int MEDFileField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
+int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
{
- return _content->getNonEmptyLevels(mname,levs);
+ return contentNotNullBase()->getNonEmptyLevels(mname,levs);
}
-std::vector<TypeOfField> MEDFileField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
+std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
{
- return _content->getTypesOfFieldAvailable();
+ return contentNotNullBase()->getTypesOfFieldAvailable();
}
-std::vector< std::vector<std::pair<int,int> > > MEDFileField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
+std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
{
- return _content->getFieldSplitedByType(mname,types,typesF,pfls,locs);
-}
-std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
- std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
-{
- return _content->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
-}
-
-MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
-{
- return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,id,ft,infos,nbOfStep);
-}
-
-MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA():_field_type(-1)
-{
-}
-
-MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):_name(fieldName),_field_type(-1)
-{
+ return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
}
/*!
- * \param [in] fieldId field id in C mode
+ * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
+ * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
+ * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
*/
-MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
-try:_name("")
+std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
{
- med_field_type typcha;
- //
- int ncomp=MEDfieldnComponent(fid,fieldId+1);
- INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- med_bool localMesh;
- int nbOfStep;
- MEDfieldInfo(fid,fieldId+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
- _name=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
- _field_type=MEDFileUtilities::TraduceFieldType(typcha);
- _infos.resize(ncomp);
- for(int j=0;j<ncomp;j++)
- _infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
- //
- finishLoading(fid,nbOfStep);
+ const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
+ if(!content)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
+ std::size_t sz(contentsSplit.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ ret[i]=shallowCpy();
+ ret[i]->_content=contentsSplit[i];
+ }
+ return ret;
}
-catch(INTERP_KERNEL::Exception& e)
- {
- throw e;
- }
-MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
-try:_name(fieldName),_infos(infos),_field_type(ft)
-{
- finishLoading(fid,nbOfStep);
-}
-catch(INTERP_KERNEL::Exception& e)
+MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
{
- throw e;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
+ if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
+ ret->_content=_content->deepCpy();
+ ret->deepCpyGlobs(*this);
+ return ret.retn();
}
-std::size_t MEDFileFieldMultiTSWithoutSDA::getHeapMemorySize() const
+int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
{
- std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
- for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
- ret+=(*it).capacity();
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- if((const MEDFileField1TSWithoutSDA *)(*it))
- ret+=(*it)->getHeapMemorySize();
- return ret;
+ return contentNotNullBase()->copyTinyInfoFrom(field,arr);
}
-MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
-{
- MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret=new MEDFileFieldMultiTSWithoutSDA(*this);
- std::size_t i=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
- {
- if((const MEDFileField1TSWithoutSDA *)*it)
- ret->_time_steps[i]=(*it)->deepCpy();
- }
- return ret.retn();
-}
+//= MEDFileField1TS
-const std::vector<std::string>& MEDFileFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
+/*!
+ * Returns a new instance of MEDFileField1TS holding data of the first time step of
+ * the first field that has been read from a specified MED file.
+ * \param [in] fileName - the name of the MED file to read.
+ * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ * \throw If reading the file fails.
+ */
+MEDFileField1TS *MEDFileField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
{
- if(_time_steps.empty())
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getInfos : not time steps !");
- return _time_steps[0]->getInfo();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName);
+ ret->contentNotNull();
+ return ret.retn();
}
/*!
- * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
+ * Returns a new instance of MEDFileField1TS holding data of the first time step of
+ * a given field that has been read from a specified MED file.
+ * \param [in] fileName - the name of the MED file to read.
+ * \param [in] fieldName - the name of the field to read.
+ * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ * \throw If reading the file fails.
+ * \throw If there is no field named \a fieldName in the file.
*/
-DataArrayDouble *MEDFileFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
{
- return getTimeStepEntry(iteration,order).getUndergroundDataArray();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName);
+ ret->contentNotNull();
+ return ret.retn();
}
/*!
- * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
+ * Returns a new instance of MEDFileField1TS holding data of a given time step of
+ * a given field that has been read from a specified MED file.
+ * \param [in] fileName - the name of the MED file to read.
+ * \param [in] fieldName - the name of the field to read.
+ * \param [in] iteration - the iteration number of a required time step.
+ * \param [in] order - the iteration order number of required time step.
+ * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ * \throw If reading the file fails.
+ * \throw If there is no field named \a fieldName in the file.
+ * \throw If the required time step is missing from the file.
*/
-DataArrayDouble *MEDFileFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
- return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order);
+ ret->contentNotNull();
+ return ret.retn();
}
-std::string MEDFileFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
+/*!
+ * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
+ * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
+ *
+ * Returns a new instance of MEDFileField1TS holding either a shallow copy
+ * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
+ * \warning this is a shallow copy constructor
+ * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
+ * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
+ * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ */
+MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
{
- if(_time_steps.empty())
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
- return _time_steps[0]->getMeshName();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
+ ret->contentNotNull();
+ return ret.retn();
}
-void MEDFileFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
+/*!
+ * Returns a new empty instance of MEDFileField1TS.
+ * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ */
+MEDFileField1TS *MEDFileField1TS::New()
{
- std::string oldName(getMeshName());
- std::vector< std::pair<std::string,std::string> > v(1);
- v[0].first=oldName; v[0].second=newMeshName;
- changeMeshNames(v);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
+ ret->contentNotNull();
+ return ret.retn();
}
-bool MEDFileFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
{
- bool ret=false;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- {
- MEDFileField1TSWithoutSDA *cur(*it);
- if(cur)
- ret=cur->changeMeshNames(modifTab) || ret;
- }
+ const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
+ const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
return ret;
}
-bool MEDFileFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
- MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
{
- bool ret=false;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- {
- MEDFileField1TSWithoutSDA *f1ts(*it);
- if(f1ts)
- ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
- }
+ MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
+ MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
return ret;
}
-void MEDFileFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
{
- if(_time_steps.empty())
- {
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
- obj->setFieldNoProfileSBT(field,glob);
- copyTinyInfoFrom(field);
- _time_steps.push_back(obj);
- }
- else
- {
- checkCoherencyOfTinyInfo(field);
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
- obj->setFieldNoProfileSBT(field,glob);
- _time_steps.push_back(obj);
- }
+ if(!f)
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
+ if(!((DataArray*)arr))
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
+ DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
+ if(!arrOutC)
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
+ f->setArray(arrOutC);
}
-void MEDFileFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
{
- if(_time_steps.empty())
- {
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
- obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
- copyTinyInfoFrom(field);
- _time_steps.push_back(obj);
- }
- else
- {
- checkCoherencyOfTinyInfo(field);
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
- obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
- _time_steps.push_back(obj);
- }
+ if(!((DataArray*)arr))
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
+ DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
+ if(!arrOutC)
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
+ arrOutC->incrRef();
+ return arrOutC;
}
-std::string MEDFileFieldMultiTSWithoutSDA::getDtUnit() const throw(INTERP_KERNEL::Exception)
+MEDFileField1TS::MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeField1TS(fileName)
{
- if(_time_steps.empty())
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
- return _time_steps[0]->getDtUnit();
}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
-std::string MEDFileFieldMultiTSWithoutSDA::getName() const
+MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeField1TS(fileName,fieldName)
{
- return _name;
}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
-void MEDFileFieldMultiTSWithoutSDA::setName(const char *name)
+MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
{
- _name=name;
}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
-void MEDFileFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
+/*!
+ * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
+ * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
+ *
+ * \warning this is a shallow copy constructor
+ */
+MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
+try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
{
- std::string startLine(bkOffset,' ');
- oss << startLine << "Field multi time steps";
- if(fmtsId>=0)
- oss << " (" << fmtsId << ")";
- oss << " has the following name: \"" << _name << "\"." << std::endl;
- oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
- for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
- {
- oss << startLine << " - \"" << *it << "\"" << std::endl;
- }
- int i=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
- {
- std::string chapter(17,'0'+i);
- oss << startLine << chapter << std::endl;
- const MEDFileField1TSWithoutSDA *cur=(*it);
- if(cur)
- cur->simpleRepr(bkOffset+2,oss,i);
- else
- oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
- oss << startLine << chapter << std::endl;
- }
}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
-std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
+MEDFileField1TS::MEDFileField1TS()
{
- std::size_t sz=_time_steps.size();
- std::vector< std::pair<int,int> > ret(sz);
- ret1.resize(sz);
- for(std::size_t i=0;i<sz;i++)
- {
- const MEDFileField1TSWithoutSDA *f1ts=_time_steps[i];
- if(f1ts)
- {
- ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
- }
- else
- {
- std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- return ret;
+ _content=new MEDFileField1TSWithoutSDA;
}
-void MEDFileFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception)
-{
- _time_steps.resize(nbPdt);
- for(int i=0;i<nbPdt;i++)
- {
- std::vector< std::pair<int,int> > ts;
- med_int numdt=0,numo=0;
+/*!
+ * Returns a new MEDCouplingFieldDouble of a given type lying on
+ * mesh entities of a given dimension of the first mesh in MED file. If \a this field
+ * has not been constructed via file reading, an exception is thrown.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If \a this field has not been constructed via file reading.
+ * \throw If the MED file is not readable.
+ * \throw If there is no mesh in the MED file.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
+ * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
+ * \sa getFieldOnMeshAtLevel()
+ */
+MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ if(getFileName2().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,0,renumPol,this,arrOut,*contentNotNull());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble of a given type lying on
+ * the top level cells of the first mesh in MED file. If \a this field
+ * has not been constructed via file reading, an exception is thrown.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If \a this field has not been constructed via file reading.
+ * \throw If the MED file is not readable.
+ * \throw If there is no mesh in the MED file.
+ * \throw If no field values of the given \a type.
+ * \throw If no field values lying on the top level support.
+ * \sa getFieldAtLevel()
+ */
+MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ if(getFileName2().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,0,renumPol,this,arrOut,*contentNotNull());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of the new field.
+ * \param [in] mesh - the supporting mesh.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If no field of \a this is lying on \a mesh.
+ * \throw If the mesh is empty.
+ * \throw If no field values of the given \a type are available.
+ * \sa getFieldAtLevel()
+ * \sa getFieldOnMeshAtLevel()
+ */
+MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [in] mesh - the supporting mesh.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
+ * \throw If no field of \a this is lying on \a mesh.
+ * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
+ * \sa getFieldAtLevel()
+ * \sa getFieldOnMeshAtLevel()
+ */
+MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
+ * This method is called "Old" because in MED3 norm a field has only one meshName
+ * attached, so this method is for readers of MED2 files. If \a this field
+ * has not been constructed via file reading, an exception is thrown.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [in] mName - a name of the supporting mesh.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If the MED file is not readable.
+ * \throw If there is no mesh named \a mName in the MED file.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
+ * \throw If \a this field has not been constructed via file reading.
+ * \throw If no field of \a this is lying on the mesh named \a mName.
+ * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
+ * \sa getFieldAtLevel()
+ */
+MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ if(getFileName2().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());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
+/*!
+ * Returns values and a profile of the field of a given type lying on a given support.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of the field.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [in] mesh - the supporting mesh.
+ * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
+ * field of interest lies on. If the field lies on all entities of the given
+ * dimension, all ids in \a pfl are zero. The caller is to delete this array
+ * using decrRef() as it is no more needed.
+ * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
+ * field. The caller is to delete this array using decrRef() as it is no more needed.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
+ * \throw If no field of \a this is lying on \a mesh.
+ * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
+ */
+DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
+ return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
+}
+
+/*!
+ * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
+ * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
+ * "Sort By Type"), if not, an exception is thrown.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] field - the field to add to \a this.
+ * \throw If the name of \a field is empty.
+ * \throw If the data array of \a field is not set.
+ * \throw If the data array is already allocated but has different number of components
+ * than \a field.
+ * \throw If the underlying mesh of \a field has no name.
+ * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
+ */
+void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
+{
+ setFileName("");
+ contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
+}
+
+/*!
+ * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
+ * of a given mesh are used as the support of the given field (a real support is not used).
+ * Elements of the given mesh must be sorted suitable for writing to MED file.
+ * Order of underlying mesh entities of the given field specified by \a profile parameter
+ * is not prescribed; this method permutes field values to have them sorted by element
+ * type as required for writing to MED file. A new profile is added only if no equal
+ * profile is missing.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] field - the field to add to \a this.
+ * \param [in] mesh - the supporting mesh of \a field.
+ * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
+ * \param [in] profile - ids of mesh entities on which corresponding field values lie.
+ * \throw If either \a field or \a mesh or \a profile has an empty name.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
+ * \throw If the data array of \a field is not set.
+ * \throw If the data array of \a this is already allocated but has different number of
+ * components than \a field.
+ * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
+ * \sa setFieldNoProfileSBT()
+ */
+void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
+{
+ setFileName("");
+ contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
+}
+
+MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileField1TS(*this);
+}
+
+DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNull()->getUndergroundDataArrayDouble();
+}
+
+DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
+}
+
+std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
+ std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
+}
+
+//= MEDFileIntField1TS
+
+MEDFileIntField1TS *MEDFileIntField1TS::New()
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
+ ret->contentNotNull();
+ return ret.retn();
+}
+
+MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName);
+ ret->contentNotNull();
+ return ret.retn();
+}
+
+MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName);
+ ret->contentNotNull();
+ return ret.retn();
+}
+
+MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order);
+ ret->contentNotNull();
+ return ret.retn();
+}
+
+MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
+ ret->contentNotNull();
+ return ret.retn();
+}
+
+MEDFileIntField1TS::MEDFileIntField1TS()
+{
+ _content=new MEDFileIntField1TSWithoutSDA;
+}
+
+MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeField1TS(fileName)
+{
+}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
+
+MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeField1TS(fileName,fieldName)
+{
+}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
+
+MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
+{
+}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
+
+/*!
+ * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
+ * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
+ *
+ * \warning this is a shallow copy constructor
+ */
+MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
+{
+}
+
+MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileIntField1TS(*this);
+}
+
+/*!
+ * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
+ * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
+ * "Sort By Type"), if not, an exception is thrown.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] field - the field to add to \a this. The field double values are ignored.
+ * \param [in] arrOfVals - the values of the field \a field used.
+ * \throw If the name of \a field is empty.
+ * \throw If the data array of \a field is not set.
+ * \throw If the data array is already allocated but has different number of components
+ * than \a field.
+ * \throw If the underlying mesh of \a field has no name.
+ * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
+ */
+void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
+{
+ setFileName("");
+ contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
+}
+
+/*!
+ * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
+ * of a given mesh are used as the support of the given field (a real support is not used).
+ * Elements of the given mesh must be sorted suitable for writing to MED file.
+ * Order of underlying mesh entities of the given field specified by \a profile parameter
+ * is not prescribed; this method permutes field values to have them sorted by element
+ * type as required for writing to MED file. A new profile is added only if no equal
+ * profile is missing.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] field - the field to add to \a this. The field double values are ignored.
+ * \param [in] arrOfVals - the values of the field \a field used.
+ * \param [in] mesh - the supporting mesh of \a field.
+ * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
+ * \param [in] profile - ids of mesh entities on which corresponding field values lie.
+ * \throw If either \a field or \a mesh or \a profile has an empty name.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
+ * \throw If the data array of \a field is not set.
+ * \throw If the data array of \a this is already allocated but has different number of
+ * components than \a field.
+ * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
+ * \sa setFieldNoProfileSBT()
+ */
+void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
+{
+ setFileName("");
+ contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
+}
+
+const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
+ const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
+ return ret;
+}
+
+MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ if(getFileName2().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,0,renumPol,this,arrOut2,*contentNotNull());
+ DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
+ if(!arrOutC)
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
+ arrOut=arrOutC;
+ return ret.retn();
+}
+
+DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
+{
+ if(!((DataArray *)arr))
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
+ DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
+ if(!arrC)
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
+ arrC->incrRef();
+ return arrC;
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble of a given type lying on
+ * the top level cells of the first mesh in MED file. If \a this field
+ * has not been constructed via file reading, an exception is thrown.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [out] arrOut - the DataArrayInt containing values of field.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If \a this field has not been constructed via file reading.
+ * \throw If the MED file is not readable.
+ * \throw If there is no mesh in the MED file.
+ * \throw If no field values of the given \a type.
+ * \throw If no field values lying on the top level support.
+ * \sa getFieldAtLevel()
+ */
+MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ if(getFileName2().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,0,renumPol,this,arr,*contentNotNull());
+ arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of the new field.
+ * \param [in] mesh - the supporting mesh.
+ * \param [out] arrOut - the DataArrayInt containing values of field.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If no field of \a this is lying on \a mesh.
+ * \throw If the mesh is empty.
+ * \throw If no field values of the given \a type are available.
+ * \sa getFieldAtLevel()
+ * \sa getFieldOnMeshAtLevel()
+ */
+MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
+ arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [out] arrOut - the DataArrayInt containing values of field.
+ * \param [in] mesh - the supporting mesh.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
+ * \throw If no field of \a this is lying on \a mesh.
+ * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
+ * \sa getFieldAtLevel()
+ * \sa getFieldOnMeshAtLevel()
+ */
+MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
+ arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
+ * This method is called "Old" because in MED3 norm a field has only one meshName
+ * attached, so this method is for readers of MED2 files. If \a this field
+ * has not been constructed via file reading, an exception is thrown.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [in] mName - a name of the supporting mesh.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [out] arrOut - the DataArrayInt containing values of field.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If the MED file is not readable.
+ * \throw If there is no mesh named \a mName in the MED file.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
+ * \throw If \a this field has not been constructed via file reading.
+ * \throw If no field of \a this is lying on the mesh named \a mName.
+ * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
+ * \sa getFieldAtLevel()
+ */
+MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ if(getFileName2().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());
+ arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+ return ret.retn();
+}
+
+/*!
+ * Returns values and a profile of the field of a given type lying on a given support.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of the field.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [in] mesh - the supporting mesh.
+ * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
+ * field of interest lies on. If the field lies on all entities of the given
+ * dimension, all ids in \a pfl are zero. The caller is to delete this array
+ * using decrRef() as it is no more needed.
+ * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
+ * field. The caller is to delete this array using decrRef() as it is no more needed.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
+ * \throw If no field of \a this is lying on \a mesh.
+ * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
+ */
+DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
+ return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+}
+
+MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
+{
+ MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
+ MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
+ return ret;
+}
+
+DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNull()->getUndergroundDataArrayInt();
+}
+
+//= MEDFileAnyTypeFieldMultiTSWithoutSDA
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
+{
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
+{
+}
+
+/*!
+ * \param [in] fieldId field id in C mode
+ */
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
+{
+ med_field_type typcha;
+ std::string dtunitOut;
+ int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
+ setDtUnit(dtunitOut.c_str());
+ finishLoading(fid,nbOfStep,typcha);
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
+try:MEDFileFieldNameScope(fieldName),_infos(infos)
+{
+ setDtUnit(dtunit.c_str());
+ finishLoading(fid,nbOfStep,fieldTyp);
+}
+catch(INTERP_KERNEL::Exception& e)
+{
+ throw e;
+}
+
+std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
+{
+ std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
+ for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
+ ret+=(*it).capacity();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
+ ret+=(*it)->getHeapMemorySize();
+ return ret;
+}
+
+/*!
+ * If one of the id in [ \a startIds , \a endIds ) points to a null element, there is not throw. Simply, this empty element is added as if it were not
+ * NULL.
+ */
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
+ ret->setInfo(_infos);
+ int sz=(int)_time_steps.size();
+ for(const int *id=startIds;id!=endIds;id++)
+ {
+ if(*id>=0 && *id<sz)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
+ if(tse)
+ {
+ tse->incrRef();
+ tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
+ }
+ ret->pushBackTimeStep(tse2);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
+ oss << " ! Should be in [0," << sz << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ if(ret->getNumberOfTS()>0)
+ ret->synchronizeNameScope();
+ ret->copyNameScope(*this);
+ return ret.retn();
+}
+
+/*!
+ * If one of the id in the input range points to a null element, there is not throw. Simply, this empty element is added as if it were not
+ * NULL.
+ */
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
+{
+ static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
+ int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
+ ret->setInfo(_infos);
+ int sz=(int)_time_steps.size();
+ int j=bg;
+ for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
+ {
+ if(j>=0 && j<sz)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
+ if(tse)
+ {
+ tse->incrRef();
+ tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
+ }
+ ret->pushBackTimeStep(tse2);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
+ oss << " ! Should be in [0," << sz << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ if(ret->getNumberOfTS()>0)
+ ret->synchronizeNameScope();
+ ret->copyNameScope(*this);
+ return ret.retn();
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
+{
+ int id=0;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
+ if(!cur)
+ continue;
+ std::pair<int,int> p(cur->getIteration(),cur->getOrder());
+ if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
+ ids->pushBackSilent(id);
+ }
+ return buildFromTimeStepIds(ids->begin(),ids->end());
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
+{
+ int id=0;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
+ if(!cur)
+ continue;
+ std::pair<int,int> p(cur->getIteration(),cur->getOrder());
+ if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
+ ids->pushBackSilent(id);
+ }
+ return buildFromTimeStepIds(ids->begin(),ids->end());
+}
+
+const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
+{
+ return _infos;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
+{
+ _infos=info;
+}
+
+int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ int ret=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
+ if(pt->isDealingTS(iteration,order))
+ return ret;
+ }
+ std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
+ std::vector< std::pair<int,int> > vp=getIterations();
+ for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
+ oss << "(" << (*it2).first << "," << (*it2).second << ") ";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ return *_time_steps[getTimeStepPos(iteration,order)];
+}
+
+MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
+{
+ return *_time_steps[getTimeStepPos(iteration,order)];
+}
+
+std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
+{
+ if(_time_steps.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
+ return _time_steps[0]->getMeshName();
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
+{
+ std::string oldName(getMeshName());
+ std::vector< std::pair<std::string,std::string> > v(1);
+ v[0].first=oldName; v[0].second=newMeshName;
+ changeMeshNames(v);
+}
+
+bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ bool ret=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
+ if(cur)
+ ret=cur->changeMeshNames(modifTab) || ret;
+ }
+ return ret;
+}
+
+/*!
+ * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
+ */
+DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ return getTimeStepEntry(iteration,order).getUndergroundDataArray();
+}
+
+/*!
+ * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
+ */
+DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+{
+ return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
+}
+
+bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
+ MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ bool ret=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
+ if(f1ts)
+ ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
+ }
+ return ret;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
+{
+ std::string startLine(bkOffset,' ');
+ oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
+ if(fmtsId>=0)
+ oss << " (" << fmtsId << ")";
+ oss << " has the following name: \"" << _name << "\"." << std::endl;
+ oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
+ for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
+ {
+ oss << startLine << " - \"" << *it << "\"" << std::endl;
+ }
+ int i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
+ {
+ std::string chapter(17,'0'+i);
+ oss << startLine << chapter << std::endl;
+ const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
+ if(cur)
+ cur->simpleRepr(bkOffset+2,oss,i);
+ else
+ oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
+ oss << startLine << chapter << std::endl;
+ }
+}
+
+std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
+{
+ std::size_t sz=_time_steps.size();
+ std::vector< std::pair<int,int> > ret(sz);
+ ret1.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
+ if(f1ts)
+ {
+ ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return ret;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
+ if(!tse2)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
+ checkCoherencyOfType(tse2);
+ if(_time_steps.empty())
+ {
+ setName(tse2->getName().c_str());
+ setInfo(tse2->getInfo());
+ }
+ checkThatComponentsMatch(tse2->getInfo());
+ _time_steps.push_back(tse);
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
+{
+ std::size_t nbOfCompo=_infos.size();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
+ if(cur)
+ {
+ if((cur->getInfo()).size()!=nbOfCompo)
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
+ oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ cur->copyNameScope(*this);
+ }
+ }
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt, med_field_type fieldTyp) throw(INTERP_KERNEL::Exception)
+{
+ _time_steps.resize(nbPdt);
+ for(int i=0;i<nbPdt;i++)
+ {
+ std::vector< std::pair<int,int> > ts;
+ med_int numdt=0,numo=0;
med_int meshIt=0,meshOrder=0;
med_float dt=0.0;
MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
- _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,_field_type,numdt,numo,_infos);
- _time_steps[i]->finishLoading(fid);
+ switch(fieldTyp)
+ {
+ case MED_FLOAT64:
+ {
+ _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
+ break;
+ }
+ case MED_INT32:
+ {
+ _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading : managed field type are : FLOAT64, INT32 !");
+ }
+ _time_steps[i]->finishLoading(fid,*this);
+ }
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
+{
+ if(_time_steps.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
+ checkThatNbOfCompoOfTSMatchThis();
+ std::vector<std::string> infos(getInfo());
+ int nbComp=infos.size();
+ INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
+ for(int i=0;i<nbComp;i++)
+ {
+ std::string info=infos[i];
+ std::string c,u;
+ MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
+ MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
+ MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
+ }
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
+ MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
+ int nbOfTS=_time_steps.size();
+ for(int i=0;i<nbOfTS;i++)
+ _time_steps[i]->writeLL(fid,opts,*this);
+}
+
+int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
+{
+ return _time_steps.size();
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
+ if(tmp)
+ newTS.push_back(*it);
+ }
+ _time_steps=newTS;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
+ int maxId=(int)_time_steps.size();
+ int ii=0;
+ std::set<int> idsToDel;
+ for(const int *id=startIds;id!=endIds;id++,ii++)
+ {
+ if(*id>=0 && *id<maxId)
+ {
+ idsToDel.insert(*id);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ for(int iii=0;iii<maxId;iii++)
+ if(idsToDel.find(iii)==idsToDel.end())
+ newTS.push_back(_time_steps[iii]);
+ _time_steps=newTS;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
+{
+ static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
+ int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
+ if(nbOfEntriesToKill==0)
+ return ;
+ std::size_t sz=_time_steps.size();
+ std::vector<bool> b(sz,true);
+ int j=bg;
+ for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
+ b[j]=false;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
+ for(std::size_t i=0;i<sz;i++)
+ if(b[i])
+ newTS.push_back(_time_steps[i]);
+ _time_steps=newTS;
+}
+
+int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ int ret=0;
+ std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
+ if(tmp)
+ {
+ int it2,ord;
+ tmp->getTime(it2,ord);
+ if(it2==iteration && order==ord)
+ return ret;
+ else
+ oss << "(" << it2 << "," << ord << "), ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
+{
+ int ret=0;
+ std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
+ oss.precision(15);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
+ if(tmp)
+ {
+ int it2,ord;
+ double ti=tmp->getTime(it2,ord);
+ if(fabs(time-ti)<eps)
+ return ret;
+ else
+ oss << ti << ", ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
+{
+ int lgth=_time_steps.size();
+ std::vector< std::pair<int,int> > ret(lgth);
+ for(int i=0;i<lgth;i++)
+ _time_steps[i]->fillIteration(ret[i]);
+ return ret;
+}
+
+/*!
+ * This method has 3 inputs 'iteration' 'order' 'mname'. 'mname' can be null if the user is the general case where there is only one meshName lying on 'this'
+ * This method returns two things.
+ * - The absolute dimension of 'this' in first parameter.
+ * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
+ * to the first output parameter. The values in 'levs' will be returned in decreasing order.
+ *
+ * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
+ * Only these 3 discretizations will be taken into account here.
+ *
+ * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
+ * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
+ * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
+ *
+ * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
+ * It is possible (even if it is not common) that the highest level in 'this' were not equal to the meshDimension of the underlying mesh in 'this'.
+ *
+ * Let's consider the typical following case :
+ * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
+ * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
+ * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
+ * TETRA4 and SEG2
+ * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
+ *
+ * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
+ *
+ * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
+ * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
+ * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
+ * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
+ */
+int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
+{
+ return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
+}
+
+const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
+{
+ if(pos<0 || pos>=(int)_time_steps.size())
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
+ if(item==0)
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
+ oss << "\nTry to use following method eraseEmptyTS !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return item;
+}
+
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
+{
+ if(pos<0 || pos>=(int)_time_steps.size())
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
+ if(item==0)
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
+ oss << "\nTry to use following method eraseEmptyTS !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return item;
+}
+
+std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
+{
+ std::vector<std::string> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
+ ret.insert(ret.end(),tmp.begin(),tmp.end());
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
+{
+ std::vector<std::string> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
+ ret.insert(ret.end(),tmp.begin(),tmp.end());
+ }
+ return ret;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ (*it)->changePflsRefsNamesGen2(mapOfModif);
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ (*it)->changeLocsRefsNamesGen2(mapOfModif);
+}
+
+std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
+{
+ int lgth=_time_steps.size();
+ std::vector< std::vector<TypeOfField> > ret(lgth);
+ for(int i=0;i<lgth;i++)
+ _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
+ return ret;
+}
+
+/*!
+ * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
+ */
+std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
+{
+ return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
+ std::size_t i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
+ {
+ if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
+ ret->_time_steps[i]=(*it)->deepCpy();
+ }
+ return ret.retn();
+}
+
+std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
+{
+ std::size_t sz(_infos.size()),sz2(_time_steps.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
+ std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ ret[i]=shallowCpy();
+ ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
+ }
+ for(std::size_t i=0;i<sz2;i++)
+ {
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
+ if(ret1.size()!=sz)
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ ts[i]=ret1;
+ }
+ for(std::size_t i=0;i<sz;i++)
+ for(std::size_t j=0;j<sz2;j++)
+ ret[i]->_time_steps[j]=ts[j][i];
+ return ret;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
+{
+ _name=field->getName();
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
+ if(!arr)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
+ _infos=arr->getInfoOnComponents();
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
+{
+ static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
+ if(_name!=field->getName())
+ {
+ std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
+ oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(!arr)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
+ checkThatComponentsMatch(arr->getInfoOnComponents());
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
+{
+ static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
+ if(getInfo().size()!=compos.size())
+ {
+ std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
+ oss << " number of components of element to append (" << compos.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(_infos!=compos)
+ {
+ std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
+ std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
+ oss << " But compo in input fields are : ";
+ std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
+ oss << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
+{
+ std::size_t sz=_infos.size();
+ int j=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
+ {
+ const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
+ if(elt)
+ if(elt->getInfo().size()!=sz)
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
+ oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ if(!field)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
+ if(!_time_steps.empty())
+ checkCoherencyOfTinyInfo(field,arr);
+ MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
+ objC->setFieldNoProfileSBT(field,arr,glob,*this);
+ copyTinyInfoFrom(field,arr);
+ _time_steps.push_back(obj);
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ if(!field)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
+ if(!_time_steps.empty())
+ checkCoherencyOfTinyInfo(field,arr);
+ MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
+ objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
+ copyTinyInfoFrom(field,arr);
+ _time_steps.push_back(obj);
+}
+
+//= MEDFileFieldMultiTSWithoutSDA
+
+MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
+}
+
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
+{
+}
+
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
+{
+}
+
+/*!
+ * \param [in] fieldId field id in C mode
+ */
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
+{
+}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
+
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
+{
+}
+catch(INTERP_KERNEL::Exception& e)
+{ throw e; }
+
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileField1TSWithoutSDA;
+}
+
+void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
+{
+ if(!f1ts)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
+ const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
+ if(!f1tsC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
+}
+
+const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
+{
+ return MEDFileField1TSWithoutSDA::TYPE_STR;
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFieldMultiTSWithoutSDA(*this);
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFieldMultiTSWithoutSDA;
+}
+
+/*!
+ * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
+ * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
+ */
+std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
+ const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
+ return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
+}
+
+MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
+{
+}
+
+MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
+try:MEDFileFieldGlobsReal(fileName)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ _content=BuildContentFrom(fid,fileName);
+ loadGlobals(fid);
+}
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+{
+ med_field_type typcha;
+ std::vector<std::string> infos;
+ std::string dtunit;
+ int i=-1;
+ MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
+ switch(typcha)
+ {
+ case MED_FLOAT64:
+ {
+ ret=new MEDFileFieldMultiTSWithoutSDA(fid,i);
+ break;
+ }
+ case MED_INT32:
+ {
+ ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i);
+ break;
+ }
+ default:
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ ret->setDtUnit(dtunit.c_str());
+ return ret.retn();
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ med_field_type typcha;
+ //
+ std::vector<std::string> infos;
+ std::string dtunit,fieldName;
+ MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
+ switch(typcha)
+ {
+ case MED_FLOAT64:
+ {
+ ret=new MEDFileFieldMultiTSWithoutSDA(fid,0);
+ break;
+ }
+ case MED_INT32:
+ {
+ ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0);
+ break;
+ }
+ default:
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ ret->setDtUnit(dtunit.c_str());
+ return ret.retn();
+}
+
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ if(!c)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
+ if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
+ ret->setFileName(fileName);
+ ret->_content=c; c->incrRef();
+ return ret.retn();
+ }
+ if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
+ ret->setFileName(fileName);
+ ret->_content=c; c->incrRef();
+ return ret.retn();
+ }
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
+}
+
+MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+try:MEDFileFieldGlobsReal(fileName)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ _content=BuildContentFrom(fid,fileName,fieldName);
+ loadGlobals(fid);
+}
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+//= MEDFileIntFieldMultiTSWithoutSDA
+
+MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
+}
+
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
+{
+}
+
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
+{
+}
+
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
+{
+}
+catch(INTERP_KERNEL::Exception& e)
+{ throw e; }
+
+/*!
+ * \param [in] fieldId field id in C mode
+ */
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
+{
+}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
+
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileIntField1TSWithoutSDA;
+}
+
+void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
+{
+ if(!f1ts)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
+ const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
+ if(!f1tsC)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
+}
+
+const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
+{
+ return MEDFileIntField1TSWithoutSDA::TYPE_STR;
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileIntFieldMultiTSWithoutSDA(*this);
+}
+
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileIntFieldMultiTSWithoutSDA;
+}
+
+//= MEDFileAnyTypeFieldMultiTS
+
+/*!
+ * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
+ * that has been read from a specified MED file.
+ * \param [in] fileName - the name of the MED file to read.
+ * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ * \throw If reading the file fails.
+ */
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
+ ret->loadGlobals(fid);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
+ * that has been read from a specified MED file.
+ * \param [in] fileName - the name of the MED file to read.
+ * \param [in] fieldName - the name of the field to read.
+ * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ * \throw If reading the file fails.
+ * \throw If there is no field named \a fieldName in the file.
+ */
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
+ ret->loadGlobals(fid);
+ return ret.retn();
+}
+
+/*!
+ * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
+ * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
+ *
+ * \warning this is a shallow copy constructor
+ */
+MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
+{
+ if(!shallowCopyOfContent)
+ {
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
+ otherPtr->incrRef();
+ _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
+ }
+ else
+ {
+ _content=other.shallowCpy();
}
}
-void MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
{
- _name=field->getName();
- if(_name.empty())
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
- const DataArrayDouble *arr=field->getArray();
- if(!arr)
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
- _infos=arr->getInfoOnComponents();
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
+ return ret;
+}
+
+const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
+ return ret;
+}
+
+std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
+{
+ return contentNotNullBase()->getPflsReallyUsed2();
+}
+
+std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
+{
+ return contentNotNullBase()->getLocsReallyUsed2();
+}
+
+std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
+{
+ return contentNotNullBase()->getPflsReallyUsedMulti2();
+}
+
+std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
+{
+ return contentNotNullBase()->getLocsReallyUsedMulti2();
+}
+
+void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+{
+ contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
+}
+
+void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+{
+ contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
+}
+
+int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
+{
+ return contentNotNullBase()->getNumberOfTS();
+}
+
+void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
+{
+ contentNotNullBase()->eraseEmptyTS();
+}
+
+void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
+{
+ contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
+}
+
+void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
+{
+ contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
+}
+
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
+ ret->_content=c;
+ return ret.retn();
+}
+
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
+ ret->_content=c;
+ return ret.retn();
+}
+
+std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
+{
+ return contentNotNullBase()->getIterations();
+}
+
+void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
+ pushBackTimeStep(*it);
+}
+
+void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
+{
+ if(!f1ts)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
+ checkCoherencyOfType(f1ts);
+ f1ts->incrRef();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
+ MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
+ c->incrRef();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
+ if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
+ _content->pushBackTimeStep(cSafe);
+ appendGlobs(*f1ts,1e-12);
+}
+
+void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
+{
+ contentNotNullBase()->synchronizeNameScope();
+}
+
+int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->getPosOfTimeStep(iteration,order);
+}
+
+int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->getPosGivenTime(time,eps);
+}
+
+int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
+}
+
+std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->getTypesOfFieldAvailable();
+}
+
+std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
+}
+
+std::string MEDFileAnyTypeFieldMultiTS::getName() const
+{
+ return contentNotNullBase()->getName();
+}
+
+void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
+{
+ contentNotNullBase()->setName(name);
+}
+
+std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->getDtUnit();
+}
+
+void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
+{
+ contentNotNullBase()->setDtUnit(dtUnit);
+}
+
+void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
+{
+ contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
+}
+
+std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->getTimeSteps(ret1);
+}
+
+std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->getMeshName();
+}
+
+void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
+{
+ contentNotNullBase()->setMeshName(newMeshName);
+}
+
+bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->changeMeshNames(modifTab);
+}
+
+const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->getInfo();
+}
+
+void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
+{
+ return contentNotNullBase()->setInfo(info);
+}
+
+int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
+{
+ const std::vector<std::string> ret=getInfo();
+ return (int)ret.size();
+}
+
+void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
+{
+ writeGlobals(fid,*this);
+ contentNotNullBase()->writeLL(fid,*this);
+}
+
+/*!
+ * Writes \a this field into a MED file specified by its name.
+ * \param [in] fileName - the MED file name.
+ * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
+ * - 2 - erase; an existing file is removed.
+ * - 1 - append; same data should not be present in an existing file.
+ * - 0 - overwrite; same data present in an existing file is overwritten.
+ * \throw If the field name is not set.
+ * \throw If no field data is set.
+ * \throw If \a mode == 1 and the same data is present in an existing file.
+ */
+void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ writeLL(fid);
+}
+
+std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
+{
+ std::ostringstream oss;
+ contentNotNullBase()->simpleRepr(0,oss,-1);
+ simpleReprGlobs(oss);
+ return oss.str();
+}
+
+std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
+{
+ std::size_t ret=0;
+ if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
+ ret+=_content->getHeapMemorySize();
+ return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
+}
+
+/*!
+ * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
+ * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
+ * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
+ */
+std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
+ if(!content)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
+ std::size_t sz(contentsSplit.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ ret[i]=shallowCpy();
+ ret[i]->_content=contentsSplit[i];
+ }
+ return ret;
+}
+
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
+ if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
+ ret->_content=_content->deepCpy();
+ ret->deepCpyGlobs(*this);
+ return ret.retn();
+}
+
+MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
+{
+ return _content;
+}
+
+/*!
+ * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
+ * \param [in] iteration - the iteration number of a required time step.
+ * \param [in] order - the iteration order number of required time step.
+ * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
+ * delete this field using decrRef() as it is no more needed.
+ * \throw If there is no required time step in \a this field.
+ */
+MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ int pos=getPosOfTimeStep(iteration,order);
+ return getTimeStepAtPos(pos);
+}
+
+/*!
+ * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
+ * \param [in] time - the time of the time step of interest.
+ * \param [in] eps - a precision used to compare time values.
+ * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
+ * delete this field using decrRef() as it is no more needed.
+ * \throw If there is no required time step in \a this field.
+ */
+MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
+{
+ int pos=getPosGivenTime(time,eps);
+ return getTimeStepAtPos(pos);
+}
+
+MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileAnyTypeFieldMultiTSIterator(this);
+}
+
+//= MEDFileFieldMultiTS
+
+/*!
+ * Returns a new empty instance of MEDFileFieldMultiTS.
+ * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ */
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
+{
+ return new MEDFileFieldMultiTS;
+}
+
+/*!
+ * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
+ * that has been read from a specified MED file.
+ * \param [in] fileName - the name of the MED file to read.
+ * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ * \throw If reading the file fails.
+ */
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName);
+ ret->contentNotNull();//to check that content type matches with \a this type.
+ return ret.retn();
}
-void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
+/*!
+ * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
+ * that has been read from a specified MED file.
+ * \param [in] fileName - the name of the MED file to read.
+ * \param [in] fieldName - the name of the field to read.
+ * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ * \throw If reading the file fails.
+ * \throw If there is no field named \a fieldName in the file.
+ */
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
{
- static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
- if(_name!=field->getName())
- {
- std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
- oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- const DataArrayDouble *arr=field->getArray();
- if(!arr)
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
- if(_infos!=arr->getInfoOnComponents())
- {
- std::ostringstream oss; oss << MSG << "components ! should be \"";
- std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
- oss << " But compo in input fields are : ";
- std::vector<std::string> tmp=arr->getInfoOnComponents();
- std::copy(tmp.begin(),tmp.end(),std::ostream_iterator<std::string>(oss,", "));
- oss << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName);
+ ret->contentNotNull();//to check that content type matches with \a this type.
+ return ret.retn();
}
-void MEDFileFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
+/*!
+ * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
+ * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
+ *
+ * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
+ * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
+ * \warning this is a shallow copy constructor
+ * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
+ * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
+ * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
+ * is to delete this field using decrRef() as it is no more needed.
+ */
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
{
- if(_time_steps.empty())
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
- std::vector<std::string> infos(getInfo());
- int nbComp=infos.size();
- INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
- for(int i=0;i<nbComp;i++)
- {
- std::string info=infos[i];
- std::string c,u;
- MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
- MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
- MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
- }
- if(_name.empty())
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
- MEDfieldCr(fid,_name.c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
- int nbOfTS=_time_steps.size();
- for(int i=0;i<nbOfTS;i++)
- _time_steps[i]->writeLL(fid,opts);
+ return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
}
-int MEDFileFieldMultiTSWithoutSDA::getNumberOfTS() const
+MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
{
- return _time_steps.size();
+ return new MEDFileFieldMultiTS(*this);
}
-void MEDFileFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
+void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- {
- const MEDFileField1TSWithoutSDA *tmp=(*it);
- if(tmp)
- newTS.push_back(*it);
- }
- _time_steps=newTS;
+ if(!f1ts)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
+ const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
+ if(!f1tsC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
}
-void MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
+/*!
+ * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
+ * \param [in] pos - a time step id.
+ * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
+ * delete this field using decrRef() as it is no more needed.
+ * \throw If \a pos is not a valid time step id.
+ */
+MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
- int maxId=(int)_time_steps.size();
- int ii=0;
- std::set<int> idsToDel;
- for(const int *id=startIds;id!=endIds;id++,ii++)
+ const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
+ if(!item)
{
- if(*id>=0 && *id<maxId)
- {
- idsToDel.insert(*id);
- }
- else
- {
- std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- for(int iii=0;iii<maxId;iii++)
- if(idsToDel.find(iii)==idsToDel.end())
- newTS.push_back(_time_steps[iii]);
- _time_steps=newTS;
-}
-
-int MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
-{
- int ret=0;
- std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
+ const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
+ if(itemC)
{
- const MEDFileField1TSWithoutSDA *tmp(*it);
- if(tmp)
- {
- int it2,ord;
- tmp->getTime(it2,ord);
- if(it2==iteration && order==ord)
- return ret;
- else
- oss << "(" << it2 << "," << ord << "), ";
- }
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
+ ret->shallowCpyGlobs(*this);
+ return ret.retn();
}
+ std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
-int MEDFileFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
+/*!
+ * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
+ * mesh entities of a given dimension of the first mesh in MED file.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [in] iteration - the iteration number of a required time step.
+ * \param [in] order - the iteration order number of required time step.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If the MED file is not readable.
+ * \throw If there is no mesh in the MED file.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
+ * \throw If no field values of the required parameters are available.
+ */
+MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
{
- int ret=0;
- std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
- oss.precision(15);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
- {
- const MEDFileField1TSWithoutSDA *tmp(*it);
- if(tmp)
- {
- int it2,ord;
- double ti=tmp->getTime(it2,ord);
- if(fabs(time-ti)<eps)
- return ret;
- else
- oss << ti << ", ";
- }
- }
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
}
-std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getIterations() const
+/*!
+ * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
+ * the top level cells of the first mesh in MED file.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [in] iteration - the iteration number of a required time step.
+ * \param [in] order - the iteration order number of required time step.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
+ *
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If the MED file is not readable.
+ * \throw If there is no mesh in the MED file.
+ * \throw If no field values of the required parameters are available.
+ */
+MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
{
- int lgth=_time_steps.size();
- std::vector< std::pair<int,int> > ret(lgth);
- for(int i=0;i<lgth;i++)
- _time_steps[i]->fillIteration(ret[i]);
- return ret;
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
}
/*!
- * This method has 3 inputs 'iteration' 'order' 'mname'. 'mname' can be null if the user is the general case where there is only one meshName lying on 'this'
- * This method returns two things.
- * - The absolute dimension of 'this' in first parameter.
- * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
- * to the first output parameter. The values in 'levs' will be returned in decreasing order.
- *
- * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
- * Only these 3 discretizations will be taken into account here.
- *
- * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
- * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
- * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
+ * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
+ * a given support.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of interest.
+ * \param [in] iteration - the iteration number of a required time step.
+ * \param [in] order - the iteration order number of required time step.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [in] mesh - the supporting mesh.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
*
- * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
- * It is possible (even if it is not common) that the highest level in 'this' were not equal to the meshDimension of the underlying mesh in 'this'.
- *
- * Let's consider the typical following case :
- * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
- * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
- * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
- * TETRA4 and SEG2
- * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
+ * \throw If no field of \a this is lying on \a mesh.
+ * \throw If no field values of the required parameters are available.
+ */
+MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
+/*!
+ * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
+ * given support.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of the new field.
+ * \param [in] iteration - the iteration number of a required time step.
+ * \param [in] order - the iteration order number of required time step.
+ * \param [in] mesh - the supporting mesh.
+ * \param [in] renumPol - specifies how to permute values of the result field according to
+ * the optional numbers of cells and nodes, if any. The valid values are
+ * - 0 - do not permute.
+ * - 1 - permute cells.
+ * - 2 - permute nodes.
+ * - 3 - permute cells and nodes.
*
- * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
- *
- * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
- * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
- * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
- * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
+ * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed.
+ * \throw If no field of \a this is lying on \a mesh.
+ * \throw If no field values of the required parameters are available.
+ */
+MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
+/*!
+ * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
+ * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
+ * This method is useful for MED2 file format when field on different mesh was autorized.
+ */
+MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
+ MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
+ return ret.retn();
+}
+
+/*!
+ * Returns values and a profile of the field of a given type, of a given time step,
+ * lying on a given support.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] type - a spatial discretization of the field.
+ * \param [in] iteration - the iteration number of a required time step.
+ * \param [in] order - the iteration order number of required time step.
+ * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [in] mesh - the supporting mesh.
+ * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
+ * field of interest lies on. If the field lies on all entities of the given
+ * dimension, all ids in \a pfl are zero. The caller is to delete this array
+ * using decrRef() as it is no more needed.
+ * \param [in] glob - the global data storing profiles and localization.
+ * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
+ * field. The caller is to delete this array using decrRef() as it is no more needed.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
+ * \throw If no field of \a this is lying on \a mesh.
+ * \throw If no field values of the required parameters are available.
*/
-int MEDFileFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
{
- return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
+ return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
}
-std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
+const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
{
- int lgth=_time_steps.size();
- std::vector< std::vector<TypeOfField> > ret(lgth);
- for(int i=0;i<lgth;i++)
- _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
+ const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
+ return ret;
+}
+
+ MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
+{
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
+ MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
return ret;
}
/*!
- * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
+ * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
+ * the given field is checked if its elements are sorted suitable for writing to MED file
+ * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] field - the field to add to \a this.
+ * \throw If the name of \a field is empty.
+ * \throw If the data array of \a field is not set.
+ * \throw If existing time steps have different name or number of components than \a field.
+ * \throw If the underlying mesh of \a field has no name.
+ * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
*/
-std::vector< std::vector< std::pair<int,int> > > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
+void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
{
- return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
+ const DataArrayDouble *arr=0;
+ if(field)
+ arr=field->getArray();
+ contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
}
/*!
- * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
- * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
+ * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
+ * a given dimension of a given mesh are used as the support of the given field.
+ * Elements of the given mesh must be sorted suitable for writing to MED file.
+ * Order of underlying mesh entities of the given field specified by \a profile parameter
+ * is not prescribed; this method permutes field values to have them sorted by element
+ * type as required for writing to MED file.
+ * For more info, see \ref AdvMEDLoaderAPIFieldRW
+ * \param [in] field - the field to add to \a this.
+ * \param [in] mesh - the supporting mesh of \a field.
+ * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
+ * \param [in] profile - ids of mesh entities on which corresponding field values lie.
+ * \throw If either \a field or \a mesh or \a profile has an empty name.
+ * \throw If existing time steps have different name or number of components than \a field.
+ * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
+ * \throw If the data array of \a field is not set.
+ * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
*/
-std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
+void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
{
- return getTimeStepEntry(iteration,order).getFieldSplitedByType2(mname,types,typesF,pfls,locs);
+ const DataArrayDouble *arr=0;
+ if(field)
+ arr=field->getArray();
+ contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
}
-const MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+MEDFileFieldMultiTS::MEDFileFieldMultiTS()
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- if((*it)->isDealingTS(iteration,order))
- return *(*it);
- std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
- std::vector< std::pair<int,int> > vp=getIterations();
- for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
- oss << "(" << (*it2).first << "," << (*it2).second << ") ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ _content=new MEDFileFieldMultiTSWithoutSDA;
}
-MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
+MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeFieldMultiTS(fileName)
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- if((*it)->isDealingTS(iteration,order))
- return *(*it);
- std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
- std::vector< std::pair<int,int> > vp=getIterations();
- for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
- oss << "(" << (*it2).first << "," << (*it2).second << ") ";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
-const MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
+MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
{
- if(pos<0 || pos>=(int)_time_steps.size())
- {
- std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- const MEDFileField1TSWithoutSDA *item=_time_steps[pos];
- if(item==0)
- {
- std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
- oss << "\nTry to use following method eraseEmptyTS !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- return item;
}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
-MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
+MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
{
- if(pos<0 || pos>=(int)_time_steps.size())
- {
- std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- MEDFileField1TSWithoutSDA *item=_time_steps[pos];
- if(item==0)
- {
- std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
- oss << "\nTry to use following method eraseEmptyTS !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- return item;
}
-std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
+std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
{
- std::vector<std::string> ret;
- std::set<std::string> ret2;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- {
- std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
- for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
- if(ret2.find(*it2)==ret2.end())
- {
- ret.push_back(*it2);
- ret2.insert(*it2);
- }
- }
- return ret;
+ return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
}
-std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
+DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
{
- std::vector<std::string> ret;
- std::set<std::string> ret2;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- {
- std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
- for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
- if(ret2.find(*it2)==ret2.end())
- {
- ret.push_back(*it2);
- ret2.insert(*it2);
- }
- }
- return ret;
+ return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
}
-std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
+DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
{
- std::vector<std::string> ret;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- {
- std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
- ret.insert(ret.end(),tmp.begin(),tmp.end());
- }
- return ret;
+ return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
}
-std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
+//= MEDFileAnyTypeFieldMultiTSIterator
+
+MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
{
- std::vector<std::string> ret;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if(fmts)
{
- std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
- ret.insert(ret.end(),tmp.begin(),tmp.end());
+ fmts->incrRef();
+ _nb_iter=fmts->getNumberOfTS();
}
- return ret;
}
-void MEDFileFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- (*it)->changePflsRefsNamesGen2(mapOfModif);
}
-void MEDFileFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
+MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
- (*it)->changeLocsRefsNamesGen2(mapOfModif);
+ if(_iter_id<_nb_iter)
+ {
+ MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
+ if(fmts)
+ return fmts->getTimeStepAtPos(_iter_id++);
+ else
+ return 0;
+ }
+ else
+ return 0;
}
+//= MEDFileIntFieldMultiTS
+
/*!
* Returns a new empty instance of MEDFileFieldMultiTS.
- * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
+ * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
* is to delete this field using decrRef() as it is no more needed.
*/
-MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
+MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
{
- return new MEDFileFieldMultiTS;
+ return new MEDFileIntFieldMultiTS;
}
/*!
- * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
+ * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
* that has been read from a specified MED file.
* \param [in] fileName - the name of the MED file to read.
- * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
+ * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
* is to delete this field using decrRef() as it is no more needed.
* \throw If reading the file fails.
*/
-MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
{
- return new MEDFileFieldMultiTS(fileName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName);
+ ret->contentNotNull();//to check that content type matches with \a this type.
+ return ret.retn();
}
/*!
- * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
+ * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
* that has been read from a specified MED file.
* \param [in] fileName - the name of the MED file to read.
* \param [in] fieldName - the name of the field to read.
- * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
+ * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
* is to delete this field using decrRef() as it is no more needed.
* \throw If reading the file fails.
* \throw If there is no field named \a fieldName in the file.
*/
-MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
{
- return new MEDFileFieldMultiTS(fileName,fieldName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName);
+ ret->contentNotNull();//to check that content type matches with \a this type.
+ return ret.retn();
}
/*!
- * Returns a new instance of MEDFileFieldMultiTS holding either deep or shallow copy
- * of a given MEDFileFieldMultiTSWithoutSDA.
- * \param [in] other - a MEDFileFieldMultiTSWithoutSDA to copy.
+ * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
+ * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
+ *
+ * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
+ * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
+ * \warning this is a shallow copy constructor
+ * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
* \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
- * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
+ * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
* is to delete this field using decrRef() as it is no more needed.
*/
-MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
-{
- return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
-}
-
-std::size_t MEDFileFieldMultiTS::getHeapMemorySize() const
-{
- std::size_t ret=0;
- if((const MEDFileFieldMultiTSWithoutSDA*)_content)
- ret+=_content->getHeapMemorySize();
- return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
-}
-
-MEDFileFieldMultiTS *MEDFileFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
-{
- MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(*this);
- if((const MEDFileFieldMultiTSWithoutSDA *)_content)
- ret->_content=_content->deepCpy();
- ret->deepCpyGlobs(*this);
- return ret.retn();
-}
-
-/*!
- * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
- * \param [in] pos - a time step id.
- * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
- * delete this field using decrRef() as it is no more needed.
- * \throw If \a pos is not a valid time step id.
- */
-MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
-{
- const MEDFileField1TSWithoutSDA *item=_content->getTimeStepAtPos2(pos);
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*item,false);
- ret->shallowCpyGlobs(*this);
- return ret.retn();
-}
-
-/*!
- * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
- * \param [in] iteration - the iteration number of a required time step.
- * \param [in] order - the iteration order number of required time step.
- * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
- * delete this field using decrRef() as it is no more needed.
- * \throw If there is no required time step in \a this field.
- */
-MEDFileField1TS *MEDFileFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
-{
- int pos=getPosOfTimeStep(iteration,order);
- return getTimeStepAtPos(pos);
-}
-
-/*!
- * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
- * \param [in] time - the time of the time step of interest.
- * \param [in] eps - a precision used to compare time values.
- * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
- * delete this field using decrRef() as it is no more needed.
- * \throw If there is no required time step in \a this field.
- */
-MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
-{
- int pos=getPosGivenTime(time,eps);
- return getTimeStepAtPos(pos);
-}
-
-MEDFileFieldMultiTSIterator *MEDFileFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
-{
- return new MEDFileFieldMultiTSIterator(this);
-}
-
-std::string MEDFileFieldMultiTS::simpleRepr() const
+MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
{
- std::ostringstream oss;
- _content->simpleRepr(0,oss,-1);
- MEDFileFieldGlobsReal::simpleRepr(oss);
- return oss.str();
+ return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
}
-void MEDFileFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
+MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
{
- writeGlobals(fid,*this);
- _content->writeLL(fid,*this);
+ return new MEDFileIntFieldMultiTS(*this);
}
-/*!
- * Writes \a this field into a MED file specified by its name.
- * \param [in] fileName - the MED file name.
- * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
- * - 2 - erase; an existing file is removed.
- * - 1 - append; same data should not be present in an existing file.
- * - 0 - overwrite; same data present in an existing file is overwritten.
- * \throw If the field name is not set.
- * \throw If no field data is set.
- * \throw If \a mode == 1 and the same data is present in an existing file.
- */
-void MEDFileFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
{
- med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
- writeLL(fid);
+ if(!f1ts)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
+ const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
+ if(!f1tsC)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
}
/*!
* \param [in] iteration - the iteration number of a required time step.
* \param [in] order - the iteration order number of required time step.
* \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
+ * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
* \throw If no field values of the required parameters are available.
*/
-MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
{
- const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
- return myF1TS.getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
+ arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+ return ret.retn();
}
/*!
* \param [in] type - a spatial discretization of interest.
* \param [in] iteration - the iteration number of a required time step.
* \param [in] order - the iteration order number of required time step.
+ * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* \throw If there is no mesh in the MED file.
* \throw If no field values of the required parameters are available.
*/
-MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
{
- const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
- return myF1TS.getFieldAtTopLevel(type,0,renumPol,this);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
+ arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+ return ret.retn();
}
/*!
* \param [in] type - a spatial discretization of interest.
* \param [in] iteration - the iteration number of a required time step.
* \param [in] order - the iteration order number of required time step.
+ * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
* \param [in] mesh - the supporting mesh.
* \param [in] renumPol - specifies how to permute values of the result field according to
* \throw If no field of \a this is lying on \a mesh.
* \throw If no field values of the required parameters are available.
*/
-MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
{
- const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
- return myF1TS.getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
+ arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+ return ret.retn();
}
/*!
* \param [in] iteration - the iteration number of a required time step.
* \param [in] order - the iteration order number of required time step.
* \param [in] mesh - the supporting mesh.
+ * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* \throw If no field of \a this is lying on \a mesh.
* \throw If no field values of the required parameters are available.
*/
-MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
{
- const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
- return myF1TS.getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
+ arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+ return ret.retn();
}
/*!
- * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
+ * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
* This method is called 'old' because the user should give the mesh name he wants to use for it's field.
* This method is useful for MED2 file format when field on different mesh was autorized.
*/
-MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
{
- const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
- return myF1TS.getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
+ arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
+ return ret.retn();
}
/*!
* dimension, all ids in \a pfl are zero. The caller is to delete this array
* using decrRef() as it is no more needed.
* \param [in] glob - the global data storing profiles and localization.
- * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
+ * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
* field. The caller is to delete this array using decrRef() as it is no more needed.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
* \throw If no field of \a this is lying on \a mesh.
* \throw If no field values of the required parameters are available.
*/
-DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
+ const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
+ if(!myF1TSC)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
+ MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
+ return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
+}
+
+/*!
+ * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
+ * \param [in] pos - a time step id.
+ * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
+ * delete this field using decrRef() as it is no more needed.
+ * \throw If \a pos is not a valid time step id.
+ */
+MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
{
- const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
- return myF1TS.getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
+ const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
+ if(!item)
+ {
+ std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
+ if(itemC)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
+ ret->shallowCpyGlobs(*this);
+ return ret.retn();
+ }
+ std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
/*!
* \throw If the underlying mesh of \a field has no name.
* \throw If elements in the mesh are not in the order suitable for writing to the MED file.
*/
-void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
+void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
{
- _content->appendFieldNoProfileSBT(field,*this);
+ contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
}
/*!
* \throw If the data array of \a field is not set.
* \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
*/
-void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
-{
- _content->appendFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
-}
-
-MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> MEDFileFieldMultiTS::getContent()
-{
- return _content;
-}
-
-MEDFileFieldMultiTS::MEDFileFieldMultiTS():_content(new MEDFileFieldMultiTSWithoutSDA)
-{
-}
-
-
-
-MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
-try:MEDFileFieldGlobsReal(fileName)
-{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
- int nbFields=MEDnField(fid);
- if(nbFields<1)
- {
- std::ostringstream oss; oss << "MEDFileFieldMultiTS(const char *fileName) constructor : no fields in file \"" << fileName << "\" !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- _content=new MEDFileFieldMultiTSWithoutSDA(fid,0);
- //
- loadGlobals(fid);
-}
-catch(INTERP_KERNEL::Exception& e)
- {
- throw e;
- }
-
-MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
-try:MEDFileFieldGlobsReal(fileName)
-{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
- int nbFields=MEDnField(fid);
- med_field_type typcha;
- bool found=false;
- std::vector<std::string> fns(nbFields);
- for(int i=0;i<nbFields && !found;i++)
- {
- int ncomp=MEDfieldnComponent(fid,i+1);
- INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- med_bool localMesh;
- int nbOfStep;
- MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
- std::string tmp(nomcha);
- fns[i]=tmp;
- found=(tmp==fieldName);
- if(found)
- _content=new MEDFileFieldMultiTSWithoutSDA(fid,i);
- }
- if(!found)
- {
- std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
- std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- //
- loadGlobals(fid);
-}
-catch(INTERP_KERNEL::Exception& e)
- {
- throw e;
- }
-
-MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
-{
- if(!shallowCopyOfContent)
- {
- const MEDFileFieldMultiTSWithoutSDA *otherPtr(&other);
- otherPtr->incrRef();
- _content=const_cast<MEDFileFieldMultiTSWithoutSDA *>(otherPtr);
- }
- else
- {
- _content=new MEDFileFieldMultiTSWithoutSDA(other);
- }
-}
-
-std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsed() const
-{
- return _content->getPflsReallyUsed2();
-}
-
-std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsed() const
-{
- return _content->getLocsReallyUsed2();
-}
-
-std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsedMulti() const
-{
- return _content->getPflsReallyUsedMulti2();
-}
-
-std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsedMulti() const
-{
- return _content->getLocsReallyUsedMulti2();
-}
-
-void MEDFileFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
-{
- _content->changePflsRefsNamesGen2(mapOfModif);
-}
-
-void MEDFileFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
-{
- _content->changeLocsRefsNamesGen2(mapOfModif);
-}
-
-int MEDFileFieldMultiTS::getNumberOfTS() const
-{
- return _content->getNumberOfTS();
-}
-
-void MEDFileFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
-{
- _content->eraseEmptyTS();
-}
-
-void MEDFileFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
-{
- _content->eraseTimeStepIds(startIds,endIds);
-}
-
-std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getIterations() const
-{
- return _content->getIterations();
-}
-
-int MEDFileFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
-{
- return _content->getPosOfTimeStep(iteration,order);
-}
-
-int MEDFileFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
-{
- return _content->getPosGivenTime(time,eps);
-}
-
-int MEDFileFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
-{
- return _content->getNonEmptyLevels(iteration,order,mname,levs);
-}
-
-std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
-{
- return _content->getTypesOfFieldAvailable();
-}
-
-std::vector< std::vector< std::pair<int,int> > > MEDFileFieldMultiTS::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
-{
- return _content->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
-}
-
-std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
-{
- return _content->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
-}
-
-std::string MEDFileFieldMultiTS::getName() const
+void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
{
- return _content->getName();
+ contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
}
-void MEDFileFieldMultiTS::setName(const char *name)
+const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
{
- _content->setName(name);
-}
-
-void MEDFileFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
-{
- _content->simpleRepr(bkOffset,oss,fmtsId);
-}
-
-std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
-{
- return _content->getTimeSteps(ret1);
-}
-
-std::string MEDFileFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
-{
- return _content->getMeshName();
-}
-
-void MEDFileFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
-{
- _content->setMeshName(newMeshName);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
+ const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
+ return ret;
}
-bool MEDFileFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+ MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
{
- return _content->changeMeshNames(modifTab);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
+ MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
+ return ret;
}
-const std::vector<std::string>& MEDFileFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
+MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
{
- return _content->getInfo();
+ _content=new MEDFileIntFieldMultiTSWithoutSDA;
}
-DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
{
- return _content->getUndergroundDataArray(iteration,order);
}
-DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
+MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeFieldMultiTS(fileName)
{
- return _content->getUndergroundDataArrayExt(iteration,order,entries);
}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
-MEDFileFieldMultiTSIterator::MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
+MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
{
- if(fmts)
- {
- fmts->incrRef();
- _nb_iter=fmts->getNumberOfTS();
- }
}
+catch(INTERP_KERNEL::Exception& e)
+ { throw e; }
-MEDFileFieldMultiTSIterator::~MEDFileFieldMultiTSIterator()
+DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
{
+ return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
}
-MEDFileField1TS *MEDFileFieldMultiTSIterator::nextt()
-{
- if(_iter_id<_nb_iter)
- {
- MEDFileFieldMultiTS *fmts(_fmts);
- if(fmts)
- return fmts->getTimeStepAtPos(_iter_id++);
- else
- return 0;
- }
- else
- return 0;
-}
+//= MEDFileFields
MEDFileFields *MEDFileFields::New()
{
std::size_t MEDFileFields::getHeapMemorySize() const
{
- std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA>);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
- if((const MEDFileFieldMultiTSWithoutSDA *)*it)
+ std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
ret+=(*it)->getHeapMemorySize();
return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
}
MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=new MEDFileFields(*this);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
std::size_t i=0;
- for( std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
{
- if((const MEDFileFieldMultiTSWithoutSDA*)*it)
+ if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
ret->_fields[i]=(*it)->deepCpy();
}
ret->deepCpyGlobs(*this);
return ret.retn();
}
+MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFields(*this);
+}
+
+/*!
+ * This method scans for all fields in \a this which time steps ids are common. Time step are discriminated by the pair of integer (iteration,order) whatever
+ * the double time value. If all returned time steps are \b exactly those for all fields in \a this output parameter \a areThereSomeForgottenTS will be set to false.
+ * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
+ *
+ * \param [out] areThereSomeForgottenTS - indicates to the caller if there is some time steps in \a this that are not present for all fields in \a this.
+ * \return the sorted list of time steps (specified with a pair of integer iteration first and order second) present for all fields in \a this.
+ *
+ * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
+ */
+std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
+{
+ std::set< std::pair<int,int> > s;
+ bool firstShot=true;
+ areThereSomeForgottenTS=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ {
+ if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
+ continue;
+ std::vector< std::pair<int,int> > v=(*it)->getIterations();
+ std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
+ if(firstShot)
+ { s=s1; firstShot=false; }
+ else
+ {
+ std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
+ if(s!=s2)
+ areThereSomeForgottenTS=true;
+ s=s2;
+ }
+ }
+ std::vector< std::pair<int,int> > ret;
+ std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
+ return ret;
+}
+
int MEDFileFields::getNumberOfFields() const
{
return _fields.size();
{
std::vector<std::string> ret(_fields.size());
int i=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
{
- const MEDFileFieldMultiTSWithoutSDA *f=(*it);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
if(f)
{
ret[i]=f->getName();
std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
{
std::vector<std::string> ret;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
- const MEDFileFieldMultiTSWithoutSDA *cur(*it);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
if(cur)
ret.push_back(cur->getMeshName());
}
std::string startLine(bkOffset,' ');
oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
int i=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
{
- const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
if(cur)
{
oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
}
}
i=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
{
- const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
std::string chapter(17,'0'+i);
oss << startLine << chapter << std::endl;
if(cur)
}
oss << startLine << chapter << std::endl;
}
- MEDFileFieldGlobsReal::simpleRepr(oss);
+ simpleReprGlobs(oss);
}
MEDFileFields::MEDFileFields()
med_field_type typcha;
for(int i=0;i<nbFields;i++)
{
- int ncomp=MEDfieldnComponent(fid,i+1);
- INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- med_bool localMesh;
- int nbOfStep;
- MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
- int ft=MEDFileUtilities::TraduceFieldType(typcha);
- std::vector<std::string> infos(ncomp);
- for(int j=0;j<ncomp;j++)
- infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
- _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,nomcha,i+1,ft,infos,nbOfStep);
+ std::vector<std::string> infos;
+ std::string fieldName,dtunit;
+ int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
+ switch(typcha)
+ {
+ case MED_FLOAT64:
+ {
+ _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
+ break;
+ }
+ case MED_INT32:
+ {
+ _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
+ break;
+ }
+ default:
+ {
+ std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
}
loadAllGlobals(fid);
}
{
int i=0;
writeGlobals(fid,*this);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
{
- const MEDFileFieldMultiTSWithoutSDA *elt=*it;
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
if(!elt)
{
std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
{
std::vector<std::string> ret;
std::set<std::string> ret2;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
{
std::vector<std::string> ret;
std::set<std::string> ret2;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
{
std::vector<std::string> ret;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
ret.insert(ret.end(),tmp.begin(),tmp.end());
std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
{
std::vector<std::string> ret;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
ret.insert(ret.end(),tmp.begin(),tmp.end());
void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
(*it)->changePflsRefsNamesGen2(mapOfModif);
}
void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
(*it)->changeLocsRefsNamesGen2(mapOfModif);
}
_fields.resize(newSize);
}
-void MEDFileFields::pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
+void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
+ pushField(*it);
+}
+
+void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
{
if(!field)
throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
appendGlobs(*field,1e-12);
}
-void MEDFileFields::setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
+void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
{
if(!field)
throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
{
- if(i<0 || i>=(int)_fields.size())
+ destroyFieldsAtPos(&i,&i+1);
+}
+
+void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<bool> b(_fields.size(),true);
+ for(const int *i=startIds;i!=endIds;i++)
{
- std::ostringstream oss; oss << "MEDFileFields::destroyMeshAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ if(*i<0 || *i>=(int)_fields.size())
+ {
+ std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ b[*i]=false;
+ }
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
+ std::size_t j=0;
+ for(std::size_t i=0;i<_fields.size();i++)
+ if(b[i])
+ fields[j++]=_fields[i];
+ _fields=fields;
+}
+
+void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
+{
+ static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
+ int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
+ std::vector<bool> b(_fields.size(),true);
+ int k=bg;
+ for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
+ {
+ if(k<0 || k>=(int)_fields.size())
+ {
+ std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ b[k]=false;
}
- _fields.erase(_fields.begin()+i);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
+ std::size_t j=0;
+ for(std::size_t i=0;i<_fields.size();i++)
+ if(b[i])
+ fields[j++]=_fields[i];
+ _fields=fields;
}
bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
{
bool ret=false;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
{
- MEDFileFieldMultiTSWithoutSDA *cur(*it);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
if(cur)
ret=cur->changeMeshNames(modifTab) || ret;
}
bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
{
bool ret=false;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
{
- MEDFileFieldMultiTSWithoutSDA *fmts(*it);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
if(fmts)
{
ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
return ret;
}
-MEDFileFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
+MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
{
if(i<0 || i>=(int)_fields.size())
{
std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- const MEDFileFieldMultiTSWithoutSDA *fmts=_fields[i];
- MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New(*fmts,false);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
+ if(!fmts)
+ return 0;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
+ const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
+ const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
+ if(fmtsC)
+ ret=MEDFileFieldMultiTS::New(*fmtsC,false);
+ else if(fmtsC2)
+ ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
ret->shallowCpyGlobs(*this);
return ret.retn();
}
-MEDFileFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
+/*!
+ * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
+ * This method is accessible in python using __getitem__ with a list in input.
+ * \return a new object that the caller should deal with.
+ */
+MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
+ std::size_t sz=std::distance(startIds,endIds);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
+ int j=0;
+ for(const int *i=startIds;i!=endIds;i++,j++)
+ {
+ if(*i<0 || *i>=(int)_fields.size())
+ {
+ std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ fields[j]=_fields[*i];
+ }
+ ret->_fields=fields;
+ return ret.retn();
+}
+
+MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
{
return getFieldAtPos(getPosFromFieldName(fieldName));
}
+/*!
+ * 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
+ * reduced the list of fields compared to those in \a this. The returned object is a new object but the object on which it lies are only
+ * shallow copied from \a this.
+ *
+ * \param [in] meshName - the name of the mesh on w
+ * \return a new object that the caller should deal with.
+ */
+MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
+ ret->shallowCpyOnlyUsedGlobs(*this);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ {
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
+ if(!cur)
+ continue;
+ if(cur->getMeshName()==meshName)
+ {
+ cur->incrRef();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
+ ret->_fields.push_back(cur2);
+ }
+ }
+ return ret.retn();
+}
+
+/*!
+ * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
+ * Input time steps are specified using a pair of integer (iteration, order).
+ * This method can be seen as a filter applied on \a this, that returns an object containing the same number of fields than those in \a this,
+ * but for each multitimestep only the time steps in \a timeSteps are kept.
+ * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
+ *
+ * The returned object points to shallow copy of elements in \a this.
+ *
+ * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
+ * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
+ * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
+ */
+MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ {
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
+ if(!cur)
+ continue;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
+ ret->_fields.push_back(elt);
+ }
+ ret->shallowCpyOnlyUsedGlobs(*this);
+ return ret.retn();
+}
+
+/*!
+ * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
+ */
+MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ {
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
+ if(!cur)
+ continue;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
+ if(elt->getNumberOfTS()!=0)
+ ret->_fields.push_back(elt);
+ }
+ ret->shallowCpyOnlyUsedGlobs(*this);
+ return ret.retn();
+}
+
MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
{
return new MEDFileFieldsIterator(this);
std::vector<std::string> poss;
for(std::size_t i=0;i<_fields.size();i++)
{
- const MEDFileFieldMultiTSWithoutSDA *f=_fields[i];
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
if(f)
{
std::string fname(f->getName());
{
}
-MEDFileFieldMultiTS *MEDFileFieldsIterator::nextt()
+MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
{
if(_iter_id<_nb_iter)
{
};
/// @cond INTERNAL
+ class MEDFileAnyTypeField1TSWithoutSDA;
class MEDFileFieldPerMeshPerType;
class MEDFileField1TSWithoutSDA;
+ class MEDFileFieldNameScope;
class MEDFileFieldGlobsReal;
class MEDFileFieldPerMesh;
static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other);
std::size_t getHeapMemorySize() const;
MEDFileFieldPerMeshPerTypePerDisc *deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception);
- void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception);
- void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMeshPerType *getFather() const;
- void prepareLoading(med_idt fid, int profileIt, int& start) throw(INTERP_KERNEL::Exception);
- void finishLoading(med_idt fid, int profileIt, int ft) throw(INTERP_KERNEL::Exception);
+ void prepareLoading(med_idt fid, int profileIt, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void finishLoading(med_idt fid, int profileIt, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
void setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception);
int getIteration() const;
int getOrder() const;
double getTime() const;
- std::string getName() const;
std::string getMeshName() const;
TypeOfField getType() const;
void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
int getNumberOfComponents() const;
int getNumberOfTuples() const;
int getStart() const { return _start; }
- DataArrayDouble *getArray();
- const DataArrayDouble *getArray() const;
+ DataArray *getArray();
+ const DataArray *getArray() const;
+ const DataArrayDouble *getArrayDouble() const;
+ DataArrayDouble *getArrayDouble();
const std::vector<std::string>& getInfo() const;
std::string getProfile() const;
void setProfile(const char *newPflName);
{
public:
static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
- static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
std::size_t getHeapMemorySize() const;
MEDFileFieldPerMeshPerType *deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception);
- void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMesh *getFather() const;
- void prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception);
- void finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception);
- void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
+ void prepareLoading(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
void getDimension(int& dim) const;
void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
void fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception);
int getIteration() const;
int getOrder() const;
double getTime() const;
- std::string getName() const;
std::string getMeshName() const;
void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
void getSizes(int& globalSz, int& nbOfEntries) const;
INTERP_KERNEL::NormalizedCellType getGeoType() const;
int getNumberOfComponents() const;
- DataArrayDouble *getArray();
- const DataArrayDouble *getArray() const;
+ DataArray *getArray();
+ const DataArray *getArray() const;
+ const DataArrayDouble *getArrayDouble() const;
+ DataArrayDouble *getArrayDouble();
const std::vector<std::string>& getInfo() const;
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception);
std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception);
std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception);
- MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
+ MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
private:
MEDFileFieldPerMesh *_father;
class MEDFileFieldPerMesh : public RefCountObject, public MEDFileWritable
{
public:
- static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
- static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldPerMesh *New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
+ static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
std::size_t getHeapMemorySize() const;
- MEDFileFieldPerMesh *deepCpy(MEDFileField1TSWithoutSDA *_father) const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldPerMesh *deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception);
void simpleRepr(int bkOffset,std::ostream& oss, int id) const;
void copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
- void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception);
- void finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception);
- void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
+ void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void prepareLoading(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
void getDimension(int& dim) const;
int getOrder() const;
int getMeshIteration() const { return _mesh_iteration; }
int getMeshOrder() const { return _mesh_order; }
- const std::string& getDtUnit() const;
- std::string getName() const;
std::string getMeshName() const { return _mesh_name; }
int getNumberOfComponents() const;
- DataArrayDouble *getArray();
- const DataArrayDouble *getArray() const;
+ DataArray *getArray();
+ const DataArray *getArray() const;
+ DataArrayDouble *getArrayDouble();
+ const DataArrayDouble *getArrayDouble() const;
const std::vector<std::string>& getInfo() const;
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
+ DataArray *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
+ void getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception);
private:
int addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type);
MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
- const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception);
+ const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
- const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception);
+ const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *finishFieldNode2(const MEDFileFieldGlobsReal *glob,
const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
- const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *finishField4(const std::vector< std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception);
+ const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
+ DataArray *finishField4(const std::vector< std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception);
void assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception);
static void SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type,
const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs,
std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls);
static int ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception);
- MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception);
- MEDFileFieldPerMesh(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
+ MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
private:
std::string _mesh_name;
int _mesh_iteration;
int _mesh_order;
int _mesh_csit;
- MEDFileField1TSWithoutSDA *_father;
+ MEDFileAnyTypeField1TSWithoutSDA *_father;
std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > _field_pm_pt;
};
static MEDFileFieldGlobs *New();
std::size_t getHeapMemorySize() const;
MEDFileFieldGlobs *deepCpy() const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldGlobs *shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldGlobs *deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception);
void simpleRepr(std::ostream& oss) const;
void appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception);
+ void checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception);
+ void checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception);
void loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception);
void loadProfileInFile(med_idt fid, int id);
void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception);
MEDFileFieldGlobsReal(const char *fname);
MEDFileFieldGlobsReal();
std::size_t getHeapMemorySize() const;
- void simpleRepr(std::ostream& oss) const;
+ void simpleReprGlobs(std::ostream& oss) const;
+ void resetContent();
void shallowCpyGlobs(const MEDFileFieldGlobsReal& other);
void deepCpyGlobs(const MEDFileFieldGlobsReal& other);
+ void shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception);
+ void deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception);
void appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception);
+ void checkGlobsCoherency() const throw(INTERP_KERNEL::Exception);
+ void checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception);
+ void checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception);
virtual std::vector<std::string> getPflsReallyUsed() const = 0;
virtual std::vector<std::string> getLocsReallyUsed() const = 0;
virtual std::vector<std::string> getPflsReallyUsedMulti() const = 0;
//
void appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception);
void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDFileFieldGlobs *contentNotNull() throw(INTERP_KERNEL::Exception);
+ const MEDFileFieldGlobs *contentNotNull() const throw(INTERP_KERNEL::Exception);
protected:
MEDCouplingAutoRefCountObjectPtr< MEDFileFieldGlobs > _globals;
};
+ class MEDLOADER_EXPORT MEDFileFieldNameScope
+ {
+ public:
+ MEDFileFieldNameScope();
+ MEDFileFieldNameScope(const char *fieldName);
+ std::string getName() const throw(INTERP_KERNEL::Exception);
+ void setName(const char *fieldName) throw(INTERP_KERNEL::Exception);
+ std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
+ void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception);
+ void copyNameScope(const MEDFileFieldNameScope& other);
+ protected:
+ std::string _name;
+ std::string _dt_unit;
+ };
+
/*!
* SDA is for Shared Data Arrays such as profiles.
*/
- class MEDLOADER_EXPORT MEDFileField1TSWithoutSDA : public RefCountObject
+ class MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope
{
public:
- int copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
- int getDimension() const;
+ MEDFileAnyTypeField1TSWithoutSDA();
+ MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order);
int getIteration() const { return _iteration; }
int getOrder() const { return _order; }
double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _dt; }
void setTime(int iteration, int order, double val) { _dt=val; _iteration=iteration; _order=order; }
- std::string getName() const;
- void setName(const char *name);
- void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
- const std::string& getDtUnit() const { return _dt_unit; }
+ int getDimension() const;
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
int getMeshIteration() const throw(INTERP_KERNEL::Exception);
int getMeshOrder() const throw(INTERP_KERNEL::Exception);
- int getNumberOfComponents() const;
bool isDealingTS(int iteration, int order) const;
std::pair<int,int> getDtIt() const;
void fillIteration(std::pair<int,int>& p) const;
void fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
- const std::vector<std::string>& getInfo() const;
- std::vector<std::string>& getInfo();
+ std::vector<TypeOfField> getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
//
std::vector<std::string> getPflsReallyUsed2() const;
std::vector<std::string> getLocsReallyUsed2() const;
std::vector<std::string> getLocsReallyUsedMulti2() const;
void changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+ //
int getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
- std::vector<TypeOfField> getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
- std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
- MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception);
+ //
+ MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception);
- static void CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
- static std::vector<int> CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
- static MEDFileField1TSWithoutSDA *New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos);
public:
- void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
- virtual void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception);
- void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ int getNumberOfComponents() const;
+ const std::vector<std::string>& getInfo() const;
+ std::vector<std::string>& getInfo();
+ void setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception);
+ std::size_t getHeapMemorySize() const;
+ int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception);
+ void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
+ virtual MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > splitComponents() const throw(INTERP_KERNEL::Exception);
+ virtual const char *getTypeStr() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArray *createNewEmptyDataArrayInstance() const = 0;
+ virtual DataArray *getOrCreateAndGetArray() = 0;
+ virtual const DataArray *getOrCreateAndGetArray() const = 0;
+ public:
+ MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
+ DataArray *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
+ public:
bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
+ public:
+ virtual void finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
protected:
- int addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
int getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception);
- public:
- MEDFileField1TSWithoutSDA();
- MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos);
- MEDFileField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
- std::size_t getHeapMemorySize() const;
- DataArrayDouble *getOrCreateAndGetArray();
- const DataArrayDouble *getOrCreateAndGetArray() const;
+ int addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
protected:
- std::string _dt_unit;
- MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr;
std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > > _field_per_mesh;
int _iteration;
int _order;
public:
//! only useable on reading
mutable int _csit;
- //! only useable on reading. 0 is for float, 1 for int32, 2 for int64
- mutable int _field_type;
+ };
+
+ /*!
+ * SDA is for Shared Data Arrays such as profiles.
+ */
+ class MEDLOADER_EXPORT MEDFileField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA
+ {
+ public:
+ const char *getTypeStr() const throw(INTERP_KERNEL::Exception);
+ DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
+ DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+ std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
+ static void CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
+ static std::vector<int> CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
+ static MEDFileField1TSWithoutSDA *New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ public:
+ MEDFileField1TSWithoutSDA();
+ MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
+ void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception);
+ DataArray *createNewEmptyDataArrayInstance() const;
+ DataArray *getOrCreateAndGetArray();
+ const DataArray *getOrCreateAndGetArray() const;
+ DataArrayDouble *getOrCreateAndGetArrayDouble();
+ const DataArrayDouble *getOrCreateAndGetArrayDouble() const;
+ protected:
+ MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr;
+ public:
+ static const char TYPE_STR[];
};
/*!
- * User class.
+ * SDA is for Shared Data Arrays such as profiles.
*/
- class MEDLOADER_EXPORT MEDFileField1TS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal
+ class MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA
{
public:
- static MEDFileField1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
- static MEDFileField1TS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
- static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
- static MEDFileField1TS *New();
- std::string simpleRepr() const;
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
- //
- void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
- void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
- // direct forwarding to MEDFileField1TSWithoutSDA instance _content
+ MEDFileIntField1TSWithoutSDA();
+ static MEDFileIntField1TSWithoutSDA *New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ const char *getTypeStr() const throw(INTERP_KERNEL::Exception);
+ DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
+ DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+ void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception);
+ DataArray *createNewEmptyDataArrayInstance() const;
+ DataArray *getOrCreateAndGetArray();
+ const DataArray *getOrCreateAndGetArray() const;
+ DataArrayInt *getOrCreateAndGetArrayInt();
+ const DataArrayInt *getOrCreateAndGetArrayInt() const;
+ DataArrayInt *getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ protected:
+ MEDCouplingAutoRefCountObjectPtr< DataArrayInt > _arr;
public:
- std::size_t getHeapMemorySize() const;
- MEDFileField1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
- int copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ static const char TYPE_STR[];
+ };
+
+ /*!
+ * User class.
+ */
+ class MEDLOADER_EXPORT MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal
+ {
+ protected:
+ MEDFileAnyTypeField1TS();
+ MEDFileAnyTypeField1TS(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent);
+ static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
+ // direct forwarding to MEDFileAnyTypeField1TSWithoutSDA instance _content
+ public:
+ static MEDFileAnyTypeField1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
int getDimension() const;
int getIteration() const;
int getOrder() const;
void setTime(int iteration, int order, double val);
std::string getName() const;
void setName(const char *name);
+ std::string simpleRepr() const;
void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
- const std::string& getDtUnit() const;
+ std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
+ void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception);
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
std::pair<int,int> getDtIt() const;
void fillIteration(std::pair<int,int>& p) const;
void fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
+ void setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception);
const std::vector<std::string>& getInfo() const;
std::vector<std::string>& getInfo();
- DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
- MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception);
- const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception);
- int getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
std::vector<TypeOfField> getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
- std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
- std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception);
+ const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception);
+ int getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
+ public:
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > splitComponents() const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
+ int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception);
+ virtual MEDFileAnyTypeField1TS *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0;
public:
//! underground method see MEDFileField1TSWithoutSDA::setProfileNameOnLeaf
void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
//! underground method see MEDFileField1TSWithoutSDA::setLocNameOnLeaf
void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
+ std::size_t getHeapMemorySize() const;
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
std::vector<std::string> getPflsReallyUsedMulti() const;
std::vector<std::string> getLocsReallyUsedMulti() const;
void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
+ public:
+ static int LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception);
+ static int LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception);
+ public:
+ virtual med_field_type getMEDFileFieldType() const = 0;
+ MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase() throw(INTERP_KERNEL::Exception);
+ const MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase() const throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> _content;
+ };
+
+ /*!
+ * User class.
+ */
+ class MEDLOADER_EXPORT MEDFileField1TS : public MEDFileAnyTypeField1TS
+ {
+ public:
+ static MEDFileField1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileField1TS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
+ static MEDFileField1TS *New();
+ MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
+ //
+ void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ // direct forwarding to MEDFileField1TSWithoutSDA instance _content
+ public:
+ MEDFileAnyTypeField1TS *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+
+ std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
+ std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
+ public:
+ static void SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception);
+ static DataArrayDouble *ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception);
+ private:
+ med_field_type getMEDFileFieldType() const { return MED_FLOAT64; }
+ const MEDFileField1TSWithoutSDA *contentNotNull() const throw(INTERP_KERNEL::Exception);
+ MEDFileField1TSWithoutSDA *contentNotNull() throw(INTERP_KERNEL::Exception);
private:
- void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception);
MEDFileField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
MEDFileField1TS();
- int locateField(med_idt fid, const char *fileName, const char *fieldName, med_field_type& typcha) throw(INTERP_KERNEL::Exception);
- protected:
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> _content;
+ };
+
+ class MEDLOADER_EXPORT MEDFileIntField1TS : public MEDFileAnyTypeField1TS
+ {
+ public:
+ static MEDFileIntField1TS *New();
+ static MEDFileIntField1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntField1TS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntField1TS *New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent);
+ MEDFileAnyTypeField1TS *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ //
+ MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
+ //
+ void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
+ void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
+ public:
+ static DataArrayInt *ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception);
+ private:
+ med_field_type getMEDFileFieldType() const { return MED_INT32; }
+ const MEDFileIntField1TSWithoutSDA *contentNotNull() const throw(INTERP_KERNEL::Exception);
+ MEDFileIntField1TSWithoutSDA *contentNotNull() throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileIntField1TS();
+ MEDFileIntField1TS(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileIntField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent);
};
- class MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA : public RefCountObject
+ class MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope
{
+ protected:
+ MEDFileAnyTypeFieldMultiTSWithoutSDA();
+ MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception);
public:
- static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
- MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception);
std::size_t getHeapMemorySize() const;
- MEDFileFieldMultiTSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
+ virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
+ virtual std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > splitComponents() const throw(INTERP_KERNEL::Exception);
+ virtual const char *getTypeStr() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception) = 0;
+ const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
+ void setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
+ int getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ const MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception);
+ std::string getMeshName() const throw(INTERP_KERNEL::Exception);
+ void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
int getNumberOfTS() const;
void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception);
- std::vector< std::pair<int,int> > getIterations() const;
+ void eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) 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);
+ std::vector< std::pair<int,int> > getIterations() const;
+ std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
+ void pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception);
+ void synchronizeNameScope() throw(INTERP_KERNEL::Exception);
+ void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
- std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
+ void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
- std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
- virtual void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception);
- std::string getName() const;
- void setName(const char *name);
- void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
- std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
- std::string getMeshName() const throw(INTERP_KERNEL::Exception);
- void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
- bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
- const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+ std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
+ DataArray *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ DataArray *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void finishLoading(med_idt fid, int nbPdt, med_field_type fieldTyp) throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception);
public:
- const MEDFileField1TSWithoutSDA *getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception);
- MEDFileField1TSWithoutSDA *getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception);
- const MEDFileField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ const MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPflsReallyUsed2() const;
std::vector<std::string> getLocsReallyUsed2() const;
std::vector<std::string> getPflsReallyUsedMulti2() const;
void changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
protected:
- MEDFileField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception);
- std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
+ virtual med_field_type getMEDFileFieldType() const = 0;
+ void copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception);
+ void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception);
+ void checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception);
+ void checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception);
+ protected:
+ std::vector<std::string> _infos;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > _time_steps;
+ };
+
+ class MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA
+ {
+ public:
+ static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception);
+ const char *getTypeStr() const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const throw(INTERP_KERNEL::Exception);
+ std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
+ protected:
MEDFileFieldMultiTSWithoutSDA(const char *fieldName);
- MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
- void finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception);
- void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
- void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception);
+ med_field_type getMEDFileFieldType() const { return MED_FLOAT64; }
+ MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception);
+ void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception);
public:
MEDFileFieldMultiTSWithoutSDA();
- protected:
- std::string _name;
- std::vector<std::string> _infos;
- //! only useable on reading. 0 is for float, 1 for int32, 2 for int64
- mutable int _field_type;
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > _time_steps;
};
- class MEDFileFieldMultiTSIterator;
+ class MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA
+ {
+ public:
+ static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception);
+ MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception);
+ const char *getTypeStr() const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName);
+ MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception);
+ med_field_type getMEDFileFieldType() const { return MED_INT32; }
+ MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception);
+ void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception);
+ public:
+ MEDFileIntFieldMultiTSWithoutSDA();
+ };
+ class MEDFileAnyTypeFieldMultiTSIterator;
+
/*!
* User class.
*/
- class MEDLOADER_EXPORT MEDFileFieldMultiTS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal
+ class MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal
{
+ protected:
+ MEDFileAnyTypeFieldMultiTS();
+ MEDFileAnyTypeFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
+ static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
public:
- static MEDFileFieldMultiTS *New();
- static MEDFileFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
- static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
- static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
- std::size_t getHeapMemorySize() const;
- MEDFileFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
- //
- MEDFileField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
- MEDFileField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
- MEDFileField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
- MEDFileFieldMultiTSIterator *iterator() throw(INTERP_KERNEL::Exception);
- //
- std::string simpleRepr() const;
+ static MEDFileAnyTypeFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
+ std::size_t getHeapMemorySize() const;
+ virtual MEDFileAnyTypeFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > splitComponents() const throw(INTERP_KERNEL::Exception);
+ virtual MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception) = 0;
//
- void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
- void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ virtual MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception) = 0;
+ MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
public:// direct forwarding to MEDFileField1TSWithoutSDA instance _content
+ std::string getName() const;
+ void setName(const char *name);
+ std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
+ void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception);
+ std::string getMeshName() const throw(INTERP_KERNEL::Exception);
+ void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ std::string simpleRepr() const;
+ void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
int getNumberOfTS() const;
void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception);
+ void eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS *buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS *buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception);
+ std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
std::vector< std::pair<int,int> > getIterations() const;
+ void pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception);
+ void pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception);
+ void synchronizeNameScope() 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);
+ MEDFileAnyTypeFieldMultiTSIterator *iterator() throw(INTERP_KERNEL::Exception);
+ bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
+ const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
+ void setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
+ int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
-std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
- std::string getName() const;
- void setName(const char *name);
- void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
- std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
- std::string getMeshName() const throw(INTERP_KERNEL::Exception);
- void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
- bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
- const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> getContent();
public:
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
std::vector<std::string> getLocsReallyUsedMulti() const;
void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase() throw(INTERP_KERNEL::Exception);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase() const throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> _content;
+ };
+
+ /*!
+ * User class.
+ */
+ class MEDLOADER_EXPORT MEDFileFieldMultiTS : public MEDFileAnyTypeFieldMultiTS
+ {
public:
- MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> getContent();
+ static MEDFileFieldMultiTS *New();
+ static MEDFileFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
+ MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception);
+ //
+ MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
+ //
+ MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
+ //
+ void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
+ private:
+ const MEDFileFieldMultiTSWithoutSDA *contentNotNull() const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTSWithoutSDA *contentNotNull() throw(INTERP_KERNEL::Exception);
private:
MEDFileFieldMultiTS();
MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
- protected:
- MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> _content;
};
- class MEDCOUPLING_EXPORT MEDFileFieldMultiTSIterator
+ /*!
+ * User class.
+ */
+ class MEDLOADER_EXPORT MEDFileIntFieldMultiTS : public MEDFileAnyTypeFieldMultiTS
{
public:
- MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts);
- ~MEDFileFieldMultiTSIterator();
- MEDFileField1TS *nextt();
+ static MEDFileIntFieldMultiTS *New();
+ static MEDFileIntFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntFieldMultiTS *New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
+ MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
+ //
+ MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
+ //
+ void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
+ void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ //
+ DataArrayInt *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
private:
- MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> _fmts;
+ const MEDFileIntFieldMultiTSWithoutSDA *contentNotNull() const throw(INTERP_KERNEL::Exception);
+ MEDFileIntFieldMultiTSWithoutSDA *contentNotNull() throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileIntFieldMultiTS();
+ MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
+ MEDFileIntFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ };
+
+ class MEDCOUPLING_EXPORT MEDFileAnyTypeFieldMultiTSIterator
+ {
+ public:
+ MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts);
+ ~MEDFileAnyTypeFieldMultiTSIterator();
+ MEDFileAnyTypeField1TS *nextt() throw(INTERP_KERNEL::Exception);
+ private:
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> _fmts;
int _iter_id;
int _nb_iter;
};
static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
std::size_t getHeapMemorySize() const;
MEDFileFields *deepCpy() const throw(INTERP_KERNEL::Exception);
+ MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const;
+ std::vector< std::pair<int,int> > getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
void simpleRepr(int bkOffset, std::ostream& oss) const;
//
void resize(int newSize) throw(INTERP_KERNEL::Exception);
- void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
- void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
- MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
- MEDFileFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ void pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ void pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception);
+ void setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ MEDFileFields *buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception);
+ MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception);
+ MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception);
+ MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception);
MEDFileFieldsIterator *iterator() throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
+ void destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception);
+ void destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception);
bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception);
public:
- int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
std::vector<std::string> getPflsReallyUsedMulti() const;
MEDFileFields();
MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception);
private:
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> > _fields;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > _fields;
};
class MEDCOUPLING_EXPORT MEDFileFieldsIterator
public:
MEDFileFieldsIterator(MEDFileFields *fs);
~MEDFileFieldsIterator();
- MEDFileFieldMultiTS *nextt();
+ MEDFileAnyTypeFieldMultiTS *nextt();
private:
MEDCouplingAutoRefCountObjectPtr<MEDFileFields> _fs;
int _iter_id;
_groups=groups;
}
+/*!
+ * Removes all groups lying on no family. If there is no empty groups, \a this is let untouched.
+ *
+ * \return the removed groups.
+ */
+std::vector<std::string> MEDFileMesh::removeEmptyGroups() throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ret;
+ std::map<std::string, std::vector<std::string> > newGrps;
+ for(std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.begin();it!=_groups.end();it++)
+ {
+ if((*it).second.empty())
+ ret.push_back((*it).first);
+ else
+ newGrps[(*it).first]=(*it).second;
+ }
+ if(!ret.empty())
+ _groups=newGrps;
+ return ret;
+}
+
/*!
* Removes a group from \a this mesh.
* \param [in] name - the name of the group to remove.
}
}
+/*!
+ * Removes all groups in \a this that are orphan. A group is orphan if this group lies on
+ * a set of families, themselves orphan. A family is said orphan if its id appears nowhere in
+ * family field whatever its level. This method also suppresses the orphan families.
+ *
+ * \return - The list of removed groups names.
+ *
+ * \sa MEDFileMesh::removeOrphanFamilies.
+ */
+std::vector<std::string> MEDFileMesh::removeOrphanGroups() throw(INTERP_KERNEL::Exception)
+{
+ removeOrphanFamilies();
+ return removeEmptyGroups();
+}
+
+/*!
+ * Removes all families in \a this that are orphan. A family is said orphan if its id appears nowhere in
+ * family field whatever its level. Groups are updated in consequence, that is to say all groups lying on orphan family, will see their families list modified.
+ *
+ * \return - The list of removed families names.
+ * \sa MEDFileMesh::removeOrphanGroups.
+ */
+std::vector<std::string> MEDFileMesh::removeOrphanFamilies() throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> allFamIdsInUse=computeAllFamilyIdsInUse();
+ std::vector<std::string> ret;
+ if(!((DataArrayInt*)allFamIdsInUse))
+ {
+ ret=getFamiliesNames();
+ _families.clear(); _groups.clear();
+ return ret;
+ }
+ std::map<std::string,int> famMap;
+ std::map<std::string, std::vector<std::string> > grps(_groups);
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ {
+ if(allFamIdsInUse->presenceOfValue((*it).second))
+ famMap[(*it).first]=(*it).second;
+ else
+ {
+ ret.push_back((*it).first);
+ std::vector<std::string> grpsOnEraseFam=getGroupsOnFamily((*it).first.c_str());
+ for(std::vector<std::string>::const_iterator it2=grpsOnEraseFam.begin();it2!=grpsOnEraseFam.end();it2++)
+ {
+ std::map<std::string, std::vector<std::string> >::iterator it3=grps.find(*it2);//it3!=grps.empty() thanks to copy
+ std::vector<std::string>& famv=(*it3).second;
+ std::vector<std::string>::iterator it4=std::find(famv.begin(),famv.end(),(*it).first);//it4!=famv.end() thanks to copy
+ famv.erase(it4);
+ }
+ }
+ }
+ if(!ret.empty())
+ { _families=famMap; _groups=grps; }
+ return ret;
+}
+
/*!
* Renames a group in \a this mesh.
* \param [in] oldName - a current name of the group to rename.
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
std::string nname(newName);
- it=_groups.find(nname);
- if(it!=_groups.end())
+ std::map<std::string, std::vector<std::string> >::iterator it2=_groups.find(nname);
+ if(it2!=_groups.end())
{
std::ostringstream oss; oss << "Such groupname \"" << newName << "\" already exists ! Kill it before !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
return ret;
}
+/*!
+ * Returns a maximal abs(id) of families in \a this mesh.
+ * \return int - the maximal norm of family id.
+ * \throw If there are no families in \a this mesh.
+ */
+int MEDFileMesh::getMaxAbsFamilyId() const throw(INTERP_KERNEL::Exception)
+{
+ if(_families.empty())
+ throw INTERP_KERNEL::Exception("MEDFileMesh::getMaxFamilyId : no families set !");
+ int ret=-std::numeric_limits<int>::max();
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ {
+ ret=std::max(std::abs((*it).second),ret);
+ }
+ return ret;
+}
+
/*!
* Returns a maximal id of families in \a this mesh.
* \return int - the maximal family id.
int MEDFileMesh::getMaxFamilyId() const throw(INTERP_KERNEL::Exception)
{
if(_families.empty())
- throw INTERP_KERNEL::Exception("MEDFileUMesh::getMaxFamilyId : no families set !");
+ throw INTERP_KERNEL::Exception("MEDFileMesh::getMaxFamilyId : no families set !");
int ret=-std::numeric_limits<int>::max();
for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
{
int MEDFileMesh::getMinFamilyId() const throw(INTERP_KERNEL::Exception)
{
if(_families.empty())
- throw INTERP_KERNEL::Exception("MEDFileUMesh::getMinFamilyId : no families set !");
+ throw INTERP_KERNEL::Exception("MEDFileMesh::getMinFamilyId : no families set !");
int ret=std::numeric_limits<int>::max();
for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
{
return ret;
}
+/*!
+ * Returns a maximal id of families in \a this mesh. Not only named families are
+ * considered but all family fields as well.
+ * \return int - the maximal family id.
+ */
+int MEDFileMesh::getTheMaxAbsFamilyId() const throw(INTERP_KERNEL::Exception)
+{
+ int m1=-std::numeric_limits<int>::max();
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ m1=std::max(std::abs((*it).second),m1);
+ int m2=getMaxAbsFamilyIdInArrays();
+ return std::max(m1,m2);
+}
+
/*!
* Returns a maximal id of families in \a this mesh. Not only named families are
* considered but all family fields as well.
return std::max(m1,m2);
}
+/*!
+ * Returns a minimal id of families in \a this mesh. Not only named families are
+ * considered but all family fields as well.
+ * \return int - the minimal family id.
+ */
int MEDFileMesh::getTheMinFamilyId() const throw(INTERP_KERNEL::Exception)
{
int m1=std::numeric_limits<int>::max();
return std::min(m1,m2);
}
+/*!
+ * This method only considers the maps. The contain of family array is ignored here.
+ *
+ * \sa MEDFileMesh::computeAllFamilyIdsInUse
+ */
DataArrayInt *MEDFileMesh::getAllFamiliesIdsReferenced() const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
return ret.retn();
}
+/*!
+ * This method does not consider map of family name, family id. Only family field array on different levels is considered.
+ *
+ * \sa MEDFileMesh::getAllFamiliesIdsReferenced
+ */
+DataArrayInt *MEDFileMesh::computeAllFamilyIdsInUse() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> famLevs=getFamArrNonEmptyLevelsExt();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret;
+ for(std::vector<int>::const_iterator it=famLevs.begin();it!=famLevs.end();it++)
+ {
+ const DataArrayInt *arr=getFamilyFieldAtLevel(*it);//arr not null due to spec of getFamArrNonEmptyLevelsExt
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dv=arr->getDifferentValues();
+ if((DataArrayInt *) ret)
+ ret=dv->buildUnion(ret);
+ else
+ ret=dv;
+ }
+ return ret.retn();
+}
+
/*!
* true is returned if no modification has been needed. false if family
* renumbering has been needed.
refId=-1;
for(std::set<int>::const_reverse_iterator it2=levsS.rbegin();it2!=levsS.rend();it2++)
{
- const DataArrayInt *fam=getFamilyFieldAtLevel(1);
+ const DataArrayInt *fam=getFamilyFieldAtLevel(*it2);
if(fam)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=fam->getDifferentValues();
}
int offset=1;
if(!_families.empty())
- offset=getMaxFamilyId()+1;
- TranslateFamilyIds(offset,fam,fidsOfGroups);
+ offset=getMaxAbsFamilyId()+1;
+ TranslateFamilyIds(meshDimRelToMaxExt==1?offset:-offset,fam,fidsOfGroups);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=fam->getDifferentValues();
appendFamilyEntries(ids,fidsOfGroups,grpsName2);
setFamilyFieldArr(meshDimRelToMaxExt,fam);
void MEDFileMesh::TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp)
{
- famArr->applyLin(1,offset,0);
+ famArr->applyLin(offset>0?1:-1,offset,0);
for(std::vector< std::vector<int> >::iterator it1=famIdsPerGrp.begin();it1!=famIdsPerGrp.end();it1++)
- std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::bind2nd(std::plus<int>(),offset));
+ {
+ if(offset<0)
+ std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::negate<int>());
+ std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::bind2nd(std::plus<int>(),offset));
+ }
}
/*!
return ret.retn();
}
+MEDFileMesh *MEDFileUMesh::createNewEmpty() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileUMesh;
+}
+
MEDFileMesh *MEDFileUMesh::deepCpy() const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret=new MEDFileUMesh(*this);
return ret0;
}
+std::vector<int> MEDFileUMesh::getFamArrNonEmptyLevelsExt() const
+{
+ std::vector<int> ret;
+ const DataArrayInt *famCoo(_fam_coords);
+ if(famCoo)
+ ret.push_back(1);
+ int lev=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--)
+ {
+ const MEDFileUMeshSplitL1 *cur(*it);
+ if(cur)
+ if(cur->getFamilyField())
+ ret.push_back(lev);
+ }
+ return ret;
+}
+
+std::vector<int> MEDFileUMesh::getNumArrNonEmptyLevelsExt() const
+{
+ std::vector<int> ret;
+ const DataArrayInt *numCoo(_num_coords);
+ if(numCoo)
+ ret.push_back(1);
+ int lev=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--)
+ {
+ const MEDFileUMeshSplitL1 *cur(*it);
+ if(cur)
+ if(cur->getNumberField())
+ ret.push_back(lev);
+ }
+ return ret;
+}
+
+std::vector<int> MEDFileUMesh::getNameArrNonEmptyLevelsExt() const
+{
+ std::vector<int> ret;
+ const DataArrayAsciiChar *nameCoo(_name_coords);
+ if(nameCoo)
+ ret.push_back(1);
+ int lev=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--)
+ {
+ const MEDFileUMeshSplitL1 *cur(*it);
+ if(cur)
+ if(cur->getNameField())
+ ret.push_back(lev);
+ }
+ return ret;
+}
+
/*!
* Returns all relative mesh levels (**excluding nodes**) where a given group is defined.
* To include nodes, call getGrpNonEmptyLevelsExt() method.
return ret;
}
+int MEDFileUMesh::getMaxAbsFamilyIdInArrays() const throw(INTERP_KERNEL::Exception)
+{
+ int ret=-std::numeric_limits<int>::max(),tmp=-1;
+ if((const DataArrayInt *)_fam_coords)
+ {
+ int val=_fam_coords->getMaxValue(tmp);
+ ret=std::max(ret,std::abs(val));
+ }
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
+ {
+ if((const MEDFileUMeshSplitL1 *)(*it))
+ {
+ const DataArrayInt *da=(*it)->getFamilyField();
+ if(da)
+ {
+ int val=da->getMaxValue(tmp);
+ ret=std::max(ret,std::abs(val));
+ }
+ }
+ }
+ return ret;
+}
+
int MEDFileUMesh::getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception)
{
int ret=-std::numeric_limits<int>::max(),tmp=-1;
if(!((DataArrayInt *)_fam_coords))
{ _fam_coords=DataArrayInt::New(); _fam_coords->alloc(nbOfNodes,1); _fam_coords->fillWithZero(); }
//
- addGroupUnderground(ids,_fam_coords);
+ addGroupUnderground(true,ids,_fam_coords);
}
+/*!
+ * Adds a group of nodes/cells/faces/edges to \a this mesh.
+ * \param [in] ids - a DataArrayInt providing ids and a name of the group to add.
+ * The ids should be sorted and different each other (MED file norm).
+ * \throw If the node coordinates array is not set.
+ * \throw If \a ids == \c NULL.
+ * \throw If \a ids->getName() == "".
+ * \throw If \a ids does not respect the MED file norm.
+ * \throw If a group with name \a ids->getName() already exists.
+ */
void MEDFileUMesh::addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids) throw(INTERP_KERNEL::Exception)
{
std::vector<int> levs=getNonEmptyLevelsExt();
{ addNodeGroup(ids); return ; }
MEDFileUMeshSplitL1 *lev=getMeshAtLevSafe(meshDimRelToMaxExt);
DataArrayInt *fam=lev->getOrCreateAndGetFamilyField();
- addGroupUnderground(ids,fam);
+ addGroupUnderground(false,ids,fam);
}
/*!
* \param [in] ids ids and group name of the new group to add. The ids should be sorted and different each other (MED file norm).
* \parma [in,out] famArr family array on level of interest to be renumbered. The input pointer should be not \c NULL (no check of that will be performed)
*/
-void MEDFileUMesh::addGroupUnderground(const DataArrayInt *ids, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception)
+void MEDFileUMesh::addGroupUnderground(bool isNodeGroup, const DataArrayInt *ids, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception)
{
if(!ids)
throw INTERP_KERNEL::Exception("MEDFileUMesh::addGroup : NULL pointer in input !");
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffFamIds=famIds->getDifferentValues();
std::vector<int> familyIds;
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerfamiliyIds;
- int maxVal=getTheMaxFamilyId()+1;
+ int maxVal=getTheMaxAbsFamilyId()+1;
std::map<std::string,int> families(_families);
std::map<std::string, std::vector<std::string> > groups(_groups);
std::vector<std::string> fams;
{ familyIds.push_back(*famId); idsPerfamiliyIds.push_back(ret0); fams.push_back(FindOrCreateAndGiveFamilyWithId(families,*famId,created)); } // adding *famId in grp
else
{
- familyIds.push_back(maxVal); idsPerfamiliyIds.push_back(ids2); std::string locFamName=FindOrCreateAndGiveFamilyWithId(families,maxVal,created);
+ familyIds.push_back(isNodeGroup?maxVal:-maxVal); idsPerfamiliyIds.push_back(ids2);
+ std::string locFamName=FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal:-maxVal,created);
fams.push_back(locFamName);
if(existsFamily(*famId))
{
}
else
{
- familyIds.push_back(maxVal); idsPerfamiliyIds.push_back(ret0); // modifying all other groups on *famId to lie on maxVal and on maxVal+1
- familyIds.push_back(maxVal+1); idsPerfamiliyIds.push_back(ids2);//grp lie only on maxVal+1
- std::string n2(FindOrCreateAndGiveFamilyWithId(families,maxVal+1,created)); fams.push_back(n2);
+ familyIds.push_back(isNodeGroup?maxVal:-maxVal); idsPerfamiliyIds.push_back(ret0); // modifying all other groups on *famId to lie on maxVal and on maxVal+1
+ familyIds.push_back(isNodeGroup?maxVal+1:-maxVal-1); idsPerfamiliyIds.push_back(ids2);//grp lie only on maxVal+1
+ std::string n2(FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal+1:-maxVal-1,created)); fams.push_back(n2);
if(existsFamily(*famId))
{
- std::string n1(FindOrCreateAndGiveFamilyWithId(families,maxVal,created)); std::vector<std::string> v(2); v[0]=n1; v[1]=n2;
+ std::string n1(FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal:-maxVal,created)); std::vector<std::string> v(2); v[0]=n1; v[1]=n2;
ChangeAllGroupsContainingFamily(groups,getFamilyNameGivenId(*famId).c_str(),v);
}
maxVal+=2;
return _ms[traducedRk]->setRenumArr(renumArr);
}
+/*!
+ * Sets the optional names of mesh entities of a given dimension.
+ * \param [in] meshDimRelToMaxExt - the relative dimension of mesh entities.
+ * \param [in] nameArr - the array of the names.
+ * \throw If there are no mesh entities of \a meshDimRelToMaxExt dimension in \a this mesh.
+ * \throw If \a nameArr has an invalid size.
+ */
void MEDFileUMesh::setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) throw(INTERP_KERNEL::Exception)
{
if(meshDimRelToMaxExt==1)
}
DataArrayDouble *coo(_coords);
if(!coo)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::setRenumFieldArr : the coordinates have not been set !");
- nameArr->checkNbOfTuplesAndComp(coo->getNumberOfTuples(),MED_SNAME_SIZE,"MEDFileUMesh::setRenumArr : Problem in size of node numbering arr ! ");
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setNameFieldAtLevel : the coordinates have not been set !");
+ nameArr->checkNbOfTuplesAndComp(coo->getNumberOfTuples(),MED_SNAME_SIZE,"MEDFileUMesh::setNameFieldAtLevel : Problem in size of node numbering arr ! ");
nameArr->incrRef();
_name_coords=nameArr;
return ;
}
if(meshDimRelToMaxExt>1)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::setRenumArr : Dimension request is invalid (>1) !");
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setNameFieldAtLevel : Dimension request is invalid (>1) !");
int traducedRk=-meshDimRelToMaxExt;
if(traducedRk>=(int)_ms.size())
throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
return ret;
}
+int MEDFileStructuredMesh::getMaxAbsFamilyIdInArrays() const throw(INTERP_KERNEL::Exception)
+{
+ int ret=-std::numeric_limits<int>::max(),tmp=-1;
+ if((const DataArrayInt *)_fam_nodes)
+ {
+ int val=_fam_nodes->getMaxValue(tmp);
+ ret=std::max(ret,std::abs(val));
+ }
+ if((const DataArrayInt *)_fam_cells)
+ {
+ int val=_fam_cells->getMaxValue(tmp);
+ ret=std::max(ret,std::abs(val));
+ }
+ return ret;
+}
+
int MEDFileStructuredMesh::getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception)
{
int ret=-std::numeric_limits<int>::max(),tmp=-1;
renumArr->incrRef();
}
+/*!
+ * Sets the optional names of mesh entities of a given dimension.
+ * \param [in] meshDimRelToMaxExt - the relative dimension of mesh entities.
+ * \param [in] nameArr - the array of the names.
+ * \throw If there are no mesh entities of \a meshDimRelToMaxExt dimension in \a this mesh.
+ * \throw If \a nameArr has an invalid size.
+ */
void MEDFileStructuredMesh::setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) throw(INTERP_KERNEL::Exception)
{
if(meshDimRelToMaxExt!=0 && meshDimRelToMaxExt!=1)
return ret;
}
+/*!
+ * Returns the set of extensive levels (nodes included) where not NULL family arr are defined.
+ */
+std::vector<int> MEDFileStructuredMesh::getFamArrNonEmptyLevelsExt() const
+{
+ std::vector<int> ret;
+ const DataArrayInt *famNodes(_fam_nodes),*famCells(_fam_cells);
+ if(famNodes)
+ ret.push_back(1);
+ if(famCells)
+ ret.push_back(0);
+ return ret;
+}
+
+/*!
+ * Returns the set of extensive levels (nodes included) where not NULL numbering arr are defined.
+ */
+std::vector<int> MEDFileStructuredMesh::getNumArrNonEmptyLevelsExt() const
+{
+ std::vector<int> ret;
+ const DataArrayInt *numNodes(_num_nodes),*numCells(_num_cells);
+ if(numNodes)
+ ret.push_back(1);
+ if(numCells)
+ ret.push_back(0);
+ return ret;
+}
+
+/*!
+ * Returns the set of extensive levels (nodes included) where not NULL naming arr are defined.
+ */
+std::vector<int> MEDFileStructuredMesh::getNameArrNonEmptyLevelsExt() const
+{
+ std::vector<int> ret;
+ const DataArrayAsciiChar *namesCells(_names_cells);
+ if(namesCells)
+ ret.push_back(0);
+ return ret;
+}
+
/*!
* no implementation here, it is not a bug, but intresically no polyhedra in \a this.
*/
return ret.retn();
}
+MEDFileMesh *MEDFileCMesh::createNewEmpty() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileCMesh;
+}
+
MEDFileMesh *MEDFileCMesh::deepCpy() const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret=new MEDFileCMesh(*this);
return ret.retn();
}
+MEDFileMesh *MEDFileCurveLinearMesh::createNewEmpty() const throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileCurveLinearMesh;
+}
+
MEDFileMesh *MEDFileCurveLinearMesh::deepCpy() const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret=new MEDFileCurveLinearMesh(*this);
static MEDFileMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
std::size_t getHeapMemorySize() const;
+ virtual MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0;
virtual bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0;
virtual std::vector<int> getNonEmptyLevels() const = 0;
virtual std::vector<int> getNonEmptyLevelsExt() const = 0;
+ virtual std::vector<int> getFamArrNonEmptyLevelsExt() const = 0;
+ virtual std::vector<int> getNumArrNonEmptyLevelsExt() const = 0;
+ virtual std::vector<int> getNameArrNonEmptyLevelsExt() const = 0;
virtual void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
virtual void write(med_idt fid) const throw(INTERP_KERNEL::Exception);
virtual int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
std::vector<std::string> getGroupsNames() const;
std::vector<std::string> getFamiliesNames() const;
void assignFamilyNameWithGroupName() throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> removeEmptyGroups() throw(INTERP_KERNEL::Exception);
void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> removeOrphanGroups() throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> removeOrphanFamilies() throw(INTERP_KERNEL::Exception);
void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
void changeFamilyId(int oldId, int newId) throw(INTERP_KERNEL::Exception);
void changeAllGroupsContainingFamily(const char *familyNameToChange, const std::vector<std::string>& newFamiliesNames) throw(INTERP_KERNEL::Exception);
int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
+ int getMaxAbsFamilyId() const throw(INTERP_KERNEL::Exception);
int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
int getMinFamilyId() const throw(INTERP_KERNEL::Exception);
+ int getTheMaxAbsFamilyId() const throw(INTERP_KERNEL::Exception);
int getTheMaxFamilyId() const throw(INTERP_KERNEL::Exception);
int getTheMinFamilyId() const throw(INTERP_KERNEL::Exception);
+ virtual int getMaxAbsFamilyIdInArrays() const throw(INTERP_KERNEL::Exception) = 0;
virtual int getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception) = 0;
virtual int getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception) = 0;
DataArrayInt *getAllFamiliesIdsReferenced() const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *computeAllFamilyIdsInUse() const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception);
bool ensureDifferentFamIdsPerLevel() throw(INTERP_KERNEL::Exception);
static MEDFileUMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
static MEDFileUMesh *New();
std::size_t getHeapMemorySize() const;
+ MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception);
MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
void clearNonDiscrAttributes() const;
~MEDFileUMesh();
//
+ int getMaxAbsFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
int getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
int getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
int getMeshDimension() const throw(INTERP_KERNEL::Exception);
int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
std::vector<int> getNonEmptyLevels() const;
std::vector<int> getNonEmptyLevelsExt() const;
+ std::vector<int> getFamArrNonEmptyLevelsExt() const;
+ std::vector<int> getNumArrNonEmptyLevelsExt() const;
+ std::vector<int> getNameArrNonEmptyLevelsExt() const;
std::vector<int> getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception);
std::vector<int> getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception);
void synchronizeTinyInfoOnLeaves() const;
void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception);
std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const;
- void addGroupUnderground(const DataArrayInt *ids, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
+ void addGroupUnderground(bool isNodeGroup, const DataArrayInt *ids, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
friend class MEDFileMesh;
public:
std::size_t getHeapMemorySize() const;
+ int getMaxAbsFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
int getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
int getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
std::vector<int> getNonEmptyLevels() const;
std::vector<int> getNonEmptyLevelsExt() const;
+ std::vector<int> getFamArrNonEmptyLevelsExt() const;
+ std::vector<int> getNumArrNonEmptyLevelsExt() const;
+ std::vector<int> getNameArrNonEmptyLevelsExt() const;
MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception);
int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
static MEDFileCMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
std::size_t getHeapMemorySize() const;
+ MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception);
MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
static MEDFileCurveLinearMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
std::size_t getHeapMemorySize() const;
+ MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception);
MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
}
}
-int MEDFileUtilities::TraduceFieldType(med_field_type ft) throw(INTERP_KERNEL::Exception)
+const char *MEDFileUtilities::GetReadableMEDFieldType(med_field_type ft) throw(INTERP_KERNEL::Exception)
{
+ static const char medFloat64[]="MED_FLOAT64";
+ static const char medInt32[]="MED_INT32";
+ static const char medInt64[]="MED_INT64";
switch(ft)
{
case MED_FLOAT64:
- return 0;
+ return medFloat64;
case MED_INT32:
- return 1;
+ return medInt32;
case MED_INT64:
- return 2;
+ return medInt64;
default:
throw INTERP_KERNEL::Exception("Non supported field type ! Should be FLOAT64, INT32 or INT64 !");
}
namespace MEDFileUtilities
{
med_access_mode TraduceWriteMode(int medloaderwritemode) throw(INTERP_KERNEL::Exception);
- int TraduceFieldType(med_field_type ft) throw(INTERP_KERNEL::Exception);
+ const char *GetReadableMEDFieldType(med_field_type ft) throw(INTERP_KERNEL::Exception);
void CheckMEDCode(int code, med_idt fid, const char *msg) throw(INTERP_KERNEL::Exception);
void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
if ( fields )
for ( int i = 0; i < fields->getNumberOfFields(); ++i )
{
- MEDFileFieldMultiTS * f = fields->getFieldAtPos(i);
+ MEDFileAnyTypeFieldMultiTS * fB = fields->getFieldAtPos(i);
+ MEDFileFieldMultiTS * f = dynamic_cast<MEDFileFieldMultiTS *>(fB);
+ if(!f)
+ continue;// fields on int32 not managed
if ( f->getMeshName() == _fileMesh->getName() )
{
vector< vector<TypeOfField> > fTypes = f->getTypesOfFieldAvailable();
SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDLoader.py ${CMAKE_CURRENT_SOURCE_DIR}/libMEDLoader_Swig.py)
INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${MED_salomescript_PYTHON})
-INSTALL(FILES MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py MEDLoaderTest3.py medutilities.py DESTINATION ${MED_salomescript_PYTHON})
-INSTALL(FILES med2sauv sauv2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MED_salomescript_PYTHON} )
+INSTALL(FILES MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py MEDLoaderTest3.py MEDLoaderCouplingTrainingSession.py CaseIO.py CaseReader.py CaseWriter.py MEDLoaderSplitter.py medutilities.py DESTINATION ${MED_salomescript_PYTHON})
+INSTALL(FILES med2sauv PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MED_salomescript_PYTHON} )
+INSTALL(FILES sauv2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MED_salomescript_PYTHON} )
+INSTALL(FILES case2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MED_salomescript_PYTHON} )
+INSTALL(FILES med2case PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${MED_salomescript_PYTHON} )
ADD_TEST(MEDLoaderTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest.py)
ADD_TEST(MEDLoaderTest2 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest2.py)
ADD_TEST(MEDLoaderTest3 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest3.py)
ADD_TEST(MEDLoaderExamplesTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderExamplesTest.py)
ADD_TEST(SauvLoaderTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/SauvLoaderTest.py)
+ADD_TEST(MEDLoaderCouplingTrainingSession ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderCouplingTrainingSession.py)
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# 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
+#
+# Author Anthony GEAY (CEA/DEN/DM2S/STMF/LGLS)
+
+from MEDLoader import *
+
+class CaseIO:
+ dictMCTyp={NORM_HEXA8:"hexa8",NORM_POLYHED:"nfaced",NORM_QUAD4:"quad4",NORM_POLYGON:"nsided",NORM_POINT1:"point",NORM_SEG2:"bar2",NORM_SEG3:"bar3",NORM_TRI3:"tria3",NORM_TRI6:"tria6",NORM_QUAD8:"quad8",NORM_TETRA4:"tetra4",NORM_TETRA10:"tetra10",NORM_PYRA5:"pyramid5",NORM_PYRA13:"pyramid13",NORM_PENTA6:"penta6",NORM_PENTA15:"penta15",NORM_HEXA20:"hexa20"}
+ discSpatial={ON_CELLS:"element",ON_NODES:"node"}
+ dictCompo={1:"scalar",3:"vector",6:"tensor",9:"tensor9"}
+ dictMCTyp2=dict((v,k) for k,v in dictMCTyp.iteritems())
+ discSpatial2=dict((v,k) for k,v in discSpatial.iteritems())
+ dictCompo2=dict((v,k) for k,v in dictCompo.iteritems())
+ pass
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# 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
+#
+# Author Anthony GEAY (CEA/DEN/DM2S/STMF/LGLS)
+
+import numpy as np
+from MEDLoader import *
+from CaseIO import CaseIO
+import sys,re
+
+class CaseReader(CaseIO):
+ """ Converting a file in the Case format (Ensight) to the MED format.
+ A new file with the same base name and the .med extension is created.
+ """
+
+ @classmethod
+ def New(cls,fileName):
+ """ Static constructor. """
+ return CaseReader(fileName)
+ pass
+
+ def __init__(self,fileName):
+ """ Constructor """
+ self._fileName=fileName
+ self._dirName=os.path.dirname(self._fileName)
+ pass
+
+ def __traduceMesh(self,name,typ,coords,cells):
+ """ Convert a CASE mesh into a MEDCouplingUMesh. """
+ nbCoords=len(coords)
+ coo=np.array(coords,dtype="float64") ; coo=coo.reshape(nbCoords,3)
+ coo=DataArrayDouble(coo) ; coo=coo.fromNoInterlace()
+ ct=self.dictMCTyp2[typ]
+ m=MEDCouplingUMesh(name,MEDCouplingUMesh.GetDimensionOfGeometricType(ct))
+ m.setCoords(coo)
+ nbNodesPerCell=MEDCouplingMesh.GetNumberOfNodesOfGeometricType(ct)
+ cI=DataArrayInt(len(cells)+1) ; cI.iota() ; cI*=nbNodesPerCell+1
+ #
+ cells2=cells.reshape(len(cells),nbNodesPerCell)
+ c2=DataArrayInt(cells2)
+ c=DataArrayInt(len(cells),nbNodesPerCell+1) ; c[:,0]=ct ; c[:,1:]=c2-1 ; c.rearrange(1)
+ m.setConnectivity(c,cI,True)
+ m.checkCoherency2()
+ return m
+
+ def __traduceMeshForPolyhed(self,name,coords,arr0,arr1,arr2):
+ nbCoords=len(coords)
+ coo=np.array(coords,dtype="float64") ; coo=coo.reshape(nbCoords,3)
+ coo=DataArrayDouble(coo) ; coo=coo.fromNoInterlace()
+ m=MEDCouplingUMesh(name,3)
+ m.setCoords(coo)
+ #
+ arr2=arr2[:]-1
+ arr0mc0=DataArrayInt(arr0) ; arr0mc0.computeOffsets2()
+ arr0mc1=DataArrayInt(arr0).deepCpy()
+ arr0mc2=DataArrayInt(len(arr0),2) ; arr0mc2[:,0]=DataArrayInt(arr0)-1 ; arr0mc2[:,1]=1 ; arr0mc2.rearrange(1) ; arr0mc2.computeOffsets2()
+ arr0mc3=DataArrayInt.Range(0,2*len(arr0),2).buildExplicitArrByRanges(arr0mc2)
+ arr1mc0=DataArrayInt(arr1) ; arr1mc0.computeOffsets2()
+ arr1mc1=arr1mc0[arr0mc0] ; arr1mc1[1:]+=arr0mc0[1:]
+ arr1mc2=DataArrayInt(arr1).deepCpy() ; arr1mc2+=1 ; arr1mc2.computeOffsets2()
+ arr2mc0=(arr1mc2[1:])[arr0mc3]
+ #
+ c=DataArrayInt(arr1.size+arr2.size)
+ c[arr1mc1[:-1]]=NORM_POLYHED
+ c[arr2mc0]=-1
+ a=arr2mc0.buildUnion(arr1mc1[:-1]).buildComplement(len(c))
+ c[a]=DataArrayInt(arr2)
+ #
+ m.setConnectivity(c,arr1mc1,True)
+ m.checkCoherency2()
+ return m
+
+ def __traduceMeshForPolygon(self,name,coords,arr0,arr1):
+ nbCoords=len(coords)
+ coo=np.array(coords,dtype="float64") ; coo=coo.reshape(nbCoords,3)
+ coo=DataArrayDouble(coo) ; coo=coo.fromNoInterlace()
+ m=MEDCouplingUMesh(name,2)
+ m.setCoords(coo)
+ #
+ arr0_0=DataArrayInt(arr0+1) ; arr0_0.computeOffsets2()
+ arr0_1=DataArrayInt(len(arr0),2) ; arr0_1[:,1]=DataArrayInt(arr0) ; arr0_1[:,0]=1 ; arr0_1.rearrange(1) ; arr0_1.computeOffsets2()
+ arr0_2=DataArrayInt.Range(1,2*len(arr0),2).buildExplicitArrByRanges(arr0_1)
+ c=DataArrayInt(len(arr0)+len(arr1)) ; c[:]=0 ; c[arr0_0[:-1]]=NORM_POLYGON
+ c[arr0_2]=DataArrayInt(arr1-1)
+ #
+ m.setConnectivity(c,arr0_0,True)
+ m.checkCoherency2()
+ return m
+
+ def __convertGeo2MED(self,geoFileName):
+ """ Convert all the geometry (all the meshes) contained in teh CASE file into MEDCouplingUMesh'es. """
+ fd=open(os.path.join(self._dirName,geoFileName),"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0) ; fd.readline() ; fd.readline()
+ name=fd.readline().strip() ; fd.readline() ; fd.readline()
+ pos=fd.tell()
+ mcmeshes=[]
+ elt=fd.read(80) ; elt=elt.strip() ; pos+=80
+ while pos!=end:
+ if elt!="part":
+ raise Exception("Error on reading mesh #1 !")
+ fd.seek(fd.tell()+4)
+ meshName=fd.read(80).strip()
+ if fd.read(len("coordinates"))!="coordinates":
+ raise Exception("Error on reading mesh #2 !")
+ pos=fd.tell()
+ typeOfCoo=np.memmap(fd,dtype='byte',mode='r',offset=int(pos),shape=(1)).tolist()[0]
+ pos+=1+17*4
+ nbNodes=np.memmap(fd,dtype='int32',mode='r',offset=int(pos),shape=(1,)).tolist()[0]
+ pos+=4
+ coo=np.memmap(fd,dtype='float32',mode='r',offset=int(pos),shape=(nbNodes,3))
+ pos+=nbNodes*3*4 ; fd.seek(pos)#np.array(0,dtype='float%i'%(typeOfCoo)).nbytes
+ typ=fd.read(80).strip() ; pos=fd.tell()
+ mcmeshes2=[]
+ while pos!=end and typ!="part":
+ mctyp=self.dictMCTyp2[typ]
+ nbCellsOfType=np.memmap(fd,dtype='int32',mode='r',offset=int(pos),shape=(1,)).tolist()[0]
+ pos+=4
+ if mctyp!=NORM_POLYHED and mctyp!=NORM_POLYGON:
+ nbNodesPerCell=MEDCouplingMesh.GetNumberOfNodesOfGeometricType(mctyp)
+ cells=np.memmap(fd,dtype='int32',mode='r',offset=pos,shape=(nbCellsOfType,nbNodesPerCell))
+ pos+=nbCellsOfType*nbNodesPerCell*4
+ fd.seek(pos)
+ mcmeshes2.append(self.__traduceMesh(meshName,typ,coo,cells))
+ elif mctyp==NORM_POLYHED:
+ nbOfFacesPerCell=np.memmap(fd,dtype='int32',mode='r',offset=int(pos),shape=(nbCellsOfType,))
+ pos+=nbCellsOfType*4
+ szOfNbOfNodesPerFacePerCellArr=int(nbOfFacesPerCell.sum())
+ arr1=np.memmap(fd,dtype='int32',mode='r',offset=int(pos),shape=(szOfNbOfNodesPerFacePerCellArr,))#arr1 -> nbOfNodesPerFacePerCellArr
+ pos+=szOfNbOfNodesPerFacePerCellArr*4
+ szOfNodesPerFacePerCellArr=arr1.sum()
+ arr2=np.memmap(fd,dtype='int32',mode='r',offset=int(pos),shape=(szOfNodesPerFacePerCellArr,))#arr2 -> nodesPerFacePerCellArr
+ pos+=szOfNodesPerFacePerCellArr*4 ; fd.seek(pos)
+ mcmeshes2.append(self.__traduceMeshForPolyhed(meshName,coo,nbOfFacesPerCell,arr1,arr2))
+ pass
+ else:
+ nbOfNodesPerCell=np.memmap(fd,dtype='int32',mode='r',offset=int(pos),shape=(nbCellsOfType,))
+ pos+=nbCellsOfType*4
+ szOfNbOfNodesPerCellArr=int(nbOfNodesPerCell.sum())
+ arr1=np.memmap(fd,dtype='int32',mode='r',offset=int(pos),shape=(szOfNbOfNodesPerCellArr,))
+ pos+=szOfNbOfNodesPerCellArr*4 ; fd.seek(pos)
+ mcmeshes2.append(self.__traduceMeshForPolygon(meshName,coo,nbOfNodesPerCell,arr1))
+ if pos!=end:
+ elt=fd.read(80) ; elt=elt.strip() ; typ=elt[:] ; pos+=80
+ pass
+ pass
+ coo=mcmeshes2[0].getCoords() ; name=mcmeshes2[0].getName()
+ for itmesh in mcmeshes2: itmesh.setCoords(coo)
+ m=MEDCouplingUMesh.MergeUMeshesOnSameCoords(mcmeshes2) ; m.setName(name)
+ mcmeshes.append(m)
+ pass
+ #
+ ms=MEDFileMeshes()
+ ms.resize(len(mcmeshes))
+ for i,m in enumerate(mcmeshes):
+ mlm=MEDFileUMesh()
+ mlm.setMeshAtLevel(0,m)
+ ms.setMeshAtPos(i,mlm)
+ pass
+ return mcmeshes,ms
+
+ def __convertField(self,mlfields, mcmeshes, fileName, fieldName, discr, nbCompo, locId, it):
+ """ Convert the fields. """
+ stars=re.search("[\*]+",fileName).group()
+ st="%0"+str(len(stars))+"i"
+ trueFileName=fileName.replace(stars,st%(it))
+ fd=open(os.path.join(self._dirName,trueFileName),"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0)
+ name=fd.readline().strip().split(" ")[0]
+ if name!=fieldName:
+ raise Exception("ConvertField : mismatch")
+ pos=fd.tell()
+ st=fd.read(80) ; st=st.strip() ; pos=fd.tell()
+ while pos!=end:
+ if st!="part":
+ raise Exception("ConvertField : mismatch #2")
+ fdisc=MEDCouplingFieldDiscretization.New(self.discSpatial2[discr])
+ meshId=np.memmap(fd,dtype='int32',mode='r',offset=int(pos),shape=(1)).tolist()[0]-1
+ nbOfValues=fdisc.getNumberOfTuples(mcmeshes[meshId])
+ vals2=DataArrayDouble(nbOfValues,nbCompo)
+ fd.seek(pos+4)
+ st=fd.read(80).strip() ; pos=fd.tell()
+ offset=0
+ while pos!=end and st!="part":
+ if st!="coordinates":
+ nbOfValsOfTyp=mcmeshes[meshId].getNumberOfCellsWithType(self.dictMCTyp2[st])
+ else:
+ nbOfValsOfTyp=nbOfValues
+ pass
+ vals=np.memmap(fd,dtype='float32',mode='r',offset=int(pos),shape=(nbOfValsOfTyp,nbCompo))#np.memmap(fd,dtype='int32',mode='r',offset=159,shape=(1))
+ vals2[offset:offset+nbOfValsOfTyp]=DataArrayDouble(np.array(vals,dtype='float64')).fromNoInterlace()
+ pos+=nbOfValsOfTyp*nbCompo*4 ; fd.seek(pos)
+ st=fd.read(80) ; st=st.strip() ; pos=fd.tell()
+ offset+=nbOfValsOfTyp
+ pass
+ f=MEDCouplingFieldDouble(self.discSpatial2[discr],ONE_TIME) ; f.setName("%s_%s"%(fieldName,mcmeshes[meshId].getName()))
+ f.setMesh(mcmeshes[meshId]) ; f.setArray(vals2) ; f.setTime(float(it),it,-1)
+ f.checkCoherency()
+ mlfields[locId+meshId].appendFieldNoProfileSBT(f)
+ pass
+ pass
+
+ def loadInMEDFileDS(self):
+ """ Load a CASE file into a MEDFileData object. """
+ f=file(self._fileName)
+ lines=f.readlines()
+ ind=lines.index("GEOMETRY\n")
+ if ind==-1:
+ raise Exception("Error with file %s"%(fname))
+ geoName=re.match("model:([\W]*)([\w\.]+)",lines[ind+1]).group(2)
+ m1,m2=self.__convertGeo2MED(geoName)
+ ind=lines.index("VARIABLE\n")
+ fieldsInfo=[]
+ for i in xrange(ind+1,lines.index("TIME\n")):
+ m=re.match("^([\w]+)[\s]+\per[\s]+([\w]+)[\s]*\:[\s]*([\w]+)[\s]+([\S]+)$",lines[i])
+ if m:
+ spatialDisc=m.groups()[1] ; fieldName=m.groups()[2] ; nbOfCompo=self.dictCompo2[m.groups()[0]] ; fieldFileName=m.groups()[3]
+ fieldsInfo.append((fieldName,spatialDisc,nbOfCompo,fieldFileName))
+ pass
+ pass
+
+ expr=re.compile("number[\s]+of[\s]+steps[\s]*\:[\s]*([\d]+)")
+ nbOfTimeSteps=int(expr.search(filter(expr.search,lines)[0]).group(1))
+
+ expr=re.compile("filename[\s]+start[\s]+number[\s]*\:[\s]*([\d]+)")
+ startIt=int(expr.search(filter(expr.search,lines)[0]).group(1))
+
+ expr=re.compile("filename[\s]+increment[\s]*\:[\s]*([\d]+)")
+ incrIt=int(expr.search(filter(expr.search,lines)[0]).group(1))
+
+ curIt=startIt
+ mlfields=MEDFileFields()
+ mlfields.resize(len(fieldsInfo)*len(m1))
+ i=0
+ for field in fieldsInfo:
+ for m in m1:
+ mlfields.setFieldAtPos(i,MEDFileFieldMultiTS())
+ i+=1
+ pass
+ pass
+ for ts in xrange(nbOfTimeSteps):
+ i=0
+ for field in fieldsInfo:
+ self.__convertField(mlfields,m1,field[3],field[0],field[1],field[2],i,curIt)
+ i+=len(m1)
+ pass
+ curIt+=incrIt
+ pass
+ ret=MEDFileData()
+ ret.setMeshes(m2)
+ del mlfields[filter(lambda x: len(mlfields[x])==0,range(len(mlfields)))]
+ ret.setFields(mlfields)
+ return ret
+
+ pass
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# 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
+#
+# Author Anthony GEAY (CEA/DEN/DM2S/STMF/LGLS)
+
+import numpy as np
+from CaseIO import CaseIO
+from MEDLoader import *
+import sys,re,os,mmap
+
+### www-vis.lbl.gov/NERSC/Software/ensight/doc/OnlineHelp/UM-C11.pdf
+
+class CaseWriter(CaseIO):
+ """ Converting MED file format in memory to a the Case file format (Ensight).
+ A new file with the same base name and the .case extension is created with its depencies (.geo ...).
+ """
+
+ header="""FORMAT
+type: ensight gold
+GEOMETRY
+model: %(geofilewithoutpath)s
+"""
+ header_varpart="""VARIABLE"""
+ header_timepart="""TIME
+time set: 1
+number of steps: %(NbTimeSteps)i
+filename start number: 0
+filename increment: 1
+time values:
+%(TimeValues)s
+"""
+
+ @classmethod
+ def New(cls):
+ """ Static constructor. """
+ return CaseWriter()
+ pass
+
+ def __init__(self):
+ """ Constructor """
+ self.__export_groups=False
+ pass
+
+ def setMEDFileDS(self,medData):
+ """ Input should be MEDFileData instance """
+ self._med_data=medData
+ pass
+
+ def isExportingGroups(self):
+ """ return the status of exporting groups policy """
+ return self.__export_groups
+
+ def setExportingGroups(self,status):
+ assert(isinstance(status,bool))
+ self.__export_groups=status
+ pass
+
+
+ def write(self,fileName):
+ """ Write into the specified fileName series the result """
+ self._file_name=fileName
+ self._base_name_without_dir=os.path.splitext(os.path.basename(self._file_name))[0]
+ self._l=self._file_name.split(os.path.sep) ; self._l[-1]=os.path.splitext(self._l[-1])[0]
+ self._base_name_with_dir=os.path.sep.join(self._l)
+ self._real_written_file_name=[]
+ self._dico={}
+ for mesh in self._med_data.getMeshes():
+ additionnalFileNamePart=""
+ if len(self._med_data.getMeshes())!=1:
+ additionnalFileNamePart="_%s"%(mesh.getName())
+ pass
+ self._dico["geofilewithoutpath"]="%s%s.geo"%(self._base_name_without_dir,additionnalFileNamePart)
+ h0=self.header%self._dico
+ self.__writeMeshesPart(mesh,"%s%s.geo"%(self._base_name_with_dir,additionnalFileNamePart))
+ #
+ h2=self.__writeFieldsPart(self._med_data.getFields().partOfThisLyingOnSpecifiedMeshName(mesh.getName()))
+ realWrittenCaseFileNameForCurMesh="%s%s.case"%(self._base_name_with_dir,additionnalFileNamePart)
+ fheader=open(realWrittenCaseFileNameForCurMesh,"w") ; fheader.write((h0+h2)%self._dico)
+ self._real_written_file_name.append(realWrittenCaseFileNameForCurMesh)
+ pass
+ return self._real_written_file_name
+
+ def __writeMeshesPart(self,mdm,meshfn):
+ try:
+ os.remove(meshfn)
+ except:
+ pass
+ f=open(meshfn,"w+b")
+ sz=5*80
+ #
+ assert(isinstance(mdm,MEDFileUMesh))
+ ms2=[[mdm.getMeshAtLevel(lev) for lev in mdm.getNonEmptyLevels()[:1]]]
+ if self.__export_groups:
+ for grpnm in mdm.getGroupsNames():
+ ms3=[]
+ for lev in mdm.getGrpNonEmptyLevels(grpnm)[:1]:
+ m=mdm.getGroup(lev,grpnm) ; m.zipCoords()
+ ms3.append(m)
+ pass
+ ms2.append(ms3)
+ pass
+ pass
+ for ms in ms2:
+ nn=ms[0].getNumberOfNodes()
+ sz+=self.__computeSizeOfGeoFile(ms,nn)
+ pass
+ pass
+ a=np.memmap(f,dtype='byte',mode='w+',offset=0,shape=(sz,)) ; a.flush() # truncate to set the size of the file
+ mm=mmap.mmap(f.fileno(),offset=0,length=0)
+ mm.write(self.__str80("C Binary"))
+ mm.write(self.__str80("Exported from MEDCoupling/MEDLoader SALOME version %s"%(MEDCouplingVersionStr())))
+ mm.write(self.__str80("Conversion using CaseWriter class"))
+ mm.write(self.__str80("node id off"))
+ mm.write(self.__str80("element id off"))
+ for iii,ms in enumerate(ms2):
+ nn=ms[0].getNumberOfNodes()
+ mm.write(self.__str80("part"))
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(1,))
+ a[0]=iii+1 ; a.flush() ; mm.seek(mm.tell()+4) # part number maybe to change ?
+ name=ms[0].getName()
+ if iii>0:
+ name="%s_%s"%(ms2[0][0].getName(),name)
+ pass
+ mm.write(self.__str80(name))
+ mm.write(self.__str80("coordinates"))
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(1,))
+ a[0]=nn ; a.flush() # number of nodes
+ mm.seek(mm.tell()+4)
+ coo=ms[0].getCoords()
+ spaceDim=coo.getNumberOfComponents()
+ if spaceDim!=3:
+ coo=coo.changeNbOfComponents(3,0.)
+ pass
+ a=np.memmap(f,dtype='float32',mode='w+',offset=mm.tell(),shape=(3,nn))
+ c=coo.toNoInterlace() ; c.rearrange(1) ; cnp=c.toNumPyArray() ; cnp=cnp.reshape(3,nn)
+ a[:]=cnp ; a.flush() ; mm.seek(mm.tell()+3*nn*4)
+ for m in ms:
+ i=0
+ for typ2,nbelem,dummy in m.getDistributionOfTypes():
+ typ=typ2
+ if typ not in self.dictMCTyp:
+ typ=MEDCouplingMesh.GetCorrespondingPolyType(typ)
+ pass
+ mp=m[i:i+nbelem]
+ mm.write(self.__str80(self.dictMCTyp[typ]))
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(1,))
+ a[0]=nbelem ; a.flush() ; mm.seek(mm.tell()+4)
+ if typ!=NORM_POLYHED and typ!=NORM_POLYGON:
+ nbNodesPerElem=MEDCouplingMesh.GetNumberOfNodesOfGeometricType(typ)
+ c=mp.getNodalConnectivity() ; c.rearrange(nbNodesPerElem+1) ; c=c[:,1:] ; c.rearrange(1) ; c+=1
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(nbNodesPerElem*nbelem,))
+ a[:]=c.toNumPyArray() ; a.flush() ; mm.seek(mm.tell()+nbNodesPerElem*nbelem*4)
+ pass
+ elif typ==NORM_POLYHED:
+ mp.orientCorrectlyPolyhedrons()
+ c=mp.computeNbOfFacesPerCell()
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(nbelem,))
+ a[:]=c.toNumPyArray(); a.flush() ; mm.seek(mm.tell()+nbelem*4)
+ c=mp.getNodalConnectivity()[:] ; c.pushBackSilent(-1) ; c[mp.getNodalConnectivityIndex()[:-1]]=-1 ; ids=c.getIdsEqual(-1) ; nbOfNodesPerFace=ids.deltaShiftIndex()-1
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(len(nbOfNodesPerFace),))
+ a[:]=nbOfNodesPerFace.toNumPyArray() ; a.flush() ; mm.seek(mm.tell()+len(nbOfNodesPerFace)*4)
+ ids2=ids.buildComplement(ids.back()+1)
+ c2=mp.getNodalConnectivity()[ids2]+1
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(len(c2),))
+ a[:]=c2.toNumPyArray() ; a.flush() ; mm.seek(mm.tell()+len(c2)*4)
+ pass
+ else:
+ nbOfNodesPerCell=mp.getNodalConnectivityIndex().deltaShiftIndex()-1
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(len(nbOfNodesPerCell),))
+ a[:]=nbOfNodesPerCell.toNumPyArray() ; a.flush() ; mm.seek(mm.tell()+len(nbOfNodesPerCell)*4)
+ ids2=mp.getNodalConnectivityIndex().buildComplement(mp.getNodalConnectivityIndex().back()+1)
+ c2=mp.getNodalConnectivity()[ids2]+1
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(len(c2),))
+ a[:]=c2.toNumPyArray() ; a.flush() ; mm.seek(mm.tell()+len(c2)*4)
+ pass
+ i+=nbelem
+ pass
+ pass
+ pass
+ pass
+
+ def __writeFieldsPart(self,mdfs):
+ if not mdfs:
+ return ""
+ self._ze_top_dict={}
+ its,areForgottenTS=mdfs.getCommonIterations()
+ if areForgottenTS:
+ print "WARNING : some iterations are NOT present in all fields ! Kept iterations are : %s !"%(str(its))
+ pass
+ TimeValues=""
+ for it in its:
+ TimeValues+="%s\n"%(str(mdfs[0][it].getTime()[-1]))
+ pass
+ dictVars={}
+ for mdf in mdfs:
+ nbCompo=mdf.getNumberOfComponents()
+ if nbCompo not in self.dictCompo:
+ l=filter(lambda x:x-nbCompo>0,self.dictCompo.keys())
+ if len(l)==0:
+ print "Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(self.dictCompo.keys()))
+ continue
+ pass
+ print "WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(self.dictCompo.keys()))
+ nbCompo=l[0]
+ pass
+ if nbCompo in dictVars:
+ dictVars[nbCompo].append(mdf)
+ pass
+ else:
+ dictVars[nbCompo]=[mdf]
+ pass
+ pass
+ for mdf in mdfs:
+ nbCompo=mdf.getNumberOfComponents()
+ if nbCompo not in self.dictCompo:
+ l=filter(lambda x:x-nbCompo>0,self.dictCompo.keys())
+ if len(l)==0:
+ continue;
+ nbCompo=l[0]
+ pass
+ for iii,it in enumerate(its):
+ ff=mdf[it]
+ isMultiDisc=len(ff.getTypesOfFieldAvailable())>1
+ for typ in ff.getTypesOfFieldAvailable():
+ l=self._l[:] ; l[-1]="%s%s.%s"%(self._base_name_without_dir,str(iii).rjust(4,"0"),ff.getName())
+ if isMultiDisc:
+ l[-1]="%s_%s"(l[-1],MEDCouplingFieldDiscretization.New(typ).getStringRepr())
+ pass
+ fffn=l[-1]
+ try:
+ os.remove(os.path.sep.join(l))
+ except:
+ pass
+ f=open(os.path.sep.join(l),"w+b")
+ summ=0
+ for geo,[(curTyp,(bg,end),pfl,loc)] in ff.getFieldSplitedByType():
+ if typ==curTyp:
+ summ+=4*nbCompo*(end-bg)+80
+ pass
+ pass
+ a=np.memmap(f,dtype='byte',mode='w+',offset=0,shape=(2*80+4+summ,)) ; a.flush() # truncate to set the size of the file
+ mm=mmap.mmap(f.fileno(),offset=0,length=0)
+ k1=ff.getName()
+ if isMultiDisc:
+ k1="%s_%s"%(k1,MEDCouplingFieldDiscretization.New(typ).getStringRepr())
+ pass
+ mm.write(self.__str80(k1))
+ mm.write(self.__str80("part"))
+ a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(1,))
+ a[0]=1 ; a.flush() ; mm.seek(mm.tell()+4) # part number maybe to change ?
+ for geo,[(curTyp,(bg,end),pfl,loc)] in ff.getFieldSplitedByType():
+ if pfl!="":
+ raise Exception("Field \"%s\" contains profiles ! Profiles are not supported yet !"%(mdf.getName()))
+ if typ==curTyp:
+ arr=ff.getUndergroundDataArray()[bg:end].changeNbOfComponents(nbCompo,0.) ; arr=arr.toNoInterlace()
+ if typ==ON_CELLS:
+ mm.write(self.__str80(self.dictMCTyp[geo]))
+ pass
+ elif typ==ON_NODES:
+ mm.write(self.__str80("coordinates"))
+ pass
+ else:
+ print "UnManaged type of field for field \"%s\" !"%(mdf.getName())
+ pass
+ a=np.memmap(f,dtype='float32',mode='w+',offset=mm.tell(),shape=(nbCompo,end-bg))
+ b=arr.toNumPyArray() ; b=b.reshape(nbCompo,end-bg)
+ a[:]=b
+ a.flush() ; mm.seek(mm.tell()+nbCompo*(end-bg)*4)
+ pass
+ pass
+ k="%s per %s"%(self.dictCompo[nbCompo],self.discSpatial[typ])
+ if k in self._ze_top_dict:
+ if k1 in self._ze_top_dict[k]:
+ self._ze_top_dict[k][k1].append(fffn)
+ pass
+ else:
+ self._ze_top_dict[k][k1]=[fffn]
+ pass
+ else:
+ self._ze_top_dict[k]={k1:[fffn]}
+ pass
+ pass
+ pass
+ pass
+ headerPart=""
+ if len(self._ze_top_dict)!=0:
+ hvp=self.header_varpart[:]
+ for k in self._ze_top_dict:
+ for k1 in self._ze_top_dict[k]:
+ hvp+="\n%s: %s %s"%(k,k1,re.sub("([\d]{4})",4*"*",self._ze_top_dict[k][k1][0]))
+ pass
+ pass
+ hvp+="\n"
+ headerPart+=hvp
+ #
+ ddd={"NbTimeSteps":len(its),"TimeValues":TimeValues}
+ htp=self.header_timepart%ddd
+ headerPart+=htp
+ pass
+ return headerPart
+
+ @classmethod
+ def __str80(cls,st):
+ if len(st)>79:
+ raise Exception("String \"%s\" is too long (>79) !"%(st))
+ return st.ljust(79)+"\n"
+
+ def __computeSizeOfGeoFile(self,listOfMeshes,nn):
+ sz=0
+ for m in listOfMeshes:
+ distribTypes=m.getDistributionOfTypes()
+ sz+=80+4+2*80+4+nn*3*4
+ i=0
+ for typ2,nbelem,dummy in distribTypes:
+ typ=typ2
+ if typ not in self.dictMCTyp:
+ typ=MEDCouplingMesh.GetCorrespondingPolyType()
+ pass
+ if typ!=NORM_POLYHED and typ!=NORM_POLYGON:
+ sz+=80+4+MEDCouplingMesh.GetNumberOfNodesOfGeometricType(typ)*nbelem*4
+ pass
+ elif typ==NORM_POLYHED:
+ mplh=m[i:i+nbelem] ; delta=len(mplh.getNodalConnectivity())+nbelem
+ sz+=80+4+delta*4
+ pass
+ else:
+ mplh=m[i:i+nbelem] ; delta=len(mplh.getNodalConnectivity())
+ sz+=80+4+delta*4
+ pass
+ i+=nbelem
+ pass
+ pass
+ return sz
$result=convertMEDFileParameter1TS($1,$owner);
}
+%typemap(out) ParaMEDMEM::MEDFileAnyTypeFieldMultiTS*
+{
+ $result=convertMEDFileFieldMultiTS($1,$owner);
+}
+
+%typemap(out) ParaMEDMEM::MEDFileAnyTypeField1TS*
+{
+ $result=convertMEDFileField1TS($1,$owner);
+}
+
%newobject MEDLoader::ReadUMeshFromFamilies;
%newobject MEDLoader::ReadUMeshFromGroups;
%newobject MEDLoader::ReadUMeshFromFile;
%newobject MEDLoader::ReadFieldGauss;
%newobject MEDLoader::ReadFieldGaussNE;
%newobject ParaMEDMEM::MEDFileMesh::New;
+%newobject ParaMEDMEM::MEDFileMesh::createNewEmpty;
%newobject ParaMEDMEM::MEDFileMesh::deepCpy;
%newobject ParaMEDMEM::MEDFileMesh::shallowCpy;
%newobject ParaMEDMEM::MEDFileMesh::getGenMeshAtLevel;
%newobject ParaMEDMEM::MEDFileMesh::getNodeFamilyArr;
%newobject ParaMEDMEM::MEDFileMesh::getNodeFamiliesArr;
%newobject ParaMEDMEM::MEDFileMesh::getAllFamiliesIdsReferenced;
+%newobject ParaMEDMEM::MEDFileMesh::computeAllFamilyIdsInUse;
%newobject ParaMEDMEM::MEDFileUMesh::New;
%newobject ParaMEDMEM::MEDFileUMesh::getCoords;
%newobject ParaMEDMEM::MEDFileUMesh::getGroup;
%newobject ParaMEDMEM::MEDFileFields::New;
%newobject ParaMEDMEM::MEDFileFields::deepCpy;
+%newobject ParaMEDMEM::MEDFileFields::shallowCpy;
%newobject ParaMEDMEM::MEDFileFields::getFieldWithName;
%newobject ParaMEDMEM::MEDFileFields::getFieldAtPos;
-%newobject ParaMEDMEM::MEDFileFields::__getitem__;
+%newobject ParaMEDMEM::MEDFileFields::partOfThisLyingOnSpecifiedMeshName;
+%newobject ParaMEDMEM::MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps;
+%newobject ParaMEDMEM::MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps;
%newobject ParaMEDMEM::MEDFileFields::__iter__;
+
+%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::New;
+%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::deepCpy;
+%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::shallowCpy;
+%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::getTimeStepAtPos;
+%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::getTimeStep;
+%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime;
+%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::__iter__;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::New;
-%newobject ParaMEDMEM::MEDFileFieldMultiTS::deepCpy;
-%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepAtPos;
-%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStep;
-%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepGivenTime;
-%newobject ParaMEDMEM::MEDFileFieldMultiTS::__getitem__;
-%newobject ParaMEDMEM::MEDFileFieldMultiTS::__iter__;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevel;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtTopLevel;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldOnMeshAtLevel;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevelOld;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getUndergroundDataArray;
+%newobject ParaMEDMEM::MEDFileIntFieldMultiTS::New;
+%newobject ParaMEDMEM::MEDFileIntFieldMultiTS::getUndergroundDataArray;
+
+%newobject ParaMEDMEM::MEDFileAnyTypeField1TS::New;
+%newobject ParaMEDMEM::MEDFileAnyTypeField1TS::shallowCpy;
+%newobject ParaMEDMEM::MEDFileAnyTypeField1TS::deepCpy;
%newobject ParaMEDMEM::MEDFileField1TS::New;
-%newobject ParaMEDMEM::MEDFileField1TS::deepCpy;
%newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevel;
%newobject ParaMEDMEM::MEDFileField1TS::getFieldAtTopLevel;
%newobject ParaMEDMEM::MEDFileField1TS::getFieldOnMeshAtLevel;
%newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevelOld;
%newobject ParaMEDMEM::MEDFileField1TS::getUndergroundDataArray;
+%newobject ParaMEDMEM::MEDFileIntField1TS::New;
+%newobject ParaMEDMEM::MEDFileIntField1TS::getUndergroundDataArray;
%newobject ParaMEDMEM::MEDFileData::New;
%newobject ParaMEDMEM::MEDFileData::deepCpy;
%feature("unref") MEDFileMeshMultiTS "$this->decrRef();"
%feature("unref") MEDFileMeshes "$this->decrRef();"
%feature("unref") MEDFileFieldLoc "$this->decrRef();"
+%feature("unref") MEDFileAnyTypeField1TS "$this->decrRef();"
%feature("unref") MEDFileField1TS "$this->decrRef();"
+%feature("unref") MEDFileIntField1TS "$this->decrRef();"
+%feature("unref") MEDFileAnyTypeFieldMultiTS "$this->decrRef();"
%feature("unref") MEDFileFieldMultiTS "$this->decrRef();"
+%feature("unref") MEDFileIntFieldMultiTS "$this->decrRef();"
%feature("unref") MEDFileFields "$this->decrRef();"
%feature("unref") MEDFileParameter1TS "$this->decrRef();"
%feature("unref") MEDFileParameterDouble1TSWTI "$this->decrRef();"
public:
static MEDFileMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
+ virtual MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception);
virtual MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
virtual MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
- virtual void clearNonDiscrAttributes() const;
+ virtual void clearNonDiscrAttributes() const throw(INTERP_KERNEL::Exception);
void setName(const char *name);
const char *getName();
const char *getUnivName() const;
void setTimeUnit(const char *unit);
const char *getTimeUnit() const;
virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<int> getFamArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<int> getNumArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<int> getNameArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
std::vector<int> getNonEmptyLevels() const throw(INTERP_KERNEL::Exception);
std::vector<int> getNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
//
- bool existsGroup(const char *groupName) const;
- bool existsFamily(int famId) const;
- bool existsFamily(const char *familyName) const;
- void setFamilyId(const char *familyName, int id);
+ bool existsGroup(const char *groupName) const throw(INTERP_KERNEL::Exception);
+ bool existsFamily(int famId) const throw(INTERP_KERNEL::Exception);
+ bool existsFamily(const char *familyName) const throw(INTERP_KERNEL::Exception);
+ void setFamilyId(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
void setFamilyIdUnique(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
void addFamily(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
void addFamilyOnGrp(const char *grpName, const char *famName) throw(INTERP_KERNEL::Exception);
virtual void createGroupOnAll(int meshDimRelToMaxExt, const char *groupName) throw(INTERP_KERNEL::Exception);
virtual bool keepFamIdsOnlyOnLevs(const std::vector<int>& famIds, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
- void copyFamGrpMapsFrom(const MEDFileMesh& other);
- const std::map<std::string,int>& getFamilyInfo() const;
- const std::map<std::string, std::vector<std::string> >& getGroupInfo() const;
+ void copyFamGrpMapsFrom(const MEDFileMesh& other) throw(INTERP_KERNEL::Exception);
+ const std::map<std::string,int>& getFamilyInfo() const throw(INTERP_KERNEL::Exception);
+ const std::map<std::string, std::vector<std::string> >& getGroupInfo() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
void setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception);
std::vector<std::string> getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception);
void setGroupsOnFamily(const char *famName, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
- std::vector<std::string> getGroupsNames() const;
- std::vector<std::string> getFamiliesNames() const;
+ std::vector<std::string> getGroupsNames() const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getFamiliesNames() const throw(INTERP_KERNEL::Exception);
void assignFamilyNameWithGroupName() throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> removeEmptyGroups() throw(INTERP_KERNEL::Exception);
void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> removeOrphanGroups() throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> removeOrphanFamilies() throw(INTERP_KERNEL::Exception);
void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
void changeFamilyId(int oldId, int newId) throw(INTERP_KERNEL::Exception);
void setFamilyInfo(const std::map<std::string,int>& info);
void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
+ int getMaxAbsFamilyId() const throw(INTERP_KERNEL::Exception);
int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
int getMinFamilyId() const throw(INTERP_KERNEL::Exception);
+ int getTheMaxAbsFamilyId() const throw(INTERP_KERNEL::Exception);
int getTheMaxFamilyId() const throw(INTERP_KERNEL::Exception);
int getTheMinFamilyId() const throw(INTERP_KERNEL::Exception);
+ virtual int getMaxAbsFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
virtual int getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
virtual int getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception);
DataArrayInt *getAllFamiliesIdsReferenced() const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *computeAllFamilyIdsInUse() const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception);
bool ensureDifferentFamIdsPerLevel() throw(INTERP_KERNEL::Exception);
{
return self->iterator();
}
+
+ int __len__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->getNumberOfMeshes();
+ }
MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception)
{
const std::vector<double>& getRefCoords() const;
const std::vector<double>& getGaussCoords() const;
const std::vector<double>& getGaussWeights() const;
- bool isEqual(const MEDFileFieldLoc& other, double eps) const;
+ bool isEqual(const MEDFileFieldLoc& other, double eps) const throw(INTERP_KERNEL::Exception);
%extend
{
std::string __str__() const throw(INTERP_KERNEL::Exception)
class MEDFileFieldGlobsReal
{
public:
+ void resetContent();
void shallowCpyGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception);
void deepCpyGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception);
+ void shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception);
+ void deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception);
+ void appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception);
+ void checkGlobsCoherency() const throw(INTERP_KERNEL::Exception);
+ void checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception);
+ void checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPfls() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getLocs() const throw(INTERP_KERNEL::Exception);
bool existsPfl(const char *pflName) const throw(INTERP_KERNEL::Exception);
std::vector< std::pair<std::vector<std::string>, std::string > > v=convertVecPairVecStFromPy(li);
self->changeLocsNamesInStruct(v);
}
+
+ std::string simpleReprGlobs() const throw(INTERP_KERNEL::Exception)
+ {
+ std::ostringstream oss;
+ self->simpleReprGlobs(oss);
+ return oss.str();
+ }
}
};
- class MEDFileField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
+ class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
+ {
+ public:
+ static MEDFileAnyTypeField1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const 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);
+ std::string getName() throw(INTERP_KERNEL::Exception);
+ void setName(const char *name) throw(INTERP_KERNEL::Exception);
+ std::string getMeshName() throw(INTERP_KERNEL::Exception);
+ void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
+ bool isDealingTS(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ void setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception);
+ const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
+ void setTime(int iteration, int order, double val) throw(INTERP_KERNEL::Exception);
+ virtual MEDFileAnyTypeField1TS *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeField1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
+ std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
+ void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ PyObject *getTime() throw(INTERP_KERNEL::Exception)
+ {
+ int tmp1,tmp2;
+ double tmp0=self->getTime(tmp1,tmp2);
+ PyObject *res = PyList_New(3);
+ PyList_SetItem(res,0,SWIG_From_int(tmp1));
+ PyList_SetItem(res,1,SWIG_From_int(tmp2));
+ PyList_SetItem(res,2,SWIG_From_double(tmp0));
+ return res;
+ }
+
+ PyObject *getDtIt() const throw(INTERP_KERNEL::Exception)
+ {
+ std::pair<int,int> res=self->getDtIt();
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int(res.first));
+ PyTuple_SetItem(elt,1,SWIG_From_int(res.second));
+ return elt;
+ }
+
+ void setProfileNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
+ {
+ self->setProfileNameOnLeaf(0,typ,locId,newPflName,forceRenameOnGlob);
+ }
+
+ void setLocNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
+ {
+ self->setLocNameOnLeaf(0,typ,locId,newLocName,forceRenameOnGlob);
+ }
+
+ bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
+ return self->changeMeshNames(modifTab);
+ }
+
+ PyObject *getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<TypeOfField> ret=self->getTypesOfFieldAvailable();
+ PyObject *ret2=PyList_New(ret.size());
+ for(int i=0;i<(int)ret.size();i++)
+ PyList_SetItem(ret2,i,SWIG_From_int(ret[i]));
+ return ret2;
+ }
+
+ PyObject *getNonEmptyLevels(const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> ret1;
+ int ret0=self->getNonEmptyLevels(mname,ret1);
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int(ret0));
+ PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1));
+ return elt;
+ }
+
+ PyObject *getFieldSplitedByType(const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> types;
+ std::vector< std::vector<TypeOfField> > typesF;
+ std::vector< std::vector<std::string> > pfls;
+ std::vector< std::vector<std::string> > locs;
+ std::vector< std::vector< std::pair<int,int> > > ret=self->getFieldSplitedByType(mname,types,typesF,pfls,locs);
+ int sz=ret.size();
+ PyObject *ret2=PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ const std::vector< std::pair<int,int> >& dadsI=ret[i];
+ const std::vector<TypeOfField>& typesFI=typesF[i];
+ const std::vector<std::string>& pflsI=pfls[i];
+ const std::vector<std::string>& locsI=locs[i];
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
+ int sz2=ret[i].size();
+ PyObject *elt2=PyList_New(sz2);
+ for(int j=0;j<sz2;j++)
+ {
+ PyObject *elt3=PyTuple_New(4);
+ PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
+ PyObject *elt4=PyTuple_New(2); PyTuple_SetItem(elt4,0,SWIG_From_int(dadsI[j].first)); PyTuple_SetItem(elt4,1,SWIG_From_int(dadsI[j].second));
+ PyTuple_SetItem(elt3,1,elt4);
+ PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
+ PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
+ PyList_SetItem(elt2,j,elt3);
+ }
+ PyTuple_SetItem(elt,1,elt2);
+ PyList_SetItem(ret2,i,elt);
+ }
+ return ret2;
+ }
+
+ PyObject *splitComponents() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret=self->splitComponents();
+ std::size_t sz=ret.size();
+ PyObject *retPy=PyList_New(sz);
+ for(std::size_t i=0;i<sz;i++)
+ PyList_SetItem(retPy,i,convertMEDFileField1TS(ret[i].retn(), SWIG_POINTER_OWN | 0 ));
+ return retPy;
+ }
+ }
+ };
+
+ class MEDFileField1TS : public MEDFileAnyTypeField1TS
{
public:
static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
static MEDFileField1TS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
static MEDFileField1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
static MEDFileField1TS *New();
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
- void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
- MEDFileField1TS *deepCpy() const 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);
- std::string getName() throw(INTERP_KERNEL::Exception);
- void setName(const char *name) throw(INTERP_KERNEL::Exception);
- std::string getMeshName() throw(INTERP_KERNEL::Exception);
- void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
- int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
- bool isDealingTS(int iteration, int order) const throw(INTERP_KERNEL::Exception);
- const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
- void setTime(int iteration, int order, double val) throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
{
return MEDFileField1TS::New();
}
-
- std::string __str__() const throw(INTERP_KERNEL::Exception)
- {
- return self->simpleRepr();
- }
-
- PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- DataArrayDouble *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- void setProfileNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
- {
- self->setProfileNameOnLeaf(0,typ,locId,newPflName,forceRenameOnGlob);
- }
-
- void setLocNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
- {
- self->setLocNameOnLeaf(0,typ,locId,newLocName,forceRenameOnGlob);
- }
- PyObject *getTime() throw(INTERP_KERNEL::Exception)
- {
- int tmp1,tmp2;
- double tmp0=self->getTime(tmp1,tmp2);
- PyObject *res = PyList_New(3);
- PyList_SetItem(res,0,SWIG_From_int(tmp1));
- PyList_SetItem(res,1,SWIG_From_int(tmp2));
- PyList_SetItem(res,2,SWIG_From_double(tmp0));
- return res;
- }
-
- PyObject *getDtIt() const throw(INTERP_KERNEL::Exception)
- {
- std::pair<int,int> res=self->getDtIt();
- PyObject *elt=PyTuple_New(2);
- PyTuple_SetItem(elt,0,SWIG_From_int(res.first));
- PyTuple_SetItem(elt,1,SWIG_From_int(res.second));
- return elt;
- }
-
- PyObject *getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
+ void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
{
- std::vector<TypeOfField> ret=self->getTypesOfFieldAvailable();
- PyObject *ret2=PyList_New(ret.size());
- for(int i=0;i<(int)ret.size();i++)
- PyList_SetItem(ret2,i,SWIG_From_int(ret[i]));
- return ret2;
+ const DataArrayDouble *arr=0;
+ if(field)
+ arr=field->getArray();
+ self->copyTinyInfoFrom(field,arr);
}
- PyObject *getNonEmptyLevels(const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
{
- std::vector<int> ret1;
- int ret0=self->getNonEmptyLevels(mname,ret1);
- PyObject *elt=PyTuple_New(2);
- PyTuple_SetItem(elt,0,SWIG_From_int(ret0));
- PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1));
- return elt;
+ return self->simpleRepr();
}
- PyObject *getFieldSplitedByType(const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
- std::vector<INTERP_KERNEL::NormalizedCellType> types;
- std::vector< std::vector<TypeOfField> > typesF;
- std::vector< std::vector<std::string> > pfls;
- std::vector< std::vector<std::string> > locs;
- std::vector< std::vector< std::pair<int,int> > > ret=self->getFieldSplitedByType(mname,types,typesF,pfls,locs);
- int sz=ret.size();
- PyObject *ret2=PyList_New(sz);
- for(int i=0;i<sz;i++)
- {
- const std::vector< std::pair<int,int> >& dadsI=ret[i];
- const std::vector<TypeOfField>& typesFI=typesF[i];
- const std::vector<std::string>& pflsI=pfls[i];
- const std::vector<std::string>& locsI=locs[i];
- PyObject *elt=PyTuple_New(2);
- PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
- int sz2=ret[i].size();
- PyObject *elt2=PyList_New(sz2);
- for(int j=0;j<sz2;j++)
- {
- PyObject *elt3=PyTuple_New(4);
- PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
- PyObject *elt4=PyTuple_New(2); PyTuple_SetItem(elt4,0,SWIG_From_int(dadsI[j].first)); PyTuple_SetItem(elt4,1,SWIG_From_int(dadsI[j].second));
- PyTuple_SetItem(elt3,1,elt4);
- PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
- PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
- PyList_SetItem(elt2,j,elt3);
- }
- PyTuple_SetItem(elt,1,elt2);
- PyList_SetItem(ret2,i,elt);
- }
- return ret2;
+ DataArrayInt *ret1=0;
+ DataArrayDouble *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
}
PyObject *getFieldSplitedByType2(const char *mname=0) const throw(INTERP_KERNEL::Exception)
PyTuple_SetItem(ret,1,elt);
return ret;
}
-
- bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
- return self->changeMeshNames(modifTab);
- }
}
};
- class MEDFileFieldMultiTSIterator
+ class MEDFileIntField1TS : public MEDFileAnyTypeField1TS
+ {
+ public:
+ static MEDFileIntField1TS *New();
+ static MEDFileIntField1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntField1TS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ //
+ void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
+ void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileIntField1TS() throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileIntField1TS::New();
+ }
+
+ MEDFileIntField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileIntField1TS::New(fileName);
+ }
+
+ MEDFileIntField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileIntField1TS::New(fileName,fieldName);
+ }
+
+ MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileIntField1TS::New(fileName,fieldName,iteration,order);
+ }
+
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
+ PyObject *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldAtLevel(type,meshDimRelToMax,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldAtTopLevel(type,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,meshDimRelToMax,mesh,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,mesh,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldAtLevelOld(type,mname,meshDimRelToMax,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ DataArrayInt *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ DataArrayInt *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret=self->getUndergroundDataArray();
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ }
+ };
+
+ class MEDFileAnyTypeFieldMultiTSIterator
{
public:
%extend
{
PyObject *next() throw(INTERP_KERNEL::Exception)
{
- MEDFileField1TS *ret=self->nextt();
+ MEDFileAnyTypeField1TS *ret=self->nextt();
if(ret)
- return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDFileField1TS,SWIG_POINTER_OWN | 0);
+ return convertMEDFileField1TS(ret, SWIG_POINTER_OWN | 0 );
else
{
PyErr_SetString(PyExc_StopIteration,"No more data.");
}
};
- class MEDFileFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
+ class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
{
public:
- static MEDFileFieldMultiTS *New() throw(INTERP_KERNEL::Exception);
- static MEDFileFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
- static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
- MEDFileFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
- //
- MEDFileField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
- MEDFileField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
- MEDFileField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
- //
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- //
- void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
- void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
- //
- int getNumberOfTS() const throw(INTERP_KERNEL::Exception);
- void eraseEmptyTS() 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);
+ static MEDFileAnyTypeFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
+ virtual MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception);
std::string getName() const throw(INTERP_KERNEL::Exception);
void setName(const char *name) throw(INTERP_KERNEL::Exception);
+ std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
+ void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception);
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfTS() const throw(INTERP_KERNEL::Exception);
+ void eraseEmptyTS() 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);
+ void write(const char *fileName, int mode) const 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);
+ MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
+ void pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception);
+ void synchronizeNameScope() throw(INTERP_KERNEL::Exception);
%extend
- {
- MEDFileFieldMultiTS()
- {
- return MEDFileFieldMultiTS::New();
- }
+ {
+ int __len__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->getNumberOfTS();
+ }
+
+ int getTimeId(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
+ {
+ if(elt0 && PyInt_Check(elt0))
+ {//fmts[3]
+ int pos=PyInt_AS_LONG(elt0);
+ return pos;
+ }
+ else if(elt0 && PyTuple_Check(elt0))
+ {
+ if(PyTuple_Size(elt0)==2)
+ {
+ PyObject *o0=PyTuple_GetItem(elt0,0);
+ PyObject *o1=PyTuple_GetItem(elt0,1);
+ if(PyInt_Check(o0) && PyInt_Check(o1))
+ {//fmts(1,-1)
+ int iter=PyInt_AS_LONG(o0);
+ int order=PyInt_AS_LONG(o1);
+ return self->getPosOfTimeStep(iter,order);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !");
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !");
+ }
+ else if(elt0 && PyFloat_Check(elt0))
+ {
+ double val=PyFloat_AS_DOUBLE(elt0);
+ return self->getPosGivenTime(val);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !");
+ }
+
+ PyObject *getIterations() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<int,int> > res=self->getIterations();
+ PyObject *ret=PyList_New(res.size());
+ int rk=0;
+ for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+ {
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+ PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+ PyList_SetItem(ret,rk,elt);
+ }
+ return ret;
+ }
+
+ PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<double> ret1;
+ std::vector< std::pair<int,int> > ret=self->getTimeSteps(ret1);
+ std::size_t sz=ret.size();
+ PyObject *ret2=PyList_New(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ PyObject *elt=PyTuple_New(3);
+ PyTuple_SetItem(elt,0,SWIG_From_int(ret[i].first));
+ PyTuple_SetItem(elt,1,SWIG_From_int(ret[i].second));
+ PyTuple_SetItem(elt,2,SWIG_From_double(ret1[i]));
+ PyList_SetItem(ret2,i,elt);
+ }
+ return ret2;
+ }
+
+ PyObject *getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::vector<TypeOfField> > ret=self->getTypesOfFieldAvailable();
+ PyObject *ret2=PyList_New(ret.size());
+ for(int i=0;i<(int)ret.size();i++)
+ {
+ const std::vector<TypeOfField>& rett=ret[i];
+ PyObject *ret3=PyList_New(rett.size());
+ for(int j=0;j<(int)rett.size();j++)
+ PyList_SetItem(ret3,j,SWIG_From_int(rett[j]));
+ PyList_SetItem(ret2,i,ret3);
+ }
+ return ret2;
+ }
+
+ PyObject *getNonEmptyLevels(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> ret1;
+ int ret0=self->getNonEmptyLevels(iteration,order,mname,ret1);
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int(ret0));
+ PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1));
+ return elt;
+ }
+
+ PyObject *getFieldSplitedByType(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> types;
+ std::vector< std::vector<TypeOfField> > typesF;
+ std::vector< std::vector<std::string> > pfls;
+ std::vector< std::vector<std::string> > locs;
+ std::vector< std::vector< std::pair<int,int> > > ret=self->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
+ int sz=ret.size();
+ PyObject *ret2=PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ const std::vector< std::pair<int,int> >& dadsI=ret[i];
+ const std::vector<TypeOfField>& typesFI=typesF[i];
+ const std::vector<std::string>& pflsI=pfls[i];
+ const std::vector<std::string>& locsI=locs[i];
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
+ int sz2=ret[i].size();
+ PyObject *elt2=PyList_New(sz2);
+ for(int j=0;j<sz2;j++)
+ {
+ PyObject *elt3=PyTuple_New(4);
+ PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
+ PyObject *elt4=PyTuple_New(2); PyTuple_SetItem(elt4,0,SWIG_From_int(dadsI[j].first)); PyTuple_SetItem(elt4,1,SWIG_From_int(dadsI[j].second));
+ PyTuple_SetItem(elt3,1,elt4);
+ PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
+ PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
+ PyList_SetItem(elt2,j,elt3);
+ }
+ PyTuple_SetItem(elt,1,elt2);
+ PyList_SetItem(ret2,i,elt);
+ }
+ return ret2;
+ }
+
+ std::vector<int> getTimeIds(PyObject *elts) const throw(INTERP_KERNEL::Exception)
+ {
+ if(PyList_Check(elts))
+ {
+ int sz=PyList_Size(elts);
+ std::vector<int> ret(sz);
+ for(int i=0;i<sz;i++)
+ {
+ PyObject *elt=PyList_GetItem(elts,i);
+ ret[i]=ParaMEDMEM_MEDFileAnyTypeFieldMultiTS_getTimeId(self,elt);
+ }
+ return ret;
+ }
+ else
+ {
+ std::vector<int> ret(1);
+ ret[0]=ParaMEDMEM_MEDFileAnyTypeFieldMultiTS_getTimeId(self,elts);
+ return ret;
+ }
+ }
+
+ void __delitem__(PyObject *elts) throw(INTERP_KERNEL::Exception)
+ {
+ if(PySlice_Check(elts))
+ {
+ 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 !");
+ }
+ else
+ {
+ std::vector<int> idsToRemove=ParaMEDMEM_MEDFileAnyTypeFieldMultiTS_getTimeIds(self,elts);
+ if(!idsToRemove.empty())
+ self->eraseTimeStepIds(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size());
+ }
+ }
+
+ void eraseTimeStepIds(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int pos1;
+ std::vector<int> pos2;
+ DataArrayInt *pos3=0;
+ DataArrayIntTuple *pos4=0;
+ convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->eraseTimeStepIds(&pos1,&pos1+1);
+ return;
+ }
+ case 2:
+ {
+ if(pos2.empty())
+ return;
+ self->eraseTimeStepIds(&pos2[0],&pos2[0]+pos2.size());
+ return ;
+ }
+ case 3:
+ {
+ self->eraseTimeStepIds(pos3->begin(),pos3->end());
+ return ;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds : unexpected input array type recognized !");
+ }
+ }
+
+ MEDFileAnyTypeFieldMultiTSIterator *__iter__() throw(INTERP_KERNEL::Exception)
+ {
+ return self->iterator();
+ }
+
+ PyObject *__getitem__(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
+ {
+ if(elt0 && PyList_Check(elt0))
+ {
+ int sz=PyList_Size(elt0);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=DataArrayInt::New(); da->alloc(sz,1);
+ int *pt=da->getPointer();
+ for(int i=0;i<sz;i++,pt++)
+ {
+ PyObject *elt1=PyList_GetItem(elt0,i);
+ *pt=MEDFileAnyTypeFieldMultiTSgetitemSingleTS__(self,elt1);
+ }
+ return convertMEDFileFieldMultiTS(self->buildSubPart(da->begin(),da->end()),SWIG_POINTER_OWN | 0);
+ }
+ else if(elt0 && PySlice_Check(elt0))
+ {
+ 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 !");
+ }
+ else
+ return convertMEDFileField1TS(self->getTimeStepAtPos(MEDFileAnyTypeFieldMultiTSgetitemSingleTS__(self,elt0)),SWIG_POINTER_OWN | 0);
+ }
+
+ bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
+ return self->changeMeshNames(modifTab);
+ }
+
+ PyObject *splitComponents() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret=self->splitComponents();
+ std::size_t sz=ret.size();
+ PyObject *retPy=PyList_New(sz);
+ for(std::size_t i=0;i<sz;i++)
+ PyList_SetItem(retPy,i,convertMEDFileFieldMultiTS(ret[i].retn(), SWIG_POINTER_OWN | 0 ));
+ return retPy;
+ }
+
+ void pushBackTimeSteps(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<MEDFileAnyTypeField1TS *> tmp;
+ convertFromPyObjVectorOfObj<ParaMEDMEM::MEDFileAnyTypeField1TS *>(li,SWIGTYPE_p_ParaMEDMEM__MEDFileAnyTypeField1TS,"MEDFileAnyTypeField1TS",tmp);
+ self->pushBackTimeSteps(tmp);
+ }
+ }
+ };
+
+ class MEDFileFieldMultiTS : public MEDFileAnyTypeFieldMultiTS
+ {
+ public:
+ static MEDFileFieldMultiTS *New() throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ //
+ MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ //
+ void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileFieldMultiTS()
+ {
+ return MEDFileFieldMultiTS::New();
+ }
MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
{
return self->simpleRepr();
}
- int __len__() const throw(INTERP_KERNEL::Exception)
- {
- return self->getNumberOfTS();
- }
-
- MEDFileField1TS *__getitem__(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
- {
- if(elt0 && PyInt_Check(elt0))
- {//fmts[3]
- int pos=PyInt_AS_LONG(elt0);
- return self->getTimeStepAtPos(pos);
- }
- else if(elt0 && PyTuple_Check(elt0))
- {
- if(PyTuple_Size(elt0)==2)
- {
- PyObject *o0=PyTuple_GetItem(elt0,0);
- PyObject *o1=PyTuple_GetItem(elt0,1);
- if(PyInt_Check(o0) && PyInt_Check(o1))
- {//fmts(1,-1)
- int iter=PyInt_AS_LONG(o0);
- int order=PyInt_AS_LONG(o1);
- return self->getTimeStep(iter,order);
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !");
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !");
- }
- else if(elt0 && PyFloat_Check(elt0))
- {
- double val=PyFloat_AS_DOUBLE(elt0);
- return self->getTimeStepGivenTime(val);
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !");
- }
-
- MEDFileFieldMultiTSIterator *__iter__() throw(INTERP_KERNEL::Exception)
- {
- return self->iterator();
- }
-
PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- DataArrayDouble *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getIterations() const
{
- std::vector< std::pair<int,int> > res=self->getIterations();
- PyObject *ret=PyList_New(res.size());
- int rk=0;
- for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
- {
- PyObject *elt=PyTuple_New(2);
- PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
- PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
- PyList_SetItem(ret,rk,elt);
- }
+ DataArrayInt *ret1=0;
+ DataArrayDouble *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
- PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception)
- {
- std::vector<double> ret1;
- std::vector< std::pair<int,int> > ret=self->getTimeSteps(ret1);
- std::size_t sz=ret.size();
- PyObject *ret2=PyList_New(sz);
- for(std::size_t i=0;i<sz;i++)
- {
- PyObject *elt=PyTuple_New(3);
- PyTuple_SetItem(elt,0,SWIG_From_int(ret[i].first));
- PyTuple_SetItem(elt,1,SWIG_From_int(ret[i].second));
- PyTuple_SetItem(elt,2,SWIG_From_double(ret1[i]));
- PyList_SetItem(ret2,i,elt);
- }
- return ret2;
- }
-
- PyObject *getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
- {
- std::vector< std::vector<TypeOfField> > ret=self->getTypesOfFieldAvailable();
- PyObject *ret2=PyList_New(ret.size());
- for(int i=0;i<(int)ret.size();i++)
- {
- const std::vector<TypeOfField>& rett=ret[i];
- PyObject *ret3=PyList_New(rett.size());
- for(int j=0;j<(int)rett.size();j++)
- PyList_SetItem(ret3,j,SWIG_From_int(rett[j]));
- PyList_SetItem(ret2,i,ret3);
- }
- return ret2;
- }
-
- PyObject *getNonEmptyLevels(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> ret1;
- int ret0=self->getNonEmptyLevels(iteration,order,mname,ret1);
- PyObject *elt=PyTuple_New(2);
- PyTuple_SetItem(elt,0,SWIG_From_int(ret0));
- PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1));
- return elt;
- }
-
- PyObject *getFieldSplitedByType(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<INTERP_KERNEL::NormalizedCellType> types;
- std::vector< std::vector<TypeOfField> > typesF;
- std::vector< std::vector<std::string> > pfls;
- std::vector< std::vector<std::string> > locs;
- std::vector< std::vector< std::pair<int,int> > > ret=self->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
- int sz=ret.size();
- PyObject *ret2=PyList_New(sz);
- for(int i=0;i<sz;i++)
- {
- const std::vector< std::pair<int,int> >& dadsI=ret[i];
- const std::vector<TypeOfField>& typesFI=typesF[i];
- const std::vector<std::string>& pflsI=pfls[i];
- const std::vector<std::string>& locsI=locs[i];
- PyObject *elt=PyTuple_New(2);
- PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
- int sz2=ret[i].size();
- PyObject *elt2=PyList_New(sz2);
- for(int j=0;j<sz2;j++)
- {
- PyObject *elt3=PyTuple_New(4);
- PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
- PyObject *elt4=PyTuple_New(2); PyTuple_SetItem(elt4,0,SWIG_From_int(dadsI[j].first)); PyTuple_SetItem(elt4,1,SWIG_From_int(dadsI[j].second));
- PyTuple_SetItem(elt3,1,elt4);
- PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
- PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
- PyList_SetItem(elt2,j,elt3);
- }
- PyTuple_SetItem(elt,1,elt2);
- PyList_SetItem(ret2,i,elt);
- }
- return ret2;
- }
-
PyObject *getFieldSplitedByType2(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
{
std::vector<INTERP_KERNEL::NormalizedCellType> types;
ret->incrRef();
return ret;
}
+
PyObject *getUndergroundDataArrayExt(int iteration, int order) const throw(INTERP_KERNEL::Exception)
{
std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > elt1Cpp;
PyTuple_SetItem(ret,1,elt);
return ret;
}
-
- int getTimeId(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
- {
- if(elt0 && PyInt_Check(elt0))
- {//fmts[3]
- int pos=PyInt_AS_LONG(elt0);
- return pos;
- }
- else if(elt0 && PyTuple_Check(elt0))
- {
- if(PyTuple_Size(elt0)==2)
- {
- PyObject *o0=PyTuple_GetItem(elt0,0);
- PyObject *o1=PyTuple_GetItem(elt0,1);
- if(PyInt_Check(o0) && PyInt_Check(o1))
- {//fmts(1,-1)
- int iter=PyInt_AS_LONG(o0);
- int order=PyInt_AS_LONG(o1);
- return self->getPosOfTimeStep(iter,order);
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !");
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !");
- }
- else if(elt0 && PyFloat_Check(elt0))
- {
- double val=PyFloat_AS_DOUBLE(elt0);
- return self->getPosGivenTime(val);
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !");
- }
-
- std::vector<int> getTimeIds(PyObject *elts) const throw(INTERP_KERNEL::Exception)
- {
- if(PyList_Check(elts))
- {
- int sz=PyList_Size(elts);
- std::vector<int> ret(sz);
- for(int i=0;i<sz;i++)
- {
- PyObject *elt=PyList_GetItem(elts,i);
- ret[i]=ParaMEDMEM_MEDFileFieldMultiTS_getTimeId(self,elt);
- }
- return ret;
- }
- else
- {
- std::vector<int> ret(1);
- ret[0]=ParaMEDMEM_MEDFileFieldMultiTS_getTimeId(self,elts);
- return ret;
- }
- }
-
- void __delitem__(PyObject *elts) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> idsToRemove=ParaMEDMEM_MEDFileFieldMultiTS_getTimeIds(self,elts);
- if(!idsToRemove.empty())
- self->eraseTimeStepIds(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size());
- }
-
- void eraseTimeStepIds(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int sw;
- int pos1;
- std::vector<int> pos2;
- DataArrayInt *pos3=0;
- DataArrayIntTuple *pos4=0;
- convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4);
- switch(sw)
- {
- case 1:
- {
- self->eraseTimeStepIds(&pos1,&pos1+1);
- return;
- }
- case 2:
- {
- if(pos2.empty())
- return;
- self->eraseTimeStepIds(&pos2[0],&pos2[0]+pos2.size());
- return ;
- }
- case 3:
- {
- self->eraseTimeStepIds(pos3->begin(),pos3->end());
- return ;
- }
- default:
- throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::eraseTimeStepIds : unexpected input array type recognized !");
- }
- }
-
- bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
- return self->changeMeshNames(modifTab);
- }
}
};
{
PyObject *next() throw(INTERP_KERNEL::Exception)
{
- MEDFileFieldMultiTS *ret=self->nextt();
+ MEDFileAnyTypeFieldMultiTS *ret=self->nextt();
if(ret)
- return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldMultiTS,SWIG_POINTER_OWN | 0);
+ return convertMEDFileFieldMultiTS(ret, SWIG_POINTER_OWN | 0 );
else
{
PyErr_SetString(PyExc_StopIteration,"No more data.");
}
};
+ class MEDFileIntFieldMultiTS : public MEDFileAnyTypeFieldMultiTS
+ {
+ public:
+ static MEDFileIntFieldMultiTS *New();
+ static MEDFileIntFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ //
+ void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
+ void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileIntFieldMultiTS()
+ {
+ return MEDFileIntFieldMultiTS::New();
+ }
+
+ MEDFileIntFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileIntFieldMultiTS::New(fileName);
+ }
+
+ MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileIntFieldMultiTS::New(fileName,fieldName);
+ }
+
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
+ PyObject *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldAtLevel(type,iteration,order,meshDimRelToMax,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldAtTopLevel(type,iteration,order,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,iteration,order,meshDimRelToMax,mesh,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,iteration,order,mesh,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ MEDCouplingFieldDouble *ret0=self->getFieldAtLevelOld(type,iteration,order,mname,meshDimRelToMax,ret1,renumPol);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ DataArrayInt *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ DataArrayInt *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret=self->getUndergroundDataArray(iteration,order);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ }
+ };
+
class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
{
public:
static MEDFileFields *New() throw(INTERP_KERNEL::Exception);
static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
MEDFileFields *deepCpy() const throw(INTERP_KERNEL::Exception);
+ MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const;
std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
//
void resize(int newSize) throw(INTERP_KERNEL::Exception);
- void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
- void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
- MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
- MEDFileFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ void pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ void setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
%extend
{
{
return self->simpleRepr();
}
-
- MEDFileFieldMultiTS *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+
+ PyObject *getCommonIterations() const throw(INTERP_KERNEL::Exception)
{
- if(PyInt_Check(obj))
+ bool ret1;
+ std::vector< std::pair<int,int> > ret0=self->getCommonIterations(ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyObject *ret_0=PyList_New(ret0.size());
+ int rk=0;
+ for(std::vector< std::pair<int,int> >::const_iterator iter=ret0.begin();iter!=ret0.end();iter++,rk++)
{
- return self->getFieldAtPos((int)PyInt_AS_LONG(obj));
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+ PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+ PyList_SetItem(ret_0,rk,elt);
}
- else if(PyString_Check(obj))
+ PyTuple_SetItem(ret,0,ret_0);
+ PyObject *ret_1=ret1?Py_True:Py_False; Py_XINCREF(ret_1);
+ PyTuple_SetItem(ret,1,ret_1);
+ return ret;
+ }
+
+ MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(PyObject *timeSteps) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<int,int> > ts=convertTimePairIdsFromPy(timeSteps);
+ return self->partOfThisLyingOnSpecifiedTimeSteps(ts);
+ }
+
+ MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(PyObject *timeSteps) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<int,int> > ts=convertTimePairIdsFromPy(timeSteps);
+ return self->partOfThisNotLyingOnSpecifiedTimeSteps(ts);
+ }
+
+ PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ if(obj && PyList_Check(obj))
{
- return self->getFieldWithName(PyString_AsString(obj));
+ int sz=PyList_Size(obj);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=DataArrayInt::New(); da->alloc(sz,1);
+ int *pt=da->getPointer();
+ for(int i=0;i<sz;i++,pt++)
+ {
+ PyObject *elt1=PyList_GetItem(obj,i);
+ *pt=MEDFileFieldsgetitemSingleTS__(self,elt1);
+ }
+ return SWIG_NewPointerObj(SWIG_as_voidptr(self->buildSubPart(da->begin(),da->end())),SWIGTYPE_p_ParaMEDMEM__MEDFileFields, SWIG_POINTER_OWN | 0 );
}
else
- throw INTERP_KERNEL::Exception("MEDFileFields::__getitem__ : only integer or string with fieldname supported !");
+ return convertMEDFileFieldMultiTS(self->getFieldAtPos(MEDFileFieldsgetitemSingleTS__(self,obj)), SWIG_POINTER_OWN | 0 );
}
MEDFileFields *__setitem__(int obj, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
return self;
}
+ int __len__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->getNumberOfFields();
+ }
+
MEDFileFieldsIterator *__iter__() throw(INTERP_KERNEL::Exception)
{
return self->iterator();
std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
return self->changeMeshNames(modifTab);
}
+
+ int getPosOfField(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
+ {
+ if(elt0 && PyInt_Check(elt0))
+ {//fmts[3]
+ return PyInt_AS_LONG(elt0);
+ }
+ else if(elt0 && PyString_Check(elt0))
+ return self->getPosFromFieldName(PyString_AsString(elt0));
+ else
+ throw INTERP_KERNEL::Exception("MEDFileFields::getPosOfField : invalid input params ! expected fields[int], fields[string_of_field_name] !");
+ }
+
+ std::vector<int> getPosOfFields(PyObject *elts) const throw(INTERP_KERNEL::Exception)
+ {
+ if(PyList_Check(elts))
+ {
+ int sz=PyList_Size(elts);
+ std::vector<int> ret(sz);
+ for(int i=0;i<sz;i++)
+ {
+ PyObject *elt=PyList_GetItem(elts,i);
+ ret[i]=ParaMEDMEM_MEDFileFields_getPosOfField(self,elt);
+ }
+ return ret;
+ }
+ else
+ {
+ std::vector<int> ret(1);
+ ret[0]=ParaMEDMEM_MEDFileFields_getPosOfField(self,elts);
+ return ret;
+ }
+ }
+
+ void pushFields(PyObject *fields) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<MEDFileAnyTypeFieldMultiTS *> tmp;
+ convertFromPyObjVectorOfObj<ParaMEDMEM::MEDFileAnyTypeFieldMultiTS *>(fields,SWIGTYPE_p_ParaMEDMEM__MEDFileAnyTypeFieldMultiTS,"MEDFileAnyTypeFieldMultiTS",tmp);
+ self->pushFields(tmp);
+ }
+
+ void __delitem__(PyObject *elts) throw(INTERP_KERNEL::Exception)
+ {
+ if(elts && PySlice_Check(elts))
+ {
+ 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 !");
+ }
+ else
+ {
+ std::vector<int> idsToRemove=ParaMEDMEM_MEDFileFields_getPosOfFields(self,elts);
+ if(!idsToRemove.empty())
+ self->destroyFieldsAtPos(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size());
+ }
+ }
}
};
return self->simpleRepr();
}
- PyObject *isEqual(const MEDFileParameter1TS *other, double eps) const
+ PyObject *isEqual(const MEDFileParameter1TS *other, double eps) const throw(INTERP_KERNEL::Exception)
{
std::string what;
bool ret0=self->isEqual(other,eps,what);
return self->simpleRepr();
}
- PyObject *isEqual(const MEDFileParameterMultiTS *other, double eps) const
+ PyObject *isEqual(const MEDFileParameterMultiTS *other, double eps) const throw(INTERP_KERNEL::Exception)
{
std::string what;
bool ret0=self->isEqual(other,eps,what);
else
throw INTERP_KERNEL::Exception("MEDFileParameters::__getitem__ : only integer or string with meshname supported !");
}
+
+ int __len__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->getNumberOfParams();
+ }
MEDFileParameterMultiTS *getParamAtPos(int i) const throw(INTERP_KERNEL::Exception)
{
return ret;
}
- PyObject *isEqual(const MEDFileParameters *other, double eps) const
+ PyObject *isEqual(const MEDFileParameters *other, double eps) const throw(INTERP_KERNEL::Exception)
{
std::string what;
bool ret0=self->isEqual(other,eps,what);
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# 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
+#
+# Author Anthony GEAY (CEA/DEN/DM2S/STMF/LGLS)
+
+from MEDLoader import *
+from MEDCouplingRemapper import *
+import math
+
+d=DataArrayDouble.New(6,2)
+d[:,0]=3.
+d[:,1]=range(6)
+d[:,1]*=math.pi/3.
+d=d.fromPolarToCart()
+d.setInfoOnComponents(["X [m]","Y [m]"])
+print d.getValues()
+print d
+print d.magnitude().isUniform(3.,1e-12)
+#
+radius=3.
+translationToPerform=[[0.,0.],[3./2.*radius,-radius*math.sqrt(3.)/2],[3./2.*radius,radius*math.sqrt(3.)/2],[0.,radius*math.sqrt(3.)],[-3./2.*radius,radius*math.sqrt(3.)/2],[-3./2.*radius,-radius*math.sqrt(3.)/2],[0.,-radius*math.sqrt(3.)]]
+ds=len(translationToPerform)*[None]
+for pos,t in enumerate(translationToPerform):
+ ds[pos]=d[:]
+ ds[pos]+=t
+ pass
+#
+d2=DataArrayDouble.Aggregate(ds)
+oldNbOfTuples=d2.getNumberOfTuples()
+c,cI=d2.findCommonTuples(1e-12)
+tmp=c[cI[0]:cI[0+1]]
+print tmp
+a=cI.deltaShiftIndex()
+b=a-1
+myNewNbOfTuples=oldNbOfTuples-sum(b.getValues())
+o2n,newNbOfTuples=DataArrayInt.BuildOld2NewArrayFromSurjectiveFormat2(oldNbOfTuples,c,cI)
+print "Ai je trouve le bon resultat ? %s"%(str(myNewNbOfTuples==newNbOfTuples)) ; assert myNewNbOfTuples==newNbOfTuples
+#
+d3=d2.renumberAndReduce(o2n,newNbOfTuples)
+n2o=o2n.invertArrayO2N2N2O(newNbOfTuples)
+d3_bis=d2[n2o]
+print "Ai je trouve le bon resultat (2) ? %s"%(str(d3.isEqual(d3_bis,1e-12))) ; assert d3.isEqual(d3_bis,1e-12)
+#
+d3+=[3.3,4.4]
+# d3 contains coordinates
+m=MEDCouplingUMesh.New("My7hexagons",2)
+m.setCoords(d3)
+m.allocateCells(7)
+for i in xrange(7):
+ m.insertNextCell(NORM_POLYGON,o2n[6*i:6*(i+1)].getValues())
+ pass
+m.finishInsertingCells()
+m.checkCoherency()
+#
+m.writeVTK("My7hexagons.vtu")
+
+########
+
+coords=[0.,0.,0., 1.,1.,0., 1.,1.25,0., 1.,0.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0.,
+ 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0.,
+ 0.,0.,1., 1.,1.,1., 1.,1.25,1., 1.,0.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1.,
+ 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1.,
+ 0.,0.,2., 1.,1.,2., 1.,1.25,2., 1.,0.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2.,
+ 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2.,
+ 0.,0.,3., 1.,1.,3., 1.,1.25,3., 1.,0.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3.,
+ 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.]
+conn=[0,11,1,3,15,26,16,18, 1,2,4,7,13,6,-1,1,16,21,6,-1,6,21,28,13,-1,13,7,22,28,-1,7,4,19,22,-1,4,2,17,19,-1,2,1,16,17,-1,16,21,28,22,19,17,
+ 1,6,5,3,16,21,20,18, 13,10,9,6,28,25,24,21, 11,8,7,4,2,1,-1,11,26,16,1,-1,1,16,17,2,-1,2,17,19,4,-1,4,19,22,7,-1,7,8,23,22,-1,8,11,26,23,-1,26,16,17,19,22,23,
+ 7,12,14,13,22,27,29,28, 15,26,16,18,30,41,31,33, 16,17,19,22,28,21,-1,16,31,36,21,-1,21,36,43,28,-1,28,22,37,43,-1,22,19,34,37,-1,19,17,32,34,-1,17,16,31,32,-1,31,36,43,37,34,32,
+ 16,21,20,18,31,36,35,33, 28,25,24,21,43,40,39,36, 26,23,22,19,17,16,-1,26,41,31,16,-1,16,31,32,17,-1,17,32,34,19,-1,19,34,37,22,-1,22,23,38,37,-1,23,26,41,38,-1,41,31,32,34,37,38,
+ 22,27,29,28,37,42,44,43, 30,41,31,33,45,56,46,48, 31,32,34,37,43,36,-1,31,46,51,36,-1,36,51,58,43,-1,43,37,52,58,-1,37,34,49,52,-1,34,32,47,49,-1,32,31,46,47,-1,46,51,58,52,49,47,
+ 31,36,35,33,46,51,50,48, 43,40,39,36,58,55,54,51, 41,38,37,34,32,31,-1,41,56,46,31,-1,31,46,47,32,-1,32,47,49,34,-1,34,49,52,37,-1,37,38,53,52,-1,38,41,56,53,-1,56,46,47,49,52,53,
+ 37,42,44,43,52,57,59,58]
+mesh3D=MEDCouplingUMesh.New("mesh3D",3);
+mesh3D.allocateCells(18);
+mesh3D.insertNextCell(NORM_HEXA8,conn[0:8]); mesh3D.insertNextCell(NORM_POLYHED,conn[8:51]); mesh3D.insertNextCell(NORM_HEXA8,conn[51:59]); mesh3D.insertNextCell(NORM_HEXA8,conn[59:67]); mesh3D.insertNextCell(NORM_POLYHED,conn[67:110]); mesh3D.insertNextCell(NORM_HEXA8,conn[110:118]);
+mesh3D.insertNextCell(NORM_HEXA8,conn[118:126]); mesh3D.insertNextCell(NORM_POLYHED,conn[126:169]); mesh3D.insertNextCell(NORM_HEXA8,conn[169:177]); mesh3D.insertNextCell(NORM_HEXA8,conn[177:185]); mesh3D.insertNextCell(NORM_POLYHED,conn[185:228]); mesh3D.insertNextCell(NORM_HEXA8,conn[228:236]);
+mesh3D.insertNextCell(NORM_HEXA8,conn[236:244]); mesh3D.insertNextCell(NORM_POLYHED,conn[244:287]); mesh3D.insertNextCell(NORM_HEXA8,conn[287:295]); mesh3D.insertNextCell(NORM_HEXA8,conn[295:303]); mesh3D.insertNextCell(NORM_POLYHED,conn[303:346]); mesh3D.insertNextCell(NORM_HEXA8,conn[346:354]);
+mesh3D.finishInsertingCells();
+myCoords=DataArrayDouble.New(coords,60,3);
+myCoords.setInfoOnComponents(["X [m]","Y [m]","Z [m]"])
+mesh3D.setCoords(myCoords);
+mesh3D.orientCorrectlyPolyhedrons()
+mesh3D.sortCellsInMEDFileFrmt()
+mesh3D.checkCoherency()
+renum=DataArrayInt.New(60) ; renum[:15]=range(15,30) ; renum[15:30]=range(15) ; renum[30:45]=range(45,60) ; renum[45:]=range(30,45)
+mesh3D.renumberNodes(renum,60)
+#
+mesh3D.getCoords()[:]*=100.
+mesh3D.getCoords().setInfoOnComponents(["X [cm]","Y [cm]","Z [cm]"])
+#
+zLev=mesh3D.getCoords()[:,2]
+zLev=zLev.getDifferentValues(1e-12)
+zLev.sort()
+#
+tmp,cellIdsSol1=mesh3D.buildSlice3D([0.,0.,(zLev[1]+zLev[2])/2],[0.,0.,1.],1e-12)
+bary=mesh3D.getBarycenterAndOwner()
+baryZ=bary[:,2]
+cellIdsSol2=baryZ.getIdsInRange(zLev[1],zLev[2])
+nodeIds=mesh3D.findNodesOnPlane([0.,0.,zLev[0]],[0.,0.,1.],1e-10)
+mesh2D=mesh3D.buildFacePartOfMySelfNode(nodeIds,True)
+extMesh=MEDCouplingExtrudedMesh.New(mesh3D,mesh2D,0)
+cellIdsSol3=extMesh.getMesh3DIds()[mesh2D.getNumberOfCells():2*mesh2D.getNumberOfCells()]
+for i in xrange(3):
+ exec("print cellIdsSol%s.getValues()"%(i+1))
+#
+mesh3DPart=mesh3D[cellIdsSol2] # equivalent to mesh3DPart=mesh3D.buildPartOfMySelf(cellIdsSol2,True)
+mesh3DPart.zipCoords()
+print mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED]) ; assert mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED])
+print mesh3DPart.checkConsecutiveCellTypes() ; assert mesh3DPart.checkConsecutiveCellTypes()
+#print mesh3DPart.advancedRepr()
+#
+baryXY=bary[:,[0,1]]
+baryXY-=[250.,150.]
+magn=baryXY.magnitude()
+cellIds2Sol1=magn.getIdsInRange(0.,1e-12)
+#
+bary2=mesh2D.getBarycenterAndOwner()[:,[0,1]]
+bary2-=[250.,150.]
+magn=bary2.magnitude()
+ids=magn.getIdsInRange(0.,1e-12)
+idStart=int(ids) # ids is assumed to contain only one value, if not an exception is thrown
+cellIds2Sol2=extMesh.getMesh3DIds()[range(idStart,mesh3D.getNumberOfCells(),mesh2D.getNumberOfCells())]
+#
+mesh3DSlice2=mesh3D[cellIds2Sol1]
+mesh3DSlice2.zipCoords()
+#
+mesh3DSlice2bis=mesh3DSlice2.deepCpy()
+mesh3DSlice2bis.translate([0.,1000.,0.])
+mesh3DSlice2All=MEDCouplingUMesh.MergeUMeshes([mesh3DSlice2,mesh3DSlice2bis])
+mesh3DSlice2All.writeVTK("mesh3DSlice2All.vtu")
+#
+mesh3DSurf,desc,descIndx,revDesc,revDescIndx=mesh3D.buildDescendingConnectivity()
+numberOf3DCellSharing=revDescIndx.deltaShiftIndex()
+cellIds=numberOf3DCellSharing.getIdsNotEqual(1)
+mesh3DSurfInside=mesh3DSurf[cellIds]
+mesh3DSurfInside.writeVTK("mesh3DSurfInside.vtu")
+
+######
+
+xarr=DataArrayDouble.New(11,1)
+xarr.iota(0.)
+cmesh=MEDCouplingCMesh.New()
+cmesh.setCoords(xarr,xarr,xarr)
+mesh=cmesh.buildUnstructured()
+mesh.convertToPolyTypes(DataArrayInt.Range(0,mesh.getNumberOfCells(),2))
+#
+
+f=mesh.fillFromAnalytic(ON_CELLS,1,"(x-5.)*(x-5.)+(y-5.)*(y-5.)+(z-5.)*(z-5.)")
+f.setName("MyField")
+#
+f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
+f2.setMesh(mesh)
+f2.setName("MyField2")
+f2.fillFromAnalytic(1,"(x-5.)*(x-5.)+(y-5.)*(y-5.)+(z-5.)*(z-5.)")
+print "f and f2 are equal : %s"%(f.isEqualWithoutConsideringStr(f2,1e-13,1e-12)) ; assert f.isEqualWithoutConsideringStr(f2,1e-13,1e-12)
+#
+ids1=f.getArray().getIdsInRange(0.,5.)
+fPart1=f.buildSubPart(ids1)
+ids2=f.getArray().getIdsInRange(50.,1.e300)
+fPart2=f.buildSubPart(ids2)
+#Renumbering cells to follow MED file
+fPart1Cpy=fPart1.deepCpy()
+o2n=fPart1Cpy.getMesh().sortCellsInMEDFileFrmt()
+fPart1Cpy.getArray().renumberInPlace(o2n)
+#Check that fPart1Cpy and fPart1 are the same
+fPart1Cpy.substractInPlaceDM(fPart1,12,1e-12)
+fPart1Cpy.getArray().abs()
+print "Fields are the same ? %s"%(fPart1Cpy.getArray().accumulate()[0]<1e-12) ; assert fPart1Cpy.getArray().accumulate()[0]<1e-12
+#
+fPart12=MEDCouplingFieldDouble.MergeFields([fPart1,fPart2])
+# evaluation on points
+bary=fPart12.getMesh().getBarycenterAndOwner()
+arr1=fPart12.getValueOnMulti(bary)
+arr2=f.getValueOnMulti(bary)
+delta=arr1-arr2
+delta.abs()
+print "Check OK : %s"%(delta.accumulate()[0]<1e-12) ; assert delta.accumulate()[0]<1e-12
+#
+print abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10 ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10
+fPart12.getMesh().scale([0.,0.,0.],1.2)
+print abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8 ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8
+# Explosion of field
+fVec=mesh.fillFromAnalytic(ON_CELLS,3,"(x-5.)*IVec+(y-5.)*JVec+(z-5.)*KVec")
+fVecPart1=fVec.buildSubPart(ids1)
+fVecPart1.setName("fVecPart1")
+cells=fPart1.getMesh().getNumberOfCells()*[None]
+for icell,vec in enumerate(fVecPart1.getArray()):
+ m=fPart1.getMesh()[[icell]]
+ m.zipCoords()
+ m.translate(vec)
+ cells[icell]=m
+ pass
+meshFVecPart1Exploded=MEDCouplingUMesh.MergeUMeshes(cells)
+fPart1.setMesh(meshFVecPart1Exploded)
+
+####
+
+targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ];
+targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4];
+targetMesh=MEDCouplingUMesh.New("MyMesh",2);
+targetMesh.allocateCells(5);
+targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]);
+targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]);
+targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]);
+targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]);
+targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]);
+targetMesh.finishInsertingCells();
+myCoords=DataArrayDouble.New(targetCoords,9,2);
+myCoords.setInfoOnComponents(["X [km]","YY [mm]"])
+targetMesh.setCoords(myCoords);
+#
+MEDLoader.WriteUMesh("TargetMesh.med",targetMesh,True)
+#
+meshRead=MEDLoader.ReadUMeshFromFile("TargetMesh.med",targetMesh.getName(),0)
+print "Is the mesh read in file equals targetMesh ? %s"%(meshRead.isEqual(targetMesh,1e-12)) ; assert meshRead.isEqual(targetMesh,1e-12)
+#
+f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
+f.setTime(5.6,7,8)
+f.setArray(targetMesh.getBarycenterAndOwner())
+f.setMesh(targetMesh)
+f.setName("AFieldName")
+MEDLoader.WriteField("MyFirstField.med",f,True)
+#
+f2=MEDLoader.ReadFieldCell("MyFirstField.med",f.getMesh().getName(),0,f.getName(),7,8)
+print "Is the field read in file equals f ? %s"%(f2.isEqual(f,1e-12,1e-12)) ; assert f2.isEqual(f,1e-12,1e-12)
+#
+MEDLoader.WriteUMesh("MySecondField.med",f.getMesh(),True)
+MEDLoader.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f)
+#
+f2=f.clone(True)
+f2.getArray()[:]*=2.0
+f2.setTime(7.8,9,10)
+MEDLoader.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f2)
+#
+f3=MEDLoader.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),7,8)
+print "Is the field read in file equals f ? %s"%(f.isEqual(f3,1e-12,1e-12)) ; assert f.isEqual(f3,1e-12,1e-12)
+f4=MEDLoader.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),9,10)
+print "Is the field read in file equals f ? %s"%(f2.isEqual(f4,1e-12,1e-12)) ; assert f2.isEqual(f4,1e-12,1e-12)
+
+#####
+
+targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ];
+targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4];
+targetMesh=MEDCouplingUMesh.New("MyMesh",2);
+targetMesh.allocateCells(5);
+targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]);
+targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]);
+targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]);
+targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]);
+targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]);
+targetMesh.finishInsertingCells();
+myCoords=DataArrayDouble.New(targetCoords,9,2);
+myCoords.setInfoOnComponents(["X [km]","YY [mm]"])
+targetMesh.setCoords(myCoords);
+#
+targetMeshConsti=targetMesh.buildDescendingConnectivity()[0]
+targetMesh1=targetMeshConsti[[3,4,7,8]]
+targetMesh1.setName(targetMesh.getName())
+#
+meshMEDFile=MEDFileUMesh.New()
+meshMEDFile.setMeshAtLevel(0,targetMesh)
+meshMEDFile.setMeshAtLevel(-1,targetMesh1)
+# Some groups on cells Level 0
+grp0_0=DataArrayInt.New([0,1,3]) ; grp0_0.setName("grp0_Lev0")
+grp1_0=DataArrayInt.New([1,2,3,4]) ; grp1_0.setName("grp1_Lev0")
+meshMEDFile.setGroupsAtLevel(0,[grp0_0,grp1_0])
+# Some groups on cells Level -1
+grp0_M1=DataArrayInt.New([0,1]) ; grp0_M1.setName("grp0_LevM1")
+grp1_M1=DataArrayInt.New([0,1,2]) ; grp1_M1.setName("grp1_LevM1")
+grp2_M1=DataArrayInt.New([1,2,3]) ; grp2_M1.setName("grp2_LevM1")
+meshMEDFile.setGroupsAtLevel(-1,[grp0_M1,grp1_M1,grp2_M1])
+#
+meshMEDFile.write("TargetMesh2.med",2) # 2 stands for write from scratch
+#
+meshMEDFileRead=MEDFileMesh.New("TargetMesh2.med")
+meshRead0=meshMEDFileRead.getMeshAtLevel(0)
+meshRead1=meshMEDFileRead.getMeshAtLevel(-1)
+print "Is the mesh at level 0 read in file equals targetMesh ? %s"%(meshRead0.isEqual(targetMesh,1e-12)) ; assert meshRead0.isEqual(targetMesh,1e-12)
+print "Is the mesh at level -1 read in file equals targetMesh ? %s"%(meshRead1.isEqual(targetMesh1,1e-12)) ; assert meshRead1.isEqual(targetMesh1,1e-12)
+#
+print meshMEDFileRead.getGrpNonEmptyLevels("grp0_Lev0")
+grp0_0_read=meshMEDFileRead.getGroupArr(0,"grp0_Lev0")
+print "Is group \"grp0_Lev0\" are the same ? %s"%(grp0_0_read.isEqual(grp0_0)) ; assert grp0_0_read.isEqual(grp0_0)
+#
+# Fields
+#
+f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
+f.setTime(5.6,7,8)
+f.setArray(targetMesh.getBarycenterAndOwner())
+f.setMesh(targetMesh)
+f.setName("AFieldName")
+#
+fMEDFile=MEDFileField1TS.New()
+fMEDFile.setFieldNoProfileSBT(f)
+#
+fMEDFile.write("TargetMesh2.med",0) # 0 is very important here because we want to append to TargetMesh2.med and not to scratch it
+#
+fMEDFileRead=MEDFileField1TS.New("TargetMesh2.med",f.getName(),7,8)
+fRead1=fMEDFileRead.getFieldOnMeshAtLevel(ON_CELLS,0,meshMEDFileRead) # fastest method. No read in file.
+fRead2=fMEDFileRead.getFieldAtLevel(ON_CELLS,0) # basic method like, mesh is reread in file...
+print "Does the field f remains the same using fast method ? %s"%(fRead1.isEqual(f,1e-12,1e-12)) ; assert fRead1.isEqual(f,1e-12,1e-12)
+print "Does the field f remains the same using slow method ? %s"%(fRead2.isEqual(f,1e-12,1e-12)) ; assert fRead2.isEqual(f,1e-12,1e-12)
+#
+# Writing and Reading fields on profile using MEDLoader advanced API
+#
+pfl=DataArrayInt.New([1,2,3]) ; pfl.setName("My1stPfl")
+fPart=f.buildSubPart(pfl)
+fPart.setName("fPart")
+#
+fMEDFile2=MEDFileField1TS.New()
+fMEDFile2.setFieldProfile(fPart,meshMEDFileRead,0,pfl)
+fMEDFile2.write("TargetMesh2.med",0) # 0 is very important here because we want to append to TargetMesh2.med and not to scratch it
+#
+fMEDFileRead2=MEDFileField1TS.New("TargetMesh2.med",fPart.getName(),7,8)
+fPartRead,pflRead=fMEDFileRead2.getFieldWithProfile(ON_CELLS,0,meshMEDFileRead)
+print fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12) ; assert fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12)
+print pflRead.isEqualWithoutConsideringStr(pfl) ; assert pflRead.isEqualWithoutConsideringStr(pfl)
+
+#####
+
+m0=MEDCouplingCMesh()
+arr=DataArrayDouble(31,1) ; arr.iota(0.)
+m0.setCoords(arr,arr)
+m0=m0.buildUnstructured()
+m00=m0[::2] ; m00.simplexize(0) ; m01=m0[1::2]
+m0=MEDCouplingUMesh.MergeUMeshes([m00,m01])
+m0.getCoords()[:]*=1/15.
+m0.setName("mesh")
+#
+CellField=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; CellField.setTime(5.6,5,6) ; CellField.setMesh(m0)
+CellField.setName("CellField")
+CellField.fillFromAnalytic(1,"exp(-((x-1)*(x-1)+(y-1)*(y-1)))") ; CellField.getArray().setInfoOnComponent(0,"powercell [W]")
+NodeField=MEDCouplingFieldDouble(ON_NODES,ONE_TIME) ; NodeField.setTime(5.6,5,6) ; NodeField.setMesh(m0)
+NodeField.setName("NodeField")
+NodeField.fillFromAnalytic(1,"exp(-((x-1)*(x-1)+(y-1)*(y-1)))") ; NodeField.getArray().setInfoOnComponent(0,"powernode [W]")
+#
+proc0=m0.getCellsInBoundingBox([(0.,0.4),(0.,0.4)],1e-10)
+proc1=proc0.buildComplement(m0.getNumberOfCells())
+#
+NodeField0=NodeField[proc0] ; NodeField0.getMesh().setName(m0.getName()) ; CellField0=CellField[proc0] ; CellField0.setMesh(NodeField0.getMesh())
+NodeField1=NodeField[proc1] ; NodeField1.getMesh().setName(m0.getName()) ; CellField1=CellField[proc1] ; CellField1.setMesh(NodeField1.getMesh())
+#
+proc0_fname="proc0.med"
+MEDLoader.WriteField(proc0_fname,NodeField0,True)
+MEDLoader.WriteFieldUsingAlreadyWrittenMesh(proc0_fname,CellField0)
+proc1_fname="proc1.med"
+MEDLoader.WriteField(proc1_fname,NodeField1,True)
+MEDLoader.WriteFieldUsingAlreadyWrittenMesh(proc1_fname,CellField1)
+#
+CellField0_read=MEDLoader.ReadFieldCell("proc0.med","mesh",0,"CellField",5,6)
+CellField1_read=MEDLoader.ReadFieldCell("proc1.med","mesh",0,"CellField",5,6)
+CellField_read=MEDCouplingFieldDouble.MergeFields([CellField0_read,CellField1_read])
+CellFieldCpy=CellField.deepCpy()
+CellFieldCpy.substractInPlaceDM(CellField_read,10,1e-12)
+CellFieldCpy.getArray().abs()
+print CellFieldCpy.getArray().isUniform(0.,1e-12)
+#
+NodeField0_read=MEDLoader.ReadFieldNode("proc0.med","mesh",0,"NodeField",5,6)
+NodeField1_read=MEDLoader.ReadFieldNode("proc1.med","mesh",0,"NodeField",5,6)
+NodeField_read=MEDCouplingFieldDouble.MergeFields([NodeField0_read,NodeField1_read])
+NodeField_read.mergeNodes(1e-10)
+NodeFieldCpy=NodeField.deepCpy()
+NodeFieldCpy.mergeNodes(1e-10)
+NodeFieldCpy.substractInPlaceDM(NodeField_read,10,1e-12)
+print NodeFieldCpy.getArray().isUniform(0.,1e-12) ; assert NodeFieldCpy.getArray().isUniform(0.,1e-12)
+#
+fileNames=["proc0.med","proc1.med"]
+msML=[MEDFileMesh.New(fname) for fname in fileNames]
+fsML=[MEDFileFields.New(fname) for fname in fileNames]
+mergeMLMesh=MEDFileUMesh()
+mergeMLFields=MEDFileFields()
+for lev in msML[0].getNonEmptyLevels():
+ o2nML=len(msML[0].getNonEmptyLevels())*[None]
+ cs=[mML.getCoords() for mML in msML]
+ mergeMLMesh.setCoords(DataArrayDouble.Aggregate(cs))
+ ms=[mML.getMeshAtLevel(lev) for mML in msML]
+ m=MEDCouplingUMesh.MergeUMeshes(ms) ; m.setCoords(mergeMLMesh.getCoords())
+ o2nML[lev]=m.sortCellsInMEDFileFrmt()
+ mergeMLMesh.setMeshAtLevel(lev,m)
+ pass
+#
+for fieldName in fsML[0].getFieldsNames():
+ fmts=[fML[fieldName] for fML in fsML]
+ mergeField=MEDFileFieldMultiTS()
+ for dt,it,tim in fmts[0].getTimeSteps():
+ fts=[fmt[dt,it] for fmt in fmts]
+ arrs=len(fts)*[None]
+ for typp in fts[0].getTypesOfFieldAvailable():
+ arr1s=[]
+ if typp==ON_CELLS:
+ for ft in fts:
+ for geoTyp,smth in ft.getFieldSplitedByType():
+ if geoTyp!=NORM_ERROR:
+ smth1=filter(lambda x:x[0]==ON_CELLS,smth)
+ arr2s=[ft.getUndergroundDataArray()[elt[1][0]:elt[1][1]] for elt in smth1]
+ arr1s.append(DataArrayDouble.Aggregate(arr2s))
+ pass
+ pass
+ pass
+ pass
+ else:
+ for ft in fts:
+ smth=filter(lambda x:x[0]==NORM_ERROR,ft.getFieldSplitedByType())
+ arr2=DataArrayDouble.Aggregate([ft.getUndergroundDataArray()[elt[1][0][1][0]:elt[1][0][1][1]] for elt in smth])
+ arr1s.append(arr2)
+ pass
+ pass
+ arr=DataArrayDouble.Aggregate(arr1s)
+ if typp==ON_CELLS:
+ arr.renumberInPlace(o2nML[lev])
+ mcf=MEDCouplingFieldDouble(typp,ONE_TIME) ; mcf.setName(fieldName) ; mcf.setTime(tim,dt,it) ; mcf.setArray(arr)
+ mcf.setMesh(mergeMLMesh.getMeshAtLevel(lev)) ; mcf.checkCoherency()
+ mergeField.appendFieldNoProfileSBT(mcf)
+ pass
+ pass
+ mergeMLFields.pushField(mergeField)
+ pass
+mergeMLMesh.write("merge.med",2)
+mergeMLFields.write("merge.med",0)
+
+#####
+
+arr=DataArrayDouble(11) ; arr.iota(0)
+trgMesh=MEDCouplingCMesh() ; trgMesh.setCoords(arr,arr) ; trgMesh=trgMesh.buildUnstructured()
+#
+arr=DataArrayDouble(21) ; arr.iota(0) ; arr*=0.5
+srcMesh=MEDCouplingCMesh() ; srcMesh.setCoords(arr,arr) ; srcMesh=srcMesh.buildUnstructured()
+#
+tmp=srcMesh[:20] ; tmp.simplexize(0)
+srcMesh=MEDCouplingUMesh.MergeUMeshes([tmp,srcMesh[20:]])
+#
+remap=MEDCouplingRemapper()
+remap.prepare(srcMesh,trgMesh,"P0P0")
+#
+myMatrix=remap.getCrudeMatrix()
+print myMatrix # pour voir a quoi elle ressemble
+sumByRows=DataArrayDouble(len(myMatrix))
+for i,wIt in enumerate(sumByRows):
+ su=0.
+ for it in myMatrix[i]:
+ su+=myMatrix[i][it]
+ wIt[0]=su
+print "Does interpolation look OK ? %s"%(str(sumByRows.isUniform(1.,1e-12))) ; assert sumByRows.isUniform(1.,1e-12)
+#
+srcField=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; srcField.setMesh(srcMesh)
+srcField.fillFromAnalytic(1,"7-sqrt((x-5.)*(x-5.)+(y-5.)*(y-5.))") ; CellField.getArray().setInfoOnComponent(0,"powercell [W]")
+#
+#remap.transferField(srcField,1e300)
+srcField.setNature(ConservativeVolumic)
+trgFieldCV=remap.transferField(srcField,1e300)
+#
+print "ConservativeVolumic %lf == %lf"%(srcField.integral(True)[0],trgFieldCV.integral(True)[0]) ; assert abs(srcField.integral(True)[0]-trgFieldCV.integral(True)[0])<1e-6
+print "ConservativeVolumic %lf != %lf"%(srcField.getArray().accumulate()[0],trgFieldCV.getArray().accumulate()[0]) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldCV.getArray().accumulate()[0])>1e-6
+#
+srcField.setNature(Integral)
+trgFieldI=remap.transferField(srcField,1e300)
+#
+print "IntegralGlobConstraint %lf != %lf"%(srcField.integral(True)[0],trgFieldI.integral(True)[0]) ; assert abs(srcField.integral(True)[0]-trgFieldI.integral(True)[0])>1e-6
+print "IntegralGlobConstraint %lf == %lf"%(srcField.getArray().accumulate()[0],trgFieldI.getArray().accumulate()[0]) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldI.getArray().accumulate()[0])<1e-6
+
+######
+
+from numpy import *
+from math import acos
+
+med_root_dir=os.getenv("MED_ROOT_DIR")
+agitateur_file=os.path.join(os.getenv("MED_ROOT_DIR"),"share","salome","resources","med","agitateur.med")
+data=MEDFileData(agitateur_file)
+ts=data.getFields()[0].getTimeSteps()
+print ts
+#
+fMts=data.getFields()["DISTANCE_INTERFACE_ELEM_BODY_ELEM_DOM"]
+f1ts=fMts[(2,-1)]
+fMc=f1ts.getFieldAtLevel(ON_CELLS,0)
+arr=fMc.getArray()
+arr.getMinMaxPerComponent() # juste pour voir la plage de variation du champ par compo
+ids=arr.getIdsInRange(0.,1.)
+f2Mc=fMc[ids]
+#
+pressMts=data.getFields()["PRESSION_ELEM_DOM"]
+press1ts=pressMts[(2,-1)]
+pressMc=press1ts.getFieldAtLevel(ON_CELLS,0)
+pressOnAgitateurMc=pressMc[ids]
+#
+pressOnAgitateurMc.getMesh().zipCoords()
+#
+agitateurMesh3DMc=pressOnAgitateurMc.getMesh()
+m3DSurf,desc,descI,revDesc,revDescI=agitateurMesh3DMc.buildDescendingConnectivity()
+nbOf3DCellSharing=revDescI.deltaShiftIndex()
+ids2=nbOf3DCellSharing.getIdsEqual(1)
+agitateurSkinMc=m3DSurf[ids2]
+OffsetsOfTupleIdsInField=revDescI[ids2]
+tupleIdsInField=revDesc[OffsetsOfTupleIdsInField]
+pressOnSkinAgitateurMc=pressOnAgitateurMc[tupleIdsInField]
+pressOnSkinAgitateurMc.setMesh(agitateurSkinMc)
+#
+pressSkin=pressOnSkinAgitateurMc.getArray()
+pressSkin*=1e5
+areaSkin=agitateurSkinMc.getMeasureField(True).getArray()
+forceSkin=pressSkin*areaSkin
+normalSkin=agitateurSkinMc.buildOrthogonalField().getArray()
+forceVectSkin=forceSkin*normalSkin
+#
+singlePolyhedron=agitateurMesh3DMc.buildSpreadZonesWithPoly()
+singlePolyhedron.orientCorrectlyPolyhedrons()
+centerOfMass=singlePolyhedron.getBarycenterAndOwner()
+
+barySkin=agitateurSkinMc.getBarycenterAndOwner()
+posSkin=barySkin-centerOfMass
+
+torquePerCellOnSkin=DataArrayDouble.CrossProduct(posSkin,forceVectSkin)
+
+zeTorque=torquePerCellOnSkin.accumulate()
+print "couple = %r N.m"%(zeTorque[2]) ; assert abs(zeTorque[2]-0.37)<1e-2
+
+speedMts=data.getFields()["VITESSE_ELEM_DOM"]
+speed1ts=speedMts[(2,-1)]
+speedMc=speed1ts.getFieldAtLevel(ON_CELLS,0)
+speedOnSkin=speedMc.getArray()[tupleIdsInField]
+powerSkin=DataArrayDouble.Dot(forceVectSkin,speedOnSkin)
+power=powerSkin.accumulate()[0]
+print "power = %r W"%(power) ; assert abs(power-4.22)<1e-2
+
+x2=posSkin[:,0]*posSkin[:,0] ; x2=x2.accumulate()[0]
+y2=posSkin[:,1]*posSkin[:,1] ; y2=y2.accumulate()[0]
+xy=posSkin[:,0]*posSkin[:,1] ; xy=xy.accumulate()[0]
+inertiaSkin=matrix([[x2,xy],[xy,y2]])
+inertiaSkinValues,inertiaSkinVects=linalg.eig(inertiaSkin)
+pos=max(enumerate(inertiaSkinValues),key=lambda x: x[1])[0]
+vect0=inertiaSkinVects[pos].tolist()[0]
+print vect0
+
+def computeAngle(locAgitateur1ts):
+ fMc=locAgitateur1ts.getFieldAtLevel(ON_CELLS,0)
+ arr=fMc.getArray()
+ ids=arr.getIdsInRange(0.,1.)
+ f2Mc=fMc[ids]
+ m3DSurf,desc,descI,revDesc,revDescI=f2Mc.getMesh().buildDescendingConnectivity()
+ nbOf3DCellSharing=revDescI.deltaShiftIndex()
+ ids2=nbOf3DCellSharing.getIdsEqual(1)
+ agitateurSkinMc=m3DSurf[ids2]
+ #
+ singlePolyhedron=agitateurMesh3DMc.buildSpreadZonesWithPoly()
+ singlePolyhedron.orientCorrectlyPolyhedrons()
+ centerOfMass=singlePolyhedron.getBarycenterAndOwner()
+ bary=agitateurSkinMc.getBarycenterAndOwner()
+ posSkin=bary-centerOfMass
+ x2=posSkin[:,0]*posSkin[:,0] ; x2=x2.accumulate()[0]
+ y2=posSkin[:,1]*posSkin[:,1] ; y2=y2.accumulate()[0]
+ xy=posSkin[:,0]*posSkin[:,1] ; xy=xy.accumulate()[0]
+ inertiaSkin=matrix([[x2,xy],[xy,y2]])
+ inertiaSkinValues,inertiaSkinVects=linalg.eig(inertiaSkin)
+ pos=max(enumerate(inertiaSkinValues),key=lambda x: x[1])[0]
+ vect0=inertiaSkinVects[pos].tolist()[0]
+ return vect0
+
+vects=len(ts)*[None]
+for itts,locAgitateur1ts in zip(ts,data.getFields()["DISTANCE_INTERFACE_ELEM_BODY_ELEM_DOM"]):
+ angle=computeAngle(locAgitateur1ts)
+ vects[itts[0]]=angle
+ pass
+
+angle2=len(ts)*[0.]
+for pos in xrange(2,len(vects)):
+ norm1=sqrt(vects[pos-1][0]*vects[pos-1][0]+vects[pos-1][1]*vects[pos-1][1])
+ norm2=sqrt(vects[pos][0]*vects[pos][0]+vects[pos][1]*vects[pos][1])
+ crs=vects[pos-1][0]*vects[pos][0]+vects[pos-1][1]*vects[pos][1]
+ crs/=norm1 ; crs/=norm2 ; crs=min(crs,1.)
+ angle2[pos]=acos(crs)#/(ts[pos][2]-ts[pos-1][2])
+ pass
+
+omega=sum(angle2)/(ts[-1][2]-ts[0][2])
+print sum(angle2) ; assert abs(sum(angle2)-1.12)<1e-2
+print "Au pdt (%d,%d) a %r s le couple est de : %r N.m, power/omega=%r N.m"%(ts[2][0],ts[2][1],ts[2][2],zeTorque[2],power/omega)
+assert abs(power/omega-0.37)<1e-2
f.setName("MyFieldOnGaussNE");
f.checkCoherency();
return f;
+
+ def buildACompleteMEDDataStructureWithFieldsOnCells_1(cls):
+ coo=DataArrayDouble([0,0,1,0,2,0,0,1,1,1,2,1,0,2,1,2,2,2],9,2)
+ m0=MEDCouplingUMesh("mesh",2)
+ m0.setCoords(coo)
+ m0.allocateCells()
+ m0.insertNextCell(NORM_TRI3,[1,4,2])
+ m0.insertNextCell(NORM_TRI3,[4,5,2])
+ m0.insertNextCell(NORM_QUAD4,[0,3,4,1])
+ m0.insertNextCell(NORM_QUAD4,[6,7,4,3])
+ m0.insertNextCell(NORM_QUAD4,[7,8,5,4])
+ m1=m0.computeSkin()
+ mm=MEDFileUMesh()
+ #2 levels
+ mm.setMeshAtLevel(0,m0) ; mm.setMeshAtLevel(-1,m1)
+ #some grps/families on the 2 levels
+ grp0=DataArrayInt([0,2,4]); grp0.setName("gr0_0_2_4")
+ grp1=DataArrayInt([1,2,3,4]); grp1.setName("gr0_1_2_3_4")
+ grp2=DataArrayInt([0,4]); grp2.setName("gr0_0_4")
+ mm.setGroupsAtLevel(0,[grp0,grp1,grp2])
+ grp3=DataArrayInt([0,1]); grp3.setName("grM1_SegOnTri3")
+ grp4=DataArrayInt([2,3,4,5,6,7]); grp4.setName("grM1_SegOnQuad4")
+ grp5=DataArrayInt([0,3]); grp5.setName("grM1_bottom")
+ mm.setGroupsAtLevel(-1,[grp3,grp4,grp5])
+ ms=MEDFileMeshes()
+ ms.pushMesh(mm)
+ # 3 fields
+ fs=MEDFileFields()
+ # 1st Field - fNoProfile - no profile on levels 0
+ f1Name="fNoProfile"
+ timeStepsF1=[(0,-1,0.01),(1,-1,0.02)]
+ f1=MEDFileFieldMultiTS()
+ for i,(it,order,tim) in enumerate(timeStepsF1):
+ f11Tmp=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME)
+ f11Tmp.setTime(tim,it,order)
+ f11Tmp.setMesh(m0)
+ arr=DataArrayDouble(m0.getNumberOfCells(),1) ; arr.iota() ; arr+=1+i ; arr*=0.1
+ f11Tmp.setArray(arr)
+ f11Tmp.checkCoherency()
+ f11Tmp.setName(f1Name)
+ f1.appendFieldNoProfileSBT(f11Tmp)
+ pass
+ fs.pushField(f1)
+ # 2nd Field - fNoProfileMultiLevs - no profile on levels 0 and -1
+ f2Name="fNoProfileMultiLevs"
+ timeStepsF2=[(0,-1,0.),(1,-1,0.1),(2,-1,0.2)]
+ f2=MEDFileFieldMultiTS()
+ for i,(it,order,tim) in enumerate(timeStepsF2):
+ f21Tmp=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME)
+ f21Tmp.setTime(tim,it,order)
+ f21Tmp.setMesh(m0)
+ arr=DataArrayDouble(m0.getNumberOfCells(),1) ; arr.iota() ; arr+=1+i
+ f21Tmp.setArray(arr)
+ f21Tmp.checkCoherency()
+ f21Tmp.setName(f2Name)
+ f2.appendFieldNoProfileSBT(f21Tmp)
+ f22Tmp=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME)
+ f22Tmp.setTime(tim,it,order)
+ f22Tmp.setMesh(m1)
+ arr=DataArrayDouble(m1.getNumberOfCells(),1) ; arr.iota() ; arr+=100+1+i
+ f22Tmp.setArray(arr)
+ f22Tmp.checkCoherency()
+ f22Tmp.setName(f2Name)
+ f2[it,order].setFieldNoProfileSBT(f22Tmp)
+ pass
+ fs.pushField(f2)
+ # 3rd field - fProfileMultiLevs - The most complex one
+ f3Name="fProfileMultiLevs"
+ timeStepsF3=[(0,-1,0.),(1,-1,10.),(2,-1,20.),(3,-1,30.),]
+ f3=MEDFileFieldMultiTS()
+ for i,(it,order,tim) in enumerate(timeStepsF3):
+ pfl1=DataArrayInt([0,1,3,4]) ; pfl1.setName("pfl1")
+ m0Part=m0[pfl1]
+ f31Tmp=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME)
+ f31Tmp.setTime(tim,it,order)
+ f31Tmp.setMesh(m0Part)
+ arr=DataArrayDouble(m0Part.getNumberOfCells(),1) ; arr.iota() ; arr+=1000+i+1
+ f31Tmp.setArray(arr)
+ f31Tmp.checkCoherency()
+ f31Tmp.setName(f3Name)
+ f3.appendFieldProfile(f31Tmp,mm,0,pfl1)
+ pfl2=DataArrayInt([0,3]) ; pfl2.setName("pfl2Bottom")
+ m1Part=m1[pfl2]
+ f32Tmp=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME)
+ f32Tmp.setTime(tim,it,order)
+ f32Tmp.setMesh(m1Part)
+ arr=DataArrayDouble(m1Part.getNumberOfCells(),1) ; arr.iota() ; arr+=2000+1+i
+ f32Tmp.setArray(arr)
+ f32Tmp.checkCoherency()
+ f32Tmp.setName(f3Name)
+ f3[it,order].setFieldProfile(f32Tmp,mm,-1,pfl2)
+ pass
+ fs.pushField(f3)
+ #
+ data=MEDFileData() ; data.setMeshes(ms) ; data.setFields(fs)
+ return data
build1DMesh_1=classmethod(build1DMesh_1)
build2DCurveMesh_1=classmethod(build2DCurveMesh_1)
buildVecFieldOnGauss_2=classmethod(buildVecFieldOnGauss_2)
buildVecFieldOnGauss_2_Simpler=classmethod(buildVecFieldOnGauss_2_Simpler)
buildVecFieldOnGaussNE_1=classmethod(buildVecFieldOnGaussNE_1)
+ buildACompleteMEDDataStructureWithFieldsOnCells_1=classmethod(buildACompleteMEDDataStructureWithFieldsOnCells_1)
pass
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# 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
+#
+# Author Anthony GEAY (CEA/DEN/DM2S/STMF/LGLS)
+
+from MEDLoader import *
+import os
+
+class MEDLoaderSplitter:
+ @classmethod
+ def New(cls,mfd,idsLst):
+ """ mfd is a MEDFileData instance containing only one mesh. idsLst is a list of DataArrayInt containing each the ids per processor """
+ return MEDLoaderSplitter(fileName)
+ pass
+
+ def __init__(self,mfd,idsLst):
+ """ mfd is a MEDFileData instance containing only one mesh. idsLst is a list of DataArrayInt containing each the ids per processor """
+ mfmsh=mfd.getMeshes()
+ mfflds=mfd.getFields()
+ if len(mfmsh)!=1:
+ raise InterpKernelException("Works only with one mesh !")
+ mfflds=mfflds.partOfThisLyingOnSpecifiedMeshName(mfmsh[0].getName())
+ retf=self.__splitFields(mfmsh[0],mfflds,idsLst)
+ retm=self.__splitMesh(mfmsh[0],idsLst)
+ self._mfd_splitted=[MEDFileData() for i in xrange(len(idsLst))]
+ for a,b,c in zip(self._mfd_splitted,retf,retm):
+ a.setFields(b) ; a.setMeshes(c)
+ pass
+ pass
+
+ def getSplittedInstances(self):
+ return self._mfd_splitted
+
+ @classmethod
+ def __splitMEDFileField1TSNode(cls,f,f1ts,ids):
+ fRet=f[ids]
+ f1ts.setFieldNoProfileSBT(fRet)
+ pass
+
+ @classmethod
+ def __splitMEDFileField1TSCell(cls,f,f1ts,ids):
+ fRet=f[ids]
+ m=fRet.getMesh() ; m.zipCoords()
+ o2n=m.getRenumArrForMEDFileFrmt() ; fRet.renumberCells(o2n,False)
+ f1ts.setFieldNoProfileSBT(fRet)
+ pass
+
+ def __splitMEDFileField1TS(self,mm,f1ts,idsLst):
+ ret=[MEDFileField1TS() for i in xrange(len(idsLst))]
+ dico={ON_CELLS:self.__splitMEDFileField1TSCell,
+ ON_NODES:self.__splitMEDFileField1TSNode,
+ ON_GAUSS_PT:self.__splitMEDFileField1TSCell,
+ ON_GAUSS_NE:self.__splitMEDFileField1TSCell}
+ for t in f1ts.getTypesOfFieldAvailable():
+ f=f1ts.getFieldOnMeshAtLevel(t,0,mm)
+ for i,f0 in enumerate(ret):
+ dico[t](f,f0,idsLst[i])
+ pass
+ pass
+ return ret
+
+ def __splitFields(self,mm,mfflds,idsLst):
+ ret0=[MEDFileFields() for i in xrange(len(idsLst))]
+ for fmts in mfflds:
+ if len(fmts.getPflsReallyUsed())!=0:
+ print "Field \"%s\" contains profiles ! Not supported yet ! This field will be ignored !"%(fmts.getName())
+ continue
+ pass
+ ret1=[MEDFileFieldMultiTS() for i in xrange(len(idsLst))]
+ for f1ts in fmts:
+ for fmtsPart,f1tsPart in zip(ret1,self.__splitMEDFileField1TS(mm,f1ts,idsLst)):
+ fmtsPart.pushBackTimeStep(f1tsPart)
+ pass
+ pass
+ for fieldsPart,fmtsPart in zip(ret0,ret1):
+ fieldsPart.pushField(fmtsPart);
+ pass
+ pass
+ return ret0
+
+ def __splitMesh(self,mfm,idsLst):
+ ret0=[MEDFileMeshes() for i in xrange(len(idsLst))]
+ m=mfm.getMeshAtLevel(0)
+ for ret,ids in zip(ret0,idsLst):
+ mlPart=mfm.createNewEmpty()
+ mPart=m[ids] ; trad=mPart.zipCoordsTraducer()
+ trad=trad.invertArrayO2N2N2O(mPart.getNumberOfNodes())
+ mlPart.setMeshAtLevel(0,mPart)
+ if 0 in mfm.getFamArrNonEmptyLevelsExt():
+ mlPart.setFamilyFieldArr(0,mfm.getFamilyFieldAtLevel(0)[ids])
+ pass
+ if 1 in mfm.getFamArrNonEmptyLevelsExt():
+ mlPart.setFamilyFieldArr(1,mfm.getFamilyFieldAtLevel(1)[trad])
+ pass
+ mlPart.copyFamGrpMapsFrom(mfm)
+ ret.pushMesh(mlPart)
+ pass
+ return ret0
+ pass
res=mm.isEqual(mm2,1e-12)
self.assertTrue(res[0])
l=list(mm2.getFamiliesOnGroup("G2")) ; l.sort()
- self.assertEqual(['Family_10','Family_11','Family_3','Family_4','Family_7'],l)
+ self.assertEqual(['Family_-3','Family_-4','Family_-7','Family_10','Family_11'],l)
mm2.keepFamIdsOnlyOnLevs([3],[-1])
for lev in mm.getGrpNonEmptyLevelsExt("G2"):
self.assertEqual(mm.getGroupArr(lev,"G2").getValues(),mm2.getGroupArr(lev,"G2").getValues())
pass
l=list(mm2.getFamiliesOnGroup("G2")) ; l.sort()
- self.assertEqual(['Family_10','Family_11','Family_12','Family_3','Family_4','Family_7'],l)
+ self.assertEqual(['Family_-3','Family_-4','Family_-7','Family_10','Family_11'],l)
#
- self.assertEqual([7,7,6],mm2.getFamilyFieldAtLevel(-1).getValues())
- mm2.getFamilyFieldAtLevel(-1).setIJ(1,0,8)
- self.assertEqual([7,8,6],mm2.getFamilyFieldAtLevel(-1).getValues())
- self.assertTrue(not mm2.existsFamily("Family_8"))
+ self.assertEqual([-7,-7,-6],mm2.getFamilyFieldAtLevel(-1).getValues())
+ mm2.getFamilyFieldAtLevel(-1).setIJ(1,0,-8)
+ self.assertEqual([-7,-8,-6],mm2.getFamilyFieldAtLevel(-1).getValues())
+ self.assertTrue(not mm2.existsFamily("Family_-8"))
mm2.createGroupOnAll(-1,"GrpOnAllFace")
- self.assertTrue(mm2.existsFamily("Family_8"))
+ self.assertTrue(mm2.existsFamily("Family_-8"))
self.assertEqual(range(3),mm2.getGroupArr(-1,"GrpOnAllFace").getValues())
pass
def testMEDField2(self):
mm=MEDFileMesh.New("Pyfile19.med")
mm.write("Pyfile19_bis.med",2)
- ff=MEDFileFieldMultiTS.New("Pyfile19.med","VFieldOnNodes")
+ ff=MEDFileFieldMultiTS.New("Pyfile19.med")
ff.write("Pyfile19_bis.med",0)
self.assertEqual([('tyty','mm'),('uiop','MW')],MEDLoader.GetComponentsNamesOfField("Pyfile19_bis.med","VFieldOnNodes"))
pass
g3=DataArrayInt.New() ; g3.setValues([1,2,3],3,1) ; g3.setName("g3")
mm.setGroupsAtLevel(0,[g1,g2],False)
self.assertEqual(('g1','g2'),mm.getGroupsNames())
- self.assertEqual(('Family_2','Family_3'),mm.getFamiliesNames())
- self.assertEqual(('Family_2',),mm.getFamiliesOnGroup('g1'))
- self.assertEqual(('Family_3',),mm.getFamiliesOnGroup('g2'))
+ self.assertEqual(('Family_-2','Family_-3'),mm.getFamiliesNames())
+ self.assertEqual(('Family_-2',),mm.getFamiliesOnGroup('g1'))
+ self.assertEqual(('Family_-3',),mm.getFamiliesOnGroup('g2'))
mm.assignFamilyNameWithGroupName()
self.assertEqual(('g1','g2'),mm.getGroupsNames())
self.assertEqual(('g1','g2'),mm.getFamiliesNames())
mm.setMeshAtLevel(0,m)
mm.setGroupsAtLevel(0,[g1,g2,g3],False)
self.assertEqual(('g1','g2','g3'),mm.getGroupsNames())
- self.assertEqual(('Family_2', 'Family_4', 'Family_5'),mm.getFamiliesNames())
- self.assertEqual(('Family_2', 'Family_4'),mm.getFamiliesOnGroup('g1'))
- self.assertEqual(('Family_5',),mm.getFamiliesOnGroup('g2'))
- self.assertEqual(('Family_4','Family_5',),mm.getFamiliesOnGroup('g3'))
+ self.assertEqual(('Family_-2', 'Family_-4', 'Family_-5'),mm.getFamiliesNames())
+ self.assertEqual(('Family_-2', 'Family_-4'),mm.getFamiliesOnGroup('g1'))
+ self.assertEqual(('Family_-5',),mm.getFamiliesOnGroup('g2'))
+ self.assertEqual(('Family_-4','Family_-5',),mm.getFamiliesOnGroup('g3'))
mm.assignFamilyNameWithGroupName() # here it does nothing because no such group-family bijection found
self.assertEqual(('g1','g2','g3'),mm.getGroupsNames())
- self.assertEqual(('Family_2', 'Family_4', 'Family_5'),mm.getFamiliesNames())
- self.assertEqual(('Family_2', 'Family_4'),mm.getFamiliesOnGroup('g1'))
- self.assertEqual(('Family_5',),mm.getFamiliesOnGroup('g2'))
- self.assertEqual(('Family_4','Family_5',),mm.getFamiliesOnGroup('g3'))
+ self.assertEqual(('Family_-2', 'Family_-4', 'Family_-5'),mm.getFamiliesNames())
+ self.assertEqual(('Family_-2', 'Family_-4'),mm.getFamiliesOnGroup('g1'))
+ self.assertEqual(('Family_-5',),mm.getFamiliesOnGroup('g2'))
+ self.assertEqual(('Family_-4','Family_-5',),mm.getFamiliesOnGroup('g3'))
mm.changeFamilyId(5,6)
g=mm.getGroupArr(0,"g3")
self.assertTrue(g.isEqual(g3));
daTest=DataArrayInt([1,3,4,6,9,10,12]) ; daTest.setName("grp1")
mm.addGroup(0,daTest)
self.assertTrue(mm.getGroupArr(0,daTest.getName()).isEqual(daTest))
- self.assertTrue(mm.getFamilyFieldAtLevel(0).isEqual(DataArrayInt([6,2,6,8,2,6,5,6,6,7,7,4,8])))
+ self.assertTrue(mm.getFamilyFieldAtLevel(0).isEqual(DataArrayInt([-6,2,-6,-8,2,-6,-5,-6,-6,-7,-7,-4,-8])))
for lev,arr in [(1,da0),(-1,da1),(-2,da2)]:
self.assertTrue(mm.getFamilyFieldAtLevel(lev).isEqual(arr))
pass
- self.assertEqual(mm.getFamiliesNames(),('Family_4','Family_5','Family_7','Family_8','MyFam','MyOther-1','MyOtherFam'))
+ self.assertEqual(mm.getFamiliesNames(),('Family_-4','Family_-5','Family_-7','Family_-8','MyFam','MyOther-1','MyOtherFam'))
self.assertEqual(mm.getGroupsNames(),('grp0','grp1','grpA'))
self.assertEqual(mm.getFamilyNameGivenId(3),'MyOtherFam')
self.assertEqual(mm.getFamilyNameGivenId(2),'MyFam')
- for famName,famId in [('Family_4',4),('Family_5',5),('Family_7',7),('Family_8',8)]:
+ for famName,famId in [('Family_-4',-4),('Family_-5',-5),('Family_-7',-7),('Family_-8',-8)]:
self.assertEqual(mm.getFamilyNameGivenId(famId),famName)
pass
- self.assertEqual(mm.getFamiliesOnGroup("grp0"),('MyOtherFam','Family_8'))
+ self.assertEqual(mm.getFamiliesOnGroup("grp0"),('MyOtherFam','Family_-8'))
da=DataArrayInt([3,12]) ; da.setName("grp0")
self.assertTrue(mm.getGroupArr(0,"grp0").isEqual(da))
da.setValues([1])
mm.write(fname,2)
mm=MEDFileMesh.New(fname)
self.assertTrue(mm.getGroupArr(0,daTest.getName()).isEqual(daTest))
- self.assertTrue(mm.getFamilyFieldAtLevel(0).isEqual(DataArrayInt([6,2,6,8,2,6,5,6,6,7,7,4,8])))
+ self.assertTrue(mm.getFamilyFieldAtLevel(0).isEqual(DataArrayInt([-6,2,-6,-8,2,-6,-5,-6,-6,-7,-7,-4,-8])))
for lev,arr in [(1,da0),(-1,da1),(-2,da2)]:
self.assertTrue(mm.getFamilyFieldAtLevel(lev).isEqual(arr))
pass
- self.assertEqual(mm.getFamiliesNames(),('FAMILLE_ZERO','Family_4','Family_5','Family_7','Family_8','MyFam','MyOther-1','MyOtherFam'))
+ self.assertEqual(mm.getFamiliesNames(),('FAMILLE_ZERO','Family_-4','Family_-5','Family_-7','Family_-8','MyFam','MyOther-1','MyOtherFam'))
self.assertEqual(mm.getGroupsNames(),('grp0','grp1','grpA'))
self.assertEqual(mm.getFamilyNameGivenId(3),'MyOtherFam')
self.assertEqual(mm.getFamilyNameGivenId(2),'MyFam')
- for famName,famId in [('Family_4',4),('Family_5',5),('Family_7',7),('Family_8',8)]:
+ for famName,famId in [('Family_-4',-4),('Family_-5',-5),('Family_-7',-7),('Family_-8',-8)]:
self.assertEqual(mm.getFamilyNameGivenId(famId),famName)
pass
- self.assertEqual(mm.getFamiliesOnGroup("grp0"),('Family_8','MyOtherFam'))
+ self.assertEqual(mm.getFamiliesOnGroup("grp0"),('Family_-8','MyOtherFam'))
da=DataArrayInt([3,12]) ; da.setName("grp0")
self.assertTrue(mm.getGroupArr(0,"grp0").isEqual(da))
da.setValues([1])
splitOfM1[0].isEqual(DataArrayInt([0,1,2,3,6,8,10,11,12,13]))
splitOfM1[1].isEqual(DataArrayInt([4,5,7,9,14,15]))
pass
+
+ def testBugCorrection1(self):
+ fs=MEDFileFields()
+ fs.resize(3)
+ self.assertEqual(fs[0],None)
+ self.assertEqual(3,len(fs))
+ pass
+
+ def testCompareMEDFilesContainingOnlyFieldsOnCell1(self):
+ f1Name="Pyfile60.med"
+ f2Name="Pyfile61.med"
+ d1=MEDLoaderDataForTest.buildACompleteMEDDataStructureWithFieldsOnCells_1()
+ d1.write(f1Name,2)
+ d2=MEDLoaderDataForTest.buildACompleteMEDDataStructureWithFieldsOnCells_1()
+ d2.write(f2Name,2)
+ # reading and compare
+ d1=MEDFileData(f1Name) ; d2=MEDFileData(f2Name)
+ for mn in d1.getMeshes().getMeshesNames():
+ m1=d1.getMeshes()[mn]
+ m2=d2.getMeshes()[mn]
+ for lev in m1.getNonEmptyLevels():
+ grpsNames=m1.getGroupsOnSpecifiedLev(lev)
+ for grpName in grpsNames:
+ self.assertTrue(m1.getGroupArr(lev,grpName).isEqual(m2.getGroupArr(lev,grpName))) # compare groups
+ pass
+ pass
+ pass
+ for fieldn in d1.getFields().getFieldsNames():
+ f1=d1.getFields()[fieldn]
+ f2=d2.getFields()[fieldn]
+ for it,order,tim in f1.getTimeSteps():
+ f1t=f1[it,order]
+ f2t=f2[it,order]
+ if len(f1t.getPflsReallyUsed())!=0:
+ # profile case
+ for lev in f1t.getNonEmptyLevels()[1]:
+ arr1,pfl1=f1t.getFieldWithProfile(ON_CELLS,lev,m1)
+ arr2,pfl2=f2t.getFieldWithProfile(ON_CELLS,lev,m2)
+ self.assertTrue(pfl1.isEqual(pfl2))
+ self.assertTrue(arr1.isEqual(arr2,1e-10))
+ pass
+ pass
+ else:
+ # no profile case
+ for lev in f1t.getNonEmptyLevels()[1]:
+ f1mc=f1t.getFieldOnMeshAtLevel(ON_CELLS,lev,m1)
+ f2mc=f2t.getFieldOnMeshAtLevel(ON_CELLS,lev,m2)
+ self.assertTrue(f1mc.isEqual(f2mc,1e-10,1e-10))
+ pass
+ pass
+ pass
+ pass
+ pass
+
+ def testNonRegBugNormalizeFamIdsMEDFile1(self):
+ m=MEDCouplingCMesh()
+ arr=DataArrayDouble([0.,1.,2.,3.,4.])
+ m.setCoords(arr,arr,arr)
+ m=m.buildUnstructured()
+ m2=m.buildDescendingConnectivity()[0]
+ m.setName("mesh")
+ g1=DataArrayInt([0,1,2,3]) ; g1.setName("g1")
+ g2=DataArrayInt([2,3,5,6]) ; g2.setName("g2")
+ g1Face=DataArrayInt([20,21,22,23]) ; g1Face.setName("g1Face")
+ g2Face=DataArrayInt([22,23,25,26]) ; g2Face.setName("g2Face")
+ g1Node=DataArrayInt([10,11,12,13]) ; g1Node.setName("g1Node")
+ g2Node=DataArrayInt([12,13,15,16]) ; g2Node.setName("g2Node")
+ mm=MEDFileUMesh()
+ mm.setMeshAtLevel(0,m)
+ mm.setGroupsAtLevel(0,[g1,g2])
+ s1=set(mm.getFamiliesOnGroup("g1")) ; s2=set(mm.getFamiliesOnGroup("g2"))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2"),(0,))
+ mm.normalizeFamIdsMEDFile()
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2"),(0,))
+ self.assertTrue(mm.getGroupArr(0,"g1").isEqual(g1))
+ self.assertTrue(mm.getGroupArr(0,"g2").isEqual(g2))
+ self.assertEqual(s1,set(mm.getFamiliesOnGroup("g1")))
+ self.assertEqual(s2,set(mm.getFamiliesOnGroup("g2")))
+ for g in mm.getGroupsOnSpecifiedLev(0):
+ for f in mm.getFamiliesIdsOnGroup(g):
+ self.assertTrue(f<0)
+ pass
+ pass
+ #
+ mm=MEDFileUMesh()
+ mm.setMeshAtLevel(0,m)
+ mm.setMeshAtLevel(-1,m2)
+ mm.setGroupsAtLevel(0,[g1,g2])
+ mm.setGroupsAtLevel(-1,[g1Face,g2Face])
+ s1=set(mm.getFamiliesOnGroup("g1")) ; s2=set(mm.getFamiliesOnGroup("g2"))
+ s3=set(mm.getFamiliesOnGroup("g1Face")) ; s4=set(mm.getFamiliesOnGroup("g2Face"))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1Face"),(-1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2Face"),(-1,))
+ mm.normalizeFamIdsMEDFile()
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1Face"),(-1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2Face"),(-1,))
+ self.assertTrue(mm.getGroupArr(0,"g1").isEqual(g1))
+ self.assertTrue(mm.getGroupArr(0,"g2").isEqual(g2))
+ self.assertTrue(mm.getGroupArr(-1,"g1Face").isEqual(g1Face))
+ self.assertTrue(mm.getGroupArr(-1,"g2Face").isEqual(g2Face))
+ self.assertEqual(s1,set(mm.getFamiliesOnGroup("g1")))
+ self.assertEqual(s2,set(mm.getFamiliesOnGroup("g2")))
+ self.assertEqual(s3,set(mm.getFamiliesOnGroup("g1Face")))
+ self.assertEqual(s4,set(mm.getFamiliesOnGroup("g2Face")))
+ for lev in [0,-1]:
+ for g in mm.getGroupsOnSpecifiedLev(lev):
+ for f in mm.getFamiliesIdsOnGroup(g):
+ self.assertTrue(f<0)
+ pass
+ pass
+ pass
+ #
+ mm=MEDFileUMesh()
+ mm.setMeshAtLevel(0,m)
+ mm.setMeshAtLevel(-1,m2)
+ mm.setGroupsAtLevel(0,[g1,g2])
+ mm.setGroupsAtLevel(-1,[g1Face,g2Face])
+ mm.setGroupsAtLevel(1,[g1Node,g2Node])
+ s1=set(mm.getFamiliesOnGroup("g1")) ; s2=set(mm.getFamiliesOnGroup("g2"))
+ s3=set(mm.getFamiliesOnGroup("g1Face")) ; s4=set(mm.getFamiliesOnGroup("g2Face"))
+ s5=set(mm.getFamiliesOnGroup("g1Node")) ; s6=set(mm.getFamiliesOnGroup("g2Node"))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1Face"),(-1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2Face"),(-1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1Node"),(1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2Node"),(1,))
+ mm.normalizeFamIdsMEDFile()
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2"),(0,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1Face"),(-1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2Face"),(-1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g1Node"),(1,))
+ self.assertEqual(mm.getGrpNonEmptyLevelsExt("g2Node"),(1,))
+ self.assertTrue(mm.getGroupArr(0,"g1").isEqual(g1))
+ self.assertTrue(mm.getGroupArr(0,"g2").isEqual(g2))
+ self.assertTrue(mm.getGroupArr(-1,"g1Face").isEqual(g1Face))
+ self.assertTrue(mm.getGroupArr(-1,"g2Face").isEqual(g2Face))
+ self.assertTrue(mm.getGroupArr(1,"g1Node").isEqual(g1Node))
+ self.assertTrue(mm.getGroupArr(1,"g2Node").isEqual(g2Node))
+ self.assertEqual(s1,set(mm.getFamiliesOnGroup("g1")))
+ self.assertEqual(s2,set(mm.getFamiliesOnGroup("g2")))
+ self.assertEqual(s3,set(mm.getFamiliesOnGroup("g1Face")))
+ self.assertEqual(s4,set(mm.getFamiliesOnGroup("g2Face")))
+ self.assertEqual(s5,set(mm.getFamiliesOnGroup("g1Node")))
+ self.assertEqual(s6,set(mm.getFamiliesOnGroup("g2Node")))
+ for lev in [0,-1]:
+ for g in mm.getGroupsOnSpecifiedLev(lev):
+ for f in mm.getFamiliesIdsOnGroup(g):
+ self.assertTrue(f<0)
+ pass
+ pass
+ pass
+ for g in mm.getGroupsOnSpecifiedLev(1):
+ for f in mm.getFamiliesIdsOnGroup(g):
+ self.assertTrue(f>0)
+ pass
+ pass
+ pass
+
+ def testNonRegressionMantis22212ChangeGrpName(self):
+ fileName="Pyfile62.med"
+ m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp=MEDLoaderDataForTest.buildMultiLevelMesh_1()
+ m=MEDFileUMesh.New()
+ m.setCoords(m2.getCoords())
+ m.setMeshAtLevel(0,m2)
+ m.setMeshAtLevel(-1,m1)
+ m.setMeshAtLevel(-2,m0)
+ m.setFamilyFieldArr(0,f2)
+ m.setFamilyFieldArr(-1,f1)
+ m.setFamilyFieldArr(-2,f0)
+ m.setFamilyFieldArr(1,p)
+ nbOfFams=len(fns)
+ for i in xrange(nbOfFams):
+ m.addFamily(fns[i],fids[i])
+ pass
+ nbOfGrps=len(grpns)
+ for i in xrange(nbOfGrps):
+ m.setFamiliesIdsOnGroup(grpns[i],famIdsPerGrp[i])
+ pass
+ m.setName(m2.getName())
+ m.setDescription(m2.getDescription())
+ m.write(fileName,2)
+ #
+ mm0=MEDFileMesh.New(fileName)
+ mm1=MEDFileMesh.New(fileName)
+ groupNamesIni=MEDLoader.GetMeshGroupsNames(fileName,"ma")
+ for name in groupNamesIni:
+ mm1.changeGroupName(name,name+'N')
+ pass
+ mm1.write(fileName,2)
+ del mm1
+ #
+ mm2=MEDFileMesh.New(fileName)
+ for name in groupNamesIni:
+ for lev in mm0.getGrpNonEmptyLevelsExt(name):
+ arr0=mm0.getGroupArr(lev,name)
+ arr2=mm2.getGroupArr(lev,name+'N')
+ arr0.setName(name+'N')
+ self.assertTrue(arr0.isEqual(arr2))
+ pass
+ pass
+ pass
+
+ def testInt32InMEDFileFieldStar1(self):
+ fname="Pyfile63.med"
+ f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
+ arr=f1.getArray().convertToIntArr()
+ f1.setArray(None)
+ m1=f1.getMesh()
+ mm1=MEDFileUMesh.New()
+ mm1.setCoords(m1.getCoords())
+ mm1.setMeshAtLevel(0,m1)
+ mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileIntField1TS()
+ ff1.setFieldNoProfileSBT(f1,arr)
+ a,b=ff1.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertEqual(b.getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
+ self.assertTrue(b.isEqual(arr))
+ self.assertTrue(a.isEqual(f1,1e-12,1e-12))
+ ff1.write(fname,0)
+ ff2=MEDFileAnyTypeField1TS.New(fname)
+ self.assertEqual(ff2.getName(),"VectorFieldOnCells")
+ self.assertEqual(ff2.getTime(),[0,1,2.0])
+ self.assertTrue(isinstance(ff2,MEDFileIntField1TS))
+ a,b=ff1.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertEqual(b.getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
+ self.assertTrue(b.isEqual(arr))
+ self.assertTrue(a.isEqual(f1,1e-12,1e-12))
+ ff2.setTime(1,2,3.)
+ c=ff2.getUndergroundDataArray() ; c*=2
+ ff2.write(fname,0) # 2 time steps in
+ ffs1=MEDFileAnyTypeFieldMultiTS.New(fname,"VectorFieldOnCells")
+ self.assertEqual(ffs1.getTimeSteps(),[(0, 1, 2.0), (1, 2, 3.0)])
+ self.assertEqual(len(ffs1),2)
+ self.assertTrue(isinstance(ffs1,MEDFileIntFieldMultiTS))
+ a,b=ffs1[2.].getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertTrue(b.isEqual(arr))
+ self.assertTrue(a.isEqual(f1,1e-12,1e-12))
+ a,b=ffs1[2.].getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertTrue(b.isEqual(arr))
+ self.assertTrue(a.isEqual(f1,1e-12,1e-12))
+ it=ffs1.__iter__() ; it.next() ; ff2bis=it.next()
+ a,b=ff2bis.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertTrue(b.isEqual(2*arr))
+ f1.setTime(3.,1,2)
+ self.assertTrue(a.isEqual(f1,1e-12,1e-12))
+ bc=DataArrayInt(6,3) ; bc[:]=0 ; bc.setInfoOnComponents(['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
+ for it in ffs1:
+ a,b=it.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ bc+=b
+ pass
+ self.assertTrue(bc.isEqual(3*arr))
+ nf1=MEDCouplingFieldDouble(ON_NODES)
+ nf1.setTime(9.,10,-1)
+ nf1.setMesh(f1.getMesh())
+ narr=DataArrayInt(12,2) ; narr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; narr[:,0]=range(12) ; narr[:,1]=2*narr[:,0]
+ nf1.setName("VectorFieldOnNodes")
+ nff1=MEDFileIntField1TS.New()
+ nff1.setFieldNoProfileSBT(nf1,narr)
+ self.assertEqual(nff1.getInfo(),('aa [u1]','bbbvv [ppp]'))
+ self.assertEqual(nff1.getTime(),[10,-1,9.0])
+ nff1.write(fname,0)
+ #
+ nf2=MEDCouplingFieldDouble(ON_NODES)
+ nf2.setTime(19.,20,-11)
+ nf2.setMesh(f1.getMesh())
+ narr2=DataArrayInt(8,2) ; narr.setInfoOnComponents(["aapfl [u1]","bbbvvpfl [ppp]"]) ; narr2[:,0]=range(8) ; narr2[:,0]+=10 ; narr2[:,1]=3*narr2[:,0]
+ nf2.setName("VectorFieldOnNodesPfl") ; narr2.setName(nf2.getName())
+ nff2=MEDFileIntField1TS.New()
+ npfl=DataArrayInt([1,2,4,5,6,7,10,11]) ; npfl.setName("npfl")
+ nff2.setFieldProfile(nf2,narr2,mm1,0,npfl)
+ nff2.getFieldWithProfile(ON_NODES,0,mm1)
+ a,b=nff2.getFieldWithProfile(ON_NODES,0,mm1) ; b.setName(npfl.getName())
+ self.assertTrue(b.isEqual(npfl))
+ self.assertTrue(a.isEqual(narr2))
+ nff2.write(fname,0)
+ nff2bis=MEDFileIntField1TS(fname,"VectorFieldOnNodesPfl")
+ a,b=nff2bis.getFieldWithProfile(ON_NODES,0,mm1) ; b.setName(npfl.getName())
+ self.assertTrue(b.isEqual(npfl))
+ self.assertTrue(a.isEqual(narr2))
+ #
+ nf3=MEDCouplingFieldDouble(ON_NODES)
+ nf3.setName("VectorFieldOnNodesDouble")
+ nf3.setTime(29.,30,-21)
+ nf3.setMesh(f1.getMesh())
+ nf3.setArray(f1.getMesh().getCoords())
+ nff3=MEDFileField1TS.New()
+ nff3.setFieldNoProfileSBT(nf3)
+ nff3.write(fname,0)
+ fs=MEDFileFields(fname)
+ self.assertEqual(len(fs),4)
+ ffs=[it for it in fs]
+ self.assertTrue(isinstance(ffs[0],MEDFileIntFieldMultiTS))
+ self.assertTrue(isinstance(ffs[1],MEDFileIntFieldMultiTS))
+ self.assertTrue(isinstance(ffs[2],MEDFileFieldMultiTS))
+ self.assertTrue(isinstance(ffs[3],MEDFileIntFieldMultiTS))
+ #
+ self.assertTrue(fs["VectorFieldOnCells"][0].getUndergroundDataArray().isEqualWithoutConsideringStr(arr))
+ self.assertTrue(fs["VectorFieldOnCells"][1,2].getUndergroundDataArray().isEqualWithoutConsideringStr(2*arr))
+ self.assertTrue(fs["VectorFieldOnNodesPfl"][0].getUndergroundDataArray().isEqualWithoutConsideringStr(narr2))
+ self.assertTrue(fs["VectorFieldOnNodes"][9.].getUndergroundDataArray().isEqualWithoutConsideringStr(narr))
+ self.assertTrue(fs["VectorFieldOnNodesDouble"][29.].getUndergroundDataArray().isEqualWithoutConsideringStr(f1.getMesh().getCoords(),1e-12))
+ #
+ nf3_read=MEDFileFieldMultiTS(fname,"VectorFieldOnNodesDouble")
+ self.assertTrue(nf3_read[29.].getUndergroundDataArray().isEqualWithoutConsideringStr(f1.getMesh().getCoords(),1e-12))
+ self.assertRaises(InterpKernelException,MEDFileIntFieldMultiTS.New,fname,"VectorFieldOnNodesDouble")# exception because trying to read a double field with int instance
+ self.assertRaises(InterpKernelException,MEDFileFieldMultiTS.New,fname,"VectorFieldOnNodes")# exception because trying to read a int field with double instance
+ MEDFileField1TS.New(fname,"VectorFieldOnNodesDouble",30,-21)
+ self.assertRaises(InterpKernelException,MEDFileIntField1TS.New,fname,"VectorFieldOnNodesDouble",30,-21)# exception because trying to read a double field with int instance
+ MEDFileIntField1TS.New(fname,"VectorFieldOnNodes",10,-1)
+ self.assertRaises(InterpKernelException,MEDFileField1TS.New,fname,"VectorFieldOnNodes",10,-1)# exception because trying to read a double field with int instance
+ #
+ self.assertEqual(fs.getMeshesNames(),('3DSurfMesh_1','3DSurfMesh_1','3DSurfMesh_1','3DSurfMesh_1'))
+ self.assertTrue(fs.changeMeshNames([('3DSurfMesh_1','3DSurfMesh')]))
+ self.assertEqual(fs.getMeshesNames(),('3DSurfMesh','3DSurfMesh','3DSurfMesh','3DSurfMesh'))
+ self.assertTrue(not fs.changeMeshNames([('3DSurfMesh_1','3DSurfMesh')]))
+ pass
+
+ def testMEDFileFields1(self):
+ fname="Pyfile64.med"
+ f1=MEDCouplingFieldDouble(ON_NODES)
+ f1.setTime(0.001,0,-1) ; f1.setTimeUnit("us")
+ c=DataArrayDouble(12) ; c.iota(); m=MEDCouplingCMesh() ; m.setCoordsAt(0,c) ; m.setName("mesh")
+ mm=MEDFileCMesh() ; mm.setMesh(m) ; mm.write(fname,2)
+ f1.setMesh(m)
+ arr=DataArrayDouble(12,2) ; arr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; arr[:,0]=range(12) ; arr[:,1]=2*arr[:,0]
+ f1.setArray(arr)
+ f1.setName("Field1")
+ ff1=MEDFileField1TS.New()
+ ff1.setFieldNoProfileSBT(f1)
+ self.assertEqual(ff1.getDtUnit(),"us")
+ ff1.write(fname,0)
+ f1.setTime(1.001,1,-1) ; ff1=MEDFileField1TS.New() ; ff1.setFieldNoProfileSBT(f1) ; ff1.write(fname,0)
+ f1.setTime(2.001,2,-1) ; ff1=MEDFileField1TS.New() ; ff1.setFieldNoProfileSBT(f1) ; ff1.write(fname,0)
+ #
+ self.assertEqual(MEDFileFields(fname).getCommonIterations(),([(0,-1),(1,-1),(2,-1)],False))
+ ff1s=MEDFileFieldMultiTS(fname,"Field1")
+ ff1s.setName("Field2")
+ ff1s.write(fname,0)
+ self.assertEqual(MEDFileFields(fname).getCommonIterations(),([(0,-1),(1,-1),(2,-1)],False))
+ f1.setTime(3.001,3,-1) ; ff1=MEDFileField1TS.New() ; ff1.setFieldNoProfileSBT(f1) ; ff1.write(fname,0)
+ self.assertEqual(MEDFileFields(fname).getCommonIterations(),([(0,-1),(1,-1),(2,-1)],True))
+ self.assertEqual(MEDFileFields(fname).partOfThisLyingOnSpecifiedTimeSteps([(1,-1)]).getCommonIterations(),([(1,-1)],False))
+ self.assertEqual(MEDFileFields(fname).partOfThisNotLyingOnSpecifiedTimeSteps([(1,-1)]).getCommonIterations(),([(0,-1),(2,-1)],True))
+ f1.setName("Field2") ; f1.setTime(3.001,3,-1) ; ff1=MEDFileField1TS.New() ; ff1.setFieldNoProfileSBT(f1) ; ff1.write(fname,0)
+ self.assertEqual(MEDFileFields(fname).getCommonIterations(),([(0,-1),(1,-1),(2,-1),(3,-1)],False))
+ self.assertEqual(MEDFileFields(fname)[1].getDtUnit(),"us")
+ pass
+
+ # Multi time steps and multi fields management without Globals (profiles, locs) aspects
+ def testMEDFileFields2(self):
+ fname="Pyfile65.med"
+ # to check that all is initialize
+ MEDFileField1TS().__str__()
+ MEDFileFieldMultiTS().__str__()
+ # building a mesh containing 4 tri3 + 5 quad4
+ tri=MEDCouplingUMesh("tri",2)
+ tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2])
+ tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)]))
+ tris=[tri.deepCpy() for i in xrange(4)]
+ for i,elt in enumerate(tris): elt.translate([i,0])
+ tris=MEDCouplingUMesh.MergeUMeshes(tris)
+ quad=MEDCouplingUMesh("quad",2)
+ quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3])
+ quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)]))
+ quads=[quad.deepCpy() for i in xrange(5)]
+ for i,elt in enumerate(quads): elt.translate([5+i,0])
+ quads=MEDCouplingUMesh.MergeUMeshes(quads)
+ m=MEDCouplingUMesh.MergeUMeshes(tris,quads)
+ m.setName("mesh") ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"])
+ #
+ fmts0_0=MEDFileFieldMultiTS()
+ fmts0_1=MEDFileFieldMultiTS()
+ # time steps
+ for i in xrange(10):
+ infos1=["aa [bb]","ccc [ddd]"] ; name1="1stField"
+ d=DataArrayDouble(18) ; d.iota(i*10) ; d.rearrange(2) ; d.setInfoOnComponents(infos1)
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName(name1) ; f.setArray(d) ; f.setMesh(m)
+ f.setTime(float(i+1)+0.1,i+1,-i-1)
+ fmts0_0.appendFieldNoProfileSBT(f)
+ f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(f) ; fmts0_1.pushBackTimeStep(f1ts)
+ self.assertEqual(fmts0_1.getName(),name1)
+ self.assertEqual(fmts0_0.getInfo(),('aa [bb]','ccc [ddd]'))
+ self.assertEqual(fmts0_1.getInfo(),('aa [bb]','ccc [ddd]'))
+ if i>1:
+ # components names have been modified to generate errors
+ d.setInfoOnComponents(['aa [bb]','eee [dd]'])
+ self.assertRaises(InterpKernelException,fmts0_0.appendFieldNoProfileSBT,f)
+ self.assertRaises(InterpKernelException,f1ts.setInfo,['aa [bb]'])#throw because mismatch of number of components
+ f1ts.setInfo(['aa [bb]','eee [dd]'])
+ self.assertRaises(InterpKernelException,fmts0_1.pushBackTimeStep,f1ts)
+ pass
+ # add a mismatch of nb of compos
+ pass
+ fmts0_2=fmts0_0.deepCpy()
+ fmts0_3=fmts0_0.deepCpy()
+ fmts0_4=fmts0_0.deepCpy()
+ fmts0_5=fmts0_0.shallowCpy()
+ self.assertTrue(len(fmts0_0)==10 and len(fmts0_1)==10 and len(fmts0_2)==10 and len(fmts0_3)==10 and len(fmts0_4)==10 and len(fmts0_5)==10)
+ del fmts0_2[::2]
+ self.assertTrue(len(fmts0_2)==5 and fmts0_2.getIterations()==[(2,-2),(4,-4),(6,-6),(8,-8),(10,-10)])
+ del fmts0_3[[1.1,(6,-6),9]]
+ self.assertTrue(len(fmts0_3)==7 and fmts0_3.getIterations()==[(2,-2),(3,-3),(4,-4),(5,-5),(7,-7),(8,-8),(9,-9)])
+ fmts0_6=fmts0_4[[1.1,(6,-6),8]]
+ self.assertTrue(isinstance(fmts0_6,MEDFileFieldMultiTS))
+ self.assertTrue(len(fmts0_6)==3 and fmts0_6.getIterations()==[(1,-1),(6,-6),(9,-9)])
+ fmts0_7=fmts0_4[::-3]
+ self.assertTrue(isinstance(fmts0_7,MEDFileFieldMultiTS))
+ self.assertTrue(len(fmts0_7)==4 and fmts0_7.getIterations()==[(10,-10),(7,-7),(4,-4),(1,-1)])
+ #
+ fs0=MEDFileFields()
+ fs0.pushField(fmts0_0)
+ fmts0_2.setName("2ndField") ; fs0.pushField(fmts0_2)
+ fmts0_3.setName("3rdField") ; fs0.pushField(fmts0_3)
+ fmts0_4.setName("4thField") ; fs0.pushField(fmts0_4)
+ self.assertTrue(len(fs0)==4 and fs0.getFieldsNames()==('1stField','2ndField','3rdField','4thField'))
+ fs0.write(fname,2)
+ fs0=MEDFileFields(fname)
+ self.assertEqual(fs0.getCommonIterations(),([(2,-2),(4,-4),(8,-8)],True))
+ fs1=fs0.partOfThisLyingOnSpecifiedTimeSteps(fs0.getCommonIterations()[0])
+ self.assertTrue(fs1.getFieldsNames()==('1stField','2ndField','3rdField','4thField') and fs1.getCommonIterations()==([(2,-2),(4,-4),(8,-8)],False))
+ del fs1[["2ndField",3]]
+ self.assertTrue(fs1.getFieldsNames()==('1stField','3rdField') and fs1.getCommonIterations()==([(2,-2),(4,-4),(8,-8)],False))
+ fs2=fs0[[0,"4thField"]]
+ self.assertTrue(isinstance(fs2,MEDFileFields))
+ self.assertEqual(fs2.getFieldsNames(),('1stField','4thField'))
+ #
+ mm=MEDFileUMesh() ; mm.setMeshAtLevel(0,m) ; mm.write(fname,0)
+ pass
+
+ # Multi time steps and multi fields management with Globals (profiles, locs) aspects
+ def testMEDFileFields3(self):
+ fname="Pyfile66.med"
+ # building a mesh containing 4 tri3 + 5 quad4
+ tri=MEDCouplingUMesh("tri",2)
+ tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2])
+ tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)]))
+ tris=[tri.deepCpy() for i in xrange(4)]
+ for i,elt in enumerate(tris): elt.translate([i,0])
+ tris=MEDCouplingUMesh.MergeUMeshes(tris)
+ quad=MEDCouplingUMesh("quad",2)
+ quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3])
+ quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)]))
+ quads=[quad.deepCpy() for i in xrange(5)]
+ for i,elt in enumerate(quads): elt.translate([5+i,0])
+ quads=MEDCouplingUMesh.MergeUMeshes(quads)
+ m=MEDCouplingUMesh.MergeUMeshes(tris,quads)
+ m.setName("mesh") ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"])
+ #
+ mm=MEDFileUMesh() ; mm.setMeshAtLevel(0,m) ; mm.write(fname,2)
+ #
+ pfl=DataArrayInt([0,1,2,3,4,5,6]) ; pfl.setName("pfl")
+ pfl2=DataArrayInt([0,1,2,3,4,5,6,8]) ; pfl2.setName("pfl2")
+ fmts0_0=MEDFileFieldMultiTS()
+ fmts0_1=MEDFileFieldMultiTS()
+ # time steps
+ for i in xrange(10):
+ infos1=["aa [bb]","ccc [ddd]"] ; name1="1stField"
+ d=DataArrayDouble(14) ; d.iota(i*10) ; d.rearrange(2) ; d.setInfoOnComponents(infos1)
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName(name1) ; f.setArray(d) ; f.setMesh(m)
+ f.setTime(float(i+1)+0.1,i+1,-i-1)
+ fmts0_0.appendFieldProfile(f,mm,0,pfl)
+ f1ts=MEDFileField1TS() ; f1ts.setFieldProfile(f,mm,0,pfl) ; fmts0_1.pushBackTimeStep(f1ts)
+ self.assertEqual(fmts0_0.getInfo(),('aa [bb]','ccc [ddd]'))
+ self.assertEqual(fmts0_1.getInfo(),('aa [bb]','ccc [ddd]'))
+ pass
+ #
+ self.assertEqual(fmts0_0.getPfls(),10*('pfl_NORM_QUAD4',))
+ self.assertEqual(fmts0_1.getPfls(),('pfl_NORM_QUAD4',))
+ fmts0_0.zipPflsNames()
+ self.assertEqual(fmts0_0.getPfls(),('pfl_NORM_QUAD4',))
+ self.assertTrue(fmts0_1.getProfile("pfl_NORM_QUAD4").isEqual(fmts0_0.getProfile("pfl_NORM_QUAD4")))
+ fmts0_2=fmts0_0.deepCpy()
+ fmts0_3=fmts0_0.deepCpy()
+ fmts0_4=fmts0_0.deepCpy()
+ fs0=MEDFileFields()
+ fs0.pushField(fmts0_0)
+ fmts0_2.setName("2ndField") ; fs0.pushField(fmts0_2)
+ fmts0_3.setName("3rdField") ; fs0.pushField(fmts0_3)
+ fmts0_4.setName("4thField") ; fs0.pushField(fmts0_4)
+ self.assertEqual(fs0.getPfls(),('pfl_NORM_QUAD4',))
+ #
+ fmts0_5=MEDFileFieldMultiTS()
+ for i in xrange(7):
+ infos1=["aa [bb]","ccc [ddd]"] ; name1="1stField"
+ d=DataArrayDouble(16) ; d.iota(i*10) ; d.rearrange(2) ; d.setInfoOnComponents(infos1)
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName(name1) ; f.setArray(d) ; f.setMesh(m)
+ f.setTime(float(i+1)+0.1,i+1,-i-1)
+ f1ts=MEDFileField1TS() ; f1ts.setFieldProfile(f,mm,0,pfl2) ; fmts0_5.pushBackTimeStep(f1ts)
+ pass
+ fmts0_5.setName("5thField") ; fs0.pushField(fmts0_5)
+ self.assertEqual(fs0.getPfls(),('pfl_NORM_QUAD4','pfl2_NORM_QUAD4'))
+ fs0.checkGlobsCoherency()
+ fs0.write(fname,0)
+ pass
+
+ def testSplitComponents1(self):
+ fname="Pyfile67.med"
+ # building a mesh containing 4 tri3 + 5 quad4
+ tri=MEDCouplingUMesh("tri",2)
+ tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2])
+ tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)]))
+ tris=[tri.deepCpy() for i in xrange(4)]
+ for i,elt in enumerate(tris): elt.translate([i,0])
+ tris=MEDCouplingUMesh.MergeUMeshes(tris)
+ quad=MEDCouplingUMesh("quad",2)
+ quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3])
+ quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)]))
+ quads=[quad.deepCpy() for i in xrange(5)]
+ for i,elt in enumerate(quads): elt.translate([5+i,0])
+ quads=MEDCouplingUMesh.MergeUMeshes(quads)
+ m=MEDCouplingUMesh.MergeUMeshes(tris,quads)
+ m.setName("mesh") ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"])
+ #
+ mm=MEDFileUMesh() ; mm.setMeshAtLevel(0,m) ; mm.write(fname,2)
+ #
+ pfl=DataArrayInt([0,1,2,3,4,5,6]) ; pfl.setName("pfl")
+ pfl2=DataArrayInt([0,1,2,3,4,5,6,8]) ; pfl2.setName("pfl2")
+ fs=MEDFileFields()
+ fmts0_1=MEDFileFieldMultiTS()
+ # time steps
+ infos1=['aa [bb]','ccc [ddd]',"ZZZZ [MW*s]"]
+ for i in xrange(10):
+ name1="1stField"
+ d=DataArrayDouble(21) ; d.iota(i*10) ; d.rearrange(3) ; d.setInfoOnComponents(infos1)
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName(name1) ; f.setArray(d) ; f.setMesh(m)
+ f.setTime(float(i+1)+0.1,i+1,-i-1)
+ f1ts=MEDFileField1TS() ; f1ts.setFieldProfile(f,mm,0,pfl) ; fmts0_1.pushBackTimeStep(f1ts)
+ self.assertEqual(fmts0_1.getInfo(),tuple(infos1))
+ pass
+ fs.pushField(fmts0_1)
+ self.assertEqual(1,len(fs))
+ l=fmts0_1.splitComponents()
+ self.assertEqual(3,len(l))
+ for elt in l: self.assertEqual(10,len(elt))
+ for elt in l: self.assertTrue(isinstance(elt,MEDFileFieldMultiTS))
+ for elt in l:
+ elt.setName("%s_%s"%(elt.getName(),DataArray.GetVarNameFromInfo(elt.getInfo()[0])))
+ pass
+ fs.pushFields(l)
+ self.assertEqual(4,len(fs))
+ for elt in fs: self.assertEqual(10,len(elt))
+ self.assertEqual(fs.getPfls(),('pfl_NORM_QUAD4',))
+ self.assertEqual(fs.getPflsReallyUsed(),('pfl_NORM_QUAD4',))
+ #
+ fs.write(fname,0) ; del fs
+ #
+ fs1=MEDFileFields(fname)
+ self.assertEqual(fs1.getPfls(),('pfl_NORM_QUAD4',))
+ self.assertEqual(fs1.getPflsReallyUsed(),('pfl_NORM_QUAD4',))
+ self.assertEqual(4,len(fs1))
+ for i in xrange(10):
+ for j,fieldName in enumerate(['1stField_aa','1stField_ccc','1stField_ZZZZ']):
+ f1ts=fs1[fieldName][i]
+ f=f1ts.getFieldOnMeshAtLevel(ON_CELLS,0,mm)
+ d=DataArrayDouble(21) ; d.iota(i*10) ; d.rearrange(3) ; d=d[:,j] ; d.setInfoOnComponent(0,infos1[j])
+ self.assertTrue(d.isEqual(f.getArray(),1e-13))
+ pass
+ f1ts=fs1["1stField"][i]
+ f=f1ts.getFieldOnMeshAtLevel(ON_CELLS,0,mm)
+ d=DataArrayDouble(21) ; d.iota(i*10) ; d.rearrange(3) ; d.setInfoOnComponents(infos1)
+ self.assertTrue(d.isEqual(f.getArray(),1e-13))
+ pass
+ pass
pass
unittest.main()
static PyObject* convertMEDFileMesh(ParaMEDMEM::MEDFileMesh* mesh, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!mesh)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::MEDFileUMesh *>(mesh))
ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileUMesh,owner);
if(dynamic_cast<ParaMEDMEM::MEDFileCMesh *>(mesh))
static PyObject* convertMEDFileParameter1TS(ParaMEDMEM::MEDFileParameter1TS* p1ts, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!p1ts)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<MEDFileParameterDouble1TS *>(p1ts))
ret=SWIG_NewPointerObj((void*)p1ts,SWIGTYPE_p_ParaMEDMEM__MEDFileParameterDouble1TS,owner);
if(dynamic_cast<MEDFileParameterDouble1TSWTI *>(p1ts))
return ret;
}
+static PyObject* convertMEDFileField1TS(ParaMEDMEM::MEDFileAnyTypeField1TS *p, int owner) throw(INTERP_KERNEL::Exception)
+{
+ PyObject *ret=0;
+ if(!p)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
+ if(dynamic_cast<MEDFileField1TS *>(p))
+ ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_ParaMEDMEM__MEDFileField1TS,owner);
+ if(dynamic_cast<MEDFileIntField1TS *>(p))
+ ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_ParaMEDMEM__MEDFileIntField1TS,owner);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("Not recognized type of MEDFileAnyTypeField1TS on downcast !");
+ return ret;
+}
+
+static PyObject* convertMEDFileFieldMultiTS(ParaMEDMEM::MEDFileAnyTypeFieldMultiTS *p, int owner) throw(INTERP_KERNEL::Exception)
+{
+ PyObject *ret=0;
+ if(!p)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
+ if(dynamic_cast<MEDFileFieldMultiTS *>(p))
+ ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_ParaMEDMEM__MEDFileFieldMultiTS,owner);
+ if(dynamic_cast<MEDFileIntFieldMultiTS *>(p))
+ ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_ParaMEDMEM__MEDFileIntFieldMultiTS,owner);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("Not recognized type of MEDFileAnyTypeFieldMultiTS on downcast !");
+ return ret;
+}
+
static std::vector<std::pair<int,int> > convertTimePairIdsFromPy(PyObject *pyLi) throw(INTERP_KERNEL::Exception)
{
std::vector<std::pair<int,int> > ret;
throw INTERP_KERNEL::Exception(msg);
PyObject *o0=PyTuple_GetItem(o,0);
if(PyString_Check(o0))
- p.second=std::string(PyString_AsString(o0));
+ p.first=std::string(PyString_AsString(o0));
else
throw INTERP_KERNEL::Exception(msg);
PyObject *o1=PyTuple_GetItem(o,1);
PyObject *o0=PyTuple_GetItem(o,0);
if(PyList_Check(o0))
{
- int size2=PyList_Size(o0);
- p.first.resize(size2);
- for(int j=0;j<size2;j++)
+ int size3=PyList_Size(o0);
+ p.first.resize(size3);
+ for(int j=0;j<size3;j++)
{
PyObject *o0j=PyList_GetItem(o0,j);
if(PyString_Check(o0j))
}
throw INTERP_KERNEL::Exception(msg);
}
+
+/*!
+ * Called by MEDFileAnyTypeFieldMultiTS::__getitem__ when \a elt0 is neither a list nor a slice.
+ * In this case a MEDFileAnyTypeField1TS object is returned.
+ */
+int MEDFileAnyTypeFieldMultiTSgetitemSingleTS__(const MEDFileAnyTypeFieldMultiTS *self, PyObject *elt0) throw(INTERP_KERNEL::Exception)
+{
+ if(elt0 && PyInt_Check(elt0))
+ {//fmts[3]
+ return PyInt_AS_LONG(elt0);
+ }
+ else if(elt0 && PyTuple_Check(elt0))
+ {
+ if(PyTuple_Size(elt0)==2)
+ {
+ PyObject *o0=PyTuple_GetItem(elt0,0);
+ PyObject *o1=PyTuple_GetItem(elt0,1);
+ if(PyInt_Check(o0) && PyInt_Check(o1))
+ {//fmts(1,-1)
+ int iter=PyInt_AS_LONG(o0);
+ int order=PyInt_AS_LONG(o1);
+ return self->getPosOfTimeStep(iter,order);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !");
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !");
+ }
+ else if(elt0 && PyFloat_Check(elt0))
+ {
+ double val=PyFloat_AS_DOUBLE(elt0);
+ return self->getPosGivenTime(val);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int], or fmts[double] to request one time step ! To request a series of time steps invoke fmts[slice], fmts[list of int], fmts[list of double], or fmts[list of int,int] !");
+}
+
+/*!
+ * Called by MEDFileAnyTypeFieldMultiTS::__getitem__ when \a obj is neither a list nor a slice.
+ * In this case a MEDFileAnyTypeField1TS object is returned.
+ */
+int MEDFileFieldsgetitemSingleTS__(const MEDFileFields *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
+{
+ if(PyInt_Check(obj))
+ {
+ return (int)PyInt_AS_LONG(obj);
+ }
+ else if(PyString_Check(obj))
+ {
+ return self->getPosFromFieldName(PyString_AsString(obj));
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileFields::__getitem__ : only integer or string with fieldname supported !");
+}
CLEANFILES = MEDLoader_wrap.cxx MEDLoader.py
-dist_salomescript_SCRIPTS= med2sauv sauv2med
+dist_salomescript_SCRIPTS= med2sauv sauv2med case2med med2case
-dist_salomescript_DATA= MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py MEDLoaderTest3.py libMEDLoader_Swig.py medutilities.py
+dist_salomescript_DATA= MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py MEDLoaderTest3.py MEDLoaderCouplingTrainingSession.py CaseIO.py CaseReader.py CaseWriter.py MEDLoaderSplitter.py libMEDLoader_Swig.py medutilities.py
nodist_salomescript_DATA = MEDLoader.py
UNIT_TEST_PROG = MEDLoaderTest.py MEDLoaderTest2.py
--- /dev/null
+#!/usr/bin/python
+# -*- coding: iso-8859-1 -*-
+# 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
+#
+
+from CaseReader import CaseReader
+from optparse import OptionParser
+import os
+
+parser = OptionParser()
+parser.set_usage("Convert a Case file to a MED file.\n %prog [options] case_file")
+parser.add_option("-c", "--currentdir", action="store_true", dest="here", default=False,
+ help="Are generated MED file generated in current directory. By default not, MED file is generated in directory containing the input file (default False)")
+(opts, args) = parser.parse_args()
+
+if len(args) != 1:
+ parser.print_usage()
+ exit(1)
+ pass
+
+fname=args[0] #"cas_test_simple.case"
+if opts.here:
+ fOut=os.path.splitext(os.path.basename(fname))[0]+".med"
+ pass
+else:
+ fOut=os.path.splitext(fname)[0]+".med"
+ pass
+###
+cr=CaseReader(fname)
+try:
+ medfd=cr.loadInMEDFileDS()
+except:
+ print "An error occured during the conversion!"
+ print "#######################################"
+ raise
+medfd.write(fOut,2)
+print "#########\nFile \"%s\" written !\n#########"%(fOut)
+
--- /dev/null
+#!/usr/bin/python
+# -*- coding: iso-8859-1 -*-
+# 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
+#
+# Author Anthony GEAY (CEA/DEN/DM2S/STMF/LGLS)
+
+from MEDLoader import MEDFileData,InterpKernelException
+from CaseWriter import CaseWriter
+from optparse import OptionParser
+import os
+
+parser = OptionParser()
+parser.set_usage("Convert a MED file to a Case file.\n %prog [options] case_file")
+parser.add_option("-g", "--groups", action="store_true", dest="groups", default=False,
+ help="Are groups in meshes stored in MEDFile exported in output case as subparts (default False)")
+parser.add_option("-c", "--currentdir", action="store_true", dest="here", default=False,
+ help="Are generated case,geo files generated in current directory. By default not, files are generated in directory containing the input file (default False)")
+(opts, args) = parser.parse_args()
+
+if len(args) != 1:
+ parser.print_usage()
+ exit(1)
+ pass
+
+fname=os.path.abspath(args[0]) #"cas_test_simple.case"
+if opts.here:
+ fOut=os.path.splitext(os.path.basename(fname))[0]+".case"
+ pass
+else:
+ fOut=os.path.splitext(fname)[0]+".case"
+ pass
+###
+try:
+ cw=CaseWriter.New()
+ cw.setExportingGroups(opts.groups)
+ mfd=MEDFileData(fname)
+ cw.setMEDFileDS(mfd)
+ listOfWrittenFileNames=cw.write(fOut)
+except InterpKernelException as e:
+ print "An error occured during the conversion!"
+ print "#######################################"
+ raise e
+print "#########"
+for l in listOfWrittenFileNames:
+ print "File \"%s\" sucessfully written !"%(l)
+ pass
+print "#########"
CPPUNIT_ASSERT_DOUBLES_EQUAL(3, length1dField->accumulate(0), 1e-12);
// check field
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> field =
- d2->getFields()->getFieldWithName("CHAM1D");
+ dynamic_cast<MEDFileFieldMultiTS *>(d2->getFields()->getFieldWithName("CHAM1D"));
std::cout << "Number of components in field: " << field->getInfo().size() << std::endl;
CPPUNIT_ASSERT_EQUAL(6,(int)field->getInfo().size());
std::vector< std::pair<int,int> > timesteps = field->getIterations();
for (int i=0; i < field1d->getNumberOfTuples(); i++)
{
- bool ok = abs(values[i]-field1d->getIJ(i, 0)) < 1e-12;
CPPUNIT_ASSERT_DOUBLES_EQUAL( values[i], field1d->getIJ(i, 0), 1e-12 );
}
}
MEDFileFields* pointeFields = pointeMed->getFields();
for ( int i = 0; i < pointeFields->getNumberOfFields(); ++i )
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ts = pointeFields->getFieldAtPos(i);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ts = pointeFields->getFieldAtPos(i);
if ( std::string("fieldnodeint") == ts->getName())
{
pointeFields->destroyFieldAtPos( i );
// check fields
// fieldnodedouble
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldnodedoubleTS1 =
- pointeMed->getFields()->getFieldWithName("fieldnodedouble");
+ dynamic_cast<MEDFileFieldMultiTS *>(pointeMed->getFields()->getFieldWithName("fieldnodedouble"));
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldnodedoubleTS2 =
- d2->getFields()->getFieldWithName("fieldnodedouble");
+ dynamic_cast<MEDFileFieldMultiTS *>(d2->getFields()->getFieldWithName("fieldnodedouble"));
CPPUNIT_ASSERT_EQUAL( fieldnodedoubleTS1->getInfo().size(), fieldnodedoubleTS2->getInfo().size());
for ( size_t i = 0; i < fieldnodedoubleTS1->getInfo().size(); ++i )
CPPUNIT_ASSERT_EQUAL( fieldnodedoubleTS1->getInfo()[i], fieldnodedoubleTS2->getInfo()[i]);
}
// fieldcelldoublevector
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldcelldoublevectorTS1 =
- pointeMed->getFields()->getFieldWithName("fieldcelldoublevector");
+ dynamic_cast<MEDFileFieldMultiTS *>(pointeMed->getFields()->getFieldWithName("fieldcelldoublevector"));
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldcelldoublevectorTS2 =
- d2->getFields()->getFieldWithName("fieldcelldoublevector");
+ dynamic_cast<MEDFileFieldMultiTS *>(d2->getFields()->getFieldWithName("fieldcelldoublevector"));
CPPUNIT_ASSERT_EQUAL( fieldcelldoublevectorTS1->getInfo().size(), fieldcelldoublevectorTS2->getInfo().size());
for ( size_t i = 0; i < fieldcelldoublevectorTS1->getInfo().size(); ++i )
CPPUNIT_ASSERT_EQUAL( fieldcelldoublevectorTS1->getInfo()[i], fieldcelldoublevectorTS2->getInfo()[i]);
}
// "Field on 2 faces"
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> fieldOnFaces =
- d2->getFields()->getFieldWithName(f1->getName());
+ dynamic_cast<MEDFileFieldMultiTS *>(d2->getFields()->getFieldWithName(f1->getName()));
io1 = fieldOnFaces->getIterations();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> fof =
fieldOnFaces->getFieldOnMeshAtLevel(f1->getTypeOfField(),io1[0].first,io1[0].second,um1);
{
for(int i=0;i<fs->getNumberOfFields();i++)
{
- MEDFileFieldMultiTS *fmts=fs->getFieldAtPos(i);
+ MEDFileFieldMultiTS *fmts=dynamic_cast<MEDFileFieldMultiTS *>(fs->getFieldAtPos(i));
+ if(!fmts) continue;
if(fmts->getMeshName()==meshname)
{
for(int j=0;j<fmts->getNumberOfTS();j++)
{
- MEDFileField1TS *f1ts=fmts->getTimeStepAtPos(j);
+ MEDFileField1TS *f1ts=dynamic_cast<MEDFileField1TS*>(fmts->getTimeStepAtPos(j));
+ if(!f1ts) continue;
DataArrayDouble *arr=f1ts->getUndergroundDataArray();
arr->renumberInPlace(&perm[0]);
}