MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
{
- MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
+ MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
ret->_father=father;
return ret.retn();
}
INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
std::string fieldName(nasc.getName()),meshName(getMeshName());
- int iteration(getIteration()),order(getOrder());
+ int iteration(getIteration()),order(getOrder()),profilesize,nbi;
TypeOfField type(getType());
- INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
- int profilesize,nbi;
med_geometry_type mgeoti;
- med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
+ med_entity_type menti;
+ _father->entriesForMEDfile(type,mgeoti,menti);
int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
_profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
_localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
std::string fieldName(nasc.getName()),meshName(getMeshName());
int iteration(getIteration()),order(getOrder());
TypeOfField type(getType());
- INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
med_geometry_type mgeoti;
- med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
+ med_entity_type menti;
+ _father->entriesForMEDfile(type,mgeoti,menti);
if(_start>_end)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
if(_start==_end)
const char startLine[]=" ## ";
std::string startLine2(bkOffset,' ');
startLine2+=startLine;
- MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
+ INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
oss << startLine2 << "Localization #" << id << "." << std::endl;
oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
- delete tmp;
oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
{
TypeOfField type=getType();
- INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
+ INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
med_geometry_type mgeoti;
- med_entity_type menti=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti);
- const DataArray *arr=getOrCreateAndGetArray();
+ med_entity_type menti;
+ _father->entriesForMEDfile(getType(),mgeoti,menti);
+ const DataArray *arr(getOrCreateAndGetArray());
if(!arr)
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
if(!arr->isAllocated())
return _geo_type;
}
+void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
+{
+ ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
+}
+
void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
{
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
//////////////////////////////////////////////////
+MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
+{
+ if(!entities)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
+ const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
+ if(!entities2)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
+ const MEDFileStructureElement *se(entities2->getWithGT(idGT));
+ return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
+}
+
+MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
+{
+ _se.takeRef(se);
+ INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
+ _field_pm_pt_pd.resize(nbProfiles);
+ for(int i=0;i<nbProfiles;i++)
+ {
+ _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
+ }
+}
+
+int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
+{
+ return _se->getDynGT();
+}
+
+void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
+{
+ throw INTERP_KERNEL::Exception("not implemented yet !");
+}
+
+void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
+{
+ gt=getDynGT();
+ ent=MED_STRUCT_ELEMENT;
+}
+
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
+{
+ throw INTERP_KERNEL::Exception("not implemented yet !");
+}
+
+void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
+{
+ const char startLine[]=" ## ";
+ std::string startLine2(bkOffset,' ');
+ std::string startLine3(startLine2);
+ startLine3+=startLine;
+ oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
+ oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
+ int i=0;
+ for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
+ {
+ if((*it).isNotNull())
+ (*it)->simpleRepr(bkOffset,oss,i);
+ else
+ {
+ oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
+ }
+ }
+}
+
+std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
+{
+ throw INTERP_KERNEL::Exception("not implemented yet !");
+}
+
+MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
+{
+ MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
+ ret->setFather(father);
+ ret->deepCopyElements();
+ return ret.retn();
+}
+
+void MEDFileFieldPerMeshPerTypeDyn::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
+{
+ throw INTERP_KERNEL::Exception("not implemented yet !");
+}
+
+//////////////////////////////////////////////////
+
MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
{
return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
return false;
}
+bool MEDFileFieldPerMesh::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ if((*it).isNotNull())
+ {
+ const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
+ if(pt)
+ return true;
+ }
+ return false;
+}
+
+bool MEDFileFieldPerMesh::onlyStructureElements() const
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ if((*it).isNotNull())
+ {
+ const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
+ if(!pt)
+ return false;
+ }
+ return true;
+}
+
+void MEDFileFieldPerMesh::killStructureElements()
+{
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ {
+ if((*it).isNotNull())
+ {
+ const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
+ if(!pt)
+ res.push_back(*it);
+ }
+ }
+ _field_pm_pt=res;
+}
+
+void MEDFileFieldPerMesh::keepOnlyStructureElements()
+{
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ {
+ if((*it).isNotNull())
+ {
+ const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
+ if(pt)
+ res.push_back(*it);
+ }
+ }
+ _field_pm_pt=res;
+}
+
DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
{
if(!_father)
}
return new MFFPMIter2(tmp);
}
- else
- throw INTERP_KERNEL::Exception("MFFPMIter::NewCell : not recognized type !");
+ return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
}
}
return true;
return false;
}
- else
- throw INTERP_KERNEL::Exception("MFFPMIter::IsPresenceOfNode : not recognized type !");
+ return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
}
}
std::vector<int> dynGT(entities->getDynGTAvail());
for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
{
- std::cerr << "**** " << *it << std::endl;
+ int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
+ if(nbPfl>0)
+ {
+ _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
+ _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
+ }
}
}
return false;
}
+bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ if((*it)->presenceOfStructureElements())
+ return true;
+ return false;
+}
+
+bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ if(!(*it)->onlyStructureElements())
+ return false;
+ return true;
+}
+
+void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ (*it)->killStructureElements();
+}
+
+void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ (*it)->keepOnlyStructureElements();
+}
+
MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to be extracted with \"field\" method ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
{
}
-MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
+MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
{
MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
ret->deepCpyLeavesFrom(*this);
return ret.retn();
}
-MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
+MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
{
- MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
- if((const DataArrayDouble *)_arr)
+ MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
+ if(_arr.isNotNull())
ret->_arr=_arr->deepCopy();
return ret.retn();
}
return getUndergroundDataArrayTemplate();
}
-MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
+MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
{
MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
ret->deepCpyLeavesFrom(*this);
return ret.retn();
}
-MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
+MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
{
- MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
- if((const DataArrayInt *)_arr)
+ MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
+ if(_arr.isNotNull())
ret->_arr=_arr->deepCopy();
return ret.retn();
}
contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
}
-MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
+MEDFileField1TS *MEDFileField1TS::shallowCpy() const
{
return new MEDFileField1TS(*this);
}
{
}
-MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
+MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
{
return new MEDFileIntField1TS(*this);
}
return buildFromTimeStepIds(ids->begin(),ids->end());
}
+bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ if((*it)->presenceOfStructureElements())
+ return true;
+ return false;
+}
+
+bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
+{
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ if(!(*it)->onlyStructureElements())
+ return false;
+ return true;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
+{
+ std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ {
+ if((*it)->presenceOfStructureElements())
+ {
+ if(!(*it)->onlyStructureElements())
+ {
+ (*it)->killStructureElements();
+ ret.push_back(*it);
+ }
+ }
+ else
+ {
+ ret.push_back(*it);
+ }
+ }
+ _time_steps=ret;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
+{
+ std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ {
+ if((*it)->presenceOfStructureElements())
+ {
+ if(!(*it)->onlyStructureElements())
+ (*it)->keepOnlyStructureElements();
+ ret.push_back(*it);
+ }
+ }
+ _time_steps=ret;
+}
+
bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
{
for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return NewWithDynGT(fid,se,loadAll);
+}
+
+MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
+{
if(!se)
throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
return ret.retn();
}
+bool MEDFileFields::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ if((*it).isNotNull())
+ if((*it)->presenceOfStructureElements())
+ return true;
+ return false;
+}
+
+void MEDFileFields::killStructureElements()
+{
+ std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ if((*it).isNotNull())
+ {
+ if((*it)->presenceOfStructureElements())
+ {
+ if(!(*it)->onlyStructureElements())
+ {
+ (*it)->killStructureElements();
+ ret.push_back(*it);
+ }
+ }
+ else
+ {
+ ret.push_back(*it);
+ }
+ }
+ _fields=ret;
+}
+
+void MEDFileFields::keepOnlyStructureElements()
+{
+ std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ if((*it).isNotNull())
+ {
+ if((*it)->presenceOfStructureElements())
+ {
+ if(!(*it)->onlyStructureElements())
+ (*it)->keepOnlyStructureElements();
+ ret.push_back(*it);
+ }
+ }
+ _fields=ret;
+}
+
+MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
+{
+ MCAuto<MEDFileFields> ret(deepCopy());
+ ret->keepOnlyStructureElements();
+ return ret;
+}
+
MEDFileFieldsIterator *MEDFileFields::iterator()
{
return new MEDFileFieldsIterator(this);