ptr->incrRef();
return ret;
}
+
+ template<class T>
+ class MCConstAuto
+ {
+ public:
+ MCConstAuto(const MCConstAuto& other):_ptr(0) { referPtr(other._ptr); }
+ MCConstAuto(const typename MEDCoupling::MCAuto<T> & other):_ptr(0) { referPtr( (const T*) other); }
+ MCConstAuto(const T *ptr=0):_ptr(ptr) { }
+ ~MCConstAuto() { destroyPtr(); }
+ bool isNull() const { return _ptr==0; }
+ bool isNotNull() const { return !isNull(); }
+ void nullify() { destroyPtr(); _ptr=0; }
+ bool operator==(const MCConstAuto& other) const { return _ptr==other._ptr; }
+ bool operator==(const T *other) const { return _ptr==other; }
+ MCConstAuto &operator=(const MCConstAuto& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; }
+ MCConstAuto &operator=(const T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; }
+ void takeRef(const T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; if(_ptr) _ptr->incrRef(); } }
+ const T *operator->() { return _ptr ; }
+ const T *operator->() const { return _ptr; }
+ const T& operator*() { return *_ptr; }
+ const T& operator*() const { return *_ptr; }
+ operator const T *() const { return _ptr; }
+ private:
+ void referPtr(const T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); }
+ void destroyPtr() { if(_ptr) _ptr->decrRef(); }
+ private:
+ const T *_ptr;
+ };
}
#endif
MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const std::string& info);
MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const { return _info_on_compo.size(); }
MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
+ MEDCOUPLING_EXPORT virtual void *getVoidStarPointer() = 0;
MEDCOUPLING_EXPORT virtual DataArray *deepCopy() const = 0;
MEDCOUPLING_EXPORT virtual DataArray *buildNewEmptyInstance() const = 0;
MEDCOUPLING_EXPORT virtual bool isAllocated() const = 0;
MEDCOUPLING_EXPORT int getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); }
MEDCOUPLING_EXPORT std::size_t getNbOfElems() const { return _mem.getNbOfElem(); }
bool empty() const;
+ MEDCOUPLING_EXPORT void *getVoidStarPointer() { return getPointer(); }
MEDCOUPLING_EXPORT const T *getConstPointer() const { return _mem.getConstPointer(); }
MEDCOUPLING_EXPORT const T *begin() const { return getConstPointer(); }
MEDCOUPLING_EXPORT const T *end() const { return getConstPointer()+getNbOfElems(); }
MEDFileData.cxx
MEDFileFieldOverView.cxx
MEDFileMeshReadSelector.cxx
+ MEDFileMeshSupport.cxx
+ MEDFileStructureElement.cxx
+ MEDFileEntities.cxx
+ MEDFileBlowStrEltUp.cxx
SauvMedConvertor.cxx
SauvReader.cxx
SauvWriter.cxx
delete [] _content;
}
+void MEDFileString::clear()
+{
+ std::fill(_content,_content+_max_lgth+1,'\0');
+}
+
void MEDFileString::set(const char *s)
{
if((int)strlen(s)>_max_lgth)
throw INTERP_KERNEL::Exception("Name is too long to be stored in MEDfile !");
- std::fill(_content,_content+_max_lgth+1,'\0');
+ clear();
strcpy(_content,s);
}
public:
MEDFileString(int maxLgth);
~MEDFileString();
+ void clear();
void set(const char *s);
char *getPointer() { return _content; }
const char *getReprForWrite() const { return _content; }
--- /dev/null
+// Copyright (C) 2007-2017 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)
+
+#include "MEDFileBlowStrEltUp.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+
+using namespace MEDCoupling;
+
+const char MEDFileBlowStrEltUp::MED_BALL_STR[]="MED_BALL";
+
+MEDFileBlowStrEltUp::MEDFileBlowStrEltUp(const MEDFileFields *fsOnlyOnSE, const MEDFileMeshes *ms, const MEDFileStructureElements *ses)
+{
+ if(!fsOnlyOnSE || !ms || !ses)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp constructor : NULL input pointer !");
+ _ms.takeRef(ms); _ses.takeRef(ses);
+ std::vector< std::pair<std::string,std::string> > ps;
+ fsOnlyOnSE->getMeshSENames(ps);
+ std::size_t sz(ps.size());
+ _elts.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const std::pair<std::string,std::string>& p(ps[i]);
+ MCAuto<MEDFileFields> f(fsOnlyOnSE->partOfThisLyingOnSpecifiedMeshSEName(p.first,p.second));
+ _elts[i]=f;
+ }
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const std::pair<std::string,std::string>& p(ps[i]);
+ MEDFileMesh *mesh(_ms->getMeshWithName(p.first));
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp : NULL mesh !");
+ MEDFileUMesh *umesh(dynamic_cast<MEDFileUMesh *>(mesh));
+ if(!umesh)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp : Blow up of Stru Elt not managed yet for unstructured meshes !");
+ }
+}
+
+/*!
+ * \param [in] mesh - The mesh containing structure element called \a seName. After the call of this method the Structure elements parts will be removed.
+ * \param [out] mOut - the physical mesh of the structure element \a seName in mesh \a mesh
+ * \param [out] fsOut - the list of var attribute of structure element \a seName - \b WARNING no time steps here
+ */
+MCAuto<MEDFileEltStruct4Mesh> MEDFileBlowStrEltUp::dealWithSEInMesh(const std::string& seName, MEDFileUMesh *mesh, MCAuto<MEDFileUMesh>& mOut, MCAuto<MEDFileFields>& fsOut) const
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithSEInMesh : null pointer !");
+ if(seName==MED_BALL_STR)
+ {
+ MCAuto<MEDFileEltStruct4Mesh> ret(dealWithMEDBALLInMesh(mesh,mOut,fsOut));
+ mesh->killStructureElements();
+ return ret;
+ }
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithSEInMesh : only MED_BALL is managed for the moment, but if you are interested please send spec to anthony.geay@edf.fr !");
+}
+
+MCAuto<MEDFileEltStruct4Mesh> MEDFileBlowStrEltUp::dealWithMEDBALLInMesh(const MEDFileUMesh *mesh, MCAuto<MEDFileUMesh>& mOut, MCAuto<MEDFileFields>& fsOut) const
+{
+ mOut=MEDFileUMesh::New(); fsOut=MEDFileFields::New();
+ const std::vector< MCAuto<MEDFileEltStruct4Mesh> >& strs(mesh->getAccessOfUndergroundEltStrs());
+ MCAuto<MEDFileEltStruct4Mesh> zeStr;
+ for(std::vector< MCAuto<MEDFileEltStruct4Mesh> >::const_iterator it=strs.begin();it!=strs.end();it++)
+ {
+ if((*it)->getGeoTypeName()==MED_BALL_STR)
+ {
+ zeStr=*it;
+ break;
+ }
+ }
+ if(zeStr.isNull())
+ {
+ std::ostringstream oss; oss << "MEDFileBlowStrEltUp::dealWithMEDBALLInMesh : no geo type with name " << MED_BALL_STR << " in " << mesh->getName() << " !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ const DataArrayDouble *coo(mesh->getCoords());
+ if(!coo)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLInMesh : null coords !");
+ MCAuto<DataArrayInt> conn(zeStr->getConn());
+ if(conn.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLInMesh : null connectivity !");
+ conn->checkAllocated();
+ if(conn->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLInMesh : excepted to be single compo !");
+ int nbCells(conn->getNumberOfTuples());
+ MCAuto<DataArrayDouble> connOut(coo->selectByTupleIdSafe(conn->begin(),conn->end()));
+ MCAuto<MEDCouplingUMesh> mcOut(MEDCouplingUMesh::Build0DMeshFromCoords(connOut));
+ mcOut->setName(BuildNewMeshName(mesh->getName(),MED_BALL_STR));
+ mOut->setMeshAtLevel(0,mcOut);
+ const DataArrayInt *ff1(mesh->getFamilyFieldAtLevel(1));
+ if(ff1)
+ {
+ MCAuto<DataArrayInt> ff1o(ff1->selectByTupleIdSafe(conn->begin(),conn->end()));
+ mOut->setFamilyFieldArr(1,ff1o);
+ }
+ const DataArrayInt *nf1(mesh->getNumberFieldAtLevel(1));
+ if(nf1)
+ {
+ MCAuto<DataArrayInt> nf1o(nf1->selectByTupleIdSafe(conn->begin(),conn->end()));
+ mOut->setRenumFieldArr(1,nf1o);
+ }
+ MCAuto<MEDFileUMeshPerTypeCommon> md(zeStr->getMeshDef());
+ const DataArrayInt *ff0(md->getFam());
+ if(ff0)
+ mOut->setFamilyFieldArr(0,const_cast<DataArrayInt *>(ff0));
+ const DataArrayInt *nf0(md->getNum());
+ if(nf0)
+ mOut->setRenumFieldArr(0,const_cast<DataArrayInt *>(nf0));
+ mOut->copyFamGrpMapsFrom(*mesh);
+ const std::vector< MCAuto<DataArray> >& vars(zeStr->getVars());
+ for(std::vector< MCAuto<DataArray> >::const_iterator it=vars.begin();it!=vars.end();it++)
+ {
+ const DataArray *elt(*it);
+ if(!elt)
+ continue;
+ {
+ const DataArrayDouble *eltC(dynamic_cast<const DataArrayDouble *>(elt));
+ if(eltC)
+ {
+ MCAuto<MEDFileFieldMultiTS> fmts(MEDFileFieldMultiTS::New());
+ MCAuto<MEDFileField1TS> f1ts(MEDFileField1TS::New());
+ MCAuto<MEDCouplingFieldDouble> f(MEDCouplingFieldDouble::New(ON_NODES));
+ f->setMesh(mcOut);
+ f->setArray(const_cast<DataArrayDouble *>(eltC));
+ f->setName(eltC->getName());
+ f1ts->setFieldNoProfileSBT(f);
+ fmts->pushBackTimeStep(f1ts);
+ fsOut->pushField(fmts);
+ }
+ }
+ }
+ return zeStr;
+}
+
+/*!
+ * \param [in] fs - fields lying all on same mesh and on same structure element
+ * \param [in] zeStr - ze structure of current structure element
+ * \param [in] varAtt - fields containing var att of current structure element. WARNING at this stage the number of iteration are equal to one for each field in \a varAtt
+ * \param [out] zeOutputs - ze fields that are the concatenation of fields in \a fs transformed and those in \a varAtt normalized in time space
+ */
+void MEDFileBlowStrEltUp::dealWithSEInFields(const std::string& seName, const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const
+{
+ if(!fs)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithSEInFields : null pointer !");
+ if(seName==MED_BALL_STR)
+ {
+ dealWithMEDBALLSInFields(fs,zeStr,varAtt,zeOutputs);
+ return ;
+ }
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithSEInFields : only MED_BALL is managed for the moment, but if you are interested please send spec to anthony.geay@edf.fr !");
+}
+
+void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const
+{
+ int nbf(fs->getNumberOfFields());
+ std::vector< MCAuto<MEDFileAnyTypeFieldMultiTS> > elts0;
+ std::vector< MEDFileAnyTypeFieldMultiTS * > elts1;
+ std::string zeMeshName;
+ for(int i=0;i<nbf;i++)
+ {
+ MCAuto<MEDFileAnyTypeFieldMultiTS> elt(fs->getFieldAtPos(i));
+ MCAuto<MEDFileAnyTypeFieldMultiTS> eltOut(elt->buildNewEmpty());
+ int nbTS(elt->getNumberOfTS());
+ for(int j=0;j<nbTS;j++)
+ {
+ MCAuto<MEDFileAnyTypeField1TS> eltt(elt->getTimeStepAtPos(j));
+ MCAuto<MEDFileAnyTypeField1TS> elttOut(eltt->deepCopy());
+ std::string meshName(eltt->getMeshName());
+ zeMeshName=BuildNewMeshName(meshName,MED_BALL_STR);
+ elttOut->setMeshName(zeMeshName);
+ elttOut->convertMedBallIntoClassic();
+ eltOut->pushBackTimeStep(elttOut);
+ }
+ elts0.push_back(eltOut); elts1.push_back(eltOut);
+ }
+ //
+ const MEDFileMesh *zeCurrentMesh(_ms->getMeshWithName(zeMeshName));
+ //
+ std::size_t ii(0);
+ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > sp(MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(elts1));
+ for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=sp.begin();it0!=sp.end();it0++,ii++)
+ {
+ std::vector< MCAuto<MEDFileFastCellSupportComparator> > fsc;
+ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > sp2(MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(*it0,zeCurrentMesh,fsc));
+ std::size_t jj(0);
+ for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it1=sp2.begin();it1!=sp2.end();it1++,jj++)
+ {
+ for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ zeOutputs->pushField(*it2);
+ // The most exciting part. Users that put profiles on struct elements part of fields. Reduce var att.
+ if((*it1).size()<1)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath !");
+ MCAuto<MEDFileAnyTypeField1TS> zeGuideForPfl;// This var is the reference for pfl management.
+ {
+ if(!(*it1)[0])
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath 2 !");
+ int pdm((*it1)[0]->getNumberOfTS());
+ if(pdm<1)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath 3 !");
+ zeGuideForPfl=(*it1)[0]->getTimeStepAtPos(0);
+ }
+ if(zeGuideForPfl.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath 4 !");
+ std::vector<std::string> pfls(zeGuideForPfl->getPflsReallyUsed());
+ if(pfls.size()>=2)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : drink less coffee");
+ MCAuto<DataArrayInt> pflMyLove;
+ if(pfls.size()==1)
+ pflMyLove.takeRef(zeGuideForPfl->getProfile(pfls[0]));
+ // Yeah we have pfls
+ std::vector<double> t2s;
+ std::vector< std::pair<int,int> > t1s((*it1)[0]->getTimeSteps(t2s));
+ std::size_t nbTS3(t2s.size());
+ int nbf2(varAtt->getNumberOfFields());
+ for(int i=0;i<nbf2;i++)
+ {
+ MCAuto<MEDFileAnyTypeFieldMultiTS> elt(varAtt->getFieldAtPos(i));
+ int nbTS2(elt->getNumberOfTS());
+ if(nbTS2!=1)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : internal error ! The dealWithMEDBALLInMesh is expected to return a single TS !");
+ MCAuto<MEDFileAnyTypeField1TS> elt2(elt->getTimeStepAtPos(0));
+ MCAuto<MEDFileAnyTypeFieldMultiTS> elt4(elt->buildNewEmpty());
+ for(std::size_t j=0;j<nbTS3;j++)
+ {
+ MCAuto<MEDFileAnyTypeField1TS> elt3(elt2->deepCopy());
+ elt3->setTime(t1s[j].first,t1s[j].second,t2s[j]);
+ elt3->setName(BuildVarAttName(ii,sp.size(),jj,sp2.size(),elt3->getName()));
+ if(pflMyLove.isNotNull())
+ elt3->makeReduction(INTERP_KERNEL::NORM_ERROR,ON_NODES,pflMyLove);
+ elt4->pushBackTimeStep(elt3);
+ }
+ zeOutputs->pushField(elt4);
+ }
+ }
+ }
+}
+
+void MEDFileBlowStrEltUp::generate(MEDFileMeshes *msOut, MEDFileFields *allZeOutFields)
+{
+ for(std::vector< MCAuto<MEDFileFields> >::iterator elt=_elts.begin();elt!=_elts.end();elt++)
+ {
+ std::vector< std::pair<std::string,std::string> > ps;
+ (*elt)->getMeshSENames(ps);
+ if(ps.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::generateMeshes : internal error !");
+ MEDFileMesh *mesh(_ms->getMeshWithName(ps[0].first));
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::generateMeshes : NULL mesh !");
+ MEDFileUMesh *umesh(dynamic_cast<MEDFileUMesh *>(mesh));
+ if(!umesh)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::generateMeshes : Blow up of Stru Elt not managed yet for unstructured meshes !");
+ MCAuto<MEDFileUMesh> mOut;
+ MCAuto<MEDFileFields> fsOut1;
+ MCAuto<MEDFileEltStruct4Mesh> zeStr(dealWithSEInMesh(ps[0].second,umesh,mOut,fsOut1));
+ msOut->pushMesh(mOut);
+ dealWithSEInFields(ps[0].second,*elt,zeStr,fsOut1,allZeOutFields);
+ }
+}
+
+std::string MEDFileBlowStrEltUp::BuildNewMeshName(const std::string& meshName, const std::string& seName)
+{
+ std::ostringstream mNameOut;
+ mNameOut << meshName << "_" << seName;
+ return mNameOut.str();
+}
+
+std::string MEDFileBlowStrEltUp::BuildVarAttName(std::size_t iPart, std::size_t totINbParts, std::size_t jPart, std::size_t totJNbParts, const std::string& name)
+{
+ if(totINbParts==1 && totJNbParts==1)
+ return name;
+ std::ostringstream oss;
+ oss << name << "@" << iPart << "@" << jPart;
+ return oss.str();
+}
+
+void MEDFileBlowStrEltUp::DealWithSE(MEDFileFields *fs, MEDFileMeshes *ms, const MEDFileStructureElements *ses)
+{
+ MCAuto<MEDFileFields> fsSEOnly(fs->partOfThisOnStructureElements());
+ fs->killStructureElements();
+ MEDFileBlowStrEltUp bu(fsSEOnly,ms,ses);
+ bu.generate(ms,fs);
+}
--- /dev/null
+// Copyright (C) 2007-2017 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 __MEDFILEBLOWSTRELTUP_HXX__
+#define __MEDFILEBLOWSTRELTUP_HXX__
+
+#include "MEDLoaderDefines.hxx"
+#include "MEDFileUtilities.txx"
+#include "MEDFileMesh.hxx"
+#include "MEDFileField.hxx"
+#include "MEDFileStructureElement.hxx"
+
+#include "MEDCouplingRefCountObject.hxx"
+
+namespace MEDCoupling
+{
+ class MEDFileBlowStrEltUp
+ {
+ public:
+ MEDFileBlowStrEltUp(const MEDFileFields *fsOnlyOnSE, const MEDFileMeshes *ms, const MEDFileStructureElements *ses);
+ static void DealWithSE(MEDFileFields *fs, MEDFileMeshes *ms, const MEDFileStructureElements *ses);
+ private:
+ void generate(MEDFileMeshes *msOut, MEDFileFields *allZeOutFields);
+ MCAuto<MEDFileEltStruct4Mesh> dealWithSEInMesh(const std::string& seName, MEDFileUMesh *mesh, MCAuto<MEDFileUMesh>& mOut, MCAuto<MEDFileFields>& fsOut) const;
+ MCAuto<MEDFileEltStruct4Mesh> dealWithMEDBALLInMesh(const MEDFileUMesh *mesh, MCAuto<MEDFileUMesh>& mOut, MCAuto<MEDFileFields>& fsOut) const;
+ void dealWithSEInFields(const std::string& seName, const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const;
+ void dealWithMEDBALLSInFields(const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const;
+ static std::string BuildNewMeshName(const std::string& meshName, const std::string& seName);
+ static std::string BuildVarAttName(std::size_t iPart, std::size_t totINbParts, std::size_t jPart, std::size_t totJNbParts, const std::string& name);
+ public:
+ static const char MED_BALL_STR[];
+ private:
+ std::vector< MCAuto<MEDFileFields> > _elts;// split by pair(meshName,SEName)
+ MCConstAuto<MEDFileMeshes> _ms;
+ MCConstAuto<MEDFileStructureElements> _ses;
+ };
+}
+
+#endif
// Author : Anthony Geay (CEA/DEN)
#include "MEDFileData.hxx"
+#include "MEDLoaderBase.hxx"
+#include "MEDFileSafeCaller.txx"
+#include "MEDFileBlowStrEltUp.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
using namespace MEDCoupling;
MEDFileData *MEDFileData::deepCopy() const
{
MCAuto<MEDFileFields> fields;
- if((const MEDFileFields *)_fields)
+ if(_fields.isNotNull())
fields=_fields->deepCopy();
MCAuto<MEDFileMeshes> meshes;
- if((const MEDFileMeshes *)_meshes)
+ if(_meshes.isNotNull())
meshes=_meshes->deepCopy();
MCAuto<MEDFileParameters> params;
- if((const MEDFileParameters *)_params)
+ if(_params.isNotNull())
params=_params->deepCopy();
MCAuto<MEDFileData> ret(MEDFileData::New());
ret->_fields=fields; ret->_meshes=meshes; ret->_params=params;
std::size_t MEDFileData::getHeapMemorySizeWithoutChildren() const
{
- return 0;
+ return _header.capacity();
}
std::vector<const BigMemoryObject *> MEDFileData::getDirectChildrenWithNull() const
ret.push_back((const MEDFileFields *)_fields);
ret.push_back((const MEDFileMeshes *)_meshes);
ret.push_back((const MEDFileParameters *)_params);
+ ret.push_back((const MEDFileMeshSupports *)_mesh_supports);
+ ret.push_back((const MEDFileStructureElements *)_struct_elems);
return ret;
}
return !meshesImpacted.empty();
}
+void MEDFileData::dealWithStructureElements()
+{
+ if(_struct_elems.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileData::dealWithStructureElements : no structure elements in this !");
+ if(_meshes.isNull() || _fields.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileData::dealWithStructureElements : meshes and fields must be not null !");
+ MEDFileBlowStrEltUp::DealWithSE(_fields,_meshes,_struct_elems);
+}
+
/*!
* 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.
MEDFileData::MEDFileData(med_idt fid)
try
{
- _fields=MEDFileFields::New(fid);
- _meshes=MEDFileMeshes::New(fid);
- _params=MEDFileParameters::New(fid);
+ readHeader(fid);
+ _mesh_supports=MEDFileMeshSupports::New(fid);
+ _struct_elems=MEDFileStructureElements::New(fid,_mesh_supports);
+ _fields=MEDFileFields::NewWithDynGT(fid,_struct_elems,true);
+ _meshes=MEDFileMeshes::New(fid);
+ _params=MEDFileParameters::New(fid);
}
catch(INTERP_KERNEL::Exception& e)
{
void MEDFileData::writeLL(med_idt fid) const
{
- const MEDFileMeshes *ms(_meshes);
- if(ms)
- ms->writeLL(fid);
- const MEDFileFields *fs(_fields);
- if(fs)
- fs->writeLL(fid);
- const MEDFileParameters *ps(_params);
- if(ps)
- ps->writeLL(fid);
+ writeHeader(fid);
+ if(_meshes.isNotNull())
+ _meshes->writeLL(fid);
+ if(_fields.isNotNull())
+ _fields->writeLL(fid);
+ if(_params.isNotNull())
+ _params->writeLL(fid);
+ if(_mesh_supports.isNotNull())
+ _mesh_supports->writeLL(fid);
+ if(_struct_elems.isNotNull())
+ _struct_elems->writeLL(fid);
+}
+
+std::string MEDFileData::getHeader() const
+{
+ return _header;
+}
+
+
+void MEDFileData::setHeader(const std::string& header)
+{
+ _header=header;
+}
+
+void MEDFileData::readHeader(med_idt fid)
+{
+ INTERP_KERNEL::AutoPtr<char> header(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
+ int ret(MEDfileCommentRd(fid,header));
+ if(ret==0)
+ _header=MEDLoaderBase::buildStringFromFortran(header,MED_COMMENT_SIZE);
+}
+
+void MEDFileData::writeHeader(med_idt fid) const
+{
+ INTERP_KERNEL::AutoPtr<char> header(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
+ MEDLoaderBase::safeStrCpy(_header.c_str(),MED_COMMENT_SIZE,header,_too_long_str);
+ MEDFILESAFECALLERWR0(MEDfileCommentWr,(fid,header));
}
#include "MEDFileParameter.hxx"
#include "MEDFileField.hxx"
#include "MEDFileMesh.hxx"
+#include "MEDFileMeshSupport.hxx"
+#include "MEDFileStructureElement.hxx"
namespace MEDCoupling
{
MEDLOADER_EXPORT int getNumberOfParams() const;
MEDLOADER_EXPORT std::string simpleRepr() const;
//
+ MEDLOADER_EXPORT std::string getHeader() const;
+ MEDLOADER_EXPORT void setHeader(const std::string& header);
+ //
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 void dealWithStructureElements();
MEDLOADER_EXPORT static MCAuto<MEDFileData> Aggregate(const std::vector<const MEDFileData *>& mfds);
//
MEDLOADER_EXPORT void writeLL(med_idt fid) const;
private:
MEDFileData();
MEDFileData(med_idt fid);
+ void readHeader(med_idt fid);
+ void writeHeader(med_idt fid) const;
+ void readMeshSupports(med_idt fid);
private:
MCAuto<MEDFileFields> _fields;
MCAuto<MEDFileMeshes> _meshes;
MCAuto<MEDFileParameters> _params;
+ MCAuto<MEDFileMeshSupports> _mesh_supports;
+ MCAuto<MEDFileStructureElements> _struct_elems;
+ std::string _header;
};
}
--- /dev/null
+// Copyright (C) 2007-2017 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)
+
+#include "MEDFileEntities.hxx"
+
+using namespace MEDCoupling;
+
+MEDFileEntities *MEDFileEntities::BuildFrom(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+{
+ if(!entities)
+ return new MEDFileAllStaticEntites;
+ else
+ return new MEDFileStaticEntities(*entities);
+}
+
+MEDFileEntities *MEDFileEntities::BuildFrom(const MEDFileStructureElements& se)
+{
+ if(se.getNumberOf()==0)
+ return new MEDFileAllStaticEntites;
+ else
+ return new MEDFileAllStaticEntitiesPlusDyn(&se);
+}
+
+MEDFileEntities::~MEDFileEntities()
+{
+}
+
+//////////////
+
+std::vector<int> MEDFileStaticEntities::getDynGTAvail() const
+{
+ return std::vector<int>();
+}
+
+bool MEDFileStaticEntities::areAllStaticTypesPresent() const
+{
+ return false;
+}
+
+//////////////
+
+
+std::vector<int> MEDFileAllStaticEntites::getDynGTAvail() const
+{
+ return std::vector<int>();
+}
+
+bool MEDFileAllStaticEntites::areAllStaticTypesPresent() const
+{
+ return true;
+}
+
+//////////////
+
+MEDFileAllStaticEntitiesPlusDyn::MEDFileAllStaticEntitiesPlusDyn(const MEDFileStructureElements *se):_se(se)
+{
+ if(se)
+ se->incrRef();
+}
+
+std::vector<int> MEDFileAllStaticEntitiesPlusDyn::getDynGTAvail() const
+{
+ return _se->getDynGTAvail();
+}
+
+bool MEDFileAllStaticEntitiesPlusDyn::areAllStaticTypesPresent() const
+{
+ return true;
+}
+
+const MEDFileStructureElement *MEDFileAllStaticEntitiesPlusDyn::getWithGT(int idGT) const
+{
+ return _se->getWithGT(idGT);
+}
+
--- /dev/null
+// Copyright (C) 2007-2017 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 __MEDFILEENTITIES_HXX__
+#define __MEDFILEENTITIES_HXX__
+
+#include "MEDLoaderDefines.hxx"
+
+#include "MEDFileStructureElement.hxx"
+
+#include "MEDCouplingRefCountObject.hxx"
+#include "NormalizedGeometricTypes"
+
+namespace MEDCoupling
+{
+ class MEDFileEntities
+ {
+ public:
+ static MEDFileEntities *BuildFrom(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ static MEDFileEntities *BuildFrom(const MEDFileStructureElements& se);
+ virtual std::vector<int> getDynGTAvail() const = 0;
+ virtual bool areAllStaticTypesPresent() const = 0;
+ virtual ~MEDFileEntities();
+ };
+
+ class MEDFileStaticEntities : public MEDFileEntities
+ {
+ public:
+ MEDFileStaticEntities(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities):_entities(entities) { }
+ const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& getEntries() const { return _entities; }
+ std::vector<int> getDynGTAvail() const;
+ bool areAllStaticTypesPresent() const;
+ private:
+ std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > _entities;
+ };
+
+ class MEDFileAllStaticEntites : public MEDFileEntities
+ {
+ public:
+ MEDFileAllStaticEntites() { }
+ std::vector<int> getDynGTAvail() const;
+ bool areAllStaticTypesPresent() const;
+ };
+
+ class MEDFileAllStaticEntitiesPlusDyn : public MEDFileEntities
+ {
+ public:
+ MEDFileAllStaticEntitiesPlusDyn(const MEDFileStructureElements *se);
+ std::vector<int> getDynGTAvail() const;
+ bool areAllStaticTypesPresent() const;
+ const MEDFileStructureElement *getWithGT(int idGT) const;
+ private:
+ MCConstAuto<MEDFileStructureElements> _se;
+ };
+}
+
+#endif
start=_end;
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
{
return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
{
return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
}
return ret;
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerType *father) const
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
{
- MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
+ MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
ret->_father=father;
return ret.retn();
}
-MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
+MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
{
if(pd)
throw e;
}
-MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
+MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
{
}
}
}
-const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
+const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
{
return _father;
}
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(MEDFileFieldPerMeshPerType::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(MEDFileFieldPerMeshPerType::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;
return _type;
}
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
+{
+ return _father->getGeoType();
+}
+
void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
{
types.insert(_type);
_type=newType;
}
-INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
-{
- return _father->getGeoType();
-}
-
int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
{
return _father->getNumberOfComponents();
const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
{
- const MEDFileFieldPerMeshPerType *fath=_father;
+ const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
return fath->getOrCreateAndGetArray();
}
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=MEDFileFieldPerMeshPerType::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())
}
-MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
+////////////////////////////////////
+
+MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
+ {
+ }
+
+void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
{
- return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
+ _father=father;
}
-MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
+void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
{
- return new MEDFileFieldPerMeshPerType(fath,geoType);
+ std::size_t i=0;
+ for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
+ {
+ if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
+ _field_pm_pt_pd[i]=(*it)->deepCopy(this);
+ }
}
-std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
+std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
{
return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
}
-std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
+std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
{
std::vector<const BigMemoryObject *> ret;
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
return ret;
}
-MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
-{
- MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
- ret->_father=father;
- std::size_t i=0;
- for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
- {
- if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
- ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
- }
- return ret.retn();
-}
-
-void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
* \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
* \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
*/
-void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
_field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
}
-void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
+void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
{
_field_pm_pt_pd.resize(1);
_field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
_field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
}
-void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
+void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
{
MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
if(!arr || !arr->isAllocated())
- throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
_field_pm_pt_pd.resize(1);
_field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
_field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
}
-std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
+std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
{
TypeOfField type=field->getTypeOfField();
if(type!=ON_GAUSS_PT)
}
}
-std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
+std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
{
const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
return ret;
}
-std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
+std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
{
TypeOfField type=field->getTypeOfField();
if(type!=ON_GAUSS_PT)
}
}
-std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
+std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
{
const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
return ret;
}
-const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
+const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
{
return _father;
}
-void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
+bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
{
- const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
- int curDim((int)cm.getDimension());
- dim=std::max(dim,curDim);
-}
-
-bool MEDFileFieldPerMeshPerType::isUniqueLevel(int& dim) const
-{
- const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
int curDim((int)cm.getDimension());
if(dim!=std::numeric_limits<int>::max())
{
return true;
}
-void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
+void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
{
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
{
}
}
-void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
+void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
{
int sz=_field_pm_pt_pd.size();
dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
}
}
-int MEDFileFieldPerMeshPerType::getIteration() const
+int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
{
return _father->getIteration();
}
-int MEDFileFieldPerMeshPerType::getOrder() const
+int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
{
return _father->getOrder();
}
-double MEDFileFieldPerMeshPerType::getTime() const
+double MEDFileFieldPerMeshPerTypeCommon::getTime() const
{
return _father->getTime();
}
-std::string MEDFileFieldPerMeshPerType::getMeshName() const
+std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
{
return _father->getMeshName();
}
-void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
-{
- const char startLine[]=" ## ";
- std::string startLine2(bkOffset,' ');
- std::string startLine3(startLine2);
- startLine3+=startLine;
- if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
- {
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
- oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
- }
- else
- oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << 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++)
- {
- const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
- if(cur)
- cur->simpleRepr(bkOffset,oss,i);
- else
- {
- oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
- }
- }
-}
-
-void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
+void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
{
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
{
nbOfEntries+=(int)_field_pm_pt_pd.size();
}
-INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
-{
- return _geo_type;
-}
-
-
-int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
+int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
{
return _father->getNumberOfComponents();
}
-bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
+bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
{
std::size_t nb(0);
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
return nb>1;
}
-DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
+void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
+{
+ MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
+ elt.takeRef(disc);
+ _field_pm_pt_pd.push_back(elt);
+}
+
+DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
{
return _father->getOrCreateAndGetArray();
}
-const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
+const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
{
const MEDFileFieldPerMesh *fath=_father;
return fath->getOrCreateAndGetArray();
}
-const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
+const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
{
return _father->getInfo();
}
-std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
+std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
{
std::vector<std::string> ret;
std::set<std::string> ret2;
return ret;
}
-std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
+std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
{
std::vector<std::string> ret;
std::set<std::string> ret2;
return ret;
}
-std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
+std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
{
std::vector<std::string> ret;
std::set<std::string> ret2;
return ret;
}
-std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
+std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
{
std::vector<std::string> ret;
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
return ret;
}
-void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
+void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
{
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
(*it1)->changePflsRefsNamesGen(mapOfModif);
}
-void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
+void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
{
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
(*it1)->changeLocsRefsNamesGen(mapOfModif);
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
{
if(_field_pm_pt_pd.empty())
{
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
- std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
+ std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
throw INTERP_KERNEL::Exception(oss.str());
}
if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
return _field_pm_pt_pd[locId];
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
- std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
- oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
+ std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
+ oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
throw INTERP_KERNEL::Exception(oss2.str().c_str());
return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
}
-const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
+const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
{
if(_field_pm_pt_pd.empty())
{
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
- std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
+ std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
throw INTERP_KERNEL::Exception(oss.str());
}
if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
return _field_pm_pt_pd[locId];
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
- std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
- oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
+ std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
+ oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
throw INTERP_KERNEL::Exception(oss2.str().c_str());
return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
}
-void MEDFileFieldPerMeshPerType::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
-{
- if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
- {
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
- if(meshDim!=(int)cm.getDimension())
- return ;
- }
- for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
- (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
-}
-
-void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
+void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
{
int i=0;
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
}
}
-void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
+void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
{
_field_pm_pt_pd=leaves;
for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
* \param [out] its - list of pair (start,stop) kept
* \return bool - false if the type of field \a tof is not contained in \a this.
*/
-bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
+bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
{
bool ret(false);
std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
* \param [out] its - list of pair (start,stop) kept
* \return bool - false if the type of field \a tof is not contained in \a this.
*/
-bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
+bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
{
if(_field_pm_pt_pd.size()<=idOfDisc)
return false;
return true;
}
-MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
+void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
+{
+ for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
+ (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
+}
+
+void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
+{
+ for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
+ (*it)->loadBigArray(fid,nasc);
+}
+
+void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
+{
+ for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
+ {
+ (*it)->copyOptionsFrom(*this);
+ (*it)->writeLL(fid,nasc);
+ }
+}
+
+med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
+{
+ switch(ikType)
+ {
+ case ON_CELLS:
+ medfGeoType=typmai3[(int)ikGeoType];
+ return MED_CELL;
+ case ON_NODES:
+ medfGeoType=MED_NONE;
+ return MED_NODE;
+ case ON_GAUSS_NE:
+ medfGeoType=typmai3[(int)ikGeoType];
+ return MED_NODE_ELEMENT;
+ case ON_GAUSS_PT:
+ medfGeoType=typmai3[(int)ikGeoType];
+ return MED_CELL;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
+ }
+ return MED_UNDEF_ENTITY_TYPE;
+}
+
+//////////////////////////////////////////////////
+
+MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
+{
+ return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
+}
+
+MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
+{
+ return new MEDFileFieldPerMeshPerType(fath,geoType);
+}
+
+MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
+{
+ MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
+ ret->setFather(father);
+ ret->deepCopyElements();
+ return ret.retn();
+}
+
+void MEDFileFieldPerMeshPerType::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
+{
+ if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
+ {
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
+ if(meshDim!=(int)cm.getDimension())
+ return ;
+ }
+ for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
+ (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
+}
+
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
+{
+ 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));
+ int curDim((int)cm.getDimension());
+ dim=std::max(dim,curDim);
+}
+
+void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
+{
+ const char startLine[]=" ## ";
+ std::string startLine2(bkOffset,' ');
+ std::string startLine3(startLine2);
+ startLine3+=startLine;
+ if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
+ {
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
+ oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
+ }
+ else
+ oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << 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++)
+ {
+ const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
+ if(cur)
+ cur->simpleRepr(bkOffset,oss,i);
+ else
+ {
+ oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
+ }
+ }
+}
+
+std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
+{
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
+ return std::string(cm.getRepr());
+}
+
+MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
+{
+}
+
+MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
{
INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
}
}
-void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
+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)
{
- for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
- (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
+ MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(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;
}
-void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
+//////////////////////////////////////////////////
+
+MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
{
- for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
- (*it)->loadBigArray(fid,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);
}
-void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
+MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
{
- for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
+ _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++)
{
- (*it)->copyOptionsFrom(*this);
- (*it)->writeLL(fid,nasc);
+ _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
+ }
+}
+
+int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
+{
+ return _se->getDynGT();
+}
+
+std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
+{
+ return _se->getName();
+}
+
+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;
+ }
}
}
-med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
+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
{
- switch(ikType)
- {
- case ON_CELLS:
- medfGeoType=typmai3[(int)ikGeoType];
- return MED_CELL;
- case ON_NODES:
- medfGeoType=MED_NONE;
- return MED_NODE;
- case ON_GAUSS_NE:
- medfGeoType=typmai3[(int)ikGeoType];
- return MED_NODE_ELEMENT;
- case ON_GAUSS_PT:
- medfGeoType=typmai3[(int)ikGeoType];
- return MED_CELL;
- default:
- throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
- }
- return MED_UNDEF_ENTITY_TYPE;
+ 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 std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+//////////////////////////////////////////////////
+
+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);
}
std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
{
std::vector<const BigMemoryObject *> ret;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
- ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ ret.push_back(*it);
return ret;
}
MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
ret->_father=father;
std::size_t i=0;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
{
- if((const MEDFileFieldPerMeshPerType *)*it)
+ if((*it).isNotNull())
ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
}
return ret.retn();
oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
int i=0;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
{
- const MEDFileFieldPerMeshPerType *cur=*it;
- if(cur)
- cur->simpleRepr(bkOffset,oss,i);
+ if((*it).isNotNull())
+ (*it)->simpleRepr(bkOffset,oss,i);
else
{
oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
}
void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->loadBigArraysRecursively(fid,nasc);
}
void MEDFileFieldPerMesh::getDimension(int& dim) const
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->getDimension(dim);
}
bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
if(!(*it)->isUniqueLevel(dim))
return false;
return true;
void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->fillTypesOfFieldAvailable(types);
}
bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
- const MEDFileFieldPerMeshPerType *fpmt(*it);
- if(!fpmt)
+ if((*it).isNull())
continue;
- if(fpmt->presenceOfMultiDiscPerGeoType())
+ if((*it)->presenceOfMultiDiscPerGeoType())
return true;
}
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;
+}
+
+void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
+{
+ 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)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
+ if(pt->getModelName()==seName)
+ res.push_back(*it);
+ }
+ }
+ _field_pm_pt=res;
+}
+
+void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) 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)
+ {
+ ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
+ }
+ }
+}
+
DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
{
if(!_father)
{
std::vector<std::string> ret;
std::set<std::string> ret2;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
{
std::vector<std::string> ret;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
ret.insert(ret.end(),tmp.begin(),tmp.end());
{
std::vector<std::string> ret;
std::set<std::string> ret2;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
{
std::vector<std::string> ret;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
ret.insert(ret.end(),tmp.begin(),tmp.end());
return false;
}
+void MEDFileFieldPerMesh::convertMedBallIntoClassic()
+{
+ if(_field_pm_pt.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
+ if(_field_pm_pt[0].isNull())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
+ MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
+ if(pt->getNumberOfLoc()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
+ const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
+ if(!disc)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
+ MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
+ disc2->setType(ON_NODES);
+ MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
+ disc2->setFather(pt2);
+ pt2->setFather(this);
+ pt2->pushDiscretization(disc2);
+ _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
+}
+
bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
MEDFileFieldGlobsReal& glob)
{
*/
void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
{
- std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
std::vector< std::pair<int,int> > its2;
if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
*/
void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
{
- std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
std::vector< std::pair<int,int> > its2;
if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
//
- std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
- std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
for(;it1!=types.end();it1++,it2++)
{
MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
elt->setLeaves((*it1).second);
- *it2=elt;
+ MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
+ *it2=elt2;
}
_field_pm_pt=fieldPmPt;
}
void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->changePflsRefsNamesGen(mapOfModif);
}
void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->changeLocsRefsNamesGen(mapOfModif);
}
std::vector<DataArrayInt *> notNullPflsPerGeoType;
std::vector<int> locs,code;
std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
// Sort by types
SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
std::vector<DataArrayInt *> notNullPflsPerGeoType;
std::vector<int> locs,code;
std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
(*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
// Sort by types
SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
{
int globalSz=0;
int nbOfEntries=0;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
(*it)->getSizes(globalSz,nbOfEntries);
}
entries.resize(nbOfEntries);
nbOfEntries=0;
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
(*it)->fillValues(nbOfEntries,entries);
}
MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
if((*it)->getGeoType()==typ)
return (*it)->getLeafGivenLocId(locId);
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
oss << "Possiblities are : ";
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
oss << "\"" << cm2.getRepr() << "\", ";
const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
{
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
if((*it)->getGeoType()==typ)
return (*it)->getLeafGivenLocId(locId);
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
oss << "Possiblities are : ";
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
{
const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
oss << "\"" << cm2.getRepr() << "\", ";
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(int &start, 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::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++)
+ const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::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));
+ const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
+ if(!elt)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
+ m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
}
}
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);
+ MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
+ ret->_field_pm_pt.push_back(agg2);
}
return ret;
}
{
int i=0;
int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
- std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
- for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
{
INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
if(type==curType)
class MFFPMIter
{
public:
- static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
- static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ static MFFPMIter *NewCell(const MEDFileEntities *entities);
+ static bool IsPresenceOfNode(const MEDFileEntities *entities);
virtual ~MFFPMIter() { }
virtual void begin() = 0;
virtual bool finished() const = 0;
std::vector<int>::const_iterator _it;
};
-MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
{
if(!entities)
return new MFFPMIterSimple;
else
{
- std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
- for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
+ const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
+ if(entities2)
{
- if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
- tmp.push_back((*it).second);
+ std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
+ 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)
+ tmp.push_back((*it).second);
+ }
+ return new MFFPMIter2(tmp);
}
- return new MFFPMIter2(tmp);
+ return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
}
}
-bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
{
if(!entities)
return true;
else
{
- for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
- if((*it).first==ON_NODES)
- return true;
- return false;
+ 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)
+ return true;
+ return false;
+ }
+ return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
}
}
/// @endcond
-MEDFileFieldPerMesh::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):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
+MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
_father(fath)
{
INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
_mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
}
}
+ if(!entities)
+ return ;
+ std::vector<int> dynGT(entities->getDynGTAvail());
+ for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
+ {
+ 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);
+ }
+ }
}
MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
return ret;
}
+void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ (*it)->convertMedBallIntoClassic();
+}
+
+void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
+{
+ if(!pfl)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
+ std::string name(pfl->getName());
+ pfl->checkAllocated();
+ if(pfl->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
+ if(name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
+ if(_field_per_mesh.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
+ MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
+ if(fpm.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
+ MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
+ if(disc->getType()!=tof)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
+ int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
+ DataArray *arr(getUndergroundDataArray());
+ int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
+ if(delta<0)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
+ MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
+ MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
+ MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
+ arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
+ arrOut->copyStringInfoFrom(*arr);
+ arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
+ arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
+ arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
+ setArray(arrOut);
+ disc->setEnd(e-delta);
+ disc->setProfile(name);
+}
+
/*!
* \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
* \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
}
-void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
{
med_int numdt,numit;
med_float dt;
(*it)->loadBigArraysRecursively(fid,nasc);
}
-void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
{
loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
loadBigArraysRecursively(fid,nasc);
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();
+}
+
+void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ (*it)->keepOnlyOnSE(seName);
+}
+
+void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ (*it)->getMeshSENames(ps);
+}
+
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();
}
return contentNotNullBase()->getNonEmptyLevels(mname,levs);
}
+void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
+{
+ return contentNotNullBase()->convertMedBallIntoClassic();
+}
+
+void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
+{
+ return contentNotNullBase()->makeReduction(ct,tof,pfl);
+}
+
std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
{
return contentNotNullBase()->getTypesOfFieldAvailable();
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);
}
/*!
* \param [in] fieldId field id in C mode
*/
-MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
{
med_field_type typcha;
std::string dtunitOut;
loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
}
-MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
try:MEDFileFieldNameScope(fieldName),_infos(infos)
{
setDtUnit(dtunit.c_str());
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;
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
+{
+ std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ (*it)->keepOnlyOnSE(seName);
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
+{
+ std::vector< std::pair<std::string,std::string> > ps2;
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ {
+ (*it)->getMeshSENames(ps2);
+ break;
+ }
+ if(ps2.empty())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ {
+ std::vector< std::pair<std::string,std::string> > ps3;
+ (*it)->getMeshSENames(ps3);
+ if(ps2!=ps3)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
+ }
+ for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
+ {
+ std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
+ if(it2==ps.end())
+ ps.push_back(*it);
+ }
+}
+
bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
{
for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
}
}
-void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
{
_time_steps.resize(nbPdt);
for(int i=0;i<nbPdt;i++)
//= MEDFileFieldMultiTSWithoutSDA
-MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
{
return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
}
/*!
* \param [in] fieldId field id in C mode
*/
-MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
{
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
{
}
throw e;
}
-MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
{
med_field_type typcha;
std::vector<std::string> infos;
return ret;
}
-MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
try:MEDFileFieldGlobsReal(fid)
{
_content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
//= MEDFileIntFieldMultiTSWithoutSDA
-MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
{
return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
}
{
}
-MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
{
}
/*!
* \param [in] fieldId field id in C mode
*/
-MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
{
}
MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
- MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,&entities));
+ INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
+ MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
ret->contentNotNull();//to check that content type matches with \a this type.
return ret.retn();
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
{
}
MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
- MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,&entities));
+ INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
+ MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
ret->contentNotNull();//to check that content type matches with \a this type.
return ret.retn();
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
{
}
return New(fid,loadAll);
}
+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 new MEDFileFields(fid,loadAll,0,entities);
+}
+
MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
{
return new MEDFileFields(fid,loadAll,0,0);
MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
{
MEDFileUtilities::CheckFileForRead(fileName);
+ INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
- return new MEDFileFields(fid,loadAll,0,&entities);
+ return new MEDFileFields(fid,loadAll,0,ent);
}
std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
{
}
-MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
+MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
try:MEDFileFieldGlobsReal(fid)
{
int nbFields(MEDnField(fid));
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;
+}
+
+void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
+{
+ std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ if((*it).isNotNull())
+ {
+ if((*it)->getMeshName()!=meshName)
+ continue;
+ std::vector< std::pair<std::string,std::string> > ps;
+ (*it)->getMeshSENames(ps);
+ std::pair<std::string,std::string> p(meshName,seName);
+ if(std::find(ps.begin(),ps.end(),p)!=ps.end())
+ (*it)->keepOnlyOnSE(seName);
+ ret.push_back(*it);
+ }
+ _fields=ret;
+}
+
+void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
+{
+ for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ if((*it).isNotNull())
+ (*it)->getMeshSENames(ps);
+}
+
+MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
+{
+ MCAuto<MEDFileFields> ret(deepCopy());
+ ret->keepOnlyStructureElements();
+ return ret;
+}
+
+MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
+{
+ MCAuto<MEDFileFields> ret(deepCopy());
+ ret->keepOnlyOnMeshSE(meshName,seName);
+ return ret;
+}
+
+void MEDFileFields::aggregate(const MEDFileFields& other)
+{
+ int nbFieldsToAdd(other.getNumberOfFields());
+ std::vector<std::string> fsn(getFieldsNames());
+ for(int i=0;i<nbFieldsToAdd;i++)
+ {
+ MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
+ std::string name(elt->getName());
+ if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
+ {
+ std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ pushField(elt);
+ }
+}
+
MEDFileFieldsIterator *MEDFileFields::iterator()
{
return new MEDFileFieldsIterator(this);
#include "MEDFileFieldOverView.hxx"
#include "MEDFileUtilities.txx"
+#include "MEDFileEntities.hxx"
#include "MCAuto.hxx"
#include "MEDLoaderTraits.hxx"
/// @cond INTERNAL
class MEDFileAnyTypeField1TSWithoutSDA;
+ class MEDFileFieldPerMeshPerTypeCommon;
class MEDFileFieldPerMeshPerType;
class MEDFileField1TSWithoutSDA;
class MEDFileFieldNameScope;
class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject, public MEDFileWritable
{
public:
- static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd);
- static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId);
+ static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd);
+ static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId);
static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other);
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
- MEDFileFieldPerMeshPerTypePerDisc *deepCopy(MEDFileFieldPerMeshPerType *father) const;
+ MEDFileFieldPerMeshPerTypePerDisc *deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const;
void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
void assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob);
void getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const;
void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const;
- const MEDFileFieldPerMeshPerType *getFather() const;
+ const MEDFileFieldPerMeshPerTypeCommon *getFather() const;
void loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc);
void loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc);
void setNewStart(int newValueOfStart);
int getNumberOfTuples() const;
int getStart() const { return _start; }
int getEnd() const { return _end; }
+ void setEnd(int endd) { _end=endd; }
int getNumberOfVals() const { return _nval; }
DataArray *getOrCreateAndGetArray();
const DataArray *getOrCreateAndGetArray() const;
void setLocalization(const std::string& newLocName);
int getLocId() const { return _loc_id; }
void setLocId(int newId) const { _loc_id=newId; }
- void setFather(MEDFileFieldPerMeshPerType *newFather) { _father=newFather; }
+ void setFather(MEDFileFieldPerMeshPerTypeCommon *newFather) { _father=newFather; }
void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
void getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs,
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) { }
+ MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *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);
+ MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd);
+ MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const std::string& dummy);
MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other);
MEDFileFieldPerMeshPerTypePerDisc();
private:
void goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr);
private:
TypeOfField _type;
- MEDFileFieldPerMeshPerType *_father;
+ MEDFileFieldPerMeshPerTypeCommon *_father;
int _start;
int _end;
//! _nval is different than end-start in case of ON_GAUSS_PT and ON_GAUSS_NE ! (_nval=(_end-_start)/nbi)
mutable int _tmp_work1;
};
- class MEDFileFieldPerMeshPerType : public RefCountObject, public MEDFileWritable
+ class MEDFileFieldPerMeshPerTypeCommon : public RefCountObject, public MEDFileWritable
{
public:
- static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType);
- static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd);
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
- MEDFileFieldPerMeshPerType *deepCopy(MEDFileFieldPerMesh *father) const;
void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
void assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob);
void loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc);
void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const;
- void getDimension(int& dim) const;
bool isUniqueLevel(int& dim) const;
void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
void fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const;
int getOrder() const;
double getTime() const;
std::string getMeshName() const;
- void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
void getSizes(int& globalSz, int& nbOfEntries) const;
- INTERP_KERNEL::NormalizedCellType getGeoType() const;
int getNumberOfComponents() const;
bool presenceOfMultiDiscPerGeoType() const;
+ void pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc);
DataArray *getOrCreateAndGetArray();
const DataArray *getOrCreateAndGetArray() const;
const std::vector<std::string>& getInfo() const;
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:
+ MEDFileFieldPerMeshPerTypeCommon(MEDFileFieldPerMesh *father):_father(father) { }
+ void setFather(MEDFileFieldPerMesh *father);
+ public:
+ virtual ~MEDFileFieldPerMeshPerTypeCommon();
+ virtual void getDimension(int& dim) const = 0;
+ virtual INTERP_KERNEL::NormalizedCellType getGeoType() const = 0;
+ virtual void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const = 0;
+ virtual void simpleRepr(int bkOffset, std::ostream& oss, int id) const = 0;
+ virtual std::string getGeoTypeRepr() const = 0;
+ virtual MEDFileFieldPerMeshPerTypeCommon *deepCopy(MEDFileFieldPerMesh *father) const = 0;
+ virtual 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 = 0;
+ protected:
+ void deepCopyElements();
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);
private:
MEDFileFieldPerMesh *_father;
+ protected:
std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > _field_pm_pt_pd;
+ };
+
+ class MEDFileFieldPerMeshPerType : public MEDFileFieldPerMeshPerTypeCommon
+ {
+ public:
+ static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType);
+ static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd);
+ 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);
+ public:// overload of abstract methods
+ void getDimension(int& dim) const;
+ INTERP_KERNEL::NormalizedCellType getGeoType() const;
+ void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const;
+ void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
+ std::string getGeoTypeRepr() const;
+ MEDFileFieldPerMeshPerType *deepCopy(MEDFileFieldPerMesh *father) const;
+ 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;
+ private:
+ MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd);
+ MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt);
+ private:
INTERP_KERNEL::NormalizedCellType _geo_type;
};
+ class MEDFileFieldPerMeshPerTypeDyn : public MEDFileFieldPerMeshPerTypeCommon
+ {
+ public:
+ static MEDFileFieldPerMeshPerTypeDyn *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc);
+ int getDynGT() const;
+ std::string getModelName() const;
+ public:
+ void getDimension(int& dim) const;
+ INTERP_KERNEL::NormalizedCellType getGeoType() const;
+ void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const;
+ void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
+ std::string getGeoTypeRepr() const;
+ MEDFileFieldPerMeshPerTypeDyn *deepCopy(MEDFileFieldPerMesh *father) const;
+ 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;
+ private:
+ MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc);
+ private:
+ MCConstAuto<MEDFileStructureElement> _se;
+ };
+
class MEDFileMesh;
class MEDFileFieldPerMesh : public RefCountObject, public MEDFileWritable
{
public:
static MEDFileFieldPerMesh *New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
- static MEDFileFieldPerMesh *NewOnRead(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);
+ static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities);
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
MEDFileFieldPerMesh *deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const;
std::string getMeshName() const { return _mesh_name; }
int getNumberOfComponents() const;
bool presenceOfMultiDiscPerGeoType() const;
+ bool presenceOfStructureElements() const;
+ bool onlyStructureElements() const;
+ void killStructureElements();
+ void keepOnlyStructureElements();
+ void keepOnlyOnSE(const std::string& seName);
+ void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
DataArray *getOrCreateAndGetArray();
const DataArray *getOrCreateAndGetArray() const;
const std::vector<std::string>& getInfo() const;
std::vector<std::string> getLocsReallyUsed() const;
std::vector<std::string> getPflsReallyUsedMulti() const;
std::vector<std::string> getLocsReallyUsedMulti() const;
+ void convertMedBallIntoClassic();
bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
void keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its);
const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs,
std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls);
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(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *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:
int _mesh_iteration;
int _mesh_order;
MEDFileAnyTypeField1TSWithoutSDA *_father;
- std::vector< MCAuto< MEDFileFieldPerMeshPerType > > _field_pm_pt;
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > _field_pm_pt;
};
class MEDFileFieldGlobsReal;
MEDLOADER_EXPORT void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
//
MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
+ MEDLOADER_EXPORT void convertMedBallIntoClassic();
+ MEDLOADER_EXPORT void makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl);
MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
//
MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
MEDLOADER_EXPORT std::vector<std::string>& getInfo();
MEDLOADER_EXPORT bool presenceOfMultiDiscPerGeoType() const;
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const;
+ MEDLOADER_EXPORT bool onlyStructureElements() const;
+ MEDLOADER_EXPORT void killStructureElements();
+ MEDLOADER_EXPORT void keepOnlyStructureElements();
+ MEDLOADER_EXPORT void keepOnlyOnSE(const std::string& seName);
+ MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& infos);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
public:
MEDLOADER_EXPORT void allocNotFromFile(int newNbOfTuples);
MEDLOADER_EXPORT bool allocIfNecessaryTheArrayToReceiveDataFromFile();
- MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities);
MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc);
- MEDLOADER_EXPORT void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ MEDLOADER_EXPORT void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities);
MEDLOADER_EXPORT void unloadArrays();
MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const;
protected:
public:
MEDLOADER_EXPORT MEDFileField1TSWithoutSDA();
MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
- MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const;
- MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *deepCopy() const;
+ MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *shallowCpy() const;
+ MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *deepCopy() const;
MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *convertToInt() const;
public:
static const char TYPE_STR[];
public:
MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA();
MEDLOADER_EXPORT static MEDFileIntField1TSWithoutSDA *New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
- MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *deepCopy() const;
- MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const;
+ MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *deepCopy() const;
+ MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *shallowCpy() const;
MEDLOADER_EXPORT const char *getTypeStr() const;
MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
+ MEDLOADER_EXPORT void convertMedBallIntoClassic();
+ MEDLOADER_EXPORT void makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl);
public:
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();
MEDLOADER_EXPORT void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
// direct forwarding to MEDFileField1TSWithoutSDA instance _content
public:
- MEDLOADER_EXPORT MEDFileAnyTypeField1TS *shallowCpy() const;
+ MEDLOADER_EXPORT MEDFileField1TS *shallowCpy() const;
MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArray() const;
MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDLOADER_EXPORT static MEDFileIntField1TS *New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileIntField1TS *New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent);
MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const;
- MEDLOADER_EXPORT MEDFileAnyTypeField1TS *shallowCpy() const;
+ MEDLOADER_EXPORT MEDFileIntField1TS *shallowCpy() const;
//
MEDLOADER_EXPORT MEDCouplingFieldInt *field(const MEDFileMesh *mesh) const;
MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const;
protected:
MEDFileAnyTypeFieldMultiTSWithoutSDA();
MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName);
- MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
- MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
public:
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *buildFromTimeStepIds2(int bg, int end, int step) const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const;
+ MEDLOADER_EXPORT bool onlyStructureElements() const;
+ MEDLOADER_EXPORT void killStructureElements();
+ MEDLOADER_EXPORT void keepOnlyStructureElements();
+ MEDLOADER_EXPORT void keepOnlyOnSE(const std::string& seName);
+ MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
MEDLOADER_EXPORT int getPosOfTimeStep(int iteration, int order) const;
MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const;
MEDLOADER_EXPORT std::vector< std::pair<int,int> > getIterations() const;
MEDLOADER_EXPORT DataArray *getUndergroundDataArray(int iteration, int order) const;
MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
- MEDLOADER_EXPORT void loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ MEDLOADER_EXPORT void loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts) const;
MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc);
class MEDFileFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA
{
public:
- MEDLOADER_EXPORT static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
- MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ MEDLOADER_EXPORT static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
+ MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
MEDLOADER_EXPORT const char *getTypeStr() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const;
MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA *convertToInt() const;
protected:
MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName);
- MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
med_field_type getMEDFileFieldType() const { return MED_FLOAT64; }
MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const;
void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const;
class MEDFileIntFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA
{
public:
- MEDLOADER_EXPORT static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
- MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ MEDLOADER_EXPORT static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
+ MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
MEDLOADER_EXPORT const char *getTypeStr() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const;
MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA *convertToDouble() const;
protected:
MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName);
- MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
med_field_type getMEDFileFieldType() const { return MED_INT32; }
MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const;
void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const;
protected:
MEDFileAnyTypeFieldMultiTS();
MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms);
- MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities=0);
+ MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0);
MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c);
static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid);
static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms);
- static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
public:
MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(med_idt fid, bool loadAll=true);
MEDFileFieldMultiTS();
MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms);
- MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities=0);
+ MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0);
};
/*!
MEDFileIntFieldMultiTS();
MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms);
- MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities=0);
+ MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0);
};
class MEDFileAnyTypeFieldMultiTSIterator
};
class MEDFileFieldsIterator;
-
+ class MEDFileStructureElements;
+
/*!
* Use class.
*/
MEDLOADER_EXPORT static MEDFileFields *New();
MEDLOADER_EXPORT static MEDFileFields *New(const std::string& fileName, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileFields *New(med_idt fid, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileFields *NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileFields *NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileFields *New(DataArrayByte *db) { return BuildFromMemoryChunk<MEDFileFields>(db); }
MEDLOADER_EXPORT static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0);
MEDLOADER_EXPORT static MEDFileFields *LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll=true);
MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const;
MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
MEDLOADER_EXPORT MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const;
+ MEDLOADER_EXPORT void killStructureElements();
+ MEDLOADER_EXPORT void keepOnlyStructureElements();
+ MEDLOADER_EXPORT void keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName);
+ MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
+ MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisOnStructureElements() const;
+ MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const;
+ MEDLOADER_EXPORT void aggregate(const MEDFileFields& other);
MEDLOADER_EXPORT MEDFileFieldsIterator *iterator();
MEDLOADER_EXPORT void destroyFieldAtPos(int i);
MEDLOADER_EXPORT void destroyFieldsAtPos(const int *startIds, const int *endIds);
private:
~MEDFileFields() { }
MEDFileFields();
- MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
+ MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
private:
std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > _fields;
};
#include <limits>
#include <cmath>
+extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
+extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
extern med_geometry_type typmai3[34];
using namespace MEDCoupling;
std::size_t MEDFileUMesh::getHeapMemorySizeWithoutChildren() const
{
std::size_t ret(MEDFileMesh::getHeapMemorySizeWithoutChildren());
- ret+=_ms.capacity()*(sizeof(MCAuto<MEDFileUMeshSplitL1>));
+ ret+=_ms.capacity()*(sizeof(MCAuto<MEDFileUMeshSplitL1>))+_elt_str.capacity()*sizeof(MCAuto<MEDFileEltStruct4Mesh>);
return ret;
}
ret.push_back((const PartDefinition *)_part_coords);
for(std::vector< MCAuto<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
ret.push_back((const MEDFileUMeshSplitL1*) *it);
+ for(std::vector< MCAuto<MEDFileEltStruct4Mesh> >::const_iterator it=_elt_str.begin();it!=_elt_str.end();it++)
+ ret.push_back((const MEDFileEltStruct4Mesh *)*it);
return ret;
}
int dummy0,dummy1;
std::string dummy2;
MEDCoupling::MEDCouplingAxisType dummy3;
- int mid(MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy3,dummy0,dummy1,dummy2));
+ INTERP_KERNEL::AutoCppPtr<MeshOrStructMeshCls> mid(MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy3,dummy0,dummy1,dummy2));
if(meshType!=UNSTRUCTURED)
{
std::ostringstream oss; oss << "loadPartUMeshFromFile : Trying to load as unstructured an existing mesh with name '" << mName << "' !";
int dummy0,dummy1;
std::string dummy2;
MEDCoupling::MEDCouplingAxisType axType;
- int mid(MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,axType,dummy0,dummy1,dummy2));
+ INTERP_KERNEL::AutoCppPtr<MeshOrStructMeshCls> mid(MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,axType,dummy0,dummy1,dummy2));
setAxisType(axType);
if(meshType!=UNSTRUCTURED)
{
}
loaderl2.loadAll(fid,mid,mName,dt,it,mrs);
dispatchLoadedPart(fid,loaderl2,mName,mrs);
+ // Structure element part...
+ int nModels(-1);
+ {
+ med_bool chgt=MED_FALSE,trsf=MED_FALSE;
+ nModels=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,MED_GEO_ALL,MED_CONNECTIVITY,MED_NODAL,&chgt,&trsf);
+ }
+ if(nModels<=0)
+ return ;
+ _elt_str.resize(nModels);
+ for(int i=0;i<nModels;i++)
+ _elt_str[i]=MEDFileEltStruct4Mesh::New(fid,mName,dt,it,i,mrs);
}
void MEDFileUMesh::dispatchLoadedPart(med_idt fid, const MEDFileUMeshL2& loaderl2, const std::string& mName, MEDFileMeshReadSelector *mrs)
}
}
+bool MEDFileUMesh::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto<MEDFileEltStruct4Mesh> >::const_iterator it=_elt_str.begin();it!=_elt_str.end();it++)
+ if((*it).isNotNull())
+ return true;
+ return false;
+}
+
+void MEDFileUMesh::killStructureElements()
+{
+ _elt_str.clear();
+}
+
/*!
* Returns the optional numbers of mesh entities of a given dimension transformed using
* DataArrayInt::invertArrayN2O2O2N().
int dummy0,dummy1;
std::string dtunit;
MEDCoupling::MEDCouplingAxisType axType;
- int mid=MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,axType,dummy0,dummy1,dtunit);
+ INTERP_KERNEL::AutoCppPtr<MeshOrStructMeshCls> mid(MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,axType,dummy0,dummy1,dtunit));
if(meshType!=CARTESIAN)
{
std::ostringstream oss; oss << "Trying to load as cartesian an existing mesh with name '" << mName << "' that is NOT cartesian !";
int dummy0,dummy1;
std::string dtunit;
MEDCoupling::MEDCouplingAxisType axType;
- int mid=MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,axType,dummy0,dummy1,dtunit);
+ INTERP_KERNEL::AutoCppPtr<MeshOrStructMeshCls> mid(MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,axType,dummy0,dummy1,dtunit));
setAxisType(axType);
if(meshType!=CURVE_LINEAR)
{
}
}
+bool MEDFileMeshMultiTS::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto<MEDFileMesh> >::const_iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
+ if((*it).isNotNull())
+ if((*it)->presenceOfStructureElements())
+ return true;
+ return false;
+}
+
+void MEDFileMeshMultiTS::killStructureElements()
+{
+ for(std::vector< MCAuto<MEDFileMesh> >::iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
+ if((*it).isNotNull())
+ (*it)->killStructureElements();
+}
+
void MEDFileMeshMultiTS::writeLL(med_idt fid) const
{
MEDFileJoints *joints(getJoints());
}
}
+bool MEDFileMeshes::presenceOfStructureElements() const
+{
+ for(std::vector< MCAuto<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++)
+ if((*it).isNotNull())
+ if((*it)->presenceOfStructureElements())
+ return true;
+ return false;
+}
+
+void MEDFileMeshes::killStructureElements()
+{
+ for(std::vector< MCAuto<MEDFileMeshMultiTS> >::iterator it=_meshes.begin();it!=_meshes.end();it++)
+ if((*it).isNotNull())
+ (*it)->killStructureElements();
+}
+
MEDFileMeshesIterator::MEDFileMeshesIterator(MEDFileMeshes *ms):_ms(ms),_iter_id(0),_nb_iter(0)
{
if(ms)
else
return 0;
}
+
+INTERP_KERNEL::NormalizedCellType MEDFileMesh::ConvertFromMEDFileGeoType(med_geometry_type geoType)
+{
+ med_geometry_type *pos(std::find(typmai,typmai+MED_N_CELL_FIXED_GEO,geoType));
+ if(pos==typmai+MED_N_CELL_FIXED_GEO)
+ {
+ if(geoType==MED_NO_GEOTYPE)
+ return INTERP_KERNEL::NORM_ERROR;
+ std::ostringstream oss; oss << "MEDFileMesh::ConvertFromMEDFileGeoType : no entry with " << geoType << " !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ return typmai2[std::distance(typmai,pos)];
+}
+
+TypeOfField MEDFileMesh::ConvertFromMEDFileEntity(med_entity_type etype)
+{
+ switch(etype)
+ {
+ case MED_NODE:
+ return ON_NODES;
+ case MED_CELL:
+ return ON_CELLS;
+ default:
+ {
+ std::ostringstream oss; oss << "EDFileMesh::ConvertFromMEDFileEntity : not recognized entity " << etype << " !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+}
+
+
MEDLOADER_EXPORT virtual std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const;
MEDLOADER_EXPORT virtual void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const = 0;
MEDLOADER_EXPORT virtual MEDFileMesh *cartesianize() const = 0;
+ MEDLOADER_EXPORT virtual bool presenceOfStructureElements() const = 0;
+ MEDLOADER_EXPORT virtual void killStructureElements() { }
//
MEDLOADER_EXPORT bool areFamsEqual(const MEDFileMesh *other, std::string& what) const;
MEDLOADER_EXPORT bool areGrpsEqual(const MEDFileMesh *other, std::string& what) const;
const MEDFileEquivalences *getEquivalences() const { return _equiv; }
void killEquivalences() { _equiv=(MEDFileEquivalences *)0; }
void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); }
+ static INTERP_KERNEL::NormalizedCellType ConvertFromMEDFileGeoType(med_geometry_type geoType);
+ static TypeOfField ConvertFromMEDFileEntity(med_entity_type etype);
protected:
MEDFileMesh();
//! protected because no way in MED file API to specify this name
MEDLOADER_EXPORT void clearNodeAndCellNumbers();
MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
MEDLOADER_EXPORT void setName(const std::string& name);
+ MEDLOADER_EXPORT const std::vector< MCAuto<MEDFileEltStruct4Mesh> >& getAccessOfUndergroundEltStrs() const { return _elt_str; }
//
MEDLOADER_EXPORT int getMaxAbsFamilyIdInArrays() const;
MEDLOADER_EXPORT int getMaxFamilyIdInArrays() const;
MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
MEDLOADER_EXPORT MEDFileMesh *cartesianize() const;
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const;
+ MEDLOADER_EXPORT void killStructureElements();
MEDLOADER_EXPORT std::vector<int> getNonEmptyLevels() const;
MEDLOADER_EXPORT std::vector<int> getNonEmptyLevelsExt() const;
MEDLOADER_EXPORT std::vector<int> getFamArrNonEmptyLevelsExt() const;
MCAuto<DataArrayAsciiChar> _name_coords;
mutable MCAuto<DataArrayInt> _rev_num_coords;
MCAuto<PartDefinition> _part_coords;
+ std::vector< MCAuto<MEDFileEltStruct4Mesh> > _elt_str;
};
class MEDFileStructuredMesh : public MEDFileMesh
MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const { return false; }
MEDLOADER_EXPORT virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0;
// tools
MEDLOADER_EXPORT bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell);
MEDLOADER_EXPORT void setOneTimeStep(MEDFileMesh *mesh1TimeStep);
MEDLOADER_EXPORT MEDFileJoints *getJoints() const;
MEDLOADER_EXPORT void setJoints(MEDFileJoints* joints);
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const;
+ MEDLOADER_EXPORT void killStructureElements();
private:
~MEDFileMeshMultiTS() { }
void loadFromFile(med_idt fid, const std::string& mName);
MEDLOADER_EXPORT void pushMesh(MEDFileMesh *mesh);
MEDLOADER_EXPORT void setMeshAtPos(int i, MEDFileMesh *mesh);
MEDLOADER_EXPORT void destroyMeshAtPos(int i);
+ MEDLOADER_EXPORT bool presenceOfStructureElements() const;
+ MEDLOADER_EXPORT void killStructureElements();
private:
~MEDFileMeshes() { }
void checkConsistencyLight() const;
using namespace MEDCoupling;
+MEDFileUMeshPerTypeCommon *MEDFileUMeshPerTypeCommon::New()
+{
+ return new MEDFileUMeshPerTypeCommon;
+}
+
+void MEDFileUMeshPerTypeCommon::loadCommonPart(med_idt fid, const char *mName, int dt, int it, int curNbOfElem, med_geometry_type geoElt,
+ med_entity_type entity, MEDFileMeshReadSelector *mrs)
+{
+ med_bool changement,transformation;
+ _fam=0;
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(!mrs || mrs->isCellFamilyFieldReading())
+ {
+ _fam=DataArrayInt::New();
+ _fam->alloc(curNbOfElem,1);
+ if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,geoElt,_fam->getPointer())!=0)
+ std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ }
+ }
+ _num=0;
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(!mrs || mrs->isCellNumFieldReading())
+ {
+ _num=DataArrayInt::New();
+ _num->alloc(curNbOfElem,1);
+ if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,geoElt,_num->getPointer())!=0)
+ _num=0;
+ }
+ }
+ _names=0;
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NAME,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(!mrs || mrs->isCellNameFieldReading())
+ {
+ _names=DataArrayAsciiChar::New();
+ _names->alloc(curNbOfElem+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
+ if(MEDmeshEntityNameRd(fid,mName,dt,it,entity,geoElt,_names->getPointer())!=0)
+ _names=0;
+ else
+ _names->reAlloc(curNbOfElem);//not a bug to avoid the memory corruption due to last \0 at the end
+ }
+ }
+}
+
+std::size_t MEDFileUMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
+{
+ return 0;
+}
+
+std::vector<const BigMemoryObject *> MEDFileUMeshPerTypeCommon::getDirectChildrenWithNull() const
+{
+ std::vector<const BigMemoryObject *> ret;
+ ret.push_back((const DataArrayInt *)_num);
+ ret.push_back((const DataArrayInt *)_fam);
+ ret.push_back((const DataArrayAsciiChar *)_names);
+ return ret;
+}
+
MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2, MEDFileMeshReadSelector *mrs)
{
med_entity_type whichEntity;
std::size_t MEDFileUMeshPerType::getHeapMemorySizeWithoutChildren() const
{
- return 0;
+ return MEDFileUMeshPerTypeCommon::getHeapMemorySizeWithoutChildren()+0;
}
std::vector<const BigMemoryObject *> MEDFileUMeshPerType::getDirectChildrenWithNull() const
{
- std::vector<const BigMemoryObject *> ret;
+ std::vector<const BigMemoryObject *> ret(MEDFileUMeshPerTypeCommon::getDirectChildrenWithNull());
ret.push_back((const MEDCoupling1GTUMesh *)_m);
- ret.push_back((const DataArrayInt *)_num);
- ret.push_back((const DataArrayInt *)_fam);
- ret.push_back((const DataArrayAsciiChar *)_names);
return ret;
}
}
MEDFileUMeshPerType::MEDFileUMeshPerType(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
- med_entity_type entity, MEDFileMeshReadSelector *mrs):_entity(entity)
+ med_entity_type entity, MEDFileMeshReadSelector *mrs)
{
med_bool changement,transformation;
int curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation));
MEDFILESAFECALLERRD0(MEDmeshElementConnectivityRd,(fid,mName,dt,it,entity,geoElt,MED_NODAL,MED_FULL_INTERLACE,conn->getPointer()));
std::transform(conn->begin(),conn->end(),conn->getPointer(),std::bind2nd(std::plus<int>(),-1));
mc->setNodalConnectivity(conn);
- loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
+ loadCommonPart(fid,mName,dt,it,curNbOfElem,geoElt,entity,mrs);
}
void MEDFileUMeshPerType::loadPartStaticType(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
loadPartOfCellCommonPart(fid,mName,strt,end,step,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
}
-void MEDFileUMeshPerType::loadCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt,
- med_entity_type entity, MEDFileMeshReadSelector *mrs)
-{
- med_bool changement,transformation;
- _fam=0;
- if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
- {
- if(!mrs || mrs->isCellFamilyFieldReading())
- {
- _fam=DataArrayInt::New();
- _fam->alloc(curNbOfElem,1);
- if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,geoElt,_fam->getPointer())!=0)
- std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
- }
- }
- _num=0;
- if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
- {
- if(!mrs || mrs->isCellNumFieldReading())
- {
- _num=DataArrayInt::New();
- _num->alloc(curNbOfElem,1);
- if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,geoElt,_num->getPointer())!=0)
- _num=0;
- }
- }
- _names=0;
- if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NAME,MED_NODAL,&changement,&transformation)>0)
- {
- if(!mrs || mrs->isCellNameFieldReading())
- {
- _names=DataArrayAsciiChar::New();
- _names->alloc(curNbOfElem+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
- if(MEDmeshEntityNameRd(fid,mName,dt,it,entity,geoElt,_names->getPointer())!=0)
- _names=0;
- else
- _names->reAlloc(curNbOfElem);//not a bug to avoid the memory corruption due to last \0 at the end
- }
- }
-}
-
void MEDFileUMeshPerType::loadPartOfCellCommonPart(med_idt fid, const char *mName, int strt, int stp, int step, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs)
{
med_bool changement,transformation;
std::transform(conn->begin(),conn->end(),conn->getPointer(),std::bind2nd(std::plus<int>(),-1));
std::transform(connI->begin(),connI->end(),connI->getPointer(),std::bind2nd(std::plus<int>(),-1));
mc->setNodalConnectivity(conn,connI);
- loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
+ loadCommonPart(fid,mName,dt,it,curNbOfElem,geoElt,entity,mrs);
}
void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, int connFaceLgth, med_geometry_type geoElt,
}
}
mc->setNodalConnectivity(conn,connI);
- loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,MED_POLYHEDRON,entity,mrs);
+ loadCommonPart(fid,mName,dt,it,curNbOfElem,MED_POLYHEDRON,entity,mrs);
}
void MEDFileUMeshPerType::Write(med_idt fid, const std::string& mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names)
class MEDCouplingUMesh;
class MEDFileMeshReadSelector;
- class MEDFileUMeshPerType : public RefCountObject
+ class MEDFileUMeshPerTypeCommon : public RefCountObject
+ {
+ public:
+ static MEDFileUMeshPerTypeCommon *New();
+ void loadCommonPart(med_idt fid, const char *mName, int dt, int it, int curNbOfElem, med_geometry_type geoElt,
+ med_entity_type entity, MEDFileMeshReadSelector *mrs);
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ const DataArrayInt *getFam() const { return _fam; }
+ const DataArrayInt *getNum() const { return _num; }
+ const DataArrayAsciiChar *getNames() const { return _names; }
+ protected:
+ MCAuto<DataArrayInt> _num;
+ MCAuto<DataArrayInt> _fam;
+ MCAuto<DataArrayAsciiChar> _names;
+ };
+
+ class MEDFileUMeshPerType : public MEDFileUMeshPerTypeCommon
{
public:
static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2, MEDFileMeshReadSelector *mrs);
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
int getDim() const;
MEDCoupling1GTUMesh *getMesh() const { return const_cast<MEDCoupling1GTUMesh *>((const MEDCoupling1GTUMesh *)_m); }
- const DataArrayInt *getFam() const { return _fam; }
- const DataArrayInt *getNum() const { return _num; }
- const DataArrayAsciiChar *getNames() const { return _names; }
const PartDefinition *getPartDef() const { return _pd; }
static void Write(med_idt fid, const std::string& mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names);
private:
med_entity_type entity, MEDFileMeshReadSelector *mrs);
void loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, int connFaceLgth, med_geometry_type geoElt,
med_entity_type entity, MEDFileMeshReadSelector *mrs);
- void loadCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs);
void loadPartOfCellCommonPart(med_idt fid, const char *mName, int strt, int stp, int step, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs);
private:
MCAuto<MEDCoupling1GTUMesh> _m;
- MCAuto<DataArrayInt> _num;
- MCAuto<DataArrayInt> _fam;
- MCAuto<DataArrayAsciiChar> _names;
MCAuto<PartDefinition> _pd;
- med_entity_type _entity;
};
}
#include "MEDLoaderBase.hxx"
#include "MEDFileSafeCaller.txx"
#include "MEDFileMeshReadSelector.hxx"
+#include "MEDFileStructureElement.hxx"
+#include "MEDFileMeshSupport.hxx"
#include "MEDCouplingUMesh.hxx"
int MEDFileMeshL2::ZE_SEP2_FOR_FAMILY_KILLERS=4;
-MEDFileMeshL2::MEDFileMeshL2():_name(MED_NAME_SIZE),_description(MED_COMMENT_SIZE),_univ_name(MED_LNAME_SIZE),_dt_unit(MED_LNAME_SIZE)
-{
-}
-
-std::size_t MEDFileMeshL2::getHeapMemorySizeWithoutChildren() const
-{
- return 0;
-}
-
-std::vector<const BigMemoryObject *> MEDFileMeshL2::getDirectChildrenWithNull() const
-{
- return std::vector<const BigMemoryObject *>();
-}
-
-int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& dt, int& it, std::string& dtunit1)
+std::vector<std::string> MeshCls::getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const
{
med_mesh_type type_maillage;
- char maillage_description[MED_COMMENT_SIZE+1];
- char dtunit[MED_LNAME_SIZE+1];
- med_int spaceDim,dim;
- char nommaa[MED_NAME_SIZE+1];
- med_int n=MEDnMesh(fid);
- bool found=false;
- int ret=-1;
+ med_int spaceDim;
med_sorting_type stype;
- std::vector<std::string> ms;
- int nstep;
med_axis_type axistype;
- for(int i=0;i<n && !found;i++)
- {
- int naxis(MEDmeshnAxis(fid,i+1));
- INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
- MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit));
- dtunit1=MEDLoaderBase::buildStringFromFortran(dtunit,sizeof(dtunit));
- std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
- ms.push_back(cur);
- if(cur==mname)
- {
- found=true;
- ret=i+1;
- }
- }
- if(!found)
- {
- std::ostringstream oss;
- oss << "No such meshname (" << mname << ") in file ! Must be in : ";
- std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- axType=TraduceAxisType(axistype);
+ int naxis(MEDmeshnAxis(fid,getID()));
+ INTERP_KERNEL::AutoPtr<char> nameTmp(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> axisname(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> axisunit(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> univTmp(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
+ if(MEDmeshInfo(fid,getID(),nameTmp,&spaceDim,&Mdim,&type_maillage,description.getPointer(),dtunit.getPointer(),
+ &stype,&nstep,&axistype,axisname,axisunit)!=0)
+ throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
+ MEDmeshUniversalNameRd(fid,nameTmp,univName.getPointer());// do not protect MEDFILESAFECALLERRD0 call : Thanks to fra.med.
+ axType=MEDFileMeshL2::TraduceAxisType(axistype);
switch(type_maillage)
{
case MED_UNSTRUCTURED_MESH:
case MED_STRUCTURED_MESH:
{
med_grid_type gt;
- MEDFILESAFECALLERRD0(MEDmeshGridTypeRd,(fid,mname.c_str(),>));
+ MEDFILESAFECALLERRD0(MEDmeshGridTypeRd,(fid,mName.c_str(),>));
switch(gt)
{
case MED_CARTESIAN_GRID:
case MED_CURVILINEAR_GRID:
meshType=CURVE_LINEAR;
break;
- case MED_POLAR_GRID:// this is not a bug. A MED file POLAR_GRID is deal by CARTESIAN MEDLoader
+ case MED_POLAR_GRID:// this is not a bug. A MED file POLAR_GRID is deal by CARTESIAN MEDLoader
meshType=CARTESIAN;
break;
default:
- throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::getAxisInfoOnMesh : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
}
break;
}
default:
throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized mesh type !");
}
- med_int numdt,numit;
- med_float dtt;
- MEDFILESAFECALLERRD0(MEDmeshComputationStepInfo,(fid,mname.c_str(),1,&numdt,&numit,&dtt));
- dt=numdt; it=numit;
- return ret;
+ //
+ std::vector<std::string> infosOnComp(naxis);
+ for(int i=0;i<naxis;i++)
+ {
+ std::string info(MEDLoaderBase::buildUnionUnit(((char *)axisname)+i*MED_SNAME_SIZE,MED_SNAME_SIZE,((char *)axisunit)+i*MED_SNAME_SIZE,MED_SNAME_SIZE));
+ infosOnComp[i]=info;
+ }
+ return infosOnComp;
}
-double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it)
+double MeshCls::checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const
{
bool found=false;
med_int numdt,numit;
return dtt;
}
-/*!
- * non static and non const method because _description, _dt_unit... are set in this method.
- */
-std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim)
+std::vector<std::string> StructMeshCls::getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const
+{
+ INTERP_KERNEL::AutoPtr<char> msn(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> zeDescription(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
+ med_axis_type medAxType;
+ int nAxis(MEDsupportMeshnAxis(fid,getID()));
+ INTERP_KERNEL::AutoPtr<char> axisName(new char[MED_SNAME_SIZE*nAxis+1]),axisUnit(new char[MED_SNAME_SIZE*nAxis+1]);
+ int spaceDim(0),meshDim(0);
+ MEDFILESAFECALLERRD0(MEDsupportMeshInfo,(fid,getID(),msn,&spaceDim,&meshDim,zeDescription,&medAxType,axisName,axisUnit));
+ std::string descriptionCpp(MEDLoaderBase::buildStringFromFortran(zeDescription,MED_COMMENT_SIZE));
+ description.set(descriptionCpp.c_str());
+ dtunit.clear(); univName.clear(); meshType=UNSTRUCTURED; nstep=1;
+ axType=MEDFileMeshL2::TraduceAxisType(medAxType);
+ //int nmodels(0);
+ //med_bool chgt=MED_FALSE,trsf=MED_FALSE;
+ //nmodels=MEDmeshnEntity(fid,_name.c_str(),MED_NO_DT,MED_NO_IT,MED_STRUCT_ELEMENT,MED_GEO_ALL,MED_CONNECTIVITY,MED_NODAL,&chgt,&trsf);
+ std::vector<std::string> ret;
+ for(int i=0;i<nAxis;i++)
+ {
+ std::string info(DataArray::BuildInfoFromVarAndUnit(MEDLoaderBase::buildStringFromFortran(axisName+i*MED_SNAME_SIZE,MED_SNAME_SIZE),
+ MEDLoaderBase::buildStringFromFortran(axisUnit+i*MED_SNAME_SIZE,MED_SNAME_SIZE)));
+ ret.push_back(info);
+ }
+ return ret;
+}
+
+double StructMeshCls::checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const
+{
+ return 0.;
+}
+
+MEDFileMeshL2::MEDFileMeshL2():_name(MED_NAME_SIZE),_description(MED_COMMENT_SIZE),_univ_name(MED_LNAME_SIZE),_dt_unit(MED_LNAME_SIZE)
+{
+}
+
+std::size_t MEDFileMeshL2::getHeapMemorySizeWithoutChildren() const
+{
+ return 0;
+}
+
+std::vector<const BigMemoryObject *> MEDFileMeshL2::getDirectChildrenWithNull() const
+{
+ return std::vector<const BigMemoryObject *>();
+}
+
+INTERP_KERNEL::AutoCppPtr<MeshOrStructMeshCls> MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& dt, int& it, std::string& dtunit1)
{
med_mesh_type type_maillage;
- med_int spaceDim;
+ char maillage_description[MED_COMMENT_SIZE+1];
+ char dtunit[MED_LNAME_SIZE+1];
+ med_int spaceDim,dim;
+ char nommaa[MED_NAME_SIZE+1];
+ med_int n=MEDnMesh(fid);
+ char found(0);
+ int ret=-1;
med_sorting_type stype;
+ std::vector<std::string> ms;
+ int nstep;
med_axis_type axistype;
- int naxis(MEDmeshnAxis(fid,mId));
- INTERP_KERNEL::AutoPtr<char> nameTmp=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> univTmp=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
- if(MEDmeshInfo(fid,mId,nameTmp,&spaceDim,&Mdim,&type_maillage,_description.getPointer(),_dt_unit.getPointer(),
- &stype,&nstep,&axistype,axisname,axisunit)!=0)
- throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
- MEDmeshUniversalNameRd(fid,nameTmp,_univ_name.getPointer());// do not protect MEDFILESAFECALLERRD0 call : Thanks to fra.med.
- axType=TraduceAxisType(axistype);
- switch(type_maillage)
- {
- case MED_UNSTRUCTURED_MESH:
- meshType=UNSTRUCTURED;
- break;
- case MED_STRUCTURED_MESH:
- {
- med_grid_type gt;
- MEDFILESAFECALLERRD0(MEDmeshGridTypeRd,(fid,mName.c_str(),>));
- switch(gt)
+ for(int i=0;i<n && found==0;i++)
+ {
+ int naxis(MEDmeshnAxis(fid,i+1));
+ INTERP_KERNEL::AutoPtr<char> axisname(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE)),axisunit(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE));
+ MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit));
+ dtunit1=MEDLoaderBase::buildStringFromFortran(dtunit,sizeof(dtunit));
+ std::string cur(MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa)));
+ ms.push_back(cur);
+ if(cur==mName)
{
- case MED_CARTESIAN_GRID:
- meshType=CARTESIAN;
- break;
- case MED_CURVILINEAR_GRID:
- meshType=CURVE_LINEAR;
- break;
- case MED_POLAR_GRID:// this is not a bug. A MED file POLAR_GRID is deal by CARTESIAN MEDLoader
- meshType=CARTESIAN;
+ found=1;
+ ret=i+1;
+ }
+ }
+ if(found==0)
+ {//last chance ! Is it a support mesh ?
+ int nbSM(MEDnSupportMesh(fid));
+ for(int i=0;i<nbSM && found==0;i++)
+ {
+ int naxis(MEDsupportMeshnAxis(fid,i+1));
+ INTERP_KERNEL::AutoPtr<char> axisname(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE)),axisunit(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE));
+ MEDFILESAFECALLERRD0(MEDsupportMeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,maillage_description,&axistype,axisname,axisunit));
+ std::string cur(MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa)));
+ ms.push_back(cur);
+ if(cur==mName)
+ {
+ found=2;
+ ret=i+1;
+ }
+ }
+ }
+ ////////////////////////
+ switch(found)
+ {
+ case 1:
+ {
+ axType=TraduceAxisType(axistype);
+ switch(type_maillage)
+ {
+ case MED_UNSTRUCTURED_MESH:
+ meshType=UNSTRUCTURED;
break;
+ case MED_STRUCTURED_MESH:
+ {
+ med_grid_type gt;
+ MEDFILESAFECALLERRD0(MEDmeshGridTypeRd,(fid,mName.c_str(),>));
+ switch(gt)
+ {
+ case MED_CARTESIAN_GRID:
+ meshType=CARTESIAN;
+ break;
+ case MED_CURVILINEAR_GRID:
+ meshType=CURVE_LINEAR;
+ break;
+ case MED_POLAR_GRID:// this is not a bug. A MED file POLAR_GRID is deal by CARTESIAN MEDLoader
+ meshType=CARTESIAN;
+ break;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
+ }
+ break;
+ }
default:
- throw INTERP_KERNEL::Exception("MEDFileMeshL2::getAxisInfoOnMesh : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
- }
- break;
+ throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized mesh type !");
+ }
+ med_int numdt,numit;
+ med_float dtt;
+ MEDFILESAFECALLERRD0(MEDmeshComputationStepInfo,(fid,mName.c_str(),1,&numdt,&numit,&dtt));
+ dt=numdt; it=numit;
+ return new MeshCls(ret);
+ }
+ case 2:
+ {
+ meshType=UNSTRUCTURED;
+ dt=MED_NO_DT; it=MED_NO_IT; dtunit1.clear();
+ axType=axType=TraduceAxisType(axistype);
+ return new StructMeshCls(ret);
}
default:
- throw INTERP_KERNEL::Exception("MEDFileMeshL2::getMeshIdFromName : unrecognized mesh type !");
- }
- //
- std::vector<std::string> infosOnComp(naxis);
- for(int i=0;i<naxis;i++)
- {
- std::string info=MEDLoaderBase::buildUnionUnit(((char *)axisname)+i*MED_SNAME_SIZE,MED_SNAME_SIZE,((char *)axisunit)+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
- infosOnComp[i]=info;
+ {
+ std::ostringstream oss;
+ oss << "No such meshname (" << mName << ") in file ! Must be in : ";
+ std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
- return infosOnComp;
+
+}
+
+/*!
+ * non static and non const method because _description, _dt_unit... are set in this method.
+ */
+std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim)
+{
+ return mId->getAxisInfoOnMesh(fid,mName,meshType,axType,nstep,Mdim,_description,_dt_unit,_univ_name);
}
void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const std::string& meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs)
{
}
-std::vector<std::string> MEDFileUMeshL2::loadCommonPart(med_idt fid, int mId, const std::string& mName, int dt, int it, int& Mdim)
+std::vector<std::string> MEDFileUMeshL2::loadCommonPart(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it, int& Mdim)
{
Mdim=-3;
_name.set(mName.c_str());
}
if(meshType!=UNSTRUCTURED)
throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
- _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
+ _time=mId->checkMeshTimeStep(fid,mName,nstep,dt,it);
_iteration=dt;
_order=it;
return ret;
}
-void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileUMeshL2::loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
int Mdim;
std::vector<std::string> infosOnComp(loadCommonPart(fid,mId,mName,dt,it,Mdim));
if(Mdim==-4)
return ;
loadConnectivity(fid,Mdim,mName,dt,it,mrs);//to improve check (dt,it) coherency
- loadCoords(fid,mId,infosOnComp,mName,dt,it);
+ loadCoords(fid,infosOnComp,mName,dt,it);
}
-void MEDFileUMeshL2::loadPart(med_idt fid, int mId, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileUMeshL2::loadPart(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs)
{
int Mdim;
std::vector<std::string> infosOnComp(loadCommonPart(fid,mId,mName,dt,it,Mdim));
for(std::vector< std::vector< MCAuto<MEDFileUMeshPerType> > >::const_iterator it0=_per_type_mesh.begin();it0!=_per_type_mesh.end();it0++)
for(std::vector< MCAuto<MEDFileUMeshPerType> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
(*it1)->getMesh()->renumberNodesWithOffsetInConn(-nMin);
- loadPartCoords(fid,mId,infosOnComp,mName,dt,it,nMin,nMax);
+ loadPartCoords(fid,infosOnComp,mName,dt,it,nMin,nMax);
}
void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
sortTypes();
}
-void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it)
+void MEDFileUMeshL2::loadCoords(med_idt fid, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it)
{
int spaceDim((int)infosOnComp.size());
med_bool changement,transformation;
_coords->setInfoOnComponent(i,infosOnComp[i]);
}
-void MEDFileUMeshL2::loadPartCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it, int nMin, int nMax)
+void MEDFileUMeshL2::loadPartCoords(med_idt fid, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it, int nMin, int nMax)
{
med_bool changement,transformation;
int spaceDim((int)infosOnComp.size()),nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation));
{
}
-void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it)
+void MEDFileCMeshL2::loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it)
{
_name.set(mName.c_str());
int nstep;
int Mdim;
MEDCoupling::MEDCouplingMeshType meshType;
MEDCoupling::MEDCouplingAxisType dummy3;
- std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,dummy3,nstep,Mdim);
+ std::vector<std::string> infosOnComp(getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,dummy3,nstep,Mdim));
if(meshType!=CARTESIAN)
throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
- _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
+ _time=mId->checkMeshTimeStep(fid,mName,nstep,dt,it);
_iteration=dt;
_order=it;
//
{
}
-void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it)
+void MEDFileCLMeshL2::loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it)
{
_name.set(mName.c_str());
int nstep;
int Mdim;
MEDCoupling::MEDCouplingMeshType meshType;
MEDCoupling::MEDCouplingAxisType dummy3;
- std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,dummy3,nstep,Mdim);
+ std::vector<std::string> infosOnComp(getAxisInfoOnMesh(fid,mId,mName,meshType,dummy3,nstep,Mdim));
if(meshType!=CURVE_LINEAR)
throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
- _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
+ _time=mId->checkMeshTimeStep(fid,mName,nstep,dt,it);
_iteration=dt;
_order=it;
//
if(m)
m->setCoords(coords);
}
+
+MEDFileEltStruct4Mesh *MEDFileEltStruct4Mesh::New(med_idt fid, const std::string& mName, int dt, int it, int iterOnStEltOfMesh, MEDFileMeshReadSelector *mrs)
+{
+ return new MEDFileEltStruct4Mesh(fid,mName,dt,it,iterOnStEltOfMesh,mrs);
+}
+
+std::size_t MEDFileEltStruct4Mesh::getHeapMemorySizeWithoutChildren() const
+{
+ return _geo_type_name.capacity()+_vars.capacity()*sizeof(MCAuto<DataArray>);
+}
+
+std::vector<const MEDCoupling::BigMemoryObject*> MEDFileEltStruct4Mesh::getDirectChildrenWithNull() const
+{
+ std::vector<const MEDCoupling::BigMemoryObject*> ret;
+ ret.push_back(_conn);
+ ret.push_back(_common);
+ for(std::vector< MCAuto<DataArray> >::const_iterator it=_vars.begin();it!=_vars.end();it++)
+ ret.push_back(*it);
+ return ret;
+}
+
+MEDFileEltStruct4Mesh::MEDFileEltStruct4Mesh(med_idt fid, const std::string& mName, int dt, int it, int iterOnStEltOfMesh, MEDFileMeshReadSelector *mrs)
+{
+ med_geometry_type geoType;
+ INTERP_KERNEL::AutoPtr<char> geoTypeName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ MEDFILESAFECALLERRD0(MEDmeshEntityInfo,(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,iterOnStEltOfMesh+1,geoTypeName,&geoType));
+ _geo_type=geoType;
+ _geo_type_name=MEDLoaderBase::buildStringFromFortran(geoTypeName,MED_NAME_SIZE);
+ int nCells(0);
+ {
+ med_bool chgt=MED_FALSE,trsf=MED_FALSE;
+ nCells=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,geoType,MED_CONNECTIVITY,MED_NODAL,&chgt,&trsf);
+ }
+ MCAuto<MEDFileMeshSupports> mss(MEDFileMeshSupports::New(fid));
+ MCAuto<MEDFileStructureElements> mse(MEDFileStructureElements::New(fid,mss));
+ int nbEntities(mse->getNumberOfNodesPerSE(_geo_type_name));
+ _conn=DataArrayInt::New(); _conn->alloc(nCells,nbEntities);
+ MEDFILESAFECALLERRD0(MEDmeshElementConnectivityRd,(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,_geo_type,MED_NODAL,MED_FULL_INTERLACE,_conn->getPointer()));
+ _common=MEDFileUMeshPerTypeCommon::New();
+ _common->loadCommonPart(fid,mName.c_str(),dt,it,nCells,geoType,MED_STRUCT_ELEMENT,mrs);
+ std::vector<std::string> vns(mse->getVarAttsOf(_geo_type_name));
+ std::size_t sz(vns.size());
+ _vars.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDFileSEVarAtt *var(mse->getVarAttOf(_geo_type_name,vns[i]));
+ MCAuto<DataArray> gen(var->getGenerator());
+ MCAuto<DataArray> arr(gen->buildNewEmptyInstance());
+ arr->alloc(nCells,var->getNbOfComponents());
+ arr->setName(vns[i]);
+ MEDFILESAFECALLERRD0(MEDmeshStructElementVarAttRd,(fid,mName.c_str(),dt,it,_geo_type,vns[i].c_str(),arr->getVoidStarPointer()));
+ _vars[i]=arr;
+ }
+}
#include "MEDCouplingCurveLinearMesh.hxx"
#include "MCAuto.hxx"
+#include "InterpKernelAutoPtr.hxx"
+
#include "med.h"
#include <map>
{
class MEDFileMeshReadSelector;
+ class MeshOrStructMeshCls
+ {
+ protected:
+ MeshOrStructMeshCls(int mid):_mid(mid) { }
+ public:
+ int getID() const { return _mid; }
+ virtual std::vector<std::string> getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const = 0;
+ virtual double checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const = 0;
+ private:
+ int _mid;
+ };
+
+ class MeshCls : public MeshOrStructMeshCls
+ {
+ public:
+ MeshCls(int mid):MeshOrStructMeshCls(mid) { }
+ std::vector<std::string> getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const;
+ double checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const;
+ };
+
+ class StructMeshCls : public MeshOrStructMeshCls
+ {
+ public:
+ StructMeshCls(int mid):MeshOrStructMeshCls(mid) { }
+ std::vector<std::string> getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const;
+ double checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const;
+ };
+
class MEDFileMeshL2 : public RefCountObject
{
public:
int getOrder() const { return _order; }
double getTime() const { return _time; }
MCAuto<PartDefinition> getPartDefOfCoo() const { return _part_coords; }
- std::vector<std::string> getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim);
- static int GetMeshIdFromName(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& dt, int& it, std::string& dtunit1);
- static double CheckMeshTimeStep(med_idt fid, const std::string& mname, int nstep, int dt, int it);
+ std::vector<std::string> getAxisInfoOnMesh(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim);
+ static INTERP_KERNEL::AutoCppPtr<MeshOrStructMeshCls> GetMeshIdFromName(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& dt, int& it, std::string& dtunit1);
static void ReadFamiliesAndGrps(med_idt fid, const std::string& mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs);
static void WriteFamiliesAndGrps(med_idt fid, const std::string& mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol);
static bool RenameFamiliesFromFileToMem(std::vector< std::string >& famNames);
{
public:
MEDFileUMeshL2();
- std::vector<std::string> loadCommonPart(med_idt fid, int mId, const std::string& mName, int dt, int it, int& Mdim);
- void loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
- void loadPart(med_idt fid, int mId, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs);
+ std::vector<std::string> loadCommonPart(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it, int& Mdim);
+ void loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ void loadPart(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs);
void loadConnectivity(med_idt fid, int mdim, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
void loadPartOfConnectivity(med_idt fid, int mdim, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs);
- void loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it);
- void loadPartCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it, int nMin, int nMax);
+ void loadCoords(med_idt fid, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it);
+ void loadPartCoords(med_idt fid, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it, int nMin, int nMax);
int getNumberOfLevels() const { return _per_type_mesh.size(); }
bool emptyLev(int levId) const { return _per_type_mesh[levId].empty(); }
const std::vector< MCAuto<MEDFileUMeshPerType> >& getLev(int levId) const { return _per_type_mesh[levId]; }
{
public:
MEDFileCMeshL2();
- void loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it);
+ void loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it);
MEDCouplingCMesh *getMesh() { return _cmesh; }
MEDCoupling::MEDCouplingAxisType getAxisType() const { return _ax_type; }
private:
{
public:
MEDFileCLMeshL2();
- void loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it);
+ void loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it);
MEDCouplingCurveLinearMesh *getMesh() { return _clmesh; }
private:
MCAuto<MEDCouplingCurveLinearMesh> _clmesh;
mutable MCAuto<DataArrayInt> _rev_num;
MEDFileUMeshPermCompute _m;
};
+
+ class MEDFileEltStruct4Mesh : public RefCountObject
+ {
+ public:
+ static MEDFileEltStruct4Mesh *New(med_idt fid, const std::string& mName, int dt, int it, int iterOnStEltOfMesh, MEDFileMeshReadSelector *mrs);
+ std::string getGeoTypeName() const { return _geo_type_name; }
+ MCAuto<DataArrayInt> getConn() const { return _conn; }
+ MCAuto<MEDFileUMeshPerTypeCommon> getMeshDef() const { return _common; }
+ const std::vector< MCAuto<DataArray> >& getVars() const { return _vars; }
+ private:
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const MEDCoupling::BigMemoryObject*> getDirectChildrenWithNull() const;
+ private:
+ ~MEDFileEltStruct4Mesh() { }
+ private:
+ MEDFileEltStruct4Mesh(med_idt fid, const std::string& mName, int dt, int it, int iterOnStEltOfMesh, MEDFileMeshReadSelector *mrs);
+ private:
+ std::string _geo_type_name;
+ int _geo_type;
+ MCAuto<DataArrayInt> _conn;
+ MCAuto<MEDFileUMeshPerTypeCommon> _common;
+ std::vector< MCAuto<DataArray> > _vars;
+ };
}
#endif
--- /dev/null
+// Copyright (C) 2007-2017 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)
+
+#include "MEDFileMeshSupport.hxx"
+#include "MEDLoaderBase.hxx"
+#include "MEDFileMeshLL.hxx"
+#include "MEDFileSafeCaller.txx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+using namespace MEDCoupling;
+
+MEDFileMeshSupports *MEDFileMeshSupports::New(const std::string& fileName)
+{
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid);
+}
+
+MEDFileMeshSupports *MEDFileMeshSupports::New(med_idt fid)
+{
+ return new MEDFileMeshSupports(fid);
+}
+
+MEDFileMeshSupports *MEDFileMeshSupports::New()
+{
+ return new MEDFileMeshSupports;
+}
+
+MEDFileMeshSupports::MEDFileMeshSupports(med_idt fid)
+{
+ int nbSM(MEDnSupportMesh(fid));
+ _supports.resize(nbSM);
+ for(int i=0;i<nbSM;i++)
+ {
+ INTERP_KERNEL::AutoPtr<char> msn(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> description(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
+ med_axis_type axType;
+ int nAxis(MEDsupportMeshnAxis(fid,i+1));
+ INTERP_KERNEL::AutoPtr<char> axisName(new char[MED_SNAME_SIZE*nAxis+1]),axisUnit(new char[MED_SNAME_SIZE*nAxis+1]);
+ int spaceDim(0),meshDim(0);
+ MEDFILESAFECALLERRD0(MEDsupportMeshInfo,(fid,i+1,msn,&spaceDim,&meshDim,description,&axType,axisName,axisUnit));
+ std::string name(MEDLoaderBase::buildStringFromFortran(msn,MED_NAME_SIZE));
+ _supports[i]=MEDFileUMesh::New(fid,name);
+ }
+}
+
+MEDFileMeshSupports::MEDFileMeshSupports()
+{
+}
+
+MEDFileMeshSupports::~MEDFileMeshSupports()
+{
+}
+
+std::vector<const BigMemoryObject *> MEDFileMeshSupports::getDirectChildrenWithNull() const
+{
+ std::size_t sz(_supports.size());
+ std::vector<const BigMemoryObject *> ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ ret[i]=_supports[i];
+ return ret;
+}
+
+std::size_t MEDFileMeshSupports::getHeapMemorySizeWithoutChildren() const
+{
+ return _supports.capacity()*sizeof(MCAuto<MEDFileUMesh>);
+}
+
+void MEDFileMeshSupports::writeLL(med_idt fid) const
+{
+ for(std::vector< MCAuto<MEDFileUMesh> >::const_iterator it=_supports.begin();it!=_supports.end();it++)
+ if((*it).isNotNull())
+ (*it)->writeLL(fid);
+}
+
+const MEDFileUMesh *MEDFileMeshSupports::getSupMeshWithName(const std::string& name) const
+{
+ std::vector<std::string> mns;
+ for(std::vector< MCAuto<MEDFileUMesh> >::const_iterator it=_supports.begin();it!=_supports.end();it++)
+ {
+ if((*it).isNotNull())
+ {
+ std::string na((*it)->getName());
+ if(na==name)
+ return *it;
+ else
+ mns.push_back(na);
+ }
+ }
+ std::ostringstream oss;
+ oss << "MEDFileMeshSupports::getSupMeshWithName : no such name \"" << name << "\". Possibilitities are :";
+ std::copy(mns.begin(),mns.end(),std::ostream_iterator<std::string>(oss,","));
+ oss << " !";
+ throw INTERP_KERNEL::Exception(oss.str());
+}
+
+int MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, const std::string& name) const
+{
+ const MEDFileUMesh *sup(getSupMeshWithName(name));
+ switch(entity)
+ {
+ case ON_NODES:
+ return sup->getNumberOfNodes();
+ case ON_CELLS:
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> gt(sup->getAllGeoTypes());
+ if(gt.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : on cells only one geometric type allowed !");
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt[0]));
+ return sup->getNumberOfCellsAtLevel(0)*cm.getNumberOfNodes();
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : not recognized entity type !");
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2017 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 __MEDFILEMESHSUPPORT_HXX__
+#define __MEDFILEMESHSUPPORT_HXX__
+
+#include "MEDLoaderDefines.hxx"
+#include "MEDFileUtilities.txx"
+#include "MEDFileMesh.hxx"
+
+#include "MEDCouplingRefCountObject.hxx"
+
+namespace MEDCoupling
+{
+ class MEDFileMeshSupports : public RefCountObject, public MEDFileWritableStandAlone
+ {
+ public:
+ MEDLOADER_EXPORT static MEDFileMeshSupports *New(const std::string& fileName);
+ MEDLOADER_EXPORT static MEDFileMeshSupports *New(med_idt fid);
+ MEDLOADER_EXPORT static MEDFileMeshSupports *New();
+ public:
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ void writeLL(med_idt fid) const;
+ const MEDFileUMesh *getSupMeshWithName(const std::string& name) const;
+ int getNumberOfNodesInConnOf(TypeOfField entity, const std::string& name) const;
+ private:
+ MEDFileMeshSupports(med_idt fid);
+ MEDFileMeshSupports();
+ ~MEDFileMeshSupports();
+ private:
+ std::vector< MCAuto<MEDFileUMesh> > _supports;
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2017 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)
+
+#include "MEDFileStructureElement.hxx"
+#include "MEDFileMeshSupport.hxx"
+#include "MEDLoaderBase.hxx"
+#include "MEDFileMeshLL.hxx"
+#include "MEDFileSafeCaller.txx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+using namespace MEDCoupling;
+
+
+std::string MEDFileSEHolder::getModelName() const
+{
+ return _father->getName();
+}
+
+std::string MEDFileSEHolder::getName() const
+{
+ return _name;
+}
+
+void MEDFileSEHolder::setName(const std::string& name)
+{
+ _name=name;
+}
+
+std::size_t MEDFileSEHolder::getHeapMemorySizeLoc() const
+{
+ return _name.capacity();
+}
+
+////////////////////
+
+MEDFileSEConstAtt *MEDFileSEConstAtt::New(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh)
+{
+ return new MEDFileSEConstAtt(fid,father,idCstAtt,mesh);
+}
+
+MEDFileSEConstAtt::MEDFileSEConstAtt(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh):MEDFileSEHolder(father)
+{
+ std::string modelName(getModelName());
+ INTERP_KERNEL::AutoPtr<char> constattname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),profilename(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ med_attribute_type constatttype;
+ int nbCompo;
+ med_entity_type met;
+ int pflSz;
+ MEDFILESAFECALLERRD0(MEDstructElementConstAttInfo,(fid,modelName.c_str(),idCstAtt+1,constattname,&constatttype,&nbCompo,&met,profilename,&pflSz));
+ std::string name(MEDLoaderBase::buildStringFromFortran(constattname,MED_NAME_SIZE));
+ setName(name);
+ setProfile(MEDLoaderBase::buildStringFromFortran(profilename,MED_NAME_SIZE));
+ _tof=MEDFileMesh::ConvertFromMEDFileEntity(met);
+ //
+ _val=MEDFileStructureElement::BuildFrom(constatttype);
+ nbCompo=MEDFileStructureElement::EffectiveNbCompo(constatttype,nbCompo);
+ if(pflSz==0 && getProfile().empty())
+ {
+ switch(met)
+ {
+ case MED_CELL:
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> gt(mesh->getAllGeoTypes());
+ if(gt.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileSEConstAtt constr : only one cell type expected !");
+ pflSz=mesh->getNumberOfCellsWithType(gt[0]);
+ break;
+ }
+ case MED_NODE:
+ {
+ pflSz=mesh->getNumberOfNodes();
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileSEConstAtt cstr : not recognized entity type !");
+ }
+ }
+ if(constatttype==MED_ATT_NAME)
+ pflSz++;
+ _val->alloc(pflSz,nbCompo);
+ MEDFILESAFECALLERRD0(MEDstructElementConstAttRd,(fid,modelName.c_str(),name.c_str(),_val->getVoidStarPointer()));
+ if(constatttype==MED_ATT_NAME)
+ { pflSz--; _val->reAlloc(pflSz); }
+}
+
+std::vector<const BigMemoryObject *> MEDFileSEConstAtt::getDirectChildrenWithNull() const
+{
+ std::vector<const BigMemoryObject *> ret;
+ ret.push_back(_val);
+ return ret;
+}
+
+std::size_t MEDFileSEConstAtt::getHeapMemorySizeWithoutChildren() const
+{
+ return getHeapMemorySizeLoc()+_pfl.capacity();
+}
+
+void MEDFileSEConstAtt::writeLL(med_idt fid) const
+{
+}
+
+void MEDFileSEConstAtt::setProfile(const std::string& name)
+{
+ _pfl=name;
+}
+
+std::string MEDFileSEConstAtt::getProfile() const
+{
+ return _pfl;
+}
+
+////////////////////
+
+MEDFileSEVarAtt *MEDFileSEVarAtt::New(med_idt fid, MEDFileStructureElement *father, int idVarAtt)
+{
+ return new MEDFileSEVarAtt(fid,father,idVarAtt);
+}
+
+MEDFileSEVarAtt::MEDFileSEVarAtt(med_idt fid, MEDFileStructureElement *father, int idVarAtt):MEDFileSEHolder(father)
+{
+ std::string modelName(getModelName());
+ INTERP_KERNEL::AutoPtr<char> varattname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),profilename(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ med_attribute_type varatttype;
+ {
+ int pflSz;
+ MEDFILESAFECALLERRD0(MEDstructElementVarAttInfo,(fid,modelName.c_str(),idVarAtt+1,varattname,&varatttype,&_nb_compo));
+ }
+ setName(MEDLoaderBase::buildStringFromFortran(varattname,MED_NAME_SIZE));
+ _gen=MEDFileStructureElement::BuildFrom(varatttype);
+ _gen->alloc(0,1);
+}
+
+std::vector<const BigMemoryObject *> MEDFileSEVarAtt::getDirectChildrenWithNull() const
+{
+ return std::vector<const BigMemoryObject *>();
+}
+
+std::size_t MEDFileSEVarAtt::getHeapMemorySizeWithoutChildren() const
+{
+ return getHeapMemorySizeLoc();
+}
+
+void MEDFileSEVarAtt::writeLL(med_idt fid) const
+{
+}
+
+////////////////////
+
+MEDFileStructureElement *MEDFileStructureElement::New(med_idt fid, int idSE, const MEDFileMeshSupports *ms)
+{
+ return new MEDFileStructureElement(fid,idSE,ms);
+}
+
+MEDFileStructureElement::MEDFileStructureElement(med_idt fid, int idSE, const MEDFileMeshSupports *ms)
+{
+ INTERP_KERNEL::AutoPtr<char> modelName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),supportMeshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ med_geometry_type sgeoType;
+ med_entity_type entiyType;
+ int nConsAttr(0),nVarAttr(0);
+ {
+ med_bool anyPfl;
+ int nnode(0),ncell(0);
+ MEDFILESAFECALLERRD0(MEDstructElementInfo,(fid,idSE+1,modelName,&_id_type,&_dim,supportMeshName,&entiyType,&nnode,&ncell,&sgeoType,&nConsAttr,&anyPfl,&nVarAttr));
+ }
+ _name=MEDLoaderBase::buildStringFromFortran(modelName,MED_NAME_SIZE);
+ _sup_mesh_name=MEDLoaderBase::buildStringFromFortran(supportMeshName,MED_NAME_SIZE);
+ _geo_type=MEDFileMesh::ConvertFromMEDFileGeoType(sgeoType);
+ _tof=MEDFileMesh::ConvertFromMEDFileEntity(entiyType);
+ _cst_att.resize(nConsAttr);
+ for(int i=0;i<nConsAttr;i++)
+ _cst_att[i]=MEDFileSEConstAtt::New(fid,this,i,ms->getSupMeshWithName(_sup_mesh_name));
+ _var_att.resize(nVarAttr);
+ for(int i=0;i<nVarAttr;i++)
+ _var_att[i]=MEDFileSEVarAtt::New(fid,this,i);
+}
+
+std::vector<const BigMemoryObject *> MEDFileStructureElement::getDirectChildrenWithNull() const
+{
+ std::vector<const BigMemoryObject *> ret;
+ for(std::vector< MCAuto<MEDFileSEConstAtt> >::const_iterator it=_cst_att.begin();it!=_cst_att.end();it++)
+ ret.push_back(*it);
+ for(std::vector< MCAuto<MEDFileSEVarAtt> >::const_iterator it=_var_att.begin();it!=_var_att.end();it++)
+ ret.push_back(*it);
+ return ret;
+}
+
+std::size_t MEDFileStructureElement::getHeapMemorySizeWithoutChildren() const
+{
+ return _name.capacity()+_cst_att.capacity()*sizeof(MCAuto<MEDFileSEConstAtt>)+_var_att.capacity()*sizeof(MCAuto<MEDFileSEVarAtt>);
+}
+
+void MEDFileStructureElement::writeLL(med_idt fid) const
+{
+}
+
+std::string MEDFileStructureElement::getName() const
+{
+ return _name;
+}
+
+MCAuto<DataArray> MEDFileStructureElement::BuildFrom(med_attribute_type mat)
+{
+ MCAuto<DataArray> ret;
+ switch(mat)
+ {
+ case MED_ATT_INT:
+ {
+ ret=DataArrayInt::New();
+ break;
+ }
+ case MED_ATT_FLOAT64:
+ {
+ ret=DataArrayDouble::New();
+ break;
+ }
+ case MED_ATT_NAME:
+ {
+ ret=DataArrayAsciiChar::New();
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileStructureElement::BuildFrom : not recognized type ! Only INT and FLOAT64 !");
+ }
+ return ret;
+}
+
+int MEDFileStructureElement::EffectiveNbCompo(med_attribute_type mat, int nbCompo)
+{
+ switch(mat)
+ {
+ case MED_ATT_INT:
+ case MED_ATT_FLOAT64:
+ return nbCompo;
+ case MED_ATT_NAME:
+ return nbCompo*MED_NAME_SIZE;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileStructureElement::BuildFrom : not recognized type ! Only INT and FLOAT64 !");
+ }
+}
+
+int MEDFileStructureElement::getDynGT() const
+{
+ return _id_type;
+}
+
+TypeOfField MEDFileStructureElement::getEntity() const
+{
+ return _tof;
+}
+
+std::string MEDFileStructureElement::getMeshName() const
+{
+ return _sup_mesh_name;
+}
+
+std::vector<std::string> MEDFileStructureElement::getVarAtts() const
+{
+ std::vector<std::string> ret;
+ for(std::vector< MCAuto<MEDFileSEVarAtt> >::const_iterator it=_var_att.begin();it!=_var_att.end();it++)
+ if((*it).isNotNull())
+ ret.push_back((*it)->getName());
+ return ret;
+}
+
+const MEDFileSEVarAtt *MEDFileStructureElement::getVarAtt(const std::string& varName) const
+{
+ for(std::vector< MCAuto<MEDFileSEVarAtt> >::const_iterator it=_var_att.begin();it!=_var_att.end();it++)
+ if((*it).isNotNull())
+ if((*it)->getName()==varName)
+ return *it;
+ std::ostringstream oss; oss << "MEDFileStructureElement::getVarAtt : no var att with name \"" << varName << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str());
+}
+
+////////////////////
+
+MEDFileStructureElements *MEDFileStructureElements::New(const std::string& fileName, const MEDFileMeshSupports *ms)
+{
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,ms);
+}
+
+MEDFileStructureElements *MEDFileStructureElements::New(med_idt fid, const MEDFileMeshSupports *ms)
+{
+ return new MEDFileStructureElements(fid,ms);
+}
+
+MEDFileStructureElements *MEDFileStructureElements::New()
+{
+ return new MEDFileStructureElements;
+}
+
+std::vector<const BigMemoryObject *> MEDFileStructureElements::getDirectChildrenWithNull() const
+{
+ std::vector<const BigMemoryObject *> ret;
+ for(std::vector< MCAuto<MEDFileStructureElement> >::const_iterator it=_elems.begin();it!=_elems.end();it++)
+ ret.push_back(*it);
+ return ret;
+}
+
+std::size_t MEDFileStructureElements::getHeapMemorySizeWithoutChildren() const
+{
+ return _elems.capacity()*sizeof(MEDFileStructureElement);
+}
+
+void MEDFileStructureElements::writeLL(med_idt fid) const
+{
+}
+
+MEDFileStructureElements::MEDFileStructureElements(med_idt fid, const MEDFileMeshSupports *ms)
+{
+ int nbSE(MEDnStructElement(fid));
+ _elems.resize(nbSE);
+ for(int i=0;i<nbSE;i++)
+ _elems[i]=MEDFileStructureElement::New(fid,i,ms);
+ _sup.takeRef(ms);
+}
+
+MEDFileStructureElements::MEDFileStructureElements()
+{
+}
+
+MEDFileStructureElements::~MEDFileStructureElements()
+{
+}
+
+int MEDFileStructureElements::getNumberOf() const
+{
+ return _elems.size();
+}
+
+std::vector<int> MEDFileStructureElements::getDynGTAvail() const
+{
+ std::vector<int> ret;
+ for(std::vector< MCAuto<MEDFileStructureElement> >::const_iterator it=_elems.begin();it!=_elems.end();it++)
+ {
+ const MEDFileStructureElement *elt(*it);
+ if(elt)
+ ret.push_back(elt->getDynGT());
+ }
+ return ret;
+}
+
+const MEDFileStructureElement *MEDFileStructureElements::getWithGT(int idGT) const
+{
+ for(std::vector< MCAuto<MEDFileStructureElement> >::const_iterator it=_elems.begin();it!=_elems.end();it++)
+ if((*it).isNotNull())
+ {
+ if((*it)->getDynGT()==idGT)
+ return *it;
+ }
+ std::ostringstream oss; oss << "MEDFileStructureElements::getWithGT : no such geo type " << idGT << " !";
+ throw INTERP_KERNEL::Exception(oss.str());
+}
+
+int MEDFileStructureElements::getNumberOfNodesPerSE(const std::string& seName) const
+{
+ if(seName=="MED_PARTICLE")
+ return 1;
+ const MEDFileStructureElement *se(getSEWithName(seName));
+ std::string meshName(se->getMeshName());
+ return _sup->getNumberOfNodesInConnOf(se->getEntity(),meshName);
+}
+
+const MEDFileStructureElement *MEDFileStructureElements::getSEWithName(const std::string& seName) const
+{
+ for(std::vector< MCAuto<MEDFileStructureElement> >::const_iterator it=_elems.begin();it!=_elems.end();it++)
+ {
+ if((*it).isNotNull())
+ if((*it)->getName()==seName)
+ return *it;
+ }
+ std::ostringstream oss; oss << "MEDFileStructureElements::getSEWithName : no such structure element with name " << seName << " !";
+ throw INTERP_KERNEL::Exception(oss.str());
+}
+
+std::vector<std::string> MEDFileStructureElements::getVarAttsOf(const std::string& seName) const
+{
+ const MEDFileStructureElement *se(getSEWithName(seName));
+ return se->getVarAtts();
+}
+
+const MEDFileSEVarAtt *MEDFileStructureElements::getVarAttOf(const std::string &seName, const std::string& varName) const
+{
+ const MEDFileStructureElement *se(getSEWithName(seName));
+ return se->getVarAtt(varName);
+}
--- /dev/null
+// Copyright (C) 2007-2017 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 __MEDFILESTRUCTUREELEMENT_HXX__
+#define __MEDFILESTRUCTUREELEMENT_HXX__
+
+#include "MEDLoaderDefines.hxx"
+#include "MEDFileUtilities.txx"
+#include "MEDFileMesh.hxx"
+
+#include "MEDCouplingRefCountObject.hxx"
+
+namespace MEDCoupling
+{
+ class MEDFileStructureElement;
+ class MEDFileMeshSupports;
+ class MEDFileUMesh;
+
+ class MEDFileSEHolder
+ {
+ public:
+ std::string getModelName() const;
+ std::string getName() const;
+ protected:
+ MEDFileSEHolder(MEDFileStructureElement *father):_father(father) { }
+ void setName(const std::string& name);
+ std::size_t getHeapMemorySizeLoc() const;
+ private:
+ MEDFileStructureElement *_father;
+ std::string _name;
+ };
+
+class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileSEHolder
+ {
+ public:
+ static MEDFileSEConstAtt *New(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh);
+ public:
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ void writeLL(med_idt fid) const;
+ void setProfile(const std::string& name);
+ std::string getProfile() const;
+ private:
+ MEDFileSEConstAtt(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh);
+ private:
+ std::string _pfl;
+ TypeOfField _tof;
+ MCAuto<DataArray> _val;
+ };
+
+ class MEDFileSEVarAtt : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileSEHolder
+ {
+ public:
+ static MEDFileSEVarAtt *New(med_idt fid, MEDFileStructureElement *father, int idVarAtt);
+ public:
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ void writeLL(med_idt fid) const;
+ int getNbOfComponents() const { return _nb_compo; }
+ MCAuto<DataArray> getGenerator() const { return _gen; }
+ private:
+ MEDFileSEVarAtt(med_idt fid, MEDFileStructureElement *father, int idVarAtt);
+ private:
+ int _nb_compo;
+ MCAuto<DataArray> _gen;
+ };
+
+ class MEDFileStructureElement : public RefCountObject, public MEDFileWritableStandAlone
+ {
+ public:
+ MEDLOADER_EXPORT static MEDFileStructureElement *New(med_idt fid, int idSE, const MEDFileMeshSupports *ms);
+ MEDLOADER_EXPORT std::string getName() const;
+ MEDLOADER_EXPORT int getDynGT() const;
+ MEDLOADER_EXPORT TypeOfField getEntity() const;
+ MEDLOADER_EXPORT std::string getMeshName() const;
+ MEDLOADER_EXPORT std::vector<std::string> getVarAtts() const;
+ MEDLOADER_EXPORT const MEDFileSEVarAtt *getVarAtt(const std::string& varName) const;
+ public:
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ void writeLL(med_idt fid) const;
+ public:
+ static MCAuto<DataArray> BuildFrom(med_attribute_type mat);
+ static int EffectiveNbCompo(med_attribute_type mat, int nbCompo);
+ private:
+ MEDFileStructureElement(med_idt fid, int idSE, const MEDFileMeshSupports *ms);
+ private:
+ int _id_type;
+ std::string _name;
+ std::string _sup_mesh_name;
+ INTERP_KERNEL::NormalizedCellType _geo_type;
+ TypeOfField _tof;
+ int _dim;
+ std::vector< MCAuto<MEDFileSEConstAtt> > _cst_att;
+ std::vector< MCAuto<MEDFileSEVarAtt> > _var_att;
+ };
+
+ class MEDFileStructureElements : public RefCountObject, public MEDFileWritableStandAlone
+ {
+ public:
+ MEDLOADER_EXPORT static MEDFileStructureElements *New(const std::string& fileName, const MEDFileMeshSupports *ms);
+ MEDLOADER_EXPORT static MEDFileStructureElements *New(med_idt fid, const MEDFileMeshSupports *ms);
+ MEDLOADER_EXPORT static MEDFileStructureElements *New();
+ MEDLOADER_EXPORT int getNumberOf() const;
+ MEDLOADER_EXPORT std::vector<int> getDynGTAvail() const;
+ MEDLOADER_EXPORT const MEDFileStructureElement *getWithGT(int idGT) const;
+ MEDLOADER_EXPORT int getNumberOfNodesPerSE(const std::string& seName) const;
+ MEDLOADER_EXPORT const MEDFileStructureElement *getSEWithName(const std::string& seName) const;
+ MEDLOADER_EXPORT std::vector<std::string> getVarAttsOf(const std::string& seName) const;
+ MEDLOADER_EXPORT const MEDFileSEVarAtt *getVarAttOf(const std::string &seName, const std::string& varName) const;
+ public:
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ void writeLL(med_idt fid) const;
+ private:
+ MEDFileStructureElements(med_idt fid, const MEDFileMeshSupports *ms);
+ MEDFileStructureElements();
+ ~MEDFileStructureElements();
+ private:
+ std::vector< MCAuto<MEDFileStructureElement> > _elems;
+ MCConstAuto<MEDFileMeshSupports> _sup;
+ };
+}
+
+#endif
%newobject MEDCoupling::MEDFileFields::partOfThisLyingOnSpecifiedMeshName;
%newobject MEDCoupling::MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps;
%newobject MEDCoupling::MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps;
+%newobject MEDCoupling::MEDFileFields::partOfThisOnStructureElements;
%newobject MEDCoupling::MEDFileFields::__iter__;
%newobject MEDCoupling::MEDFileFields::extractPart;
void setJoints( MEDFileJoints* joints );
void initializeEquivalences();
void killEquivalences();
+ bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
+ void killStructureElements() throw(INTERP_KERNEL::Exception);
%extend
{
std::string __str__() const throw(INTERP_KERNEL::Exception)
void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
void cartesianizeMe() throw(INTERP_KERNEL::Exception);
+ bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
+ void killStructureElements() throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileMeshes()
MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const throw(INTERP_KERNEL::Exception);
+ bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
+ void aggregate(const MEDFileFields& other) throw(INTERP_KERNEL::Exception);
+ void killStructureElements() throw(INTERP_KERNEL::Exception);
+ void keepOnlyStructureElements() throw(INTERP_KERNEL::Exception);
+ void keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName) throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
bool removeFieldsWithoutAnyTimeStep() throw(INTERP_KERNEL::Exception);
%extend
{
return self->simpleRepr();
}
+
+ MEDFileFields *partOfThisOnStructureElements() const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<MEDFileFields> ret(self->partOfThisOnStructureElements());
+ return ret.retn();
+ }
+ MEDFileFields *partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<MEDFileFields> ret(self->partOfThisLyingOnSpecifiedMeshSEName(meshName,seName));
+ return ret.retn();
+ }
+
static MEDFileFields *LoadSpecificEntities(const std::string& fileName, PyObject *entities, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
std::vector<std::pair<int,int> > tmp(convertTimePairIdsFromPy(entities));
return MEDFileFields::LoadSpecificEntities(fileName,entitiesCpp,loadAll);
}
+ PyObject *getMeshSENames() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::string,std::string> > ps;
+ self->getMeshSENames(ps);
+ return convertVectPairStToPy(ps);
+ }
+
PyObject *getCommonIterations() const throw(INTERP_KERNEL::Exception)
{
bool ret1;
//
bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName) throw(INTERP_KERNEL::Exception);
bool unPolyzeMeshes() throw(INTERP_KERNEL::Exception);
+ void dealWithStructureElements() throw(INTERP_KERNEL::Exception);
+ std::string getHeader() const throw(INTERP_KERNEL::Exception);
+ void setHeader(const std::string& header) throw(INTERP_KERNEL::Exception);
//
%extend
{
return ret;
}
+PyObject *convertVectPairStToPy(const std::vector< std::pair<std::string, std::string > >& vec)
+{
+ int sz=(int)vec.size();
+ PyObject *ret=PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ PyObject *t=PyTuple_New(2);
+ PyTuple_SetItem(t,0,PyString_FromString(vec[i].first.c_str()));
+ PyTuple_SetItem(t,1,PyString_FromString(vec[i].second.c_str()));
+ PyList_SetItem(ret,i,t);
+ }
+ return ret;
+}
+
std::vector< std::pair<std::string, std::string > > convertVecPairStStFromPy(PyObject *pyLi)
{
std::vector< std::pair<std::string, std::string > > ret;