#include "MEDLoaderTraits.hxx"
#include "MEDFileSafeCaller.txx"
#include "MEDFileFieldOverView.hxx"
+#include "MEDFileBlowStrEltUp.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldTemplate.hxx"
const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
+MEDFileGTKeeper::~MEDFileGTKeeper()
+{
+}
+
+MEDFileGTKeeper *MEDFileGTKeeperSta::deepCopy() const
+{
+ return new MEDFileGTKeeperSta(_geo_type);
+}
+
+INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperSta::getGeoType() const
+{
+ return _geo_type;
+}
+
+std::string MEDFileGTKeeperSta::getRepr() const
+{
+ return INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr();
+}
+
+bool MEDFileGTKeeperSta::isEqual(const MEDFileGTKeeper *other) const
+{
+ const MEDFileGTKeeperSta *otherC(dynamic_cast<const MEDFileGTKeeperSta *>(other));
+ if(!otherC)
+ return false;
+ return _geo_type==otherC->_geo_type;
+}
+
+MEDFileGTKeeperDyn::MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se):_mesh(mesh),_section(section),_se(se)
+{
+ if(mesh)
+ mesh->incrRef();
+ if(section)
+ section->incrRef();
+ if(se)
+ se->incrRef();
+ if(_mesh.isNull() || _section.isNull() || _se.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn constructor : null pointer not allowed !");
+}
+
+MEDFileGTKeeper *MEDFileGTKeeperDyn::deepCopy() const
+{
+ return new MEDFileGTKeeperDyn(_mesh,_section,_se);
+}
+
+INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperDyn::getGeoType() const
+{
+ throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn::getGeoType : not valid !");
+}
+
+std::string MEDFileGTKeeperDyn::getRepr() const
+{
+ std::ostringstream oss;
+ oss << _se->getDynGT();
+ return oss.str();
+}
+
+bool MEDFileGTKeeperDyn::isEqual(const MEDFileGTKeeper *other) const
+{
+ const MEDFileGTKeeperDyn *otherC(dynamic_cast<const MEDFileGTKeeperDyn *>(other));
+ if(!otherC)
+ return false;
+ return this==otherC;
+}
+
MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
{
return new MEDFileFieldLoc(fid,locName);
}
-MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
+MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id, const MEDFileEntities *entities)
{
- return new MEDFileFieldLoc(fid,id);
+ return new MEDFileFieldLoc(fid,id,entities);
}
MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
- _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
- const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
+ _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
_nb_node_per_cell=cm.getNumberOfNodes();
_ref_coo.resize(_dim*_nb_node_per_cell);
_gs_coo.resize(_dim*_nb_gauss_pt);
MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
}
-MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
+MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities)
{
med_geometry_type geotype;
med_geometry_type sectiongeotype;
INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
_name=locName;
- _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
- const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
- _nb_node_per_cell=cm.getNumberOfNodes();
+ std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE));
+ if(sectionName.empty())
+ {
+ _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
+ _nb_node_per_cell=cm.getNumberOfNodes();
+ }
+ else
+ {
+ const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
+ if(!entities2)
+ {
+ std::ostringstream oss; oss << "MEDFileFieldLoc cstr : for loc \"" << _name << "\" presence of non static type ! Expect entities !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ const MEDFileStructureElement *se(entities2->getWithGT(geotype));
+ const MEDFileUMesh *um(entities2->getSupMeshWithName(se->getMeshName()));
+ const MEDFileUMesh *section(entities2->getSupMeshWithName(sectionName));
+ _gt=new MEDFileGTKeeperDyn(um,section,se);
+ {
+ int dummy;
+ MEDFILESAFECALLERWR0(MEDmeshGeotypeParameter,(fid,geotype,&dummy,&_nb_node_per_cell));
+ }
+ }
_ref_coo.resize(_dim*_nb_node_per_cell);
_gs_coo.resize(_dim*_nb_gauss_pt);
_w.resize(_nb_gauss_pt);
}
MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
- const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
- _w(w)
+ const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_gt(new MEDFileGTKeeperSta(geoType)),_ref_coo(refCoo),_gs_coo(gsCoo),_w(w)
{
- const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
_dim=cm.getDimension();
_nb_node_per_cell=cm.getNumberOfNodes();
_nb_gauss_pt=_w.size();
}
+
+MEDFileFieldLoc::MEDFileFieldLoc(const MEDFileFieldLoc& other):_dim(other._dim),_nb_gauss_pt(other._nb_gauss_pt),_gt(other._gt->deepCopy()),_nb_node_per_cell(other._nb_node_per_cell),_name(other._name),_ref_coo(other._ref_coo),_gs_coo(other._gs_coo),_w(other._w)
+{
+}
+
MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
{
return new MEDFileFieldLoc(*this);
{
static const char OFF7[]="\n ";
oss << "\"" << _name << "\"" << OFF7;
- oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
+ oss << "GeoType=" << _gt->getRepr() << OFF7;
oss << "Dimension=" << _dim << OFF7;
oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
return false;
if(_nb_node_per_cell!=other._nb_node_per_cell)
return false;
- if(_geo_type!=other._geo_type)
+ if(!_gt->isEqual(other._gt))
return false;
if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
return false;
void MEDFileFieldLoc::writeLL(med_idt fid) const
{
- MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
+ MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)getGeoType()],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
}
std::string MEDFileFieldLoc::repr() const
{
std::ostringstream oss; oss.precision(15);
- const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
_locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
}
-void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
+void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
{
int nProfil=MEDnProfile(fid);
for(int i=0;i<nProfil;i++)
_locs.resize(sz);
for(int i=0;i<sz;i++)
{
- _locs[i]=MEDFileFieldLoc::New(fid,i);
+ _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
}
}
contentNotNull()->loadGlobals(fid,*this);
}
-void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
+void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
{
- contentNotNull()->loadAllGlobals(fid);
+ contentNotNull()->loadAllGlobals(fid,entities);
}
void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
}
}
}
- loadAllGlobals(fid);
+ loadAllGlobals(fid,entities);
}
catch(INTERP_KERNEL::Exception& e)
{
(*it)->getMeshSENames(ps);
}
+void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
+{
+ MCAuto<MEDFileFields> fsSEOnly(partOfThisOnStructureElements());
+ killStructureElements();
+ MEDFileBlowStrEltUp bu(fsSEOnly,ms,ses);
+ bu.generate(ms,this);
+}
+
MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
{
MCAuto<MEDFileFields> ret(deepCopy());
class MEDCouplingFieldDouble;
class MEDFileMesh;
+ class MEDFileGTKeeper
+ {
+ public:
+ virtual MEDFileGTKeeper *deepCopy() const = 0;
+ virtual INTERP_KERNEL::NormalizedCellType getGeoType() const = 0;
+ virtual std::string getRepr() const = 0;
+ virtual bool isEqual(const MEDFileGTKeeper *other) const = 0;
+ virtual ~MEDFileGTKeeper();
+ };
+
+ class MEDFileGTKeeperSta : public MEDFileGTKeeper
+ {
+ public:
+ MEDFileGTKeeperSta(INTERP_KERNEL::NormalizedCellType gt):_geo_type(gt) { }
+ MEDFileGTKeeper *deepCopy() const;
+ INTERP_KERNEL::NormalizedCellType getGeoType() const;
+ std::string getRepr() const;
+ bool isEqual(const MEDFileGTKeeper *other) const;
+ private:
+ INTERP_KERNEL::NormalizedCellType _geo_type;
+ };
+
+
+ class MEDFileGTKeeperDyn : public MEDFileGTKeeper
+ {
+ public:
+ MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se);
+ MEDFileGTKeeper *deepCopy() const;
+ INTERP_KERNEL::NormalizedCellType getGeoType() const;
+ std::string getRepr() const;
+ bool isEqual(const MEDFileGTKeeper *other) const;
+ private:
+ MCConstAuto<MEDFileUMesh> _mesh;
+ MCConstAuto<MEDFileUMesh> _section;
+ MCConstAuto<MEDFileStructureElement> _se;
+ };
+
class MEDFileFieldLoc : public RefCountObject
{
public:
MEDLOADER_EXPORT std::string getName() const { return _name; }
MEDLOADER_EXPORT void setName(const std::string& name);
static MEDFileFieldLoc *New(med_idt fid, const std::string& locName);
- static MEDFileFieldLoc *New(med_idt fid, int id);
+ static MEDFileFieldLoc *New(med_idt fid, int i, const MEDFileEntities *entities);
static MEDFileFieldLoc *New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
MEDLOADER_EXPORT const std::vector<double>& getRefCoords() const { return _ref_coo; }
MEDLOADER_EXPORT const std::vector<double>& getGaussCoords() const { return _gs_coo; }
MEDLOADER_EXPORT const std::vector<double>& getGaussWeights() const { return _w; }
- MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getGeoType() const { return _geo_type; }
+ MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getGeoType() const { return _gt->getGeoType(); }
MEDLOADER_EXPORT bool isEqual(const MEDFileFieldLoc& other, double eps) const;
private:
+ MEDFileFieldLoc(const MEDFileFieldLoc& other);
MEDFileFieldLoc(med_idt fid, const std::string& locName);
- MEDFileFieldLoc(med_idt fid, int id);
+ MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities);
MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
private:
int _dim;
int _nb_gauss_pt;
+ INTERP_KERNEL::AutoCppPtr<MEDFileGTKeeper> _gt;
int _nb_node_per_cell;
std::string _name;
- INTERP_KERNEL::NormalizedCellType _geo_type;
std::vector<double> _ref_coo;
std::vector<double> _gs_coo;
std::vector<double> _w;
void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
void loadProfileInFile(med_idt fid, int id);
void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real);
- void loadAllGlobals(med_idt fid);
+ void loadAllGlobals(med_idt fid, const MEDFileEntities *entities);
void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
std::vector<std::string> getPfls() const;
std::vector<std::string> getLocs() const;
MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id);
MEDLOADER_EXPORT void loadGlobals(med_idt fid);
- MEDLOADER_EXPORT void loadAllGlobals(med_idt fid);
+ MEDLOADER_EXPORT void loadAllGlobals(med_idt fid, const MEDFileEntities *entities=0);
MEDLOADER_EXPORT void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
MEDLOADER_EXPORT std::vector<std::string> getPfls() const;
MEDLOADER_EXPORT std::vector<std::string> getLocs() const;
MEDLOADER_EXPORT void keepOnlyStructureElements();
MEDLOADER_EXPORT void keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName);
MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
+ MEDLOADER_EXPORT void blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses);
MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisOnStructureElements() const;
MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const;
MEDLOADER_EXPORT void aggregate(const MEDFileFields& other);
%newobject MEDCoupling::MEDFileMeshes::__getitem__;
%newobject MEDCoupling::MEDFileMeshes::__iter__;
+%newobject MEDCoupling::MEDFileMeshSupports::New;
+
+%newobject MEDCoupling::MEDFileStructureElements::New;
+
%newobject MEDCoupling::MEDFileFields::New;
+%newobject MEDCoupling::MEDFileFields::NewWithDynGT;
%newobject MEDCoupling::MEDFileFields::LoadPartOf;
%newobject MEDCoupling::MEDFileFields::LoadSpecificEntities;
%newobject MEDCoupling::MEDFileFields::deepCopy;
%feature("unref") MEDFileAnyTypeFieldMultiTS "$this->decrRef();"
%feature("unref") MEDFileFieldMultiTS "$this->decrRef();"
%feature("unref") MEDFileIntFieldMultiTS "$this->decrRef();"
+%feature("unref") MEDFileMeshSupports "$this->decrRef();"
+%feature("unref") MEDFileStructureElements "$this->decrRef();"
%feature("unref") MEDFileFields "$this->decrRef();"
%feature("unref") MEDFileParameter1TS "$this->decrRef();"
%feature("unref") MEDFileParameterDouble1TSWTI "$this->decrRef();"
}
}
};
+
+ class MEDFileMeshSupports : public RefCountObject, public MEDFileWritableStandAlone
+ {
+ public:
+ static MEDFileMeshSupports *New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
+ };
+
+ class MEDFileStructureElements : public RefCountObject, public MEDFileWritableStandAlone
+ {
+ public:
+ static MEDFileStructureElements *New(const std::string& fileName, const MEDFileMeshSupports *ms) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileStructureElements();
+ };
class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone
{
static MEDFileFields *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
static MEDFileFields *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception);
static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0) throw(INTERP_KERNEL::Exception);
+ static MEDFileFields *NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll=true) throw(INTERP_KERNEL::Exception);
MEDFileFields *deepCopy() const throw(INTERP_KERNEL::Exception);
MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception);
void loadArrays() throw(INTERP_KERNEL::Exception);
void killStructureElements() throw(INTERP_KERNEL::Exception);
void keepOnlyStructureElements() throw(INTERP_KERNEL::Exception);
void keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName) throw(INTERP_KERNEL::Exception);
+ void blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses) throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
bool removeFieldsWithoutAnyTimeStep() throw(INTERP_KERNEL::Exception);
%extend