* \throw If \a a[ *i* ]->getMeshDimension() < 0.
* \throw If the meshes in \a a are of different dimension (getMeshDimension()).
*/
-MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const std::vector<const MEDCouplingUMesh *>& a)
{
std::size_t sz=a.size();
if(sz==0)
/// @cond INTERNAL
-MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(std::vector<const MEDCouplingUMesh *>& a)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(const std::vector<const MEDCouplingUMesh *>& a)
{
if(a.empty())
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MergeUMeshes : input array must be NON EMPTY !");
MEDCOUPLING_EXPORT int split2DCells(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *midOpt=0, const DataArrayInt *midOptI=0);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const std::vector<const MEDCouplingUMesh *>& a);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr);
void getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints,
double eps, MCAuto<DataArrayInt>& elts, MCAuto<DataArrayInt>& eltsIndex) const;
/// @cond INTERNAL
- static MEDCouplingUMesh *MergeUMeshesLL(std::vector<const MEDCouplingUMesh *>& a);
+ static MEDCouplingUMesh *MergeUMeshesLL(const std::vector<const MEDCouplingUMesh *>& a);
typedef int (*DimM1DescNbrer)(int id, unsigned nb, const INTERP_KERNEL::CellModel& cm, bool compute, const int *conn1, const int *conn2);
template<class SonsGenerator>
MEDCouplingUMesh *buildDescendingConnectivityGen(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx, DimM1DescNbrer nbrer) const;
return !meshesImpacted.empty();
}
+/*!
+ * Precondition : all instances in \a mfds should have a single mesh with fields on it. If there is an instance with not exactly one mesh an exception will be thrown.
+ * You can invoke MEDFileFields::partOfThisLyingOnSpecifiedMeshName method to make it work.
+ */
+MCAuto<MEDFileData> MEDFileData::Aggregate(const std::vector<const MEDFileData *>& mfds)
+{
+ if(mfds.empty())
+ throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : empty vector !");
+ std::size_t sz(mfds.size()),i(0);
+ MCAuto<MEDFileData> ret(MEDFileData::New());
+ std::vector<const MEDFileUMesh *> ms(sz);
+ std::vector< std::vector< std::pair<int,int> > > dts(sz);
+ for(std::vector<const MEDFileData *>::const_iterator it=mfds.begin();it!=mfds.end();it++,i++)
+ {
+ const MEDFileData *elt(*it);
+ if(!elt)
+ throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : presence of NULL pointer !");
+ const MEDFileMeshes *meshes(elt->getMeshes());
+ if(!meshes)
+ throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : presence of an instance with no meshes attached on it !");
+ if(meshes->getNumberOfMeshes()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : all instances in input vector must lie on exactly one mesh ! To have it you can invoke partOfThisLyingOnSpecifiedMeshName method.");
+ const MEDFileMesh *mesh(meshes->getMeshAtPos(0));
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : presence of null mesh in a MEDFileData instance among input vector !");
+ const MEDFileUMesh *umesh(dynamic_cast<const MEDFileUMesh *>(mesh));
+ if(!umesh)
+ throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : works only for unstructured meshes !");
+ ms[i]=umesh;
+ dts[i]=umesh->getAllDistributionOfTypes();
+ }
+ MCAuto<MEDFileUMesh> agg_m(MEDFileUMesh::Aggregate(ms));
+ MCAuto<MEDFileMeshes> mss(MEDFileMeshes::New()); mss->pushMesh(agg_m);
+ ret->setMeshes(mss);
+ // fields
+ std::vector<std::string> fieldNames(mfds[0]->getFields()->getFieldsNames());
+ std::set<std::string> fieldNamess(fieldNames.begin(),fieldNames.end());
+ if(fieldNames.size()!=fieldNamess.size())
+ throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : field names must be different each other !");
+ std::vector< std::vector<const MEDFileAnyTypeFieldMultiTS *> > vectOfFields(fieldNames.size());
+ MCAuto<MEDFileFields> fss(MEDFileFields::New());
+ for(std::vector<const MEDFileData *>::const_iterator it=mfds.begin();it!=mfds.end();it++)
+ {
+ std::vector<std::string> fieldNames0((*it)->getFields()->getFieldsNames());
+ std::set<std::string> fieldNamess0(fieldNames0.begin(),fieldNames0.end());
+ if(fieldNamess!=fieldNamess0)
+ throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : field names must be the same for all input instances !");
+ i=0;
+ for(std::vector<std::string>::const_iterator it1=fieldNames.begin();it1!=fieldNames.end();it1++,i++)
+ {
+ const MEDFileAnyTypeFieldMultiTS *fmts((*it)->getFields()->getFieldWithName(*it1));
+ if(!fmts)
+ throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : internal error 1 !");
+ vectOfFields[i].push_back(fmts);
+ }
+ }
+ i=0;
+ for(std::vector<std::string>::const_iterator it1=fieldNames.begin();it1!=fieldNames.end();it1++,i++)
+ {
+ MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(MEDFileAnyTypeFieldMultiTS::Aggregate(vectOfFields[i],dts));
+ fmts->setMeshName(agg_m->getName());
+ fss->pushField(fmts);
+ }
+ ret->setFields(fss);
+ return ret;
+}
+
MEDFileData::MEDFileData()
{
}
MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
MEDLOADER_EXPORT bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName);
MEDLOADER_EXPORT bool unPolyzeMeshes();
+ MEDLOADER_EXPORT static MCAuto<MEDFileData> Aggregate(const std::vector<const MEDFileData *>& mfds);
//
MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
private:
#include "MEDFileField.hxx"
#include "MEDFileMesh.hxx"
#include "MEDLoaderBase.hxx"
+#include "MEDLoaderTraits.hxx"
#include "MEDFileUtilities.hxx"
#include "MEDFileSafeCaller.txx"
#include "MEDFileFieldOverView.hxx"
return true;
}
-MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
-{
-}
-
MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
{
INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
throw INTERP_KERNEL::Exception(oss.str());
}
+/*!
+ * dts = level 1 meshes to aggregate. Level 2 all geo type. Level 3 pair specifying geo type and number of elem in geotype.
+ */
+MCAuto<MEDFileFieldPerMeshPerTypePerDisc> MEDFileFieldPerMeshPerTypePerDisc::Aggregate(int &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
+{
+ MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
+ for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
+ {
+ if(!(*it).second->getProfile().empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
+ if(!(*it).second->getLocalization().empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
+ //getNumberOfTuples
+ }
+ return ret;
+}
+
+MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
+{
+ MCAuto<MEDFileFieldPerMeshPerType> ret(new MEDFileFieldPerMeshPerType(father,gt));
+ std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
+ for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
+ {
+ for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
+ m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
+ }
+ for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
+ {
+ MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
+ ret->_field_pm_pt_pd.push_back(agg);
+ }
+ return ret;
+}
+
+MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
+{
+ MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
+ std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
+ std::size_t i(0);
+ for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
+ {
+ const std::vector< MCAuto< MEDFileFieldPerMeshPerType > >& v((*it)->_field_pm_pt);
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it2=v.begin();it2!=v.end();it2++)
+ {
+ INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
+ m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,*it2));
+ }
+ }
+ int start(0);
+ for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
+ {
+ MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
+ ret->_field_pm_pt.push_back(agg);
+ }
+ return ret;
+}
+
int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
{
int i=0;
return ret.retn();
}
+void MEDFileField1TSWithoutSDA::aggregate(const std::vector<const MEDFileField1TSWithoutSDA *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
+{
+ if(f1tss.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::aggregate : empty vector !");
+ std::vector<const MEDFileFieldPerMesh *> pms;
+ for(std::vector<const MEDFileField1TSWithoutSDA *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++)
+ {
+ if(!*it)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::aggregate : presence of null pointer in input vector !");
+ if((*it)->_field_per_mesh.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::aggregate : no info !");
+ pms.push_back((*it)->_field_per_mesh[0]);
+ }
+ std::vector<std::pair< int, std::pair<int,int> > > extractInfo;
+ MCAuto<MEDFileFieldPerMesh> fpm(MEDFileFieldPerMesh::Aggregate(pms,dts,this,extractInfo));
+ _field_per_mesh.push_back(fpm);
+ int iteration,order;
+ double tv(f1tss[0]->getTime(iteration,order));
+ _iteration=iteration; _order=order; _dt=tv;
+
+}
+
/*!
* Returns a pointer to the underground DataArrayDouble instance. So the
* caller should not decrRef() it. This method allows for a direct access to the field
return fmtsOut.retn();
}
+template<class T>
+MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
+{
+ MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
+ if(f1tss.empty())
+ throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
+ std::size_t sz(f1tss.size()),i(0);
+ std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
+ for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
+ {
+ typename MLFieldTraits<T>::F1TSType const *elt(*it);
+ if(!elt)
+ throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
+ f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
+ }
+ typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
+ if(!retc)
+ throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
+ retc->aggregate(f1tsw,dts);
+ return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
+}
+
+template<class T>
+MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
+{
+ MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
+ if(fmtss.empty())
+ throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
+ std::size_t sz(fmtss.size());
+ for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
+ {
+ typename MLFieldTraits<T>::FMTSType const *elt(*it);
+ if(!elt)
+ throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
+ }
+ int nbTS(fmtss[0]->getNumberOfTS());
+ for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
+ if((*it)->getNumberOfTS()!=nbTS)
+ throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
+ for(int iterTS=0;iterTS<nbTS;iterTS++)
+ {
+ std::size_t i(0);
+ std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
+ for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
+ {
+ f1tss[i]=(*it)->getTimeStepAtPos(i);
+ }
+ MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
+ ret->pushBackTimeStep(f1ts);
+ }
+ return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
+}
+
+/*!
+ * \a dts and \a ftmss are expected to have same size.
+ */
+MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
+{
+ if(fmtss.empty())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
+ std::size_t sz(fmtss.size());
+ std::vector<const MEDFileFieldMultiTS *> fmtss1;
+ std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
+ for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
+ {
+ if(!(*it))
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
+ const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
+ if(elt1)
+ {
+ fmtss1.push_back(elt1);
+ continue;
+ }
+ const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
+ if(elt2)
+ {
+ fmtss2.push_back(elt2);
+ continue;
+ }
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
+ }
+ if(fmtss1.size()!=sz && fmtss2.size()!=sz)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
+ if(fmtss1.size()==sz)
+ return AggregateHelperFMTS<double>(fmtss1,dts);
+ if(fmtss2.size()!=sz)
+ return AggregateHelperFMTS<int>(fmtss2,dts);
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
+}
+
MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
{
return new MEDFileAnyTypeFieldMultiTSIterator(this);
* delete this field using decrRef() as it is no more needed.
* \throw If \a pos is not a valid time step id.
*/
-MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
+MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
{
const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
if(!item)
int getNumberOfTuples() const;
int getStart() const { return _start; }
int getEnd() const { return _end; }
+ int getNumberOfVals() const { return _nval; }
DataArray *getOrCreateAndGetArray();
const DataArray *getOrCreateAndGetArray() const;
const std::vector<std::string>& getInfo() const;
static MEDFileFieldPerMeshPerTypePerDisc *NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
bool isPfl, int nbi, int offset, std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
MEDFileFieldGlobsReal& glob, bool ¬InExisting);
+ static MCAuto<MEDFileFieldPerMeshPerTypePerDisc> Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo);
+ MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type):_type(type),_father(fath),_start(-1),_end(-1),_nval(-1),_loc_id(-5),_profile_it(-1) { }
private:
MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd);
MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const std::string& dummy);
void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId);
const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) const;
+ int getNumberOfLoc() const { return _field_pm_pt_pd.size(); }
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;
void fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
void setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves);
bool keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its);
bool keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its);
static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType);
+ static MCAuto<MEDFileFieldPerMeshPerType> Aggregate(int &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo);
+ MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):_father(father),_geo_type(gt) { }
private:
std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells);
std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells);
std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells);
std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells);
MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd);
- MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType);
private:
MEDFileFieldPerMesh *_father;
std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > _field_pm_pt_pd;
void getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId);
const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const;
+ static MCAuto<MEDFileFieldPerMesh> Aggregate(const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo);
private:
int addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type);
MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
static int ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs);
MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
+ MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const std::string& meshName, int meshIt, int meshOrd):_father(fath),_mesh_name(meshName),_mesh_iteration(meshIt),_mesh_order(meshOrd) { }
private:
std::string _mesh_name;
int _mesh_iteration;
MEDLOADER_EXPORT DataArrayDouble *getOrCreateAndGetArrayDouble();
MEDLOADER_EXPORT const DataArrayDouble *getOrCreateAndGetArrayDouble() const;
MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *convertToInt() const;
+ MEDLOADER_EXPORT void aggregate(const std::vector<const MEDFileField1TSWithoutSDA *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts);
protected:
MCAuto< DataArrayDouble > _arr;
public:
MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayInt() const;
MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const;
+ MEDLOADER_EXPORT void aggregate(const std::vector<const MEDFileIntField1TSWithoutSDA *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts);
protected:
MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
protected:
public:
MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *buildNewEmpty() const = 0;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const;
+ MEDLOADER_EXPORT static MCAuto<MEDFileAnyTypeFieldMultiTS> Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts);
public:
MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed() const;
MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed() const;
MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll=true);
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const;
MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const;
- MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const;
+ MEDLOADER_EXPORT MEDFileIntField1TS *getTimeStepAtPos(int pos) const;
MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const;
//
MEDLOADER_EXPORT MEDCouplingFieldInt *field(int iteration, int order, const MEDFileMesh *mesh) const;
return ret;
}
+/*!
+ * \sa getAllDistributionOfTypes
+ */
std::vector<int> MEDFileMesh::getDistributionOfTypes(int meshDimRelToMax) const
{
MCAuto<MEDCouplingMesh> mLev(getMeshAtLevel(meshDimRelToMax));
return sp->getDirectUndergroundSingleGeoTypeMesh(gt);
}
+/*!
+ * This method returns for each geo types in \a this number of cells with this geo type.
+ * This method returns info as a vector of pair. The first element of pair is geo type and the second the number of cells associated.
+ * This method also returns the number of nodes of \a this (key associated is NORM_ERROR)
+ *
+ * \sa getDistributionOfTypes
+ */
+std::vector< std::pair<int,int> > MEDFileUMesh::getAllDistributionOfTypes() const
+{
+ std::vector< std::pair<int,int> > ret;
+ std::vector<int> nel(getNonEmptyLevels());
+ for(std::vector<int>::reverse_iterator it=nel.rbegin();it!=nel.rend();it++)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> gt(getGeoTypesAtLevel(*it));
+ for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it1=gt.begin();it1!=gt.end();it1++)
+ {
+ int nbCells(getNumberOfCellsWithType(*it1));
+ ret.push_back(std::pair<int,int>(*it1,nbCells));
+ }
+ }
+ ret.push_back(std::pair<int,int>(INTERP_KERNEL::NORM_ERROR,getNumberOfNodes()));
+ return ret;
+}
+
/*!
* Given a relative level \a meshDimRelToMax it returns the sorted vector of geometric types present in \a this.
* \throw if the reqsuested \a meshDimRelToMax does not exist.
return ret;
}
+MCAuto<MEDFileUMesh> MEDFileUMesh::Aggregate(const std::vector<const MEDFileUMesh *>& meshes)
+{
+ if(meshes.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::Aggregate : empty input vector !");
+ std::size_t sz(meshes.size()),i(0);
+ std::vector<const DataArrayDouble *> coos(sz);
+ std::vector<const DataArrayInt *> fam_coos(sz),num_coos(sz);
+ for(std::vector<const MEDFileUMesh *>::const_iterator it=meshes.begin();it!=meshes.end();it++,i++)
+ {
+ if(!(*it))
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::Aggregate : presence of NULL pointer in input vector !");
+ coos[i]=(*it)->getCoords();
+ fam_coos[i]=(*it)->getFamilyFieldAtLevel(1);
+ num_coos[i]=(*it)->getNumberFieldAtLevel(1);
+ }
+ const MEDFileUMesh *ref(meshes[0]);
+ int spaceDim(ref->getSpaceDimension()),meshDim(ref->getMeshDimension());
+ std::vector<int> levs(ref->getNonEmptyLevels());
+ std::map<int, std::vector<const DataArrayInt *> > m_fam,m_renum;
+ std::map<int, std::vector<const MEDCouplingUMesh *> > m_mesh;
+ std::map<std::string,int> map1;
+ std::map<std::string, std::vector<std::string> > map2;
+ for(std::vector<const MEDFileUMesh *>::const_iterator it=meshes.begin();it!=meshes.end();it++,i++)
+ {
+ if((*it)->getSpaceDimension()!=spaceDim)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::Aggregate : space dimension must be homogeneous !");
+ if((*it)->getMeshDimension()!=meshDim)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::Aggregate : mesh dimension must be homogeneous !");
+ if((*it)->getNonEmptyLevels()!=levs)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::Aggregate : levels must be the same for elements in input vector !");
+ for(std::vector<int>::const_iterator it2=levs.begin();it2!=levs.end();it2++)
+ {
+ m_mesh[*it2].push_back((*it)->getMeshAtLevel(*it2));
+ m_fam[*it2].push_back((*it)->getFamilyFieldAtLevel(*it2));
+ m_renum[*it2].push_back((*it)->getNumberFieldAtLevel(*it2));
+ }
+ const std::map<std::string,int>& locMap1((*it)->getFamilyInfo());
+ for(std::map<std::string,int>::const_iterator it3=locMap1.begin();it3!=locMap1.end();it3++)
+ map1[(*it3).first]=(*it3).second;
+ const std::map<std::string, std::vector<std::string> >& locMap2((*it)->getGroupInfo());
+ for(std::map<std::string, std::vector<std::string> >::const_iterator it4=locMap2.begin();it4!=locMap2.end();it4++)
+ map2[(*it4).first]=(*it4).second;
+ }
+ // Easy part : nodes
+ MCAuto<MEDFileUMesh> ret(MEDFileUMesh::New());
+ MCAuto<DataArrayDouble> coo(DataArrayDouble::Aggregate(coos));
+ ret->setCoords(coo);
+ if(std::find(fam_coos.begin(),fam_coos.end(),(const DataArrayInt *)0)==fam_coos.end())
+ {
+ MCAuto<DataArrayInt> fam_coo(DataArrayInt::Aggregate(fam_coos));
+ ret->setFamilyFieldArr(1,fam_coo);
+ }
+ if(std::find(num_coos.begin(),num_coos.end(),(const DataArrayInt *)0)==num_coos.end())
+ {
+ MCAuto<DataArrayInt> num_coo(DataArrayInt::Aggregate(num_coos));
+ ret->setRenumFieldArr(1,num_coo);
+ }
+ // cells
+ for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
+ {
+ std::map<int, std::vector<const MEDCouplingUMesh *> >::const_iterator it2(m_mesh.find(*it));
+ if(it2==m_mesh.end())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::Aggregate : internal error 1 !");
+ MCAuto<MEDCouplingUMesh> mesh(MEDCouplingUMesh::MergeUMeshes((*it2).second));
+ mesh->setCoords(coo); mesh->setName(ref->getName());
+ ret->setMeshAtLevel(*it,mesh);
+ MCAuto<DataArrayInt> renum(mesh->sortCellsInMEDFileFrmt());
+ std::map<int, std::vector<const DataArrayInt *> >::const_iterator it3(m_fam.find(*it)),it4(m_renum.find(*it));
+ if(it3!=m_fam.end())
+ {
+ const std::vector<const DataArrayInt *>& fams((*it3).second);
+ if(std::find(fams.begin(),fams.end(),(const DataArrayInt *)0)==fams.end())
+ {
+ MCAuto<DataArrayInt> famm(DataArrayInt::Aggregate(fams));
+ famm->renumberInPlace(renum->begin());
+ ret->setFamilyFieldArr(*it,famm);
+ }
+ }
+ if(it4!=m_renum.end())
+ {
+ const std::vector<const DataArrayInt *>& renums((*it4).second);
+ if(std::find(renums.begin(),renums.end(),(const DataArrayInt *)0)==renums.end())
+ {
+ MCAuto<DataArrayInt> renumm(DataArrayInt::Aggregate(renums));
+ renumm->renumberInPlace(renum->begin());
+ ret->setRenumFieldArr(1,renumm);
+ }
+ }
+ }
+ //
+ ret->setFamilyInfo(map1);
+ ret->setGroupInfo(map2);
+ ret->setName(ref->getName());
+ return ret;
+}
+
void MEDFileUMesh::serialize(std::vector<double>& tinyDouble, std::vector<int>& tinyInt, std::vector<std::string>& tinyStr, std::vector< MCAuto<DataArrayInt> >& bigArraysI, MCAuto<DataArrayDouble>& bigArrayD)
{
clearNonDiscrAttributes();
MEDLOADER_EXPORT DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
MEDLOADER_EXPORT MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const;
MEDLOADER_EXPORT std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const;
+ MEDLOADER_EXPORT std::vector< std::pair<int,int> > getAllDistributionOfTypes() const;
MEDLOADER_EXPORT MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const;
MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const;
MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const;
MEDLOADER_EXPORT MEDFileUMesh *linearToQuadratic(int conversionType=0, double eps=1e-12) const;
MEDLOADER_EXPORT MEDFileUMesh *quadraticToLinear(double eps=1e-12) const;
MEDLOADER_EXPORT MCAuto<MEDFileUMesh> symmetry3DPlane(const double point[3], const double normalVector[3]) const;
+ MEDLOADER_EXPORT static MCAuto<MEDFileUMesh> Aggregate(const std::vector<const MEDFileUMesh *>& meshes);
// serialization
MEDLOADER_EXPORT void serialize(std::vector<double>& tinyDouble, std::vector<int>& tinyInt, std::vector<std::string>& tinyStr,
std::vector< MCAuto<DataArrayInt> >& bigArraysI, MCAuto<DataArrayDouble>& bigArrayD);
--- /dev/null
+// Copyright (C) 2016 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, or (at your option) any later version.
+//
+// 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 (EDF R&D)
+
+#ifndef __MEDLOADERTRAITS_HXX__
+#define __MEDLOADERTRAITS_HXX__
+
+#include "MEDLoaderDefines.hxx"
+
+namespace MEDCoupling
+{
+ template<class T>
+ struct MEDLOADER_EXPORT MLFieldTraits
+ {
+ typedef T EltType;
+ };
+
+ class MEDFileFieldMultiTS;
+ class MEDFileField1TS;
+ class MEDFileIntFieldMultiTS;
+ class MEDFileIntField1TS;
+ class MEDFileField1TSWithoutSDA;
+ class MEDFileIntField1TSWithoutSDA;
+
+ template<>
+ struct MEDLOADER_EXPORT MLFieldTraits<double>
+ {
+ typedef MEDFileFieldMultiTS FMTSType;
+ typedef MEDFileField1TS F1TSType;
+ typedef MEDFileField1TSWithoutSDA F1TSWSDAType;
+ };
+
+ template<>
+ struct MEDLOADER_EXPORT MLFieldTraits<int>
+ {
+ typedef MEDFileIntFieldMultiTS FMTSType;
+ typedef MEDFileIntField1TS F1TSType;
+ typedef MEDFileIntField1TSWithoutSDA F1TSWSDAType;
+ };
+}
+
+#endif