return true;
}
-void MEDCoupling1SGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+void MEDCoupling1SGTUMesh::checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingPointSet::checkCoherency();
const DataArrayInt *c1(_conn);
if(c1)
{
throw INTERP_KERNEL::Exception("Nodal connectivity array not defined !");
}
+void MEDCoupling1SGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingPointSet::checkCoherency();
+ checkCoherencyOfConnectivity();
+}
+
void MEDCoupling1SGTUMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
{
checkCoherency();
}
}
-/*!
- * If \a this pass this method, you are sure that connectivity arrays are not null, with exactly one component, no name, no component name, allocated.
- * In addition you are sure that the length of nodal connectivity index array is bigger than or equal to one.
- * In addition you are also sure that length of nodal connectivity is coherent with the content of the last value in the index array.
- */
-void MEDCoupling1DGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+void MEDCoupling1DGTUMesh::checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingPointSet::checkCoherency();
const DataArrayInt *c1(_conn);
if(c1)
{
int szOfC1Exp=_conn_indx->back();
if(sz2<szOfC1Exp)
{
- std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::checkCoherency : The expected length of nodal connectivity array regarding index is " << szOfC1Exp << " but the actual size of it is " << c1->getNumberOfTuples() << " !";
+ std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::checkCoherencyOfConnectivity : The expected length of nodal connectivity array regarding index is " << szOfC1Exp << " but the actual size of it is " << c1->getNumberOfTuples() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
+/*!
+ * If \a this pass this method, you are sure that connectivity arrays are not null, with exactly one component, no name, no component name, allocated.
+ * In addition you are sure that the length of nodal connectivity index array is bigger than or equal to one.
+ * In addition you are also sure that length of nodal connectivity is coherent with the content of the last value in the index array.
+ */
+void MEDCoupling1DGTUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingPointSet::checkCoherency();
+ checkCoherencyOfConnectivity();
+}
+
void MEDCoupling1DGTUMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
{
checkCoherency();
int MEDCoupling1DGTUMesh::getNumberOfCells() const
{
- checkCoherency();//do not remove
+ checkCoherencyOfConnectivity();//do not remove
return _conn_indx->getNumberOfTuples()-1;
}
MEDCOUPLING_EXPORT virtual void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual void insertNextCell(const int *nodalConnOfCellBg, const int *nodalConnOfCellEnd) throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual DataArrayInt *getNodalConnectivity() const throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual void checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception) = 0;
protected:
MEDCOUPLING_EXPORT MEDCoupling1GTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm);
MEDCOUPLING_EXPORT MEDCoupling1GTUMesh(const MEDCoupling1GTUMesh& other, bool recDeepCpy);
MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
// overload of MEDCoupling1GTUMesh
+ MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void insertNextCell(const int *nodalConnOfCellBg, const int *nodalConnOfCellEnd) throw(INTERP_KERNEL::Exception);
public://specific
MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
// overload of MEDCoupling1GTUMesh
+ MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void insertNextCell(const int *nodalConnOfCellBg, const int *nodalConnOfCellEnd) throw(INTERP_KERNEL::Exception);
public://specific
*/
MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const
{
- checkFullyDefined();
+ checkConnectivityFullyDefined();
int ncell=getNumberOfCells();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New();
ret->_mesh_dim=_mesh_dim;
*/
std::vector<MEDCouplingUMesh *> MEDCouplingUMesh::splitByType() const
{
- checkFullyDefined();
+ checkConnectivityFullyDefined();
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
int nbOfCells=getNumberOfCells();
INTERP_KERNEL::NormalizedCellType getCellModelEnum() const throw(INTERP_KERNEL::Exception);
int getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception);
virtual void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception);
+ virtual void checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception);
%extend
{
virtual void insertNextCell(PyObject *li) throw(INTERP_KERNEL::Exception)
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,i++)
{
if((const MEDFileUMeshSplitL1 *)(*it))
- ret->_ms[i]=(*it)->deepCpy();
+ ret->_ms[i]=(*it)->deepCpy(ret->_coords);
}
return ret.retn();
}
* \param [in] coords - the new node coordinates array.
* \throw If \a coords == \c NULL.
*/
-
void MEDFileUMesh::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
{
if(!coords)
_fam_coords=DataArrayInt::New();
_fam_coords->alloc(nbOfTuples,1);
_fam_coords->fillWithZero();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::iterator it=_ms.begin();it!=_ms.end();it++)
+ if((MEDFileUMeshSplitL1 *)(*it))
+ (*it)->setCoords(coords);
}
/*!
int MEDFileUMeshPerType::getDim() const
{
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type);
- return cm.getDimension();
+ return _m->getMeshDimension();
}
MEDFileUMeshPerType::MEDFileUMeshPerType(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
- med_entity_type entity, MEDFileMeshReadSelector *mrs):_type(type),_entity(entity)
+ med_entity_type entity, MEDFileMeshReadSelector *mrs):_entity(entity)
{
med_bool changement,transformation;
int curNbOfElem=MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,
&changement,&transformation);
- if(type!=INTERP_KERNEL::NORM_POLYGON && type!=INTERP_KERNEL::NORM_POLYHED)
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ if(!cm.isDynamic())
{
loadFromStaticType(fid,mName,dt,it,mdim,curNbOfElem,geoElt,type,entity,mrs);
return;
void MEDFileUMeshPerType::loadFromStaticType(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
med_entity_type entity, MEDFileMeshReadSelector *mrs)
{
- _conn=DataArrayInt::New();
- int nbOfNodesPerCell=(geoElt%100);
- _conn->alloc((nbOfNodesPerCell+1)*curNbOfElem,1);
- _conn_index=DataArrayInt::New();
- _conn_index->alloc(curNbOfElem+1,1);
- INTERP_KERNEL::AutoPtr<int> connTab=new int[(nbOfNodesPerCell)*curNbOfElem];
- MEDmeshElementConnectivityRd(fid,mName,dt,it,entity,geoElt,MED_NODAL,MED_FULL_INTERLACE,connTab);
+ _m=MEDCoupling1SGTUMesh::New(mName,type);
+ MEDCoupling1SGTUMesh *mc(dynamic_cast<MEDCoupling1SGTUMesh *>((MEDCoupling1GTUMesh *)_m));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New());
+ int nbOfNodesPerCell=mc->getNumberOfNodesPerCell();
+ conn->alloc(nbOfNodesPerCell*curNbOfElem,1);
+ MEDmeshElementConnectivityRd(fid,mName,dt,it,entity,geoElt,MED_NODAL,MED_FULL_INTERLACE,conn->getPointer());
+ std::transform(conn->begin(),conn->end(),conn->getPointer(),std::bind2nd(std::plus<int>(),-1));
+ mc->setNodalConnectivity(conn);
loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
- int *w1=_conn->getPointer();
- int *w2=_conn_index->getPointer();
- *w2++=0;
- const int *wi=connTab;
- for(int i=0;i<curNbOfElem;i++,wi+=nbOfNodesPerCell,w2++)
- {
- *w1++=(int)type;
- w1=std::transform(wi,wi+nbOfNodesPerCell,w1,std::bind2nd(std::plus<int>(),-1));
- *w2=w2[-1]+nbOfNodesPerCell+1;
- }
}
void MEDFileUMeshPerType::loadCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt,
{
med_bool changement,transformation;
med_int curNbOfElem=MEDmeshnEntity(fid,mName,dt,it,entity,MED_POLYGON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)-1;
- _conn_index=DataArrayInt::New();
- _conn_index->alloc(curNbOfElem+1,1);
- _conn=DataArrayInt::New();
- _conn->alloc(arraySize+curNbOfElem,1);
- INTERP_KERNEL::AutoPtr<int> locConn=new int[arraySize];
- MEDmeshPolygonRd(fid,mName,dt,it,MED_CELL,MED_NODAL,_conn_index->getPointer(),locConn);
- int *w1=_conn->getPointer();
- int *w2=_conn_index->getPointer();
- const int *wi=locConn;
- for(int i=0;i<curNbOfElem;i++,w2++)
- {
- *w1++=(int)INTERP_KERNEL::NORM_POLYGON;
- const int *wi2=wi+(w2[1]-w2[0]);
- w1=std::transform(wi,wi2,w1,std::bind2nd(std::plus<int>(),-1));
- wi=wi2;
- *w2=*w2-1+i;
- }
- *w2=*w2-1+curNbOfElem;
+ _m=MEDCoupling1DGTUMesh::New(mName,INTERP_KERNEL::NORM_POLYGON);
+ MEDCoupling1DGTUMesh *mc(dynamic_cast<MEDCoupling1DGTUMesh *>((MEDCoupling1GTUMesh *)_m));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New());
+ conn->alloc(arraySize,1); connI->alloc(curNbOfElem+1,1);
+ MEDmeshPolygonRd(fid,mName,dt,it,MED_CELL,MED_NODAL,connI->getPointer(),conn->getPointer());
+ std::transform(conn->begin(),conn->end(),conn->getPointer(),std::bind2nd(std::plus<int>(),-1));
+ std::transform(connI->begin(),connI->end(),connI->getPointer(),std::bind2nd(std::plus<int>(),-1));
+ mc->setNodalConnectivity(conn,connI);
loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,MED_POLYGON,entity,mrs);
}
med_bool changement,transformation;
med_int indexFaceLgth=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,MED_POLYHEDRON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation);
int curNbOfElem=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,MED_POLYHEDRON,MED_INDEX_FACE,MED_NODAL,&changement,&transformation)-1;
+ _m=MEDCoupling1DGTUMesh::New(mName,INTERP_KERNEL::NORM_POLYHED);
+ MEDCoupling1DGTUMesh *mc(dynamic_cast<MEDCoupling1DGTUMesh *>((MEDCoupling1GTUMesh *)_m));
INTERP_KERNEL::AutoPtr<int> index=new int[curNbOfElem+1];
INTERP_KERNEL::AutoPtr<int> indexFace=new int[indexFaceLgth];
INTERP_KERNEL::AutoPtr<int> locConn=new int[connFaceLgth];
MEDmeshPolyhedronRd(fid,mName,dt,it,MED_CELL,MED_NODAL,index,indexFace,locConn);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New());
int arraySize=connFaceLgth;
for(int i=0;i<curNbOfElem;i++)
arraySize+=index[i+1]-index[i]-1;
- _conn=DataArrayInt::New();
- _conn->alloc(arraySize+curNbOfElem,1);
- int *wFinalConn=_conn->getPointer();
- _conn_index=DataArrayInt::New();
- _conn_index->alloc(curNbOfElem+1,1);
- int *finalIndex=_conn_index->getPointer();
+ conn=DataArrayInt::New();
+ conn->alloc(arraySize,1);
+ int *wFinalConn=conn->getPointer();
+ connI->alloc(curNbOfElem+1,1);
+ int *finalIndex(connI->getPointer());
finalIndex[0]=0;
for(int i=0;i<curNbOfElem;i++)
{
- *wFinalConn++=(int)INTERP_KERNEL::NORM_POLYHED;
- finalIndex[i+1]=finalIndex[i]+index[i+1]-index[i]-1+indexFace[index[i+1]-1]-indexFace[index[i]-1]+1;
+ finalIndex[i+1]=finalIndex[i]+index[i+1]-index[i]-1+indexFace[index[i+1]-1]-indexFace[index[i]-1];
wFinalConn=std::transform(locConn+indexFace[index[i]-1]-1,locConn+indexFace[index[i]]-1,wFinalConn,std::bind2nd(std::plus<int>(),-1));
for(int j=index[i];j<index[i+1]-1;j++)
{
wFinalConn=std::transform(locConn+indexFace[j]-1,locConn+indexFace[j+1]-1,wFinalConn,std::bind2nd(std::plus<int>(),-1));
}
}
+ mc->setNodalConnectivity(conn,connI);
loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,MED_POLYHEDRON,entity,mrs);
}
-void MEDFileUMeshPerType::write(med_idt fid, const char *mname, int mdim, const MEDCouplingUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names)
+void MEDFileUMeshPerType::Write(med_idt fid, const char *mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names)
{
int nbOfCells=m->getNumberOfCells();
if(nbOfCells<1)
INTERP_KERNEL::NormalizedCellType ikt=m->getTypeOfCell(0);
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(ikt);
med_geometry_type curMedType=typmai3[(int)ikt];
- const int *conn=m->getNodalConnectivity()->getConstPointer();
- const int *connI=m->getNodalConnectivityIndex()->getConstPointer();
- if(ikt!=INTERP_KERNEL::NORM_POLYGON && ikt!=INTERP_KERNEL::NORM_POLYHED)
+ if(!cm.isDynamic())
{
- int nbNodesPerCell=cm.getNumberOfNodes();
- INTERP_KERNEL::AutoPtr<int> tab=new int[nbNodesPerCell*nbOfCells];
- int *w=tab;
- for(int i=0;i<nbOfCells;i++)
- w=std::transform(conn+connI[i]+1,conn+connI[i+1],w,std::bind2nd(std::plus<int>(),1));
- MEDmeshElementConnectivityWr(fid,mname,dt,it,timm,MED_CELL,curMedType,MED_NODAL,MED_FULL_INTERLACE,nbOfCells,tab);
+ const MEDCoupling1SGTUMesh *m0(dynamic_cast<const MEDCoupling1SGTUMesh *>(m));
+ if(!m0)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::Write : internal error #1 !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(m0->getNodalConnectivity()->deepCpy());
+ std::transform(arr->begin(),arr->end(),arr->getPointer(),std::bind2nd(std::plus<int>(),1));
+ MEDmeshElementConnectivityWr(fid,mname,dt,it,timm,MED_CELL,curMedType,MED_NODAL,MED_FULL_INTERLACE,nbOfCells,arr->begin());
}
else
{
+ const MEDCoupling1DGTUMesh *m0(dynamic_cast<const MEDCoupling1DGTUMesh *>(m));
+ if(!m0)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::Write : internal error #2 !");
if(ikt==INTERP_KERNEL::NORM_POLYGON)
{
- INTERP_KERNEL::AutoPtr<int> tab1=new int[nbOfCells+1];
- INTERP_KERNEL::AutoPtr<int> tab2=new int[m->getMeshLength()];
- int *wI=tab1; *wI=1;
- int *w=tab2;
- for(int i=0;i<nbOfCells;i++,wI++)
- {
- wI[1]=wI[0]+connI[i+1]-connI[i]-1;
- w=std::transform(conn+connI[i]+1,conn+connI[i+1],w,std::bind2nd(std::plus<int>(),1));
- }
- MEDmeshPolygonWr(fid,mname,dt,it,timm,MED_CELL,MED_NODAL,nbOfCells+1,tab1,tab2);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(m0->getNodalConnectivity()->deepCpy()),arrI(m0->getNodalConnectivityIndex()->deepCpy());
+ std::transform(arr->begin(),arr->end(),arr->getPointer(),std::bind2nd(std::plus<int>(),1));
+ std::transform(arrI->begin(),arrI->end(),arrI->getPointer(),std::bind2nd(std::plus<int>(),1));
+ MEDmeshPolygonWr(fid,mname,dt,it,timm,MED_CELL,MED_NODAL,nbOfCells+1,arrI->begin(),arr->begin());
}
else
{
- int meshLgth=m->getMeshLength();
+ const int *conn(m0->getNodalConnectivity()->begin()),*connI(m0->getNodalConnectivityIndex()->begin());
+ int meshLgth=m0->getNodalConnectivityLength();
int nbOfFaces=std::count(conn,conn+meshLgth,-1)+nbOfCells;
INTERP_KERNEL::AutoPtr<int> tab1=new int[nbOfCells+1];
int *w1=tab1; *w1=1;
INTERP_KERNEL::AutoPtr<int> tab2=new int[nbOfFaces+1];
int *w2=tab2; *w2=1;
- INTERP_KERNEL::AutoPtr<int> bigtab=new int[meshLgth-nbOfCells];
+ INTERP_KERNEL::AutoPtr<int> bigtab=new int[meshLgth];
int *bt=bigtab;
for(int i=0;i<nbOfCells;i++,w1++)
{
int nbOfFaces2=0;
- for(const int *w=conn+connI[i]+1;w!=conn+connI[i+1];w2++)
+ for(const int *w=conn+connI[i];w!=conn+connI[i+1];w2++)
{
const int *wend=std::find(w,conn+connI[i+1],-1);
bt=std::transform(w,wend,bt,std::bind2nd(std::plus<int>(),1));
#define __MEDFILEMESHELT_HXX__
#include "MEDCouplingMemArray.hxx"
+#include "MEDCoupling1GTUMesh.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
#include "NormalizedUnstructuredMesh.hxx"
static bool isExisting(med_idt fid, const char *mName, int dt, int it, med_geometry_type geoElt, med_entity_type& whichEntity);
std::size_t getHeapMemorySize() const { return 0; }
int getDim() const;
- const DataArrayInt *getNodal() const { return _conn; }
- const DataArrayInt *getNodalIndex() const { return _conn_index; }
+ MEDCoupling1GTUMesh *getMesh() const { return const_cast<MEDCoupling1GTUMesh *>((const MEDCoupling1GTUMesh *)_m); }
const DataArrayInt *getFam() const { return _fam; }
const DataArrayInt *getNum() const { return _num; }
const DataArrayAsciiChar *getNames() const { return _names; }
- static void write(med_idt fid, const char *mname, int mdim, const MEDCouplingUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names);
+ static void Write(med_idt fid, const char *mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names);
private:
MEDFileUMeshPerType(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
med_entity_type entity, MEDFileMeshReadSelector *mrs);
med_entity_type entity, MEDFileMeshReadSelector *mrs);
void loadCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs);
private:
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn_index;
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> _m;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names;
- INTERP_KERNEL::NormalizedCellType _type;
med_entity_type _entity;
};
}
*/
MEDFileUMeshPermCompute::operator MEDCouplingUMesh *() const
{
- _st->_m_by_types->updateTime();
_st->_num->updateTime();
if((MEDCouplingUMesh *)_m==0)
{
updateTime();
- _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types->deepCpy());
+ _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types.getUmesh()->deepCpy());
_m->renumberCells(_st->_num->getConstPointer(),true);
return _m.retn();
}
else
{
- if(_mpt_time==_st->_m_by_types->getTimeOfThis() && _num_time==_st->_num->getTimeOfThis())
+ if(_mpt_time==_st->_m_by_types.getTimeOfThis() && _num_time==_st->_num->getTimeOfThis())
return _m.retn();
else
{
updateTime();
- _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types->deepCpy());
+ _m=static_cast<MEDCouplingUMesh *>(_st->_m_by_types.getUmesh()->deepCpy());
_m->renumberCells(_st->_num->getConstPointer(),true);
return _m.retn();
}
void MEDFileUMeshPermCompute::updateTime() const
{
- _mpt_time=_st->_m_by_types->getTimeOfThis();
+ _mpt_time=_st->_m_by_types.getTimeOfThis();
_num_time=_st->_num->getTimeOfThis();
}
if(v.empty())
return;
int sz=v.size();
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msMSafe(sz);
- std::vector<const MEDCouplingUMesh *> ms(sz);
+ std::vector<const MEDCoupling1GTUMesh *> ms(sz);
+ std::vector<const DataArrayInt *> fams(sz),nums(sz);
+ std::vector<const DataArrayChar *> names(sz);
for(int i=0;i<sz;i++)
{
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp=MEDCouplingUMesh::New("",v[i]->getDim());
+ MEDCoupling1GTUMesh *elt(v[i]->getMesh());
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=l2.getCoords();
- tmp->setCoords(tmp2);
- tmp->setConnectivity(const_cast<DataArrayInt *>(v[i]->getNodal()),const_cast<DataArrayInt *>(v[i]->getNodalIndex()));
- ms[i]=tmp; msMSafe[i]=tmp;
+ elt->setCoords(tmp2);
+ ms[i]=elt;
}
- _m_by_types=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms);
- _m_by_types->setName(mName);
+ _m_by_types.assignParts(ms);
if(l2.isFamDefinedOnLev(id))
{
- int nbOfCells=_m_by_types->getNumberOfCells();
- _fam=DataArrayInt::New();
- _fam->alloc(nbOfCells,1);
- int *w=_fam->getPointer();
for(int i=0;i<sz;i++)
- w=std::copy(v[i]->getFam()->getConstPointer(),v[i]->getFam()->getConstPointer()+v[i]->getFam()->getNumberOfTuples(),w);
+ fams[i]=v[i]->getFam();
+ _fam=DataArrayInt::Aggregate(fams);
}
if(l2.isNumDefinedOnLev(id))
{
- int nbOfCells=_m_by_types->getNumberOfCells();
- _num=DataArrayInt::New();
- _num->alloc(nbOfCells,1);
- int *w=_num->getPointer();
for(int i=0;i<sz;i++)
- w=std::copy(v[i]->getNum()->getConstPointer(),v[i]->getNum()->getConstPointer()+v[i]->getNum()->getNumberOfTuples(),w);
+ nums[i]=v[i]->getNum();
+ _num=DataArrayInt::Aggregate(nums);
computeRevNum();
}
if(l2.isNamesDefinedOnLev(id))
{
- int nbOfCells=_m_by_types->getNumberOfCells();
- _names=DataArrayAsciiChar::New();
- _names->alloc(nbOfCells,MED_SNAME_SIZE);
- char *w=_names->getPointer();
for(int i=0;i<sz;i++)
- w=std::copy(v[i]->getNames()->getConstPointer(),v[i]->getNames()->getConstPointer()+v[i]->getNames()->getNbOfElems(),w);
+ names[i]=v[i]->getNames();
+ _names=dynamic_cast<DataArrayAsciiChar *>(DataArrayChar::Aggregate(names));
}
}
std::size_t MEDFileUMeshSplitL1::getHeapMemorySize() const
{
std::size_t ret=0;
- if((const MEDCouplingUMesh *)_m_by_types)
- {
- ret+=_m_by_types->getHeapMemorySize();
- if((const DataArrayDouble *)_m_by_types->getCoords())
- ret-=_m_by_types->getCoords()->getHeapMemorySize();
- }
+ ret+=_m_by_types.getHeapMemorySize();
if((const DataArrayInt*)_fam)
ret+=_fam->getHeapMemorySize();
if((const DataArrayInt*)_num)
return ret;
}
-MEDFileUMeshSplitL1 *MEDFileUMeshSplitL1::deepCpy() const
+MEDFileUMeshSplitL1 *MEDFileUMeshSplitL1::deepCpy(DataArrayDouble *coords) const
{
MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> ret=new MEDFileUMeshSplitL1(*this);
- if((const MEDCouplingUMesh*)_m_by_types)
- ret->_m_by_types=static_cast<MEDCouplingUMesh*>(_m_by_types->deepCpy());
+ ret->_m_by_types=_m_by_types.deepCpy(coords);
if((const DataArrayInt *)_fam)
ret->_fam=_fam->deepCpy();
if((const DataArrayInt *)_num)
bool MEDFileUMeshSplitL1::isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const
{
- const MEDCouplingUMesh *m1=_m_by_types;
- const MEDCouplingUMesh *m2=other->_m_by_types;
- if((m1==0 && m2!=0) || (m1!=0 && m2==0))
- {
- what="Presence of mesh in one sublevel and not in other!";
- return false;
- }
- if(m1)
- if(!m1->isEqual(m2,eps))
- {
- what="meshes at a sublevel are not deeply equal !";
- return false;
- }
+ if(!_m_by_types.isEqual(other->_m_by_types,eps,what))
+ return false;
const DataArrayInt *d1=_fam;
const DataArrayInt *d2=other->_fam;
if((d1==0 && d2!=0) || (d1!=0 && d2==0))
void MEDFileUMeshSplitL1::synchronizeTinyInfo(const MEDFileMesh& master) const
{
- const MEDCouplingUMesh *tmp=_m_by_types;
- if(!tmp)
- return ;
- (const_cast<MEDCouplingUMesh *>(tmp))->setName(master.getName());
- (const_cast<MEDCouplingUMesh *>(tmp))->setDescription(master.getDescription());
- (const_cast<MEDCouplingUMesh *>(tmp))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
- (const_cast<MEDCouplingUMesh *>(tmp))->setTimeUnit(master.getTimeUnit());
+ _m_by_types.synchronizeTinyInfo(master);
}
void MEDFileUMeshSplitL1::clearNonDiscrAttributes() const
{
- ClearNonDiscrAttributes(_m_by_types);
+ _m_by_types.clearNonDiscrAttributes();
}
void MEDFileUMeshSplitL1::ClearNonDiscrAttributes(const MEDCouplingMesh *tmp)
(const_cast<MEDCouplingMesh *>(tmp))->setTimeUnit("");
}
+void MEDFileUMeshSplitL1::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
+{
+ _m_by_types.setCoords(coords);
+}
+
void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
{
if(newOrOld)
{
m->incrRef();
_m=m;
- _m_by_types=(MEDCouplingUMesh *)m->deepCpy();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
+ _m_by_types.assignUMesh(dynamic_cast<MEDCouplingUMesh *>(m->deepCpy()));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types.getUmesh()->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
if(!da->isIdentity())
{
_num=da->invertArrayO2N2N2O(m->getNumberOfCells());
_m.updateTime();
computeRevNum();
- _m_by_types->renumberCells(da->getConstPointer(),false);
+ _m_by_types.getUmesh()->renumberCells(da->getConstPointer(),false);
}
}
else
if(!m->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_N_CELL_FIXED_GEO))
throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::assignMesh : the mode of mesh setting expects to follow the MED file numbering convention ! it is not the case !");
m->incrRef();
- _m_by_types=m;
+ _m_by_types.assignUMesh(m);
}
_fam=DataArrayInt::New();
_fam->alloc(m->getNumberOfCells(),1);
bool MEDFileUMeshSplitL1::empty() const
{
- return ((const MEDCouplingUMesh *)_m_by_types)==0;
+ return _m_by_types.empty();
}
bool MEDFileUMeshSplitL1::presenceOfOneFams(const std::vector<int>& ids) const
int MEDFileUMeshSplitL1::getMeshDimension() const
{
- return _m_by_types->getMeshDimension();
+ return _m_by_types.getMeshDimension();
}
void MEDFileUMeshSplitL1::simpleRepr(std::ostream& oss) const
{
- std::vector<int> code=_m_by_types->getDistributionOfTypes();
+ std::vector<int> code=_m_by_types.getDistributionOfTypes();
int nbOfTypes=code.size()/3;
for(int i=0;i<nbOfTypes;i++)
{
int MEDFileUMeshSplitL1::getSize() const throw(INTERP_KERNEL::Exception)
{
- if((const MEDCouplingUMesh *)_m_by_types==0)
- throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::getSize : no mesh specified at level !");
- return _m_by_types->getNumberOfCells();
+ return _m_by_types.getSize();
}
MEDCouplingUMesh *MEDFileUMeshSplitL1::getFamilyPart(const int *idsBg, const int *idsEnd, bool renum) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsToKeep=_fam->getIdsEqualList(idsBg,idsEnd);
- MEDCouplingUMesh *m=(MEDCouplingUMesh *)_m_by_types->buildPartOfMySelf(eltsToKeep->getConstPointer(),eltsToKeep->getConstPointer()+eltsToKeep->getNumberOfTuples(),true);
+ MEDCouplingUMesh *m=(MEDCouplingUMesh *)_m_by_types.getUmesh()->buildPartOfMySelf(eltsToKeep->getConstPointer(),eltsToKeep->getConstPointer()+eltsToKeep->getNumberOfTuples(),true);
if(renum)
return renumIfNeeded(m,eltsToKeep->getConstPointer());
return m;
if(renum && ((const DataArrayInt *)_num))
tmp=_m;
else
- tmp=_m_by_types;
+ { tmp=_m_by_types.getUmesh(); if(tmp) tmp->incrRef(); }
return tmp.retn();
}
{
if((DataArrayInt *)_fam)
return _fam;
- MEDCouplingUMesh *m(_m_by_types);
- if(!m)
- throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::getOrCreateAndGetFamilyField : impossible to create a family field array because no mesh specified on this level !");
- int nbOfTuples=m->getNumberOfCells();
+ int nbOfTuples=_m_by_types.getSize();
_fam=DataArrayInt::New(); _fam->alloc(nbOfTuples,1); _fam->fillWithZero();
return _fam;
}
void MEDFileUMeshSplitL1::write(med_idt fid, const char *mName, int mdim) const
{
- std::vector<MEDCouplingUMesh *> ms=_m_by_types->splitByType();
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msMSafe(ms.begin(),ms.end());
+ std::vector<MEDCoupling1GTUMesh *> ms(_m_by_types.getParts());
int start=0;
- for(std::vector<MEDCouplingUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
+ for(std::vector<MEDCoupling1GTUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
{
int nbCells=(*it)->getNumberOfCells();
int end=start+nbCells;
num=_num->substr(start,end);
if((const DataArrayAsciiChar *)_names)
names=static_cast<DataArrayAsciiChar *>(_names->substr(start,end));
- MEDFileUMeshPerType::write(fid,mName,mdim,(*it),fam,num,names);
+ MEDFileUMeshPerType::Write(fid,mName,mdim,(*it),fam,num,names);
start=end;
}
}
void MEDFileUMeshSplitL1::renumberNodesInConn(const int *newNodeNumbersO2N) throw(INTERP_KERNEL::Exception)
{
- MEDCouplingUMesh *m(_m_by_types);
+ MEDCouplingUMesh *m(_m_by_types.getUmesh());
if(!m)
return;
m->renumberNodesInConn(newNodeNumbersO2N);
_fam=0;
return ;
}
- MEDCouplingUMesh *mbt(_m_by_types);
- if(!mbt)
- throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::setFamilyArr : no mesh defined on this level !");
- famArr->checkNbOfTuplesAndComp(mbt->getNumberOfCells(),1,"MEDFileUMeshSplitL1::setFamilyArr : Problem in size of Family arr ! ");
+ int sz(_m_by_types.getSize());
+ famArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setFamilyArr : Problem in size of Family arr ! ");
famArr->incrRef();
_fam=famArr;
}
_rev_num=0;
return ;
}
- MEDCouplingUMesh *mbt(_m_by_types);
- if(!mbt)
- throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::setRenumArr : no mesh defined on this level !");
- renumArr->checkNbOfTuplesAndComp(mbt->getNumberOfCells(),1,"MEDFileUMeshSplitL1::setRenumArr : Problem in size of numbering arr ! ");
+ int sz(_m_by_types.getSize());
+ renumArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setRenumArr : Problem in size of numbering arr ! ");
renumArr->incrRef();
_num=renumArr;
computeRevNum();
_names=0;
return ;
}
- MEDCouplingUMesh *mbt(_m_by_types);
- if(!mbt)
- throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::setNameArr : no mesh defined on this level !");
- nameArr->checkNbOfTuplesAndComp(mbt->getNumberOfCells(),MED_SNAME_SIZE,"MEDFileUMeshSplitL1::setNameArr : Problem in size of name arr ! ");
+ int sz(_m_by_types.getSize());
+ nameArr->checkNbOfTuplesAndComp(sz,MED_SNAME_SIZE,"MEDFileUMeshSplitL1::setNameArr : Problem in size of name arr ! ");
nameArr->incrRef();
_names=nameArr;
}
std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams)
{
std::set<int> allfids;
-
+ //tony
}
void MEDFileUMeshSplitL1::computeRevNum() const
int maxValue=_num->getMaxValue(pos);
_rev_num=_num->invertArrayN2O2O2N(maxValue+1);
}
+
+//=
+
+MEDFileUMeshAggregateCompute::MEDFileUMeshAggregateCompute():_mp_time(0),_m_time(0)
+{
+}
+
+void MEDFileUMeshAggregateCompute::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
+{
+ std::size_t sz(mParts.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDCoupling1GTUMesh *elt(mParts[i]);
+ if(!elt)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::assignParts : presence of null pointer !");
+ ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt); elt->incrRef();
+ }
+ _m_parts=ret;
+ _mp_time=std::max(_mp_time,_m_time)+1;
+ _m=0;
+}
+
+void MEDFileUMeshAggregateCompute::assignUMesh(MEDCouplingUMesh *m)
+{
+ _m=m;
+ _m_parts.clear();
+ _m_time=std::max(_mp_time,_m_time)+1;
+}
+
+MEDCouplingUMesh *MEDFileUMeshAggregateCompute::getUmesh() const
+{
+ if(_mp_time<=_m_time)
+ return _m;
+ std::vector< const MEDCoupling1GTUMesh *> mp(_m_parts.size());
+ std::copy(_m_parts.begin(),_m_parts.end(),mp.begin());
+ _m=MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(mp);
+ _m_parts.clear();//to avoid memory peak !
+ _m_time=_mp_time+1;//+1 is important ! That is to say that only _m is OK not _m_parts because cleared !
+ return _m;
+}
+
+std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getParts() const
+{
+ if(_mp_time>=_m_time)
+ {
+ std::vector<MEDCoupling1GTUMesh *> ret(_m_parts.size());
+ std::size_t i(0);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++,i++)
+ {
+ const MEDCoupling1GTUMesh *elt(*it);
+ ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt);
+ }
+ return ret;
+ }
+ forceComputationOfPartsFromUMesh();
+ std::vector<MEDCoupling1GTUMesh *> ret(_m_parts.size());
+ std::size_t i(0);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++,i++)
+ {
+ const MEDCoupling1GTUMesh *elt(*it);
+ ret[i]=const_cast<MEDCoupling1GTUMesh *>(elt);
+ }
+ return ret;
+}
+
+void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const
+{
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh : null UMesh !");
+ std::vector<MEDCouplingUMesh *> ms(m->splitByType());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msMSafe(ms.begin(),ms.end());
+ std::size_t sz(msMSafe.size());
+ _m_parts.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ _m_parts[i]=MEDCoupling1GTUMesh::New(ms[i]);
+ _mp_time=std::max(_mp_time,_m_time)+1;
+}
+
+std::size_t MEDFileUMeshAggregateCompute::getTimeOfThis() const
+{
+ if(_mp_time>_m_time)
+ return getTimeOfParts();
+ if(_m_time>_mp_time)
+ return getTimeOfUMesh();
+ return std::max(getTimeOfParts(),getTimeOfUMesh());
+}
+
+std::size_t MEDFileUMeshAggregateCompute::getTimeOfParts() const
+{
+ std::size_t ret(0);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *elt(*it);
+ if(!elt)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : null obj in parts !");
+ ret=std::max(ret,elt->getTimeOfThis());
+ }
+ if(ret==0)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : parts is empty !");
+ return ret;
+}
+
+std::size_t MEDFileUMeshAggregateCompute::getTimeOfUMesh() const
+{
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfUMesh : unmesh is null !");
+ return m->getTimeOfThis();
+}
+
+/*!
+ * Coordinates pointer is not counted because father instance already count it !
+ */
+std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySize() const
+{
+ std::size_t ret(0);
+ ret+=_m_parts.size()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>);
+ std::size_t sz(_m_parts.size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDCoupling1GTUMesh *pt(_m_parts[i]);
+ if(pt)
+ {
+ ret+=pt->getHeapMemorySize();
+ const DataArrayDouble *coo(pt->getCoords());
+ if(coo)
+ ret-=coo->getHeapMemorySize();
+ }
+ }
+ const MEDCouplingUMesh *m(_m);
+ if(m)
+ {
+ ret+=m->getHeapMemorySize();
+ const DataArrayDouble *coo(m->getCoords());
+ if(coo)
+ ret-=coo->getHeapMemorySize();
+ }
+ return ret;
+}
+
+MEDFileUMeshAggregateCompute MEDFileUMeshAggregateCompute::deepCpy(DataArrayDouble *coords) const
+{
+ MEDFileUMeshAggregateCompute ret;
+ ret._m_parts.resize(_m_parts.size());
+ for(std::size_t i=0;i<_m_parts.size();i++)
+ {
+ const MEDCoupling1GTUMesh *elt(_m_parts[i]);
+ if(elt)
+ {
+ ret._m_parts[i]=static_cast<ParaMEDMEM::MEDCoupling1GTUMesh*>(elt->deepCpy());
+ ret._m_parts[i]->setCoords(coords);
+ }
+ }
+ ret._mp_time=_mp_time; ret._m_time=_m_time;
+ if((const MEDCouplingUMesh *)_m)
+ {
+ ret._m=static_cast<ParaMEDMEM::MEDCouplingUMesh*>(_m->deepCpy());
+ ret._m->setCoords(coords);
+ }
+ return ret;
+}
+
+bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const
+{
+ const MEDCouplingUMesh *m1(getUmesh());
+ const MEDCouplingUMesh *m2(other.getUmesh());
+ if((m1==0 && m2!=0) || (m1!=0 && m2==0))
+ {
+ what="Presence of mesh in one sublevel and not in other!";
+ return false;
+ }
+ if(m1)
+ {
+ std::string what2;
+ if(!m1->isEqualIfNotWhy(m2,eps,what2))
+ {
+ what=std::string("meshes at a sublevel are not deeply equal (")+what2+std::string(")!");
+ return false;
+ }
+ }
+ return true;
+}
+
+void MEDFileUMeshAggregateCompute::clearNonDiscrAttributes() const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ MEDFileUMeshSplitL1::ClearNonDiscrAttributes(*it);
+ MEDFileUMeshSplitL1::ClearNonDiscrAttributes(_m);
+}
+
+void MEDFileUMeshAggregateCompute::synchronizeTinyInfo(const MEDFileMesh& master) const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *tmp(*it);
+ if(tmp)
+ {
+ (const_cast<MEDCoupling1GTUMesh *>(tmp))->setName(master.getName());
+ (const_cast<MEDCoupling1GTUMesh *>(tmp))->setDescription(master.getDescription());
+ (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
+ (const_cast<MEDCoupling1GTUMesh *>(tmp))->setTimeUnit(master.getTimeUnit());
+ }
+ }
+ const MEDCouplingUMesh *m(_m);
+ if(m)
+ {
+ (const_cast<MEDCouplingUMesh *>(m))->setName(master.getName());
+ (const_cast<MEDCouplingUMesh *>(m))->setDescription(master.getDescription());
+ (const_cast<MEDCouplingUMesh *>(m))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
+ (const_cast<MEDCouplingUMesh *>(m))->setTimeUnit(master.getTimeUnit());
+ }
+}
+
+bool MEDFileUMeshAggregateCompute::empty() const
+{
+ if(_mp_time<_m_time)
+ return ((const MEDCouplingUMesh *)_m)==0;
+ //else _mp_time>=_m_time)
+ return _m_parts.empty();
+
+}
+
+int MEDFileUMeshAggregateCompute::getMeshDimension() const
+{
+ if(_mp_time<_m_time)
+ {
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : no umesh in this !");
+ return m->getMeshDimension();
+ }
+ else
+ {
+ if(_m_parts.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh is empty !");
+ const MEDCoupling1GTUMesh *m(_m_parts[0]);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getMeshDimension : part mesh contains null instance !");
+ return m->getMeshDimension();
+ }
+}
+
+std::vector<int> MEDFileUMeshAggregateCompute::getDistributionOfTypes() const
+{
+ if(_mp_time<_m_time)
+ {
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : no umesh in this !");
+ return m->getDistributionOfTypes();
+ }
+ else
+ {
+ std::vector<int> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *tmp(*it);
+ if(!tmp)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : part mesh contains null instance !");
+ std::vector<int> ret0(tmp->getDistributionOfTypes());
+ ret.insert(ret.end(),ret0.begin(),ret0.end());
+ }
+ return ret;
+ }
+}
+
+int MEDFileUMeshAggregateCompute::getSize() const throw(INTERP_KERNEL::Exception)
+{
+ if(_mp_time<_m_time)
+ {
+ const MEDCouplingUMesh *m(_m);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : no umesh in this !");
+ return m->getNumberOfCells();
+ }
+ else
+ {
+ int ret=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *m(*it);
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : part mesh contains null instance !");
+ ret+=m->getNumberOfCells();
+ }
+ return ret;
+ }
+}
+
+void MEDFileUMeshAggregateCompute::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ MEDCoupling1GTUMesh *tmp(*it);
+ if(tmp)
+ (*it)->setCoords(coords);
+ }
+ MEDCouplingUMesh *m(_m);
+ if(m)
+ m->setCoords(coords);
+}
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingCMesh.hxx"
+#include "MEDCoupling1GTUMesh.hxx"
#include "MEDCouplingCurveLinearMesh.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
void updateTime() const;
private:
const MEDFileUMeshSplitL1 *_st;
- mutable unsigned int _mpt_time;
- mutable unsigned int _num_time;
+ mutable std::size_t _mpt_time;
+ mutable std::size_t _num_time;
mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
};
+ class MEDFileUMeshAggregateCompute
+ {
+ public:
+ MEDFileUMeshAggregateCompute();
+ void assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts);
+ void assignUMesh(MEDCouplingUMesh *m);
+ MEDCouplingUMesh *getUmesh() const;
+ std::vector<MEDCoupling1GTUMesh *> getParts() const;
+ std::size_t getTimeOfThis() const;
+ std::size_t getHeapMemorySize() const;
+ MEDFileUMeshAggregateCompute deepCpy(DataArrayDouble *coords) const;
+ bool isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const;
+ void clearNonDiscrAttributes() const;
+ void synchronizeTinyInfo(const MEDFileMesh& master) const;
+ bool empty() const;
+ int getMeshDimension() const;
+ std::vector<int> getDistributionOfTypes() const;
+ int getSize() const throw(INTERP_KERNEL::Exception);
+ void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
+ private:
+ void forceComputationOfPartsFromUMesh() const;
+ std::size_t getTimeOfParts() const;
+ std::size_t getTimeOfUMesh() const;
+ private:
+ mutable std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > _m_parts;
+ mutable std::size_t _mp_time;
+ mutable std::size_t _m_time;
+ mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
+ };
+
class MEDFileUMeshSplitL1 : public RefCountObject
{
friend class MEDFileUMeshPermCompute;
MEDFileUMeshSplitL1(MEDCouplingUMesh *m);
MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld);
std::size_t getHeapMemorySize() const;
- MEDFileUMeshSplitL1 *deepCpy() const;
+ MEDFileUMeshSplitL1 *deepCpy(DataArrayDouble *coords) const;
+ void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const;
void clearNonDiscrAttributes() const;
void synchronizeTinyInfo(const MEDFileMesh& master) const;
DataArrayInt *renumIfNeededArr(const DataArrayInt *da) const;
void computeRevNum() const;
private:
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m_by_types;
+ MEDFileUMeshAggregateCompute _m_by_types;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names;
mm.write(fname,2)
##
mm=MEDFileMesh.New(fname,"mesh",-1,-1,MEDFileMeshReadSelector())
+ b4_ref_heap_mem=mm.getHeapMemorySize()
+ mm.getMeshAtLevel(0)## please let this line : force to move 1GTUMesh -> UMesh
+ mm.getMeshAtLevel(-1)## please let this line : force to move 1GTUMesh -> UMesh
ref_heap_mem=mm.getHeapMemorySize()
+ # check the gain of memory using 1GTUMesh instead of UMesh
+ self.assertTrue(ref_heap_mem-b4_ref_heap_mem>=(32+9)*4*2-32)# 32+9=nbCells 4=sizeof(int) 2=the types+index -32=loss linked to vector
#
mm=MEDFileMesh.New(fname,MEDFileMeshReadSelector(0))
self.assertEqual(len(mm.getGroupsNames()),0)