if(nModels<=0)
return ;
_elt_str.resize(nModels);
- std::cerr << "******** " << nModels << std::endl;
for(int i=0;i<nModels;i++)
_elt_str[i]=MEDFileEltStruct4Mesh::New(fid,mName,dt,it,i,mrs);
}
}
}
+bool MEDFileUMesh::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto<MEDFileEltStruct4Mesh> >::const_iterator it=_elt_str.begin();it!=_elt_str.end();it++)
+ if((*it).isNotNull())
+ return true;
+ return false;
+}
+
+void MEDFileUMesh::killStructureElements()
+{
+ _elt_str.clear();
+}
+
/*!
* Returns the optional numbers of mesh entities of a given dimension transformed using
* DataArrayInt::invertArrayN2O2O2N().
}
}
+bool MEDFileMeshMultiTS::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto<MEDFileMesh> >::const_iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
+ if((*it).isNotNull())
+ if((*it)->presenceOfStructureElements())
+ return true;
+ return false;
+}
+
+void MEDFileMeshMultiTS::killStructureElements()
+{
+ for(std::vector< MCAuto<MEDFileMesh> >::iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
+ if((*it).isNotNull())
+ (*it)->killStructureElements();
+}
+
void MEDFileMeshMultiTS::writeLL(med_idt fid) const
{
MEDFileJoints *joints(getJoints());
}
}
+bool MEDFileMeshes::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++)
+ if((*it).isNotNull())
+ if((*it)->presenceOfStructureElements())
+ return true;
+ return false;
+}
+
+void MEDFileMeshes::killStructureElements()
+{
+ for(std::vector< MCAuto<MEDFileMeshMultiTS> >::iterator it=_meshes.begin();it!=_meshes.end();it++)
+ if((*it).isNotNull())
+ (*it)->killStructureElements();
+}
+
MEDFileMeshesIterator::MEDFileMeshesIterator(MEDFileMeshes *ms):_ms(ms),_iter_id(0),_nb_iter(0)
{
if(ms)
}
}
}
+
+
MEDLOADER_EXPORT virtual std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const;
MEDLOADER_EXPORT virtual void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const = 0;
MEDLOADER_EXPORT virtual MEDFileMesh *cartesianize() const = 0;
+ MEDLOADER_EXPORT virtual bool presenceOfStructureElements() const = 0;
+ MEDLOADER_EXPORT virtual void killStructureElements() { }
//
MEDLOADER_EXPORT bool areFamsEqual(const MEDFileMesh *other, std::string& what) const;
MEDLOADER_EXPORT bool areGrpsEqual(const MEDFileMesh *other, std::string& what) const;
MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
MEDLOADER_EXPORT MEDFileMesh *cartesianize() const;
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const;
+ MEDLOADER_EXPORT void killStructureElements();
MEDLOADER_EXPORT std::vector<int> getNonEmptyLevels() const;
MEDLOADER_EXPORT std::vector<int> getNonEmptyLevelsExt() const;
MEDLOADER_EXPORT std::vector<int> getFamArrNonEmptyLevelsExt() const;
MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const { return false; }
MEDLOADER_EXPORT virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0;
// tools
MEDLOADER_EXPORT bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell);
MEDLOADER_EXPORT void setOneTimeStep(MEDFileMesh *mesh1TimeStep);
MEDLOADER_EXPORT MEDFileJoints *getJoints() const;
MEDLOADER_EXPORT void setJoints(MEDFileJoints* joints);
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const;
+ MEDLOADER_EXPORT void killStructureElements();
private:
~MEDFileMeshMultiTS() { }
void loadFromFile(med_idt fid, const std::string& mName);
MEDLOADER_EXPORT void pushMesh(MEDFileMesh *mesh);
MEDLOADER_EXPORT void setMeshAtPos(int i, MEDFileMesh *mesh);
MEDLOADER_EXPORT void destroyMeshAtPos(int i);
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const;
+ MEDLOADER_EXPORT void killStructureElements();
private:
~MEDFileMeshes() { }
void checkConsistencyLight() const;
std::size_t MEDFileEltStruct4Mesh::getHeapMemorySizeWithoutChildren() const
{
- return _geo_type_name.capacity();
+ return _geo_type_name.capacity()+_vars.capacity()*sizeof(MCAuto<DataArray>);
}
std::vector<const MEDCoupling::BigMemoryObject*> MEDFileEltStruct4Mesh::getDirectChildrenWithNull() const
std::vector<const MEDCoupling::BigMemoryObject*> ret;
ret.push_back(_conn);
ret.push_back(_common);
+ for(std::vector< MCAuto<DataArray> >::const_iterator it=_vars.begin();it!=_vars.end();it++)
+ ret.push_back(*it);
return ret;
}
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);
- //MEDFILESAFECALLERRD0(MEDmeshElementRd,(mName.c_str(),dt,it,MED_STRUCT_ELEMENT,geoType,MED_NODAL,MED_FULL_INTERLACE,conn,));
+ std::vector<std::string> vns(mse->getVarAttsOf(_geo_type_name));
+ std::size_t sz(vns.size());
+ _vars.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDFileSEVarAtt *var(mse->getVarAttOf(_geo_type_name,vns[i]));
+ MCAuto<DataArray> gen(var->getGenerator());
+ MCAuto<DataArray> arr(gen->buildNewEmptyInstance());
+ arr->alloc(nCells,var->getNbOfComponents());
+ arr->setName(vns[i]);
+ MEDFILESAFECALLERRD0(MEDmeshStructElementVarAttRd,(fid,mName.c_str(),dt,it,_geo_type,vns[i].c_str(),arr->getVoidStarPointer()));
+ }
}
int _geo_type;
MCAuto<DataArrayInt> _conn;
MCAuto<MEDFileUMeshPerTypeCommon> _common;
+ std::vector< MCAuto<DataArray> > _vars;
};
}
using namespace MEDCoupling;
+MEDFileMeshSupports *MEDFileMeshSupports::New(const std::string& fileName)
+{
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid);
+}
+
MEDFileMeshSupports *MEDFileMeshSupports::New(med_idt fid)
{
return new MEDFileMeshSupports(fid);
class MEDFileMeshSupports : public RefCountObject, public MEDFileWritableStandAlone
{
public:
+ MEDLOADER_EXPORT static MEDFileMeshSupports *New(const std::string& fileName);
MEDLOADER_EXPORT static MEDFileMeshSupports *New(med_idt fid);
MEDLOADER_EXPORT static MEDFileMeshSupports *New();
public:
return _father->getName();
}
+std::string MEDFileSEHolder::getName() const
+{
+ return _name;
+}
+
void MEDFileSEHolder::setName(const std::string& name)
{
_name=name;
return _sup_mesh_name;
}
+std::vector<std::string> MEDFileStructureElement::getVarAtts() const
+{
+ std::vector<std::string> ret;
+ for(std::vector< MCAuto<MEDFileSEVarAtt> >::const_iterator it=_var_att.begin();it!=_var_att.end();it++)
+ if((*it).isNotNull())
+ ret.push_back((*it)->getName());
+ return ret;
+}
+
+const MEDFileSEVarAtt *MEDFileStructureElement::getVarAtt(const std::string& varName) const
+{
+ for(std::vector< MCAuto<MEDFileSEVarAtt> >::const_iterator it=_var_att.begin();it!=_var_att.end();it++)
+ if((*it).isNotNull())
+ if((*it)->getName()==varName)
+ return *it;
+ std::ostringstream oss; oss << "MEDFileStructureElement::getVarAtt : no var att with name \"" << varName << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str());
+}
+
////////////////////
+MEDFileStructureElements *MEDFileStructureElements::New(const std::string& fileName, const MEDFileMeshSupports *ms)
+{
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,ms);
+}
+
MEDFileStructureElements *MEDFileStructureElements::New(med_idt fid, const MEDFileMeshSupports *ms)
{
return new MEDFileStructureElements(fid,ms);
throw INTERP_KERNEL::Exception(oss.str());
}
+std::vector<std::string> MEDFileStructureElements::getVarAttsOf(const std::string& seName) const
+{
+ const MEDFileStructureElement *se(getSEWithName(seName));
+ return se->getVarAtts();
+}
+
+const MEDFileSEVarAtt *MEDFileStructureElements::getVarAttOf(const std::string &seName, const std::string& varName) const
+{
+ const MEDFileStructureElement *se(getSEWithName(seName));
+ return se->getVarAtt(varName);
+}
class MEDFileSEHolder
{
+ public:
+ std::string getModelName() const;
+ std::string getName() const;
protected:
MEDFileSEHolder(MEDFileStructureElement *father):_father(father) { }
- std::string getModelName() const;
void setName(const std::string& name);
std::size_t getHeapMemorySizeLoc() const;
private:
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
std::size_t getHeapMemorySizeWithoutChildren() const;
void writeLL(med_idt fid) const;
+ int getNbOfComponents() const { return _nb_compo; }
+ MCAuto<DataArray> getGenerator() const { return _gen; }
private:
MEDFileSEVarAtt(med_idt fid, MEDFileStructureElement *father, int idVarAtt);
private:
MEDLOADER_EXPORT int getDynGT() const;
MEDLOADER_EXPORT TypeOfField getEntity() const;
MEDLOADER_EXPORT std::string getMeshName() const;
+ MEDLOADER_EXPORT std::vector<std::string> getVarAtts() const;
+ MEDLOADER_EXPORT const MEDFileSEVarAtt *getVarAtt(const std::string& varName) const;
public:
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
std::size_t getHeapMemorySizeWithoutChildren() const;
class MEDFileStructureElements : public RefCountObject, public MEDFileWritableStandAlone
{
public:
+ MEDLOADER_EXPORT static MEDFileStructureElements *New(const std::string& fileName, const MEDFileMeshSupports *ms);
MEDLOADER_EXPORT static MEDFileStructureElements *New(med_idt fid, const MEDFileMeshSupports *ms);
MEDLOADER_EXPORT static MEDFileStructureElements *New();
MEDLOADER_EXPORT int getNumberOf() const;
MEDLOADER_EXPORT const MEDFileStructureElement *getWithGT(int idGT) const;
MEDLOADER_EXPORT int getNumberOfNodesPerCellOf(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;
public:
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
std::size_t getHeapMemorySizeWithoutChildren() const;
void setJoints( MEDFileJoints* joints );
void initializeEquivalences();
void killEquivalences();
+ bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
+ void killStructureElements() throw(INTERP_KERNEL::Exception);
%extend
{
std::string __str__() const throw(INTERP_KERNEL::Exception)
void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
void cartesianizeMe() throw(INTERP_KERNEL::Exception);
+ bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
+ void killStructureElements() throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileMeshes()