//////////////////////////////////////////////////
-MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
+MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector< std::pair<int,med_entity_type> >& nbProfiles , const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
{
- return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
+ return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nbProfiles,nasc,pd);
}
MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
{
}
-MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
+MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector< std::pair<int,med_entity_type> >& nbProfiles, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
{
- INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ _field_pm_pt_pd.resize(std::accumulate(nbProfiles.begin(),nbProfiles.end(),0,[](int p1, const std::pair<int,med_entity_type>& p2) { return p1+p2.first; }));
+ std::size_t i(0);
+ for(auto it : nbProfiles)
+ {
+ for(int j=0;j<it.first;j++)
+ {
+ _field_pm_pt_pd[i++]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,MEDFileMesh::ConvertFromMEDFileEntity(it.second),j,pd);
+ }
+ }
+ /*INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
med_geometry_type mgeoti;
med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
- int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
_field_pm_pt_pd.resize(nbProfiles);
for(int i=0;i<nbProfiles;i++)
{
_field_pm_pt_pd.resize(nbProfiles);
for(int i=0;i<nbProfiles;i++)
_field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_CELLS,i,pd);
- }
+ }*/
}
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)
virtual bool finished() const = 0;
virtual void next() = 0;
virtual int current() const = 0;
- virtual med_entity_type currentET() const = 0;
+ virtual std::vector<med_entity_type> currentET() const = 0;
};
class MFFPMIterSimple : public MFFPMIter
public:
MFFPMIterSimple():_pos(0) { }
void begin() { _pos=0; }
- bool finished() const { return _pos/2>=MED_N_CELL_FIXED_GEO; }
+ bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
void next() { _pos++; }
- int current() const { return _pos/2; }
- med_entity_type currentET() const { return _pos%2==0?MED_CELL:MED_NODE_ELEMENT; }
+ int current() const { return _pos; }
+ std::vector<med_entity_type> currentET() const { return {MED_CELL,MED_NODE_ELEMENT}; }
private:
int _pos;
};
public:
MFFPMIterSimpleLegacy():_pos(0) { }
void begin() { _pos=0; }
- bool finished() const { return _pos/2>=MED_N_CELL_FIXED_GEO; }
+ bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
void next() { _pos++; }
- int current() const { return _pos/2; }
- med_entity_type currentET() const { return _pos%2==0?MED_DESCENDING_FACE:MED_DESCENDING_EDGE; }
+ int current() const { return _pos; }
+ std::vector<med_entity_type> currentET() const { return {MED_DESCENDING_FACE,MED_DESCENDING_EDGE}; }
private:
int _pos;
};
class MFFPMIter2 : public MFFPMIter
{
public:
- MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts, const std::vector<med_entity_type>& entityType);
+ MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts, const std::vector<med_entity_type>& entityType, bool presenceOfNodes);
void begin() { _it=_ids.begin(); }
bool finished() const { return _it==_ids.end(); }
void next() { _it++; }
int current() const { return *_it; }
- med_entity_type currentET() const { return _entityType[std::distance(_ids.begin(),_it)]; }
+ std::vector<med_entity_type> currentET() const { return {_entityType[std::distance(_ids.begin(),_it)]}; }
+ bool presenceOfNodes() const { return _presenceOfNodes; }
private:
+ bool _presenceOfNodes;
std::vector<int> _ids;
std::vector<int>::const_iterator _it;
std::vector<med_entity_type> _entityType;
{
std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
std::vector<med_entity_type> tmp2;
- const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
- for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
- {
- if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
+ const std::vector< std::pair<med_entity_type,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
+ bool presenceOfNodes(false);
+ for(std::vector< std::pair<med_entity_type,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
+ if((*it).first!=MED_NODE)
+ {
tmp.push_back((*it).second);
- tmp2.push_back((*it).first==ON_CELLS || (*it).first==ON_GAUSS_PT?MED_CELL:MED_NODE_ELEMENT);
- }
- return new MFFPMIter2(tmp,tmp2);
+ tmp2.push_back((*it).first);
+ }
+ else
+ presenceOfNodes=true;
+ return new MFFPMIter2(tmp,tmp2,presenceOfNodes);
}
return new TSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
}
const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
if(entities2)
{
- const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
- for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
- if((*it).first==ON_NODES)
+ const std::vector< std::pair<med_entity_type,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
+ for(std::vector< std::pair<med_entity_type,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
+ if((*it).first==MED_NODE)
return true;
return false;
}
}
}
-MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts, const std::vector<med_entity_type>& entityType):_entityType(entityType)
+MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts, const std::vector<med_entity_type>& entityType, bool presenceOfNodes):_presenceOfNodes(presenceOfNodes),_entityType(entityType)
{
std::size_t sz(cts.size());
_ids.resize(sz);
INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
for(iter0->begin();!iter0->finished();iter0->next())
{
- int nbProfile (MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),iter0->currentET(),typmai[iter0->current()],pflName,locName));
- if(nbProfile>0)
+ std::vector< std::pair<int,med_entity_type> > nbProfiles;
+ for(auto entity : iter0->currentET())
+ {
+ int nbProfile(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),entity,typmai[iter0->current()],pflName,locName));
+ if(nbProfile>0)
+ nbProfiles.push_back(std::pair<int,med_entity_type>(nbProfile,entity));
+ }
+ if(!nbProfiles.empty())
{
const PartDefinition *pd(0);
if(mmu)
pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
- _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
+ _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nbProfiles,nasc,pd));
setMeshName(meshName);
}
}
const PartDefinition *pd(0);
if(mmu)
pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
- _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
+ _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,{{nbProfile,MED_NODE}},nasc,pd));
setMeshName(meshName);
}
}
iter0=MFFPMIter::NewCellLegacy(entities);
for(iter0->begin();!iter0->finished();iter0->next())
{
- int nbProfile(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),iter0->currentET(),typmai[iter0->current()],pflName,locName));
- if(nbProfile>0)
+ std::vector< std::pair<int,med_entity_type> > nbProfiles;
+ for(auto entity : iter0->currentET())
+ {
+ int nbProfile(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),entity,typmai[iter0->current()],pflName,locName));
+ if(nbProfile>0)
+ nbProfiles.push_back(std::pair<int,med_entity_type>(nbProfile,entity));
+ }
+ if(!nbProfiles.empty())
{
- _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,NULL));
+ _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nbProfiles,nasc,nullptr));
setMeshName(meshName);
}
}