const T& operator*() const { return *_ptr; }
operator const T *() const { return _ptr; }
private:
- void referPtr(T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); }
+ void referPtr(const T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); }
void destroyPtr() { if(_ptr) _ptr->decrRef(); }
private:
const T *_ptr;
MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
{
- MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
+ MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
ret->_father=father;
return ret.retn();
}
throw INTERP_KERNEL::Exception("not implemented yet !");
}
-MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
+MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
{
- throw INTERP_KERNEL::Exception("not implemented yet !");
+ MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
+ ret->setFather(father);
+ ret->deepCopyElements();
+ return ret.retn();
}
void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
_field_pm_pt=res;
}
+void MEDFileFieldPerMesh::keepOnlyStructureElements()
+{
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ {
+ if((*it).isNotNull())
+ {
+ const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
+ if(pt)
+ res.push_back(*it);
+ }
+ }
+ _field_pm_pt=res;
+}
+
DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
{
if(!_father)
(*it)->killStructureElements();
}
+void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ (*it)->keepOnlyStructureElements();
+}
+
MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to be extracted with \"field\" method ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
{
- std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > res;
+ std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
if((*it).isNotNull())
{
if(!(*it)->onlyStructureElements())
{
(*it)->killStructureElements();
- res.push_back(*it);
+ ret.push_back(*it);
}
}
else
{
- res.push_back(*it);
+ ret.push_back(*it);
+ }
+ }
+ _time_steps=ret;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
+{
+ std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ {
+ if((*it)->presenceOfStructureElements())
+ {
+ if(!(*it)->onlyStructureElements())
+ (*it)->keepOnlyStructureElements();
+ ret.push_back(*it);
}
}
- _time_steps=res;
+ _time_steps=ret;
}
bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
ret.push_back(*it);
}
}
+ else
+ {
+ ret.push_back(*it);
+ }
}
- else
+ _fields=ret;
+}
+
+void MEDFileFields::keepOnlyStructureElements()
+{
+ std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ if((*it).isNotNull())
{
- ret.push_back(*it);
+ if((*it)->presenceOfStructureElements())
+ {
+ if(!(*it)->onlyStructureElements())
+ (*it)->keepOnlyStructureElements();
+ ret.push_back(*it);
+ }
}
_fields=ret;
}
-
+
MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
{
- throw INTERP_KERNEL::Exception("partOfThisOnStructureElements : not implemented yet !");
+ MCAuto<MEDFileFields> ret(deepCopy());
+ ret->keepOnlyStructureElements();
+ return ret;
}
MEDFileFieldsIterator *MEDFileFields::iterator()
void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const;
void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
std::string getGeoTypeRepr() const;
- MEDFileFieldPerMeshPerType *deepCopy(MEDFileFieldPerMesh *father) const;
+ MEDFileFieldPerMeshPerTypeDyn *deepCopy(MEDFileFieldPerMesh *father) const;
void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
private:
MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc);
bool presenceOfStructureElements() const;
bool onlyStructureElements() const;
void killStructureElements();
+ void keepOnlyStructureElements();
DataArray *getOrCreateAndGetArray();
const DataArray *getOrCreateAndGetArray() const;
const std::vector<std::string>& getInfo() const;
MEDLOADER_EXPORT bool presenceOfStructureElements() const;
MEDLOADER_EXPORT bool onlyStructureElements() const;
MEDLOADER_EXPORT void killStructureElements();
+ MEDLOADER_EXPORT void keepOnlyStructureElements();
MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& infos);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
MEDLOADER_EXPORT bool presenceOfStructureElements() const;
MEDLOADER_EXPORT bool onlyStructureElements() const;
MEDLOADER_EXPORT void killStructureElements();
+ MEDLOADER_EXPORT void keepOnlyStructureElements();
MEDLOADER_EXPORT int getPosOfTimeStep(int iteration, int order) const;
MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const;
MEDLOADER_EXPORT std::vector< std::pair<int,int> > getIterations() const;
MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
MEDLOADER_EXPORT bool presenceOfMultiDiscPerGeoType() const;
MEDLOADER_EXPORT void killStructureElements();
+ MEDLOADER_EXPORT void keepOnlyStructureElements();
MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& info);
MEDLOADER_EXPORT int getNumberOfComponents() const;
MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const;
MEDLOADER_EXPORT MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
MEDLOADER_EXPORT bool presenceOfStructureElements() const;
MEDLOADER_EXPORT void killStructureElements();
+ MEDLOADER_EXPORT void keepOnlyStructureElements();
MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisOnStructureElements() const;
MEDLOADER_EXPORT MEDFileFieldsIterator *iterator();
MEDLOADER_EXPORT void destroyFieldAtPos(int i);
}
MCAuto<MEDFileMeshSupports> mss(MEDFileMeshSupports::New(fid));
MCAuto<MEDFileStructureElements> mse(MEDFileStructureElements::New(fid,mss));
- int nbOfNodesPerCell(mse->getNumberOfNodesPerCellOf(_geo_type_name));
- _conn=DataArrayInt::New(); _conn->alloc(nCells,nbOfNodesPerCell);
+ int nbEntities(mse->getNumberOfNodesPerSE(_geo_type_name));
+ _conn=DataArrayInt::New(); _conn->alloc(nCells,nbEntities);
MEDFILESAFECALLERRD0(MEDmeshElementConnectivityRd,(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,_geo_type,MED_NODAL,MED_FULL_INTERLACE,_conn->getPointer()));
_common=MEDFileUMeshPerTypeCommon::New();
_common->loadCommonPart(fid,mName.c_str(),dt,it,nCells,geoType,MED_STRUCT_ELEMENT,mrs);
throw INTERP_KERNEL::Exception(oss.str());
}
-int MEDFileMeshSupports::getNumberOfNodesPerCellOf(const std::string& name) const
+int MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, const std::string& name) const
{
const MEDFileUMesh *sup(getSupMeshWithName(name));
- return sup->getNumberOfNodes();
+ switch(entity)
+ {
+ case ON_NODES:
+ return sup->getNumberOfNodes();
+ case ON_CELLS:
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> gt(sup->getAllGeoTypes());
+ if(gt.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : on cells only one geometric type allowed !");
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt[0]));
+ return sup->getNumberOfCellsAtLevel(0)*cm.getNumberOfNodes();
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : not recognized entity type !");
+ }
}
std::size_t getHeapMemorySizeWithoutChildren() const;
void writeLL(med_idt fid) const;
const MEDFileUMesh *getSupMeshWithName(const std::string& name) const;
- int getNumberOfNodesPerCellOf(const std::string& name) const;
+ int getNumberOfNodesInConnOf(TypeOfField entity, const std::string& name) const;
private:
MEDFileMeshSupports(med_idt fid);
MEDFileMeshSupports();
throw INTERP_KERNEL::Exception(oss.str());
}
-int MEDFileStructureElements::getNumberOfNodesPerCellOf(const std::string& seName) const
+int MEDFileStructureElements::getNumberOfNodesPerSE(const std::string& seName) const
{
+ if(seName=="MED_PARTICLE")
+ return 1;
const MEDFileStructureElement *se(getSEWithName(seName));
std::string meshName(se->getMeshName());
- return _sup->getNumberOfNodesPerCellOf(meshName);
+ return _sup->getNumberOfNodesInConnOf(se->getEntity(),meshName);
}
const MEDFileStructureElement *MEDFileStructureElements::getSEWithName(const std::string& seName) const
MEDLOADER_EXPORT int getNumberOf() const;
MEDLOADER_EXPORT std::vector<int> getDynGTAvail() const;
MEDLOADER_EXPORT const MEDFileStructureElement *getWithGT(int idGT) const;
- MEDLOADER_EXPORT int getNumberOfNodesPerCellOf(const std::string& seName) const;
+ MEDLOADER_EXPORT int getNumberOfNodesPerSE(const std::string& seName) const;
MEDLOADER_EXPORT const MEDFileStructureElement *getSEWithName(const std::string& seName) const;
MEDLOADER_EXPORT std::vector<std::string> getVarAttsOf(const std::string& seName) const;
MEDLOADER_EXPORT const MEDFileSEVarAtt *getVarAttOf(const std::string &seName, const std::string& varName) const;
MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const throw(INTERP_KERNEL::Exception);
bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
void killStructureElements() throw(INTERP_KERNEL::Exception);
+ void keepOnlyStructureElements() throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
bool removeFieldsWithoutAnyTimeStep() throw(INTERP_KERNEL::Exception);
%extend