MEDFileField.cxx
MEDFileParameter.cxx
MEDFileData.cxx
+ MEDFileFieldOverView.cxx
MEDFileMeshReadSelector.cxx
SauvMedConvertor.cxx
SauvReader.cxx
#include "MEDFileMesh.hxx"
#include "MEDLoaderBase.hxx"
#include "MEDFileUtilities.hxx"
+#include "MEDFileFieldOverView.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
throw INTERP_KERNEL::Exception(msg);
std::vector< std::pair<int,int> > curIts=curIt->getIterations();
if(refIts==curIts)
- { elt.push_back(curIt); it=lstFMTS.erase(it);}
+ { elt.push_back(curIt); it=lstFMTS.erase(it); }
else
it++;
}
return ret;
}
+/*!
+ * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
+ * All returned instances in a subvector can be safely loaded, rendered along time
+ * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
+ * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
+ * All items in \a vectFMTS must lie on the mesh (located by meshname and time step) and compatible with the input mesh \a mesh (having the same name than those in items).
+ * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
+ * For items in \a vectFMTS that are ON_NODES it is possible to appear several times (more than once or once) in the returned vector.
+ *
+ * \param [in] vectFMTS - list of multi times step part all defined each on a same spatial discretization along time and pointing to a mesh whose name is equal to \c mesh->getName().
+ * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
+ *
+ * \throw If an element in \a vectFMTS has not only one spatial discretization set.
+ * \throw If an element in \a vectFMTS change of spatial discretization along time.
+ * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
+ * \thorw If some elements in \a vectFMTS do not have the same times steps.
+ * \throw If mesh is null.
+ * \throw If an element in \a vectFMTS is null.
+ * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
+ */
+std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
+{
+ static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
+ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
+ if(vectFMTS.empty())
+ return ret;
+ std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
+ MEDFileAnyTypeFieldMultiTS *frstElt(*it);
+ std::size_t i=0;
+ std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
+ std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
+ for(;it!=vectFMTS.end();it++,i++)
+ {
+ TypeOfField tof0,tof1;
+ int ret=CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1);
+ if(ret>0)
+ {
+ if(tof1!=ON_NODES)
+ vectFMTSNotNodes.push_back(*it);
+ else
+ vectFMTSNodes.push_back(*it);
+ }
+ else
+ vectFMTSNotNodes.push_back(*it);
+ }
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
+ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
+ ret=retCell;
+ i=0;
+ for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
+ {
+ for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
+ {
+ if((*it0).empty())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
+ }
+ std::vector<MEDFileAnyTypeFieldMultiTS *> elt(1,*it2);
+ ret.push_back(elt);
+ }
+
+ return ret;
+}
+
+/*!
+ * WARNING no check here. The caller must be sure that all items in vectFMTS are coherent each other in time steps, only one same spatial discretization and not ON_NODES.
+ */
+std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps) throw(INTERP_KERNEL::Exception)
+{
+ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
+ std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
+ while(!lstFMTS.empty())
+ {
+ std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
+ MEDFileAnyTypeFieldMultiTS *ref(*it);
+ std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
+ elt.push_back(ref); it=lstFMTS.erase(it);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mesh,ref));
+ while(it!=lstFMTS.end())
+ {
+ MEDFileAnyTypeFieldMultiTS *curIt(*it);
+ if(cmp->isEqual(ref))
+ { elt.push_back(curIt); it=lstFMTS.erase(it); }
+ else
+ it++;
+ }
+ ret.push_back(elt); cmps.push_back(cmp);
+ }
+ return ret;
+}
+
+/*!
+ * This method scan the two main structs along time of \a f0 and \a f1 to see if there are all lying on the same mesh along time than those in \a mesh.
+ * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
+ *
+ * \throw If \a f0 or \a f1 has not only one spatial discretization set.
+ * \throw If \a f0 or \a f1 change of spatial discretization along time.
+ * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
+ * \thorw If \a f0 and \a f1 do not have the same times steps.
+ * \throw If mesh is null.
+ * \throw If \a f0 or \a f1 is null.
+ * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
+ */
+int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1) throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
+ if(!f0 || !f1)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
+ if(f0->getMeshName()!=mesh->getName())
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(f1->getMeshName()!=mesh->getName())
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int nts=f0->getNumberOfTS();
+ if(nts!=f1->getNumberOfTS())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
+ if(nts==0)
+ return nts;
+ for(int i=0;i<nts;i++)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
+ std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
+ if(tofs0.size()!=1 || tofs1.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
+ if(i!=0)
+ {
+ if(tof0!=tofs0[0] || tof1!=tofs1[0])
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
+ }
+ else
+ { tof0=tofs0[0]; tof1=tofs1[0]; }
+ if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh time step (" << f0cur->getMeshIteration() << ","<< f0cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh time step (" << f1cur->getMeshIteration() << ","<< f1cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
+ {
+ std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : all the time steps must be the same ! it is not the case (" << f0cur->getIteration() << "," << f0cur->getOrder() << ")!=(" << f1cur->getIteration() << "," << f1cur->getOrder() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return nts;
+}
+
MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
{
return new MEDFileAnyTypeFieldMultiTSIterator(this);
//
void appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception);
void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception);
- protected:
+ public:
MEDFileFieldGlobs *contentNotNull() throw(INTERP_KERNEL::Exception);
const MEDFileFieldGlobs *contentNotNull() const throw(INTERP_KERNEL::Exception);
protected:
};
class MEDFileAnyTypeFieldMultiTSIterator;
-
+ class MEDFileFastCellSupportComparator;
/*!
* User class.
*/
MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
static std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS) throw(INTERP_KERNEL::Exception);
+ static std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+ static int CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1) throw(INTERP_KERNEL::Exception);
public:// direct forwarding to MEDFileField1TSWithoutSDA instance _content
std::string getName() const;
void setName(const char *name);
protected:
MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase() throw(INTERP_KERNEL::Exception);
const MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase() const throw(INTERP_KERNEL::Exception);
+ private:
+ static std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps) throw(INTERP_KERNEL::Exception);
protected:
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> _content;
};
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (CEA/DEN)
+
+#include "MEDFileFieldOverView.hxx"
+#include "MEDFileField.hxx"
+#include "MEDFileMesh.hxx"
+
+#include "CellModel.hxx"
+
+using namespace ParaMEDMEM;
+
+MEDFileMeshStruct *MEDFileMeshStruct::New(const MEDFileMesh *mesh)
+{
+ return new MEDFileMeshStruct(mesh);
+}
+
+std::size_t MEDFileMeshStruct::getHeapMemorySize() const
+{
+ return 0;
+}
+
+MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh)
+{
+ std::vector<int> levs=mesh->getNonEmptyLevels();
+ _name=mesh->getName();
+ _nb_nodes=mesh->getNumberOfNodes();
+ _geo_types_distrib.resize(levs.size());
+ for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mLev=mesh->getGenMeshAtLevel(*lev);
+ _geo_types_distrib[-(*lev)]=mLev->getDistributionOfTypes();
+ }
+}
+
+int MEDFileMeshStruct::getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< std::vector<int> >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++)
+ {
+ std::size_t sz=(*it1).size();
+ if(sz%3!=0)
+ throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfElemsOfGeoType : internal error in code !");
+ std::size_t nbGeo=sz/3;
+ for(std::size_t i=0;i<nbGeo;i++)
+ if((*it1)[3*i]==(int)t)
+ return (*it1)[3*i+1];
+ }
+ throw INTERP_KERNEL::Exception("The specified geometric type is not present in the mesh structure !");
+}
+
+//=
+
+MEDFileField1TSStructItem2::MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& c, const std::string& d):_geo_type(a),_start_end(b),_pfl(DataArrayInt::New()),_loc(d),_nb_of_entity(-1)
+{
+ _pfl->setName(c.c_str());
+}
+
+void MEDFileField1TSStructItem2::checkWithMeshStructForCells(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
+ checkInRange(nbOfEnt,1,globs);
+}
+
+void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
+ checkInRange(nbOfEnt,(int)cm.getNumberOfNodes(),globs);
+}
+
+void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception)
+{
+ if(!globs)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no globals specified !");
+ if(_loc.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no localization specified !");
+ const MEDFileFieldLoc& loc=globs->getLocalization(_loc.c_str());
+ int nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type);
+ checkInRange(nbOfEnt,loc.getNumberOfGaussPoints(),globs);
+}
+
+/*!
+ * \param [in] nbOfEntity - number of entity that can be either cells or nodes. Not other possiblity.
+ * \param [in] nip - number of integration points. 1 for ON_CELLS and NO_NODES
+ */
+void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception)
+{
+ _nb_of_entity=nbOfEntity;
+ if(_pfl->getName().empty())
+ {
+ if(nbOfEntity!=(_start_end.second-_start_end.first)/nip)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Mismatch between number of entities and size of node field !");
+ return ;
+ }
+ else
+ {
+ if(!globs)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no globals found in file !");
+ const DataArrayInt *pfl=globs->getProfile(_pfl->getName().c_str());
+ if(!pfl)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Presence of a profile on field whereas no such profile found in file !");
+ if(!pfl->checkAllIdsInRange(0,nbOfEntity))
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : The profile specified is invalid !");
+ }
+}
+
+bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception)
+{
+ return _geo_type==other._geo_type && _start_end==other._start_end && _pfl->getName()==other._pfl->getName();
+}
+
+//=
+
+MEDFileField1TSStructItem::MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b):_type(a),_items(b)
+{
+}
+
+void MEDFileField1TSStructItem::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception)
+{
+ switch(_type)
+ {
+ case ON_NODES:
+ {
+ int nbOfEnt=mst->getNumberOfNodes();
+ if(_items.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : for nodes field only one subdivision supported !");
+ _items[0].checkInRange(nbOfEnt,1,globs);
+ break ;
+ }
+ case ON_CELLS:
+ {
+ for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
+ (*it).checkWithMeshStructForCells(mst,globs);
+ break;
+ }
+ case ON_GAUSS_NE:
+ {
+ for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
+ (*it).checkWithMeshStructForGaussNE(mst,globs);
+ break;
+ }
+ case ON_GAUSS_PT:
+ {
+ for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++)
+ (*it).checkWithMeshStructForGaussPT(mst,globs);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : not managed field type !");
+ }
+}
+
+bool MEDFileField1TSStructItem::operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception)
+{
+ if(_type!=other._type)
+ return false;
+ if(_items.size()!=other._items.size())
+ return false;
+ for(std::size_t i=0;i<_items.size();i++)
+ if(!(_items[i]==other._items[i]))
+ return false;
+ return true;
+}
+
+bool MEDFileField1TSStructItem::isEntityCell() const
+{
+ if(_type==ON_NODES)
+ return false;
+ else
+ return true;
+}
+
+class CmpGeo
+{
+public:
+ CmpGeo(INTERP_KERNEL::NormalizedCellType geoTyp):_geo_type(geoTyp) { }
+ bool operator()(const std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > & v) const { return _geo_type==v.first; }
+private:
+ INTERP_KERNEL::NormalizedCellType _geo_type;
+};
+
+MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception)
+{
+ if(!isEntityCell())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::simplifyMeOnCellEntity : must be on ON_CELLS, ON_GAUSS_NE or ON_GAUSS_PT !");
+ std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > > m;
+ std::size_t i=0;
+ for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++)
+ {
+ std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> > >::iterator it0(std::find_if(m.begin(),m.end(),CmpGeo((*it).getGeo())));
+ if(it0==m.end())
+ m.push_back(std::pair< INTERP_KERNEL::NormalizedCellType, std::vector<std::size_t> >((*it).getGeo(),std::vector<std::size_t>(1,i)));
+ (*it0).second.push_back(i);
+ }
+ if(m.size()==_items.size())
+ {
+ MEDFileField1TSStructItem ret(*this);
+ ret._type=ON_CELLS;
+ return ret;
+ }
+ return *this;
+}
+
+//=
+
+MEDFileField1TSStruct *MEDFileField1TSStruct::New(const MEDFileAnyTypeField1TS *ref) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileField1TSStruct(ref);
+}
+
+MEDFileField1TSStruct::MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref)
+{
+ _already_checked.push_back(BuildItemFrom(ref));
+}
+
+void MEDFileField1TSStruct::checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception)
+{
+ if(_already_checked.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::checkWithMeshStruct : not correctly initialized !");
+ _already_checked.back().checkWithMeshStruct(mst,globs);
+}
+
+bool MEDFileField1TSStruct::isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileField1TSStructItem b(BuildItemFrom(other));
+ for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
+ {
+ if((*it)==b)
+ return true;
+ }
+ return false;
+}
+
+bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other) throw(INTERP_KERNEL::Exception)
+{
+ if(_already_checked.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : no ref !");
+ MEDFileField1TSStructItem b(BuildItemFrom(other));
+ if(!_already_checked[0].isEntityCell() || !b.isEntityCell())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : only available on cell entities !");
+ return false;
+}
+
+std::size_t MEDFileField1TSStruct::getHeapMemorySize() const
+{
+ return 0;
+}
+
+MEDFileField1TSStructItem MEDFileField1TSStruct::BuildItemFrom(const MEDFileAnyTypeField1TS *ref)
+{
+ TypeOfField atype;
+ std::vector< MEDFileField1TSStructItem2 > anItems;
+ //
+ std::vector< std::vector<std::string> > pfls,locs;
+ std::vector< std::vector<TypeOfField> > typesF;
+ std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
+ std::vector< std::vector<std::pair<int,int> > > strtEnds=ref->getFieldSplitedByType(0,geoTypes,typesF,pfls,locs);
+ std::size_t nbOfGeoTypes(geoTypes.size());
+ if(nbOfGeoTypes==0)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref !");
+ bool isFirst=true;
+ for(std::size_t i=0;i<nbOfGeoTypes;i++)
+ {
+ std::size_t sz=typesF.size();
+ if(strtEnds[i].size()<1 || sz<1 || pfls[i].size()<1)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 !");
+ //
+ if(isFirst)
+ atype=typesF[i][0];
+ isFirst=false;
+ //
+ for(std::size_t j=0;j<sz;j++)
+ {
+ if(atype!=typesF[i][j])
+ anItems.push_back(MEDFileField1TSStructItem2(geoTypes[i],strtEnds[i][j],pfls[i][j],locs[i][j]));
+ else
+ throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : can be applied only on single spatial discretization fields ! Call SplitPerDiscretization method !");
+ }
+ }
+ return MEDFileField1TSStructItem(atype,anItems);
+}
+
+//=
+
+MEDFileFastCellSupportComparator *MEDFileFastCellSupportComparator::New(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFastCellSupportComparator(m,ref);
+}
+
+MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref)
+{
+ _mesh_comp=MEDFileMeshStruct::New(m);
+ int nbPts=ref->getNumberOfTS();
+ _f1ts_cmps.resize(nbPts);
+ for(int i=0;i<nbPts;i++)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=ref->getTimeStepAtPos(i);
+ _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt);
+ _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt->contentNotNull());
+ }
+}
+
+std::size_t MEDFileFastCellSupportComparator::getHeapMemorySize() const
+{
+ /*std::size_t part1=sizeof(MEDFileFastCellSupportComparator)+_mesh_name.capacity()+_already_passed_code1.capacity()*sizeof(std::vector<int>)+_already_passed_code2.capacity()*sizeof(void*)+_m_geo_types_distrib.capacity()*sizeof(std::vector<int>);
+ std::size_t part2=0;
+ for(std::vector< std::vector<int> >::const_iterator it=_already_passed_code1.begin();it!=_already_passed_code1.end();it++)
+ part2+=(*it).capacity()*(sizeof(int)+sizeof(const DataArrayInt *));
+ for(std::vector< std::vector<int> >::const_iterator it2=_m_geo_types_distrib.begin();it2!=_m_geo_types_distrib.end();it2++)
+ part2+=(*it2).capacity()*sizeof(int);
+ return part1+part2;*/
+ return 0;
+}
+
+bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception)
+{
+ int nbPts=other->getNumberOfTS();
+ if(nbPts!=(int)_f1ts_cmps.size())
+ {
+ std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isEqualRegardingPast : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ for(int i=0;i<nbPts;i++)
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=other->getTimeStepAtPos(i);
+ if(!_f1ts_cmps[i]->isEqualConsideringThePast(elt))
+ if(!_f1ts_cmps[i]->isSupportSameAs(elt))
+ return false;
+ }
+ return true;
+}
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (CEA/DEN)
+
+#ifndef __MEDFILEFIELDOVERVIEW_HXX__
+#define __MEDFILEFIELDOVERVIEW_HXX__
+
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDCouplingRefCountObject.hxx"
+
+#include "NormalizedUnstructuredMesh.hxx"
+#include "InterpKernelException.hxx"
+
+#include <vector>
+
+namespace ParaMEDMEM
+{
+ class DataArrayInt;
+ class MEDFileMesh;
+ class MEDFileFieldGlobs;
+ class MEDFileAnyTypeField1TS;
+ class MEDFileAnyTypeFieldMultiTS;
+
+ class MEDFileMeshStruct : public RefCountObject
+ {
+ public:
+ static MEDFileMeshStruct *New(const MEDFileMesh *mesh);
+ std::size_t getHeapMemorySize() const;
+ int getNumberOfNodes() const { return _nb_nodes; }
+ int getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileMeshStruct(const MEDFileMesh *mesh);
+ private:
+ const MEDFileMesh *_mesh;
+ std::string _name;
+ int _nb_nodes;
+ std::vector< std::vector<int> > _geo_types_distrib;
+ };
+
+ class MEDFileField1TSStructItem2
+ {
+ public:
+ MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& pfl, const std::string& loc);
+ void checkWithMeshStructForCells(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
+ void checkWithMeshStructForGaussNE(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
+ void checkWithMeshStructForGaussPT(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
+ //
+ INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; }
+ //! warning this method also set _nb_of_entity attribute !
+ void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
+ bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
+ private:
+ INTERP_KERNEL::NormalizedCellType _geo_type;
+ std::pair<int,int> _start_end;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _pfl;
+ std::string _loc;
+ int _nb_of_entity;
+ };
+
+ class MEDFileField1TSStructItem
+ {
+ public:
+ MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b);
+ void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
+ bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
+ bool isEntityCell() const;
+ //
+ MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception);
+ private:
+ TypeOfField _type;
+ std::vector< MEDFileField1TSStructItem2 > _items;
+ };
+
+ class MEDFileField1TSStruct : public RefCountObject
+ {
+ public:
+ static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref) throw(INTERP_KERNEL::Exception);
+ void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
+ std::size_t getHeapMemorySize() const;
+ bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other) throw(INTERP_KERNEL::Exception);
+ bool isSupportSameAs(const MEDFileAnyTypeField1TS *other) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref);
+ static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref);
+ private:
+ std::vector<MEDFileField1TSStructItem> _already_checked;
+ };
+
+ class MEDFileFastCellSupportComparator : public RefCountObject
+ {
+ public:
+ static MEDFileFastCellSupportComparator *New(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception);
+ bool isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
+ std::size_t getHeapMemorySize() const;
+ private:
+ MEDFileFastCellSupportComparator(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref);
+ private:
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> _mesh_comp;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> > _f1ts_cmps;
+ };
+}
+
+#endif
MEDFileMesh.cxx MEDFileMeshElt.cxx MEDFileBasis.cxx \
MEDFileMeshLL.cxx MEDFileField.cxx MEDFileData.cxx \
SauvMedConvertor.cxx SauvReader.cxx SauvWriter.cxx \
-MEDFileParameter.cxx MEDFileMeshReadSelector.cxx
+MEDFileParameter.cxx MEDFileMeshReadSelector.cxx MEDFileFieldOverView.cxx
libmedloader_la_CPPFLAGS= $(MED3_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
-I$(srcdir)/../INTERP_KERNEL \
void setName(const char *name) throw(INTERP_KERNEL::Exception);
std::string getMeshName() throw(INTERP_KERNEL::Exception);
void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ int getMeshIteration() const throw(INTERP_KERNEL::Exception);
+ int getMeshOrder() const throw(INTERP_KERNEL::Exception);
int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
bool isDealingTS(int iteration, int order) const throw(INTERP_KERNEL::Exception);
void setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception);
}
return retPy;
}
+
+ static PyObject *MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(PyObject *li, const MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTS;
+ convertFromPyObjVectorOfObj<ParaMEDMEM::MEDFileAnyTypeFieldMultiTS *>(li,SWIGTYPE_p_ParaMEDMEM__MEDFileAnyTypeFieldMultiTS,"MEDFileAnyTypeFieldMultiTS",vectFMTS);
+ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret=MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(vectFMTS,mesh);
+ std::size_t sz=ret.size();
+ PyObject *retPy=PyList_New(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ std::size_t sz2=ret[i].size();
+ PyObject *ret1Py=PyList_New(sz2);
+ for(std::size_t j=0;j<sz2;j++)
+ {
+ MEDFileAnyTypeFieldMultiTS *elt(ret[i][j]);
+ if(elt)
+ elt->incrRef();
+ PyList_SetItem(ret1Py,j,convertMEDFileFieldMultiTS(elt,SWIG_POINTER_OWN | 0 ));
+ }
+ PyList_SetItem(retPy,i,ret1Py);
+ }
+ return retPy;
+ }
}
};