std::ostringstream oss; oss << "Trying to load as unstructured an existing mesh with name '" << mName << "' !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- loaderl2.loadAll(fid,mid,mName,dt,it);
+ loaderl2.loadAll(fid,mid,mName,dt,it,mrs);
int lev=loaderl2.getNumberOfLevels();
_ms.resize(lev);
for(int i=0;i<lev;i++)
else
_ms[i]=0;
}
- MEDFileMeshL2::ReadFamiliesAndGrps(fid,mName,_families,_groups);
+ MEDFileMeshL2::ReadFamiliesAndGrps(fid,mName,_families,_groups,mrs);
//
setName(loaderl2.getName());
setDescription(loaderl2.getDescription());
setTimeValue(loaderl2.getTime());
setTimeUnit(loaderl2.getTimeUnit());
_coords=loaderl2.getCoords();
- _fam_coords=loaderl2.getCoordsFamily();
- _num_coords=loaderl2.getCoordsNum();
- _name_coords=loaderl2.getCoordsName();
+ if(!mrs || mrs->isNodeFamilyFieldReading())
+ _fam_coords=loaderl2.getCoordsFamily();
+ if(!mrs || mrs->isNodeNumFieldReading())
+ _num_coords=loaderl2.getCoordsNum();
+ if(!mrs || mrs->isNodeNameFieldReading())
+ _name_coords=loaderl2.getCoordsName();
computeRevNum();
}
return geoTypeReq;
}
-void MEDFileStructuredMesh::loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+void MEDFileStructuredMesh::loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception)
{
setName(strm->getName());
setDescription(strm->getDescription());
setOrder(strm->getOrder());
setTimeValue(strm->getTime());
setTimeUnit(strm->getTimeUnit());
- MEDFileMeshL2::ReadFamiliesAndGrps(fid,mName,_families,_groups);
+ MEDFileMeshL2::ReadFamiliesAndGrps(fid,mName,_families,_groups,mrs);
med_bool chgt=MED_FALSE,trsf=MED_FALSE;
int nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_FAMILY_NUMBER,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
- _fam_nodes=DataArrayInt::New();
- _fam_nodes->alloc(nbOfElt,1);
- MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NONE,_fam_nodes->getPointer());
+ if(!mrs || mrs->isNodeFamilyFieldReading())
+ {
+ _fam_nodes=DataArrayInt::New();
+ _fam_nodes->alloc(nbOfElt,1);
+ MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NONE,_fam_nodes->getPointer());
+ }
}
nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_NUMBER,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
- _num_nodes=DataArrayInt::New();
- _num_nodes->alloc(nbOfElt,1);
- MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NONE,_num_nodes->getPointer());
+ if(!mrs || mrs->isNodeNumFieldReading())
+ {
+ _num_nodes=DataArrayInt::New();
+ _num_nodes->alloc(nbOfElt,1);
+ MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NONE,_num_nodes->getPointer());
+ }
}
int meshDim=getStructuredMesh()->getMeshDimension();
med_geometry_type geoTypeReq=GetGeoTypeFromMeshDim(meshDim);
nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,geoTypeReq,MED_FAMILY_NUMBER,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
- _fam_cells=DataArrayInt::New();
- _fam_cells->alloc(nbOfElt,1);
- MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_fam_cells->getPointer());
+ if(!mrs || mrs->isCellFamilyFieldReading())
+ {
+ _fam_cells=DataArrayInt::New();
+ _fam_cells->alloc(nbOfElt,1);
+ MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_fam_cells->getPointer());
+ }
}
nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,geoTypeReq,MED_NUMBER,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
- _num_cells=DataArrayInt::New();
- _num_cells->alloc(nbOfElt,1);
- MEDmeshEntityNumberRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_num_cells->getPointer());
+ if(!mrs || mrs->isCellNumFieldReading())
+ {
+ _num_cells=DataArrayInt::New();
+ _num_cells->alloc(nbOfElt,1);
+ MEDmeshEntityNumberRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_num_cells->getPointer());
+ }
}
nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,geoTypeReq,MED_NAME,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
- _names_cells=DataArrayAsciiChar::New();
- _names_cells->alloc(nbOfElt+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
- MEDmeshEntityNameRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_names_cells->getPointer());
- _names_cells->reAlloc(nbOfElt);//not a bug to avoid the memory corruption due to last \0 at the end
+ if(!mrs || mrs->isCellNameFieldReading())
+ {
+ _names_cells=DataArrayAsciiChar::New();
+ _names_cells->alloc(nbOfElt+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
+ MEDmeshEntityNameRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_names_cells->getPointer());
+ _names_cells->reAlloc(nbOfElt);//not a bug to avoid the memory corruption due to last \0 at the end
+ }
}
nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_NAME,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
- _names_nodes=DataArrayAsciiChar::New();
- _names_nodes->alloc(nbOfElt+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
- MEDmeshEntityNameRd(fid,mName,dt,it,MED_NODE,MED_NONE,_names_nodes->getPointer());
- _names_nodes->reAlloc(nbOfElt);//not a bug to avoid the memory corruption due to last \0 at the end
+ if(!mrs || mrs->isNodeNameFieldReading())
+ {
+ _names_nodes=DataArrayAsciiChar::New();
+ _names_nodes->alloc(nbOfElt+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
+ MEDmeshEntityNameRd(fid,mName,dt,it,MED_NODE,MED_NONE,_names_nodes->getPointer());
+ _names_nodes->reAlloc(nbOfElt);//not a bug to avoid the memory corruption due to last \0 at the end
+ }
}
}
MEDCouplingCMesh *mesh=loaderl2.getMesh();
mesh->incrRef();
_cmesh=mesh;
- loadStrMeshFromFile(&loaderl2,fid,mName,dt,it);
+ loadStrMeshFromFile(&loaderl2,fid,mName,dt,it,mrs);
}
/*!
MEDCouplingCurveLinearMesh *mesh=loaderl2.getMesh();
mesh->incrRef();
_clmesh=mesh;
- loadStrMeshFromFile(&loaderl2,fid,mName,dt,it);
+ loadStrMeshFromFile(&loaderl2,fid,mName,dt,it,mrs);
}
MEDFileMeshMultiTS *MEDFileMeshMultiTS::New()
protected:
void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception);
void deepCpyAttributes() throw(INTERP_KERNEL::Exception);
- void loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ void loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs) throw(INTERP_KERNEL::Exception);
void writeStructuredLL(med_idt fid, const char *maa) const throw(INTERP_KERNEL::Exception);
virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0;
static med_geometry_type GetGeoTypeFromMeshDim(int meshDim) throw(INTERP_KERNEL::Exception);
// Author : Anthony Geay (CEA/DEN)
#include "MEDFileMeshElt.hxx"
+#include "MEDFileMeshReadSelector.hxx"
#include "MEDCouplingUMesh.hxx"
using namespace ParaMEDMEM;
-MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2)
+MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2, MEDFileMeshReadSelector *mrs)
{
med_entity_type whichEntity;
if(!isExisting(fid,mName,dt,it,geoElt,whichEntity))
return 0;
- return new MEDFileUMeshPerType(fid,mName,dt,it,mdim,geoElt,geoElt2,whichEntity);
+ return new MEDFileUMeshPerType(fid,mName,dt,it,mdim,geoElt,geoElt2,whichEntity,mrs);
}
bool MEDFileUMeshPerType::isExisting(med_idt fid, const char *mName, int dt, int it, med_geometry_type geoElt, med_entity_type& whichEntity)
}
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):_type(type),_entity(entity)
+ med_entity_type entity, MEDFileMeshReadSelector *mrs):_type(type),_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)
{
- loadFromStaticType(fid,mName,dt,it,mdim,curNbOfElem,geoElt,type,entity);
+ loadFromStaticType(fid,mName,dt,it,mdim,curNbOfElem,geoElt,type,entity,mrs);
return;
}
if(type==INTERP_KERNEL::NORM_POLYGON)
{
- loadPolyg(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity);
+ loadPolyg(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
return;
}
//if(type==INTERP_KERNEL::NORM_POLYHED)
- loadPolyh(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity);
+ loadPolyh(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
}
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)
+ med_entity_type entity, MEDFileMeshReadSelector *mrs)
{
_conn=DataArrayInt::New();
int nbOfNodesPerCell=(geoElt%100);
_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);
- loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity);
+ loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
int *w1=_conn->getPointer();
int *w2=_conn_index->getPointer();
*w2++=0;
}
void MEDFileUMeshPerType::loadCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt,
- med_entity_type entity)
+ med_entity_type entity, MEDFileMeshReadSelector *mrs)
{
med_bool changement,transformation;
- _fam=DataArrayInt::New();
- _fam->alloc(curNbOfElem,1);
+ _fam=0;
if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
- {
- if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,geoElt,_fam->getPointer())!=0)
- std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ {
+ if(!mrs || mrs->isCellFamilyFieldReading())
+ {
+ _fam=DataArrayInt::New();
+ _fam->alloc(curNbOfElem,1);
+ if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,geoElt,_fam->getPointer())!=0)
+ std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ }
}
- else
- std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ _num=0;
if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
{
- _num=DataArrayInt::New();
- _num->alloc(curNbOfElem,1);
- if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,geoElt,_num->getPointer())!=0)
- _num=0;
+ if(!mrs || mrs->isCellNumFieldReading())
+ {
+ _num=DataArrayInt::New();
+ _num->alloc(curNbOfElem,1);
+ if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,geoElt,_num->getPointer())!=0)
+ _num=0;
+ }
}
- else
- _num=0;
+ _names=0;
if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NAME,MED_NODAL,&changement,&transformation)>0)
{
- _names=DataArrayAsciiChar::New();
- _names->alloc(curNbOfElem+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
- if(MEDmeshEntityNameRd(fid,mName,dt,it,entity,geoElt,_names->getPointer())!=0)
- _names=0;
- else
- _names->reAlloc(curNbOfElem);//not a bug to avoid the memory corruption due to last \0 at the end
+ if(!mrs || mrs->isCellNameFieldReading())
+ {
+ _names=DataArrayAsciiChar::New();
+ _names->alloc(curNbOfElem+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
+ if(MEDmeshEntityNameRd(fid,mName,dt,it,entity,geoElt,_names->getPointer())!=0)
+ _names=0;
+ else
+ _names->reAlloc(curNbOfElem);//not a bug to avoid the memory corruption due to last \0 at the end
+ }
}
}
void MEDFileUMeshPerType::loadPolyg(med_idt fid, const char *mName, int dt, int it, int mdim, int arraySize, med_geometry_type geoElt,
- med_entity_type entity)
+ med_entity_type entity, MEDFileMeshReadSelector *mrs)
{
med_bool changement,transformation;
med_int curNbOfElem=MEDmeshnEntity(fid,mName,dt,it,entity,MED_POLYGON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)-1;
*w2=*w2-1+i;
}
*w2=*w2-1+curNbOfElem;
- loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,MED_POLYGON,entity);
+ loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,MED_POLYGON,entity,mrs);
}
void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, int connFaceLgth, med_geometry_type geoElt,
- med_entity_type entity)
+ med_entity_type entity, MEDFileMeshReadSelector *mrs)
{
med_bool changement,transformation;
med_int indexFaceLgth=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,MED_POLYHEDRON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation);
wFinalConn=std::transform(locConn+indexFace[j]-1,locConn+indexFace[j+1]-1,wFinalConn,std::bind2nd(std::plus<int>(),-1));
}
}
- loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,MED_POLYHEDRON,entity);
+ 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)
namespace ParaMEDMEM
{
class MEDCouplingUMesh;
+ class MEDFileMeshReadSelector;
class MEDFileUMeshPerType : public RefCountObject
{
public:
- static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2);
+ static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2, MEDFileMeshReadSelector *mrs);
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;
static void write(med_idt fid, const char *mname, int mdim, const MEDCouplingUMesh *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);
+ med_entity_type entity, MEDFileMeshReadSelector *mrs);
void 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);
+ med_entity_type entity, MEDFileMeshReadSelector *mrs);
void loadPolyg(med_idt fid, const char *mName, int dt, int it, int mdim, int arraySize, med_geometry_type geoElt,
- med_entity_type entity);
+ med_entity_type entity, MEDFileMeshReadSelector *mrs);
void loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, int connFaceLgth, med_geometry_type geoElt,
- med_entity_type entity);
- void loadCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, med_entity_type entity);
+ 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;
#include "MEDFileMeshLL.hxx"
#include "MEDFileMesh.hxx"
#include "MEDLoaderBase.hxx"
+#include "MEDFileMeshReadSelector.hxx"
#include "MEDCouplingUMesh.hxx"
if(!found)
{
std::ostringstream oss;
- oss << "No such meshname (" << mname << ") in file ! Must be in :";
+ oss << "No such meshname (" << mname << ") in file ! Must be in : ";
std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
return infosOnComp;
}
-void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const char *meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps)
+void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const char *meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs)
{
+ if(mrs && !(mrs->isCellFamilyFieldReading() || mrs->isNodeFamilyFieldReading()))
+ return ;
char nomfam[MED_NAME_SIZE+1];
med_int numfam;
int nfam=MEDnFamily(fid,meshName);
{
}
-void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it)
+void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
_name.set(mName);
int nstep;
_time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
_iteration=dt;
_order=it;
- loadConnectivity(fid,Mdim,mName,dt,it);//to improve check (dt,it) coherency
+ loadConnectivity(fid,Mdim,mName,dt,it,mrs);//to improve check (dt,it) coherency
loadCoords(fid,mId,infosOnComp,mName,dt,it);
}
-void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it)
+void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
_per_type_mesh.resize(1);
_per_type_mesh[0].clear();
for(int j=0;j<MED_N_CELL_FIXED_GEO;j++)
{
- MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,dt,it,mdim,typmai[j],typmai2[j]);
+ MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,dt,it,mdim,typmai[j],typmai2[j],mrs);
if(tmp)
_per_type_mesh[0].push_back(tmp);
}
namespace ParaMEDMEM
{
+ class MEDFileMeshReadSelector;
+
class MEDFileMeshL2 : public RefCountObject
{
public:
std::vector<std::string> getAxisInfoOnMesh(med_idt fid, int mId, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim) throw(INTERP_KERNEL::Exception);
static int GetMeshIdFromName(med_idt fid, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1) throw(INTERP_KERNEL::Exception);
static double CheckMeshTimeStep(med_idt fid, const char *mname, int nstep, int dt, int it) throw(INTERP_KERNEL::Exception);
- static void ReadFamiliesAndGrps(med_idt fid, const char *mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps);
+ static void ReadFamiliesAndGrps(med_idt fid, const char *mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs);
static void WriteFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol);
protected:
MEDFileString _name;
{
public:
MEDFileUMeshL2();
- void loadAll(med_idt fid, int mId, const char *mName, int dt, int it);
- void loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it);
+ void loadAll(med_idt fid, int mId, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ void loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
void loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
int getNumberOfLevels() const { return _per_type_mesh.size(); }
bool emptyLev(int levId) const { return _per_type_mesh[levId].empty(); }
mrs.setNodeNumFieldReading(True)
self.assertEqual(mrs.getCode(),63)
pass
+
+ def testPartialReadOfMeshes(self):
+ fname="Pyfile70.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]"])
+ m1=m.buildDescendingConnectivity()[0]
+ mm=MEDFileUMesh() ; mm.setMeshes([m,m1])
+ #
+ grp0=DataArrayInt([1,2,3,5,6]) ; grp0.setName("grp0")
+ grp1=DataArrayInt([1,2,3,5,7,8]) ; grp1.setName("grp1")
+ mm.setGroupsAtLevel(0,[grp0,grp1])
+ grp2=DataArrayInt.Range(0,32,2) ; grp2.setName("grp2")
+ grp3=DataArrayInt.Range(1,32,7) ; grp3.setName("grp3")
+ mm.setGroupsAtLevel(-1,[grp2,grp3])
+ grp4=DataArrayInt.Range(0,32,2) ; grp4.setName("grp4")
+ grp5=DataArrayInt.Range(1,32,7) ; grp5.setName("grp5")
+ mm.setGroupsAtLevel(1,[grp4,grp5])
+ mm.setRenumFieldArr(0,DataArrayInt.Range(2,11,1))
+ mm.setRenumFieldArr(-1,DataArrayInt.Range(3,35,1))
+ mm.setRenumFieldArr(1,DataArrayInt.Range(4,36,1))
+ #
+ mm.write(fname,2)
+ ##
+ mm=MEDFileMesh.New(fname,"mesh",-1,-1,MEDFileMeshReadSelector())
+ ref_heap_mem=mm.getHeapMemorySize()
+ #
+ mm=MEDFileMesh.New(fname,MEDFileMeshReadSelector(0))
+ self.assertEqual(len(mm.getGroupsNames()),0)
+ self.assertTrue(mm.getMeshAtLevel(0).isEqual(m,1e-13))
+ self.assertTrue(mm.getMeshAtLevel(-1).isEqual(m1,1e-13))
+ self.assertTrue(mm.getFamilyFieldAtLevel(0) is None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(-1) is None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(1) is None)
+ self.assertTrue(mm.getNumberFieldAtLevel(0) is None)
+ self.assertTrue(mm.getNumberFieldAtLevel(-1) is None)
+ self.assertTrue(mm.getNumberFieldAtLevel(1) is None)
+ delta1=ref_heap_mem-mm.getHeapMemorySize()
+ self.assertTrue(delta1>=4*(32+9)*3+32*4*3)
+ #
+ mm=MEDFileMesh.New(fname,MEDFileMeshReadSelector(1))
+ self.assertEqual(len(mm.getGroupsNames()),6)
+ self.assertTrue(mm.getMeshAtLevel(0).isEqual(m,1e-13))
+ self.assertTrue(mm.getMeshAtLevel(-1).isEqual(m1,1e-13))
+ self.assertTrue(mm.getFamilyFieldAtLevel(0)!=None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(-1)!=None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(1) is None)
+ self.assertTrue(mm.getNumberFieldAtLevel(0) is None)
+ self.assertTrue(mm.getNumberFieldAtLevel(-1) is None)
+ self.assertTrue(mm.getNumberFieldAtLevel(1) is None)
+ delta2=ref_heap_mem-mm.getHeapMemorySize()
+ self.assertTrue(delta2<delta1)
+ self.assertTrue(delta2>=4*(32+9)*1+32*4*3)
+ #
+ mm=MEDFileUMesh(fname,MEDFileMeshReadSelector(3))
+ self.assertEqual(len(mm.getGroupsNames()),6)
+ self.assertTrue(mm.getMeshAtLevel(0).isEqual(m,1e-13))
+ self.assertTrue(mm.getMeshAtLevel(-1).isEqual(m1,1e-13))
+ self.assertTrue(mm.getFamilyFieldAtLevel(0)!=None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(-1)!=None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(1)!=None)
+ self.assertTrue(mm.getNumberFieldAtLevel(0) is None)
+ self.assertTrue(mm.getNumberFieldAtLevel(-1) is None)
+ self.assertTrue(mm.getNumberFieldAtLevel(1) is None)
+ delta3=ref_heap_mem-mm.getHeapMemorySize()
+ self.assertTrue(delta3<delta2)
+ self.assertTrue(delta3>=4*(32+9)*1+32*4*1)
+ #
+ mm=MEDFileUMesh(fname,"mesh",-1,-1,MEDFileMeshReadSelector(19))
+ self.assertEqual(len(mm.getGroupsNames()),6)
+ self.assertTrue(mm.getMeshAtLevel(0).isEqual(m,1e-13))
+ self.assertTrue(mm.getMeshAtLevel(-1).isEqual(m1,1e-13))
+ self.assertTrue(mm.getFamilyFieldAtLevel(0)!=None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(-1)!=None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(1)!=None)
+ self.assertTrue(mm.getNumberFieldAtLevel(0)!=None)
+ self.assertTrue(mm.getNumberFieldAtLevel(-1)!=None)
+ self.assertTrue(mm.getNumberFieldAtLevel(1) is None)
+ delta4=ref_heap_mem-mm.getHeapMemorySize()
+ self.assertTrue(delta4<delta3)
+ self.assertTrue(delta4>=32*4*2)
+ #
+ mm=MEDFileUMesh.New(fname,"mesh",-1,-1,MEDFileMeshReadSelector(51))
+ self.assertEqual(len(mm.getGroupsNames()),6)
+ self.assertTrue(mm.getMeshAtLevel(0).isEqual(m,1e-13))
+ self.assertTrue(mm.getMeshAtLevel(-1).isEqual(m1,1e-13))
+ self.assertTrue(mm.getFamilyFieldAtLevel(0)!=None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(-1)!=None)
+ self.assertTrue(mm.getFamilyFieldAtLevel(1)!=None)
+ self.assertTrue(mm.getNumberFieldAtLevel(0)!=None)
+ self.assertTrue(mm.getNumberFieldAtLevel(-1)!=None)
+ self.assertTrue(mm.getNumberFieldAtLevel(1)!=None)
+ delta5=ref_heap_mem-mm.getHeapMemorySize()
+ self.assertTrue(delta5<delta4)
+ self.assertEqual(delta5,0)
+ pass
pass