From be04791d7d756c50d1e4296ddf714478dfe78de1 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 16 May 2017 16:14:40 +0200 Subject: [PATCH] Float32 managed at all levels of fields. Factorization done. Ready to be compiled/linked with medfile version dealing with float32 fields --- src/MEDCoupling/MEDCouplingFieldTemplate.cxx | 36 +- src/MEDCoupling/MEDCouplingFieldTemplate.hxx | 9 +- src/MEDLoader/MEDFileField.cxx | 1958 ++---------------- src/MEDLoader/MEDFileField.hxx | 383 ++-- src/MEDLoader/MEDFileField.txx | 957 +++++++++ src/MEDLoader/MEDLoaderTraits.hxx | 9 +- src/MEDLoader/Swig/MEDLoader.i | 10 + src/MEDLoader/Swig/MEDLoaderCommon.i | 191 +- src/MEDLoader/Swig/MEDLoaderTest3.py | 2 +- src/MEDLoader/Swig/MEDLoaderTypemaps.i | 16 + 10 files changed, 1620 insertions(+), 1951 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx index 362b92a7b..2e432b88a 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx @@ -31,17 +31,32 @@ using namespace MEDCoupling; MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble& f) { - return new MEDCouplingFieldTemplate(f); + return new MEDCouplingFieldTemplate(f,true); } MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldFloat& f) { - return new MEDCouplingFieldTemplate(f); + return new MEDCouplingFieldTemplate(f,true); } MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldInt& f) { - return new MEDCouplingFieldTemplate(f); + return new MEDCouplingFieldTemplate(f,true); +} + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::NewWithoutCheck(const MEDCouplingFieldDouble& f) +{ + return new MEDCouplingFieldTemplate(f,false); +} + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::NewWithoutCheck(const MEDCouplingFieldFloat& f) +{ + return new MEDCouplingFieldTemplate(f,false); +} + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::NewWithoutCheck(const MEDCouplingFieldInt& f) +{ + return new MEDCouplingFieldTemplate(f,false); } /*! @@ -52,22 +67,25 @@ MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(TypeOfField type) return new MEDCouplingFieldTemplate(type); } -MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f):MEDCouplingField(f,false) +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f, bool isChecked):MEDCouplingField(f,false) { forceTimeOfThis(f); - checkConsistencyLight(); + if(isChecked) + checkConsistencyLight(); } -MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f):MEDCouplingField(f,false) +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f, bool isChecked):MEDCouplingField(f,false) { forceTimeOfThis(f); - checkConsistencyLight(); + if(isChecked) + checkConsistencyLight(); } -MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f):MEDCouplingField(f,false) +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f, bool isChecked):MEDCouplingField(f,false) { forceTimeOfThis(f); - checkConsistencyLight(); + if(isChecked) + checkConsistencyLight(); } MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(TypeOfField type):MEDCouplingField(type) diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.hxx b/src/MEDCoupling/MEDCouplingFieldTemplate.hxx index 47ba2bdc6..a12842f51 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.hxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.hxx @@ -45,6 +45,9 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(const MEDCouplingFieldFloat& f); MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(const MEDCouplingFieldInt& f); MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(TypeOfField type); + MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *NewWithoutCheck(const MEDCouplingFieldDouble& f); + MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *NewWithoutCheck(const MEDCouplingFieldFloat& f); + MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *NewWithoutCheck(const MEDCouplingFieldInt& f); MEDCOUPLING_EXPORT std::string simpleRepr() const; MEDCOUPLING_EXPORT std::string advancedRepr() const; MEDCOUPLING_EXPORT void checkConsistencyLight() const; @@ -59,9 +62,9 @@ namespace MEDCoupling // MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; private: - MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f); - MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f); - MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f); + MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f, bool isChecked=true); + MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f, bool isChecked=true); + MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f, bool isChecked=true); MEDCouplingFieldTemplate(TypeOfField type); MEDCouplingFieldTemplate(const MEDCouplingFieldTemplate& other, bool deepCopy); }; diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 93338b0f6..cb09988db 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -16,7 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) #include "MEDFileField.txx" #include "MEDFileMesh.hxx" @@ -27,8 +27,6 @@ #include "MEDFileBlowStrEltUp.hxx" #include "MEDFileFieldVisitor.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingFieldDiscretization.hxx" #include "InterpKernelAutoPtr.hxx" @@ -47,8 +45,20 @@ using namespace MEDCoupling; template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA; template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA; template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA; +template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA; +template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; template class MEDCoupling::MEDFileTemplateField1TS; +template class MEDCoupling::MEDFileTemplateField1TS; template class MEDCoupling::MEDFileTemplateField1TS; +template class MEDCoupling::MEDFileNDTemplateField1TS; +template class MEDCoupling::MEDFileNDTemplateField1TS; +template class MEDCoupling::MEDFileTemplateFieldMultiTS; +template class MEDCoupling::MEDFileTemplateFieldMultiTS; +template class MEDCoupling::MEDFileTemplateFieldMultiTS; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64"; const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32"; @@ -314,7 +324,7 @@ std::string MEDFileFieldLoc::repr() const return oss.str(); } -void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { _type=field->getTypeOfField(); _start=start; @@ -389,7 +399,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int off * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points. * \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 MEDFileFieldPerMeshPerTypePerDisc::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 MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { _profile.clear(); _type=field->getTypeOfField(); @@ -498,7 +508,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start=_end; } -void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) +void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) { _start=start; _nval=arrr->getNumberOfTuples(); @@ -1193,7 +1203,7 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::getDirect return ret; } -void MEDFileFieldPerMeshPerTypeCommon::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 MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { std::vector pos=addNewEntryIfNecessary(field,offset,nbOfCells); for(std::vector::const_iterator it=pos.begin();it!=pos.end();it++) @@ -1209,21 +1219,21 @@ void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offs * \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 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) +void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { std::vector pos=addNewEntryIfNecessary(field,idsInPfl); for(std::vector::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 MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) +void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *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 MEDFileFieldPerMeshPerTypeCommon::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 MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { MCAuto pfl2=pfl->deepCopy(); if(!arr || !arr->isAllocated()) @@ -1233,7 +1243,7 @@ void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const _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 MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) +std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells) { TypeOfField type=field->getTypeOfField(); if(type!=ON_GAUSS_PT) @@ -1288,7 +1298,7 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const } } -std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) +std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells) { const MEDCouplingFieldDiscretization *disc=field->getDiscretization(); const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast(disc); @@ -1305,7 +1315,7 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(c return ret; } -std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) +std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells) { TypeOfField type=field->getTypeOfField(); if(type!=ON_GAUSS_PT) @@ -1360,7 +1370,7 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const } } -std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) +std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells) { const MEDCouplingFieldDiscretization *disc=field->getDiscretization(); const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast(disc); @@ -1959,7 +1969,7 @@ void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) mesh->getTime(_mesh_iteration,_mesh_order); } -void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { int nbOfTypes=code.size()/3; int offset=0; @@ -1982,7 +1992,7 @@ void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vec * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points. * \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 MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& code2, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& code2, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { int nbOfTypes(code.size()/3); for(int i=0;iassignNodeFieldNoProfile(start,field,arr,glob); } -void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR); _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc); @@ -5106,16 +5116,16 @@ std::vector MEDFileAnyTypeField1TSWithoutSDA::getDirect * \throw If the underlying mesh of \a field has no name. * \throw If elements in the mesh are not in the order suitable for writing to the MED file. */ -void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { - const MEDCouplingMesh *mesh=field->getMesh(); + const MEDCouplingMesh *mesh(field->getMesh()); // - TypeOfField type=field->getTypeOfField(); + TypeOfField type(field->getTypeOfField()); std::vector dummy; if(mesh) setMeshName(mesh->getName()); - int start=copyTinyInfoFrom(field,arr); - int pos=addNewEntryIfNecessary(mesh); + int start(copyTinyInfoFrom(th,field,arr)); + int pos(addNewEntryIfNecessary(mesh)); if(type!=ON_NODES) { std::vector code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh); @@ -5148,7 +5158,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFie * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. * \sa setFieldNoProfileSBT() */ -void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { if(!field) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !"); @@ -5166,7 +5176,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDou std::vector< MCAuto > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); std::vector idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin()); // start of check - MCAuto field2=field->clone(false); + MCAuto field2=field->clone(false); int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3); if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples()) { @@ -5174,7 +5184,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDou throw INTERP_KERNEL::Exception(oss.str()); } // end of check - int start=copyTinyInfoFrom(field,arrOfVals); + int start(copyTinyInfoFrom(th,field,arrOfVals)); code2=m->getDistributionOfTypes(); // int pos=addNewEntryIfNecessary(m); @@ -5192,8 +5202,8 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDou std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str()); } - int start=copyTinyInfoFrom(field,arrOfVals); - int pos=addNewEntryIfNecessary(m); + int start(copyTinyInfoFrom(th,field,arrOfVals)); + int pos(addNewEntryIfNecessary(m)); _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc); } } @@ -5222,7 +5232,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) * \throw If \a this->_arr is already allocated but has different number of components * than \a field. */ -int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) +int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr) { if(!field) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !"); @@ -5230,14 +5240,14 @@ int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDou setName(name.c_str()); if(field->getMesh()) setMeshName(field->getMesh()->getName()); - setDtUnit(field->getTimeUnit()); + setDtUnit(th->getTimeUnit()); if(name.empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !"); if(!arr) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !"); if(!arr->isAllocated()) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !"); - _dt=field->getTime(_iteration,_order); + _dt=th->getTime(_iteration,_order); getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents()); if(!getOrCreateAndGetArray()->isAllocated()) { @@ -5779,7 +5789,7 @@ MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA() } MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, - const std::vector& infos):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) + const std::vector& infos):MEDFileField1TSNDTemplateWithoutSDA(fieldName,meshName,csit,iteration,order,infos) { DataArrayInt *arr(getOrCreateAndGetArrayTemplate()); arr->setInfoAndChangeNbOfCompo(infos); @@ -5790,19 +5800,6 @@ const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const return TYPE_STR; } -MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const -{ - MCAuto ret(new MEDFileField1TSWithoutSDA); - ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this); - ret->deepCpyLeavesFrom(*this); - if(_arr.isNotNull()) - { - MCAuto arr2(_arr->convertToDblArr()); - ret->setArray(arr2); - } - return ret.retn(); -} - /*! * Returns a pointer to the underground DataArrayInt instance and a * sequence describing parameters of a support of each part of \a this field. The @@ -5877,7 +5874,7 @@ MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA() } MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, - const std::vector& infos):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) + const std::vector& infos):MEDFileField1TSNDTemplateWithoutSDA(fieldName,meshName,csit,iteration,order,infos) { DataArrayFloat *arr(getOrCreateAndGetArrayTemplate()); arr->setInfoAndChangeNbOfCompo(infos); @@ -5888,19 +5885,6 @@ const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const return TYPE_STR; } -MEDFileField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::convertToDouble() const -{ - MCAuto ret(new MEDFileField1TSWithoutSDA); - ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this); - ret->deepCpyLeavesFrom(*this); - if(_arr.isNotNull()) - { - MCAuto arr2(_arr->convertToDblArr()); - ret->setArray(arr2); - } - return ret.retn(); -} - /*! * Returns a pointer to the underground DataArrayFloat instance and a * sequence describing parameters of a support of each part of \a this field. The @@ -6056,7 +6040,7 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -6195,9 +6179,14 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector()); break; } + case MED_NODE://6432 + { + ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector()); + break; + } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -6793,7 +6782,13 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) { - return contentNotNullBase()->copyTinyInfoFrom(field,arr); + MCAuto ft(MEDCouplingFieldTemplate::New(*field)); + return copyTinyInfoFrom(field->timeDiscrSafe(),ft,arr); +} + +int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr) +{ + return contentNotNullBase()->copyTinyInfoFrom(th,field,arr); } //= MEDFileField1TS @@ -6827,70 +6822,6 @@ MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const return ret.retn(); } -void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto& arr) -{ - if(!f) - throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !"); - if(arr.isNull()) - throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !"); - DataArrayDouble *arrOutC(dynamic_cast((DataArray*)arr)); - if(!arrOutC) - throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !"); - f->setArray(arrOutC); -} - -/*! - * Return an extraction of \a this using \a extractDef map to specify the extraction. - * The keys of \a extractDef is level relative to max ext of \a mm mesh. - * - * \return A new object that the caller is responsible to deallocate. - * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart - */ -MEDFileField1TS *MEDFileField1TS::extractPart(const std::map >& extractDef, MEDFileMesh *mm) const -{ - if(!mm) - throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !"); - MCAuto ret(MEDFileField1TS::New()); - std::vector tof(getTypesOfFieldAvailable()); - for(std::vector::const_iterator it0=tof.begin();it0!=tof.end();it0++) - { - if((*it0)!=ON_NODES) - { - std::vector levs; - getNonEmptyLevels(mm->getName(),levs); - for(std::vector::const_iterator lev=levs.begin();lev!=levs.end();lev++) - { - std::map >::const_iterator it2(extractDef.find(*lev)); - if(it2!=extractDef.end()) - { - MCAuto t((*it2).second); - if(t.isNull()) - throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !"); - MCAuto f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm)); - MCAuto fOut(f->buildSubPart(t)); - ret->setFieldNoProfileSBT(fOut); - } - } - } - else - { - std::map >::const_iterator it2(extractDef.find(1)); - if(it2==extractDef.end()) - throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !"); - MCAuto t((*it2).second); - if(t.isNull()) - throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !"); - MCAuto f(getFieldOnMeshAtLevel(ON_NODES,0,mm)); - MCAuto fOut(f->deepCopy()); - DataArrayDouble *arr(f->getArray()); - MCAuto newArr(arr->selectByTupleIdSafe(t->begin(),t->end())); - fOut->setArray(newArr); - ret->setFieldNoProfileSBT(fOut); - } - } - return ret.retn(); -} - MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) try:MEDFileTemplateField1TS(fid,loadAll,ms) { @@ -6925,620 +6856,96 @@ try:MEDFileTemplateField1TS(other,shallowCopyOfContent) catch(INTERP_KERNEL::Exception& e) { throw e; } -/*! - * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance - * method should be called (getFieldOnMeshAtLevel for example). - * But for normal usage of field in MED file world this method is the most efficient to fetch data. - * - * \param [in] mesh - the mesh the field is lying on - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - */ -MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const -{ - MCAuto arrOut; - MCAuto ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); -} - -/*! - * Returns a new MEDCouplingFieldDouble of a given type lying on - * mesh entities of a given dimension of the first mesh in MED file. If \a this field - * has not been constructed via file reading, an exception is thrown. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If \a this field has not been constructed via file reading. - * \throw If the MED file is not readable. - * \throw If there is no mesh in the MED file. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. - * \throw If no field values of the given \a type or given \a meshDimRelToMax are available. - * \sa getFieldOnMeshAtLevel() - */ -MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const +MEDFileField1TS *MEDFileField1TS::shallowCpy() const { - if(getFileName().empty()) - throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); - MCAuto arrOut; - MCAuto ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + return new MEDFileField1TS(*this); } -/*! - * Returns a new MEDCouplingFieldDouble of a given type lying on - * the top level cells of the first mesh in MED file. If \a this field - * has not been constructed via file reading, an exception is thrown. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If \a this field has not been constructed via file reading. - * \throw If the MED file is not readable. - * \throw If there is no mesh in the MED file. - * \throw If no field values of the given \a type. - * \throw If no field values lying on the top level support. - * \sa getFieldAtLevel() - */ -MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const +std::vector< std::vector > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, + std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const { - if(getFileName().empty()) - throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !"); - MCAuto arrOut; - MCAuto ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs); } -/*! - * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of the new field. - * \param [in] mesh - the supporting mesh. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If no field of \a this is lying on \a mesh. - * \throw If the mesh is empty. - * \throw If no field values of the given \a type are available. - * \sa getFieldAtLevel() - * \sa getFieldOnMeshAtLevel() - */ -MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const -{ - MCAuto arrOut; - MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); -} +//= MEDFileIntField1TS -/*! - * Returns a new MEDCouplingFieldDouble of a given type lying on a given support. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] mesh - the supporting mesh. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. - * \throw If no field of \a this is lying on \a mesh. - * \throw If no field values of the given \a type or given \a meshDimRelToMax are available. - * \sa getFieldAtLevel() - * \sa getFieldOnMeshAtLevel() - */ -MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const +MCAuto MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f) { - MCAuto arrOut; - MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + if(!f) + throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !"); + int t1,t2; + double t0(f->getTime(t1,t2)); + std::string tu(f->getTimeUnit()); + MCAuto ft(MEDCouplingFieldTemplate::New(*f)); + MCAuto ret(MEDCouplingFieldDouble::New(*ft)); + ret->setTime(t0,t1,t2); ret->setTimeUnit(tu); + return ret; } -/*! - * Returns a new MEDCouplingFieldDouble of a given type lying on a given support. - * This method is called "Old" because in MED3 norm a field has only one meshName - * attached, so this method is for readers of MED2 files. If \a this field - * has not been constructed via file reading, an exception is thrown. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] mName - a name of the supporting mesh. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If the MED file is not readable. - * \throw If there is no mesh named \a mName in the MED file. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. - * \throw If \a this field has not been constructed via file reading. - * \throw If no field of \a this is lying on the mesh named \a mName. - * \throw If no field values of the given \a type or given \a meshDimRelToMax are available. - * \sa getFieldAtLevel() - */ -MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const -{ - if(getFileName().empty()) - throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); - MCAuto arrOut; - MCAuto ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); -} +//= MEDFileFloatField1TS -/*! - * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is - * checked if its elements are sorted suitable for writing to MED file ("STB" stands for - * "Sort By Type"), if not, an exception is thrown. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] field - the field to add to \a this. - * \throw If the name of \a field is empty. - * \throw If the data array of \a field is not set. - * \throw If the data array is already allocated but has different number of components - * than \a field. - * \throw If the underlying mesh of \a field has no name. - * \throw If elements in the mesh are not in the order suitable for writing to the MED file. - */ -void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) -{ - setFileName(""); - contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull()); -} +//= MEDFileFloatField1TS -/*! - * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense - * can be an aggregation of several MEDCouplingFieldDouble instances. - * The mesh support of input parameter \a field is ignored here, it can be NULL. - * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax, - * and \a profile. - * - * This method will check that the field based on the computed support is coherent. If not an exception will be thrown. - * A new profile is added only if no equal profile is missing. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] field - the field to add to \a this. The mesh support of field is ignored. - * \param [in] mesh - the supporting mesh of \a field. - * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES). - * \param [in] profile - ids of mesh entities on which corresponding field values lie. - * \throw If either \a field or \a mesh or \a profile has an empty name. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh. - * \throw If the data array of \a field is not set. - * \throw If the data array of \a this is already allocated but has different number of - * components than \a field. - * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. - * \sa setFieldNoProfileSBT() - */ -void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) -{ - setFileName(""); - contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull()); -} +//= MEDFileAnyTypeFieldMultiTSWithoutSDA -MEDFileField1TS *MEDFileField1TS::shallowCpy() const +MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA() { - return new MEDFileField1TS(*this); } -std::vector< std::vector > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, - std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const +MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName) { - return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs); } -//= MEDFileIntField1TS - -MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,loadAll,ms) +/*! + * \param [in] fieldId field id in C mode + */ +MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) { + med_field_type typcha; + std::string dtunitOut,meshName; + int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName)); + setMeshName(meshName); + setDtUnit(dtunitOut.c_str()); + loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities); } -catch(INTERP_KERNEL::Exception& e) -{ throw e; } -MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,fieldName,loadAll,ms) +MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) +try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos) { + setDtUnit(dtunit.c_str()); + loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities); } catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { + throw e; } -catch(INTERP_KERNEL::Exception& e) -{ throw e; } -/*! - * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied. - * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. - * - * \warning this is a shallow copy constructor - */ -MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateField1TS(other,shallowCopyOfContent) +std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const { + std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto)); + for(std::vector::const_iterator it=_infos.begin();it!=_infos.end();it++) + ret+=(*it).capacity(); + return ret; } -MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const +std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const { - return new MEDFileIntField1TS(*this); + std::vector ret; + for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it); + return ret; } /*! - * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied - * following the given input policy. - * - * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) - * By default (true) the globals are deeply copied. - * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field. + * If one of the id in [ \a startIds , \a endIds ) points to a null element, there is not throw. Simply, this empty element is added as if it were not + * NULL. */ -MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const +MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const { - MCAuto ret; - const MEDFileAnyTypeField1TSWithoutSDA *content(_content); - if(content) - { - const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast(content); - if(!contc) - throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !"); - MCAuto newc(contc->convertToDouble()); - ret=static_cast(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc)); - } - else - ret=MEDFileField1TS::New(); - if(isDeepCpyGlobs) - ret->deepCpyGlobs(*this); - else - ret->shallowCpyGlobs(*this); - return ret.retn(); -} - -/*! - * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is - * checked if its elements are sorted suitable for writing to MED file ("STB" stands for - * "Sort By Type"), if not, an exception is thrown. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] field - the field to add to \a this. - * \throw If the name of \a field is empty. - * \throw If the data array of \a field is not set. - * \throw If the data array is already allocated but has different number of components - * than \a field. - * \throw If the underlying mesh of \a field has no name. - * \throw If elements in the mesh are not in the order suitable for writing to the MED file. - */ -void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field) -{ - MCAuto field2(ConvertFieldIntToFieldDouble(field)); - setFileName(""); - contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull()); -} - -/*! - * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense - * can be an aggregation of several MEDCouplingFieldDouble instances. - * The mesh support of input parameter \a field is ignored here, it can be NULL. - * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax, - * and \a profile. - * - * This method will check that the field based on the computed support is coherent. If not an exception will be thrown. - * A new profile is added only if no equal profile is missing. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] field - the field to add to \a this. - * \param [in] mesh - the supporting mesh of \a field. - * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES). - * \param [in] profile - ids of mesh entities on which corresponding field values lie. - * \throw If either \a field or \a mesh or \a profile has an empty name. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh. - * \throw If the data array of \a field is not set. - * \throw If the data array of \a this is already allocated but has different number of - * components than \a field. - * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. - * \sa setFieldNoProfileSBT() - */ -void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) -{ - MCAuto field2(ConvertFieldIntToFieldDouble(field)); - setFileName(""); - contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull()); -} - -MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const -{ - if(getFileName().empty()) - throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); - MCAuto arrOut; - MCAuto ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull())); - MCAuto ret2(SetDataArrayDoubleInIntField(ret,arrOut)); - return ret2.retn(); -} - -MCAuto MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto& arr) -{ - int t1,t2; - double t0(f->getTime(t1,t2)); - MCAuto arr2(DynamicCastSafe(arr)); - MCAuto ft(MEDCouplingFieldTemplate::New(*f)); - MCAuto ret(MEDCouplingFieldInt::New(*ft)); - ret->setTime(t0,t1,t2); ret->setArray(arr2); - return ret.retn(); -} - -MCAuto MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f) -{ - if(!f) - throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !"); - int t1,t2; - double t0(f->getTime(t1,t2)); - MCAuto ft(MEDCouplingFieldTemplate::New(*f)); - MCAuto ret(MEDCouplingFieldDouble::New(*ft)); - ret->setTime(t0,t1,t2); - return ret; -} - -MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map >& extractDef, MEDFileMesh *mm) const -{ - throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !"); -} - -/*! - * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance - * method should be called (getFieldOnMeshAtLevel for example). - * But for normal usage of field in MED file world this method is the most efficient to fetch data. - * - * \param [in] mesh - the mesh the field is lying on - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The - * caller is to delete this field using decrRef() as it is no more needed. - */ -MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const -{ - MCAuto arrOut; - MCAuto ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull())); - MCAuto ret2(SetDataArrayDoubleInIntField(ret,arrOut)); - return ret2.retn(); -} - -/*! - * Returns a new MEDCouplingFieldInt of a given type lying on - * the top level cells of the first mesh in MED file. If \a this field - * has not been constructed via file reading, an exception is thrown. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If \a this field has not been constructed via file reading. - * \throw If the MED file is not readable. - * \throw If there is no mesh in the MED file. - * \throw If no field values of the given \a type. - * \throw If no field values lying on the top level support. - * \sa getFieldAtLevel() - */ -MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const -{ - if(getFileName().empty()) - throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !"); - MCAuto arrOut; - MCAuto ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull())); - MCAuto ret2(SetDataArrayDoubleInIntField(ret,arrOut)); - return ret2.retn(); -} - -/*! - * Returns a new MEDCouplingFieldInt of given type lying on a given mesh. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of the new field. - * \param [in] mesh - the supporting mesh. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If no field of \a this is lying on \a mesh. - * \throw If the mesh is empty. - * \throw If no field values of the given \a type are available. - * \sa getFieldAtLevel() - * \sa getFieldOnMeshAtLevel() - */ -MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const -{ - MCAuto arrOut; - MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull())); - MCAuto ret2(SetDataArrayDoubleInIntField(ret,arrOut)); - return ret2.retn(); -} - -/*! - * Returns a new MEDCouplingFieldInt of a given type lying on a given support. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] mesh - the supporting mesh. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. - * \throw If no field of \a this is lying on \a mesh. - * \throw If no field values of the given \a type or given \a meshDimRelToMax are available. - * \sa getFieldAtLevel() - * \sa getFieldOnMeshAtLevel() - */ -MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const -{ - MCAuto arrOut; - MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull())); - MCAuto ret2(SetDataArrayDoubleInIntField(ret,arrOut)); - return ret2.retn(); -} - -/*! - * Returns a new MEDCouplingFieldDouble of a given type lying on a given support. - * This method is called "Old" because in MED3 norm a field has only one meshName - * attached, so this method is for readers of MED2 files. If \a this field - * has not been constructed via file reading, an exception is thrown. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] mName - a name of the supporting mesh. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If the MED file is not readable. - * \throw If there is no mesh named \a mName in the MED file. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. - * \throw If \a this field has not been constructed via file reading. - * \throw If no field of \a this is lying on the mesh named \a mName. - * \throw If no field values of the given \a type or given \a meshDimRelToMax are available. - * \sa getFieldAtLevel() - */ -MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const -{ - if(getFileName().empty()) - throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); - MCAuto arrOut; - MCAuto ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()); - MCAuto ret2(SetDataArrayDoubleInIntField(ret,arrOut)); - return ret2.retn(); -} - -//= MEDFileFloatField1TS - -MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,fieldName,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -//= MEDFileFloatField1TS - -//= MEDFileAnyTypeFieldMultiTSWithoutSDA - -MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA() -{ -} - -MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName) -{ -} - -/*! - * \param [in] fieldId field id in C mode - */ -MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) -{ - med_field_type typcha; - std::string dtunitOut,meshName; - int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName)); - setMeshName(meshName); - setDtUnit(dtunitOut.c_str()); - loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities); -} - -MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) -try:MEDFileFieldNameScope(fieldName,meshName),_infos(infos) -{ - setDtUnit(dtunit.c_str()); - loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities); -} -catch(INTERP_KERNEL::Exception& e) -{ - throw e; -} - -std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const -{ - std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto)); - for(std::vector::const_iterator it=_infos.begin();it!=_infos.end();it++) - ret+=(*it).capacity(); - return ret; -} - -std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const -{ - std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it); - return ret; -} - -/*! - * If one of the id in [ \a startIds , \a endIds ) points to a null element, there is not throw. Simply, this empty element is added as if it were not - * NULL. - */ -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const -{ - MCAuto ret=createNew(); - ret->setInfo(_infos); - int sz=(int)_time_steps.size(); - for(const int *id=startIds;id!=endIds;id++) + MCAuto ret=createNew(); + ret->setInfo(_infos); + int sz=(int)_time_steps.size(); + for(const int *id=startIds;id!=endIds;id++) { if(*id>=0 && *idloadStructureAndBigArraysRecursively(fid,*this,ms,entities); @@ -8464,9 +7876,12 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCoup throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !"); if(!_time_steps.empty()) checkCoherencyOfTinyInfo(field,arr); - MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance(); + MEDFileAnyTypeField1TSWithoutSDA *objC(createNew1TSWithoutSDAEmptyInstance()); MCAuto obj(objC); - objC->setFieldNoProfileSBT(field,arr,glob,*this); + { + MCAuto ft(MEDCouplingFieldTemplate::New(*field)); + objC->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,arr,glob,*this); + } copyTinyInfoFrom(field,arr); _time_steps.push_back(obj); } @@ -8479,7 +7894,10 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingF checkCoherencyOfTinyInfo(field,arr); MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance(); MCAuto obj(objC); - objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this); + { + MCAuto ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field)); + objC->setFieldProfile(field->timeDiscrSafe(),ft,arr,mesh,meshDimRelToMax,profile,glob,*this); + } copyTinyInfoFrom(field,arr); setMeshName(objC->getMeshName()); _time_steps.push_back(obj); @@ -8507,109 +7925,50 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) +/*! + * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially + * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller. + */ +std::vector< std::vector > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const { - return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities); + const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order); + const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); + if(!myF1TSC) + throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !"); + return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs); } -MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA() +MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const { + MCAuto ret(new MEDFileIntFieldMultiTSWithoutSDA); + ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this); + int i=0; + for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++) + { + const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it); + if(eltToConv) + { + const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast(eltToConv); + if(!eltToConvC) + throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !"); + MCAuto elt=eltToConvC->convertToInt(); + ret->setIteration(i,elt); + } + } + return ret.retn(); } -MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName,meshName) +//= MEDFileAnyTypeFieldMultiTS + +MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS() { } -/*! - * \param [in] fieldId field id in C mode - */ -MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) -try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) +MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileFieldGlobsReal(fid) { -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) -try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const -{ - return new MEDFileField1TSWithoutSDA; -} - -void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const -{ - if(!f1ts) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); - const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast(f1ts); - if(!f1tsC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !"); -} - -const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const -{ - return MEDFileField1TSWithoutSDA::TYPE_STR; -} - -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const -{ - return new MEDFileFieldMultiTSWithoutSDA(*this); -} - -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const -{ - return new MEDFileFieldMultiTSWithoutSDA; -} - -/*! - * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially - * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller. - */ -std::vector< std::vector > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order); - const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !"); - return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs); -} - -MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const -{ - MCAuto ret(new MEDFileIntFieldMultiTSWithoutSDA); - ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this); - int i=0; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++) - { - const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it); - if(eltToConv) - { - const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast(eltToConv); - if(!eltToConvC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !"); - MCAuto elt=eltToConvC->convertToInt(); - ret->setIteration(i,elt); - } - } - return ret.retn(); -} - -//= MEDFileAnyTypeFieldMultiTS - -MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS() -{ -} - -MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileFieldGlobsReal(fid) -{ - _content=BuildContentFrom(fid,loadAll,ms); - loadGlobals(fid); + _content=BuildContentFrom(fid,loadAll,ms); + loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) { @@ -8637,9 +7996,14 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); break; } + case MED_NODE://6432 + { + ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); + break; + } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -8668,9 +8032,14 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); break; } + case MED_NODE://6432 + { + ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + break; + } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -8717,87 +8086,6 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -//= MEDFileIntFieldMultiTSWithoutSDA - -MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) -{ - return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities); -} - -MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA() -{ -} - -MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName,meshName) -{ -} - -MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) -try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -/*! - * \param [in] fieldId field id in C mode - */ -MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(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; } - -MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const -{ - return new MEDFileIntField1TSWithoutSDA; -} - -void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const -{ - if(!f1ts) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); - const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast(f1ts); - if(!f1tsC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !"); -} - -const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const -{ - return MEDFileIntField1TSWithoutSDA::TYPE_STR; -} - -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const -{ - return new MEDFileIntFieldMultiTSWithoutSDA(*this); -} - -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const -{ - return new MEDFileIntFieldMultiTSWithoutSDA; -} - -MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const -{ - MCAuto ret(new MEDFileFieldMultiTSWithoutSDA); - ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this); - int i=0; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++) - { - const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it); - if(eltToConv) - { - const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast(eltToConv); - if(!eltToConvC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !"); - MCAuto elt=eltToConvC->convertToDouble(); - ret->setIteration(i,elt); - } - } - return ret.retn(); -} - //= MEDFileAnyTypeFieldMultiTS /*! @@ -9478,27 +8766,6 @@ int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiT return nts; } -/*! - * Return an extraction of \a this using \a extractDef map to specify the extraction. - * The keys of \a extractDef is level relative to max ext of \a mm mesh. - * - * \return A new object that the caller is responsible to deallocate. - */ -MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map >& extractDef, MEDFileMesh *mm) const -{ - if(!mm) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !"); - MCAuto fmtsOut(buildNewEmpty()); - int nbTS(getNumberOfTS()); - for(int i=0;i f1ts(getTimeStepAtPos(i)); - MCAuto f1tsOut(f1ts->extractPart(extractDef,mm)); - fmtsOut->pushBackTimeStep(f1tsOut); - } - return fmtsOut.retn(); -} - template MCAuto AggregateHelperF1TS(const std::vector< typename MLFieldTraits::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair > >& dts) { @@ -9597,100 +8864,11 @@ MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() //= MEDFileFieldMultiTS -/*! - * Returns a new empty instance of MEDFileFieldMultiTS. - * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller - * is to delete this field using decrRef() as it is no more needed. - */ -MEDFileFieldMultiTS *MEDFileFieldMultiTS::New() -{ - return new MEDFileFieldMultiTS; -} - -/*! - * Returns a new instance of MEDFileFieldMultiTS holding data of the first field - * that has been read from a specified MED file. - * \param [in] fileName - the name of the MED file to read. - * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller - * is to delete this field using decrRef() as it is no more needed. - * \throw If reading the file fails. - */ -MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll) -{ - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - return New(fid,loadAll); -} - -MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll) -{ - MCAuto ret(new MEDFileFieldMultiTS(fid,loadAll,0)); - ret->contentNotNull();//to check that content type matches with \a this type. - return ret.retn(); -} - -/*! - * Returns a new instance of MEDFileFieldMultiTS holding data of a given field - * that has been read from a specified MED file. - * \param [in] fileName - the name of the MED file to read. - * \param [in] fieldName - the name of the field to read. - * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller - * is to delete this field using decrRef() as it is no more needed. - * \throw If reading the file fails. - * \throw If there is no field named \a fieldName in the file. - */ -MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) -{ - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - return New(fid,fieldName,loadAll); -} - -MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll) -{ - MCAuto ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0)); - ret->contentNotNull();//to check that content type matches with \a this type. - return ret.retn(); -} - -/*! - * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied. - * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. - * - * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy - * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself. - * \warning this is a shallow copy constructor - * \param [in] other - a MEDFileField1TSWithoutSDA to copy. - * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created. - * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller - * is to delete this field using decrRef() as it is no more needed. - */ -MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent) -{ - return new MEDFileFieldMultiTS(other,shallowCopyOfContent); -} - -MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll) -{ - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - INTERP_KERNEL::AutoCppPtr ent(new MEDFileStaticEntities(entities)); - MCAuto ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent)); - ret->contentNotNull();//to check that content type matches with \a this type. - return ret.retn(); -} - MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const { return new MEDFileFieldMultiTS(*this); } -void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const -{ - if(!f1ts) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); - const MEDFileField1TS *f1tsC=dynamic_cast(f1ts); - if(!f1tsC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !"); -} - /*! * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied * following the given input policy. @@ -9720,322 +8898,21 @@ MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) c return ret.retn(); } -/*! - * Returns a new MEDFileField1TS holding data of a given time step of \a this field. - * \param [in] pos - a time step id. - * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to - * delete this field using decrRef() as it is no more needed. - * \throw If \a pos is not a valid time step id. - */ -MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const +MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileTemplateFieldMultiTS(fid,loadAll,ms) { - const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos); - if(!item) - { - std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !"; - throw INTERP_KERNEL::Exception(oss.str()); - } - const MEDFileField1TSWithoutSDA *itemC=dynamic_cast(item); - if(itemC) - { - MCAuto ret=MEDFileField1TS::New(*itemC,false); - ret->shallowCpyGlobs(*this); - return ret.retn(); - } - std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !"; - throw INTERP_KERNEL::Exception(oss.str()); } +catch(INTERP_KERNEL::Exception& e) +{ throw e; } -/*! - * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on - * mesh entities of a given dimension of the first mesh in MED file. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If the MED file is not readable. - * \throw If there is no mesh in the MED file. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. - * \throw If no field values of the required parameters are available. - */ -MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const +MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) +try:MEDFileTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order); - const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !"); - MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); } +catch(INTERP_KERNEL::Exception& e) +{ throw e; } -/*! - * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on - * the top level cells of the first mesh in MED file. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If the MED file is not readable. - * \throw If there is no mesh in the MED file. - * \throw If no field values of the required parameters are available. - */ -MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order); - const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !"); - MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); -} - -/*! - * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance - * method should be called (getFieldOnMeshAtLevel for example). - * But for normal usage of field in MED file world this method is the most efficient to fetch data. - * - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] mesh - the mesh the field is lying on - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - */ -MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); - MCAuto arrOut; - MCAuto ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); -} - -/*! - * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on - * a given support. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] mesh - the supporting mesh. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. - * \throw If no field of \a this is lying on \a mesh. - * \throw If no field values of the required parameters are available. - */ -MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); - const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !"); - MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); -} - -/*! - * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a - * given support. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of the new field. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] mesh - the supporting mesh. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If no field of \a this is lying on \a mesh. - * \throw If no field values of the required parameters are available. - */ -MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order); - const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !"); - MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); -} - -/*! - * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel. - * This method is called 'old' because the user should give the mesh name he wants to use for it's field. - * This method is useful for MED2 file format when field on different mesh was autorized. - */ -MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order); - const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !"); - MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); -} - -/*! - * Returns values and a profile of the field of a given type, of a given time step, - * lying on a given support. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of the field. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] mesh - the supporting mesh. - * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the - * field of interest lies on. If the field lies on all entities of the given - * dimension, all ids in \a pfl are zero. The caller is to delete this array - * using decrRef() as it is no more needed. - * \param [in] glob - the global data storing profiles and localization. - * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the - * field. The caller is to delete this array using decrRef() as it is no more needed. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh. - * \throw If no field of \a this is lying on \a mesh. - * \throw If no field values of the required parameters are available. - */ -DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order); - const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !"); - MCAuto ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase()); - return MEDFileField1TS::ReturnSafelyTypedDataArray(ret); -} - -const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const -{ - const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content); - if(!pt) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !"); - const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast(pt); - if(!ret) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !"); - return ret; -} - -MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() -{ - MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content); - if(!pt) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !"); - MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast(pt); - if(!ret) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !"); - return ret; -} - -/*! - * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of - * the given field is checked if its elements are sorted suitable for writing to MED file - * ("STB" stands for "Sort By Type"), if not, an exception is thrown. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] field - the field to add to \a this. - * \throw If the name of \a field is empty. - * \throw If the data array of \a field is not set. - * \throw If existing time steps have different name or number of components than \a field. - * \throw If the underlying mesh of \a field has no name. - * \throw If elements in the mesh are not in the order suitable for writing to the MED file. - */ -void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) -{ - const DataArrayDouble *arr=0; - if(field) - arr=field->getArray(); - contentNotNull()->appendFieldNoProfileSBT(field,arr,*this); -} - -/*! - * Adds a MEDCouplingFieldDouble to \a this as another time step. - * The mesh support of input parameter \a field is ignored here, it can be NULL. - * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax, - * and \a profile. - * - * This method will check that the field based on the computed support is coherent. If not an exception will be thrown. - * A new profile is added only if no equal profile is missing. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] field - the field to add to \a this. The mesh support of field is ignored. - * \param [in] mesh - the supporting mesh of \a field. - * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES). - * \param [in] profile - ids of mesh entities on which corresponding field values lie. - * \throw If either \a field or \a mesh or \a profile has an empty name. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh. - * \throw If the data array of \a field is not set. - * \throw If the data array of \a this is already allocated but has different number of - * components than \a field. - * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. - * \sa setFieldNoProfileSBT() - */ -void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) -{ - const DataArrayDouble *arr=0; - if(field) - arr=field->getArray(); - contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this); -} - -MEDFileFieldMultiTS::MEDFileFieldMultiTS() -{ - _content=new MEDFileFieldMultiTSWithoutSDA; -} - -MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) -try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent) +MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS(other,shallowCopyOfContent) { } @@ -10044,21 +8921,6 @@ std::vector< std::vector > MEDFileFieldMultiTS::getFieldSplit return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs); } -DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const -{ - return static_cast(contentNotNull()->getUndergroundDataArray(iteration,order)); -} - -DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const -{ - return static_cast(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries)); -} - -MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const -{ - return MEDFileFieldMultiTS::New(); -} - //= MEDFileAnyTypeFieldMultiTSIterator MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0) @@ -10090,459 +8952,6 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() //= MEDFileIntFieldMultiTS -/*! - * Returns a new empty instance of MEDFileFieldMultiTS. - * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller - * is to delete this field using decrRef() as it is no more needed. - */ -MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New() -{ - return new MEDFileIntFieldMultiTS; -} - -/*! - * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field - * that has been read from a specified MED file. - * \param [in] fileName - the name of the MED file to read. - * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller - * is to delete this field using decrRef() as it is no more needed. - * \throw If reading the file fails. - */ -MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll) -{ - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - return New(fid,loadAll); -} - -MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll) -{ - MCAuto ret(new MEDFileIntFieldMultiTS(fid,loadAll,0)); - ret->contentNotNull();//to check that content type matches with \a this type. - return ret.retn(); -} - -/*! - * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field - * that has been read from a specified MED file. - * \param [in] fileName - the name of the MED file to read. - * \param [in] fieldName - the name of the field to read. - * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller - * is to delete this field using decrRef() as it is no more needed. - * \throw If reading the file fails. - * \throw If there is no field named \a fieldName in the file. - */ -MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) -{ - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - return New(fid,fieldName,loadAll); -} - -MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll) -{ - MCAuto ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0)); - ret->contentNotNull();//to check that content type matches with \a this type. - return ret.retn(); -} - -/*! - * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied. - * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. - * - * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy - * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself. - * \warning this is a shallow copy constructor - * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy. - * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created. - * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller - * is to delete this field using decrRef() as it is no more needed. - */ -MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent) -{ - return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent); -} - -MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll) -{ - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - INTERP_KERNEL::AutoCppPtr ent(new MEDFileStaticEntities(entities)); - MCAuto ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent)); - ret->contentNotNull();//to check that content type matches with \a this type. - return ret.retn(); -} - -/*! - * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied - * following the given input policy. - * - * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) - * By default (true) the globals are deeply copied. - * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field. - */ -MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const -{ - MCAuto ret; - const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content); - if(content) - { - const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast(content); - if(!contc) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !"); - MCAuto newc(contc->convertToDouble()); - ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc)); - } - else - ret=MEDFileFieldMultiTS::New(); - if(isDeepCpyGlobs) - ret->deepCpyGlobs(*this); - else - ret->shallowCpyGlobs(*this); - return ret.retn(); -} - -MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const -{ - return new MEDFileIntFieldMultiTS(*this); -} - -void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const -{ - if(!f1ts) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); - const MEDFileIntField1TS *f1tsC=dynamic_cast(f1ts); - if(!f1tsC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !"); -} - -/*! - * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance - * method should be called (getFieldOnMeshAtLevel for example). - * But for normal usage of field in MED file world this method is the most efficient to fetch data. - * - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] mesh - the mesh the field is lying on - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The - * caller is to delete this field using decrRef() as it is no more needed. - */ -MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); - const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast(&myF1TS)); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !"); - MCAuto arrOut; - MCAuto ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase())); - MCAuto ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut)); - return ret2.retn(); -} - -/*! - * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on - * mesh entities of a given dimension of the first mesh in MED file. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If the MED file is not readable. - * \throw If there is no mesh in the MED file. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. - * \throw If no field values of the required parameters are available. - */ -MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); - const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast(&myF1TS)); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !"); - MCAuto arr; - MCAuto ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase())); - MCAuto ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr)); - return ret2.retn(); -} - -/*! - * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on - * the top level cells of the first mesh in MED file. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If the MED file is not readable. - * \throw If there is no mesh in the MED file. - * \throw If no field values of the required parameters are available. - */ -MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); - const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast(&myF1TS)); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !"); - MCAuto arr; - MCAuto ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase())); - MCAuto ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr)); - return ret2.retn(); -} - -/*! - * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on - * a given support. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of interest. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] mesh - the supporting mesh. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. - * \throw If no field of \a this is lying on \a mesh. - * \throw If no field values of the required parameters are available. - */ -MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); - const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast(&myF1TS)); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !"); - MCAuto arr; - MCAuto ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase())); - MCAuto ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr)); - return ret2.retn(); -} - -/*! - * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a - * given support. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of the new field. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] mesh - the supporting mesh. - * \param [out] arrOut - the DataArrayInt containing values of field. - * \param [in] renumPol - specifies how to permute values of the result field according to - * the optional numbers of cells and nodes, if any. The valid values are - * - 0 - do not permute. - * - 1 - permute cells. - * - 2 - permute nodes. - * - 3 - permute cells and nodes. - * - * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The - * caller is to delete this field using decrRef() as it is no more needed. - * \throw If no field of \a this is lying on \a mesh. - * \throw If no field values of the required parameters are available. - */ -MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); - const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast(&myF1TS)); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !"); - MCAuto arr; - MCAuto ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase())); - MCAuto ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr)); - return ret2.retn(); -} - -/*! - * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel. - * This method is called 'old' because the user should give the mesh name he wants to use for it's field. - * This method is useful for MED2 file format when field on different mesh was autorized. - */ -MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); - const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast(&myF1TS)); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !"); - MCAuto arr; - MCAuto ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase())); - MCAuto ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr)); - return ret2.retn(); -} - -/*! - * Returns values and a profile of the field of a given type, of a given time step, - * lying on a given support. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] type - a spatial discretization of the field. - * \param [in] iteration - the iteration number of a required time step. - * \param [in] order - the iteration order number of required time step. - * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. - * \param [in] mesh - the supporting mesh. - * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the - * field of interest lies on. If the field lies on all entities of the given - * dimension, all ids in \a pfl are zero. The caller is to delete this array - * using decrRef() as it is no more needed. - * \param [in] glob - the global data storing profiles and localization. - * \return DataArrayInt * - a new instance of DataArrayInt holding values of the - * field. The caller is to delete this array using decrRef() as it is no more needed. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh. - * \throw If no field of \a this is lying on \a mesh. - * \throw If no field values of the required parameters are available. - */ -DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const -{ - const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order); - const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); - if(!myF1TSC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !"); - MCAuto ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase()); - return MEDFileIntField1TS::ReturnSafelyTypedDataArray(ret); -} - -/*! - * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field. - * \param [in] pos - a time step id. - * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to - * delete this field using decrRef() as it is no more needed. - * \throw If \a pos is not a valid time step id. - */ -MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const -{ - const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos); - if(!item) - { - std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !"; - throw INTERP_KERNEL::Exception(oss.str()); - } - const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast(item); - if(itemC) - { - MCAuto ret=MEDFileIntField1TS::New(*itemC,false); - ret->shallowCpyGlobs(*this); - return ret.retn(); - } - std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !"; - throw INTERP_KERNEL::Exception(oss.str()); -} - -/*! - * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of - * the given field is checked if its elements are sorted suitable for writing to MED file - * ("STB" stands for "Sort By Type"), if not, an exception is thrown. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] field - the field to add to \a this. - * \throw If the name of \a field is empty. - * \throw If the data array of \a field is not set. - * \throw If existing time steps have different name or number of components than \a field. - * \throw If the underlying mesh of \a field has no name. - * \throw If elements in the mesh are not in the order suitable for writing to the MED file. - */ -void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field) -{ - MCAuto field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field)); - contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this); -} - -/*! - * Adds a MEDCouplingFieldDouble to \a this as another time step. - * The mesh support of input parameter \a field is ignored here, it can be NULL. - * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax, - * and \a profile. - * - * This method will check that the field based on the computed support is coherent. If not an exception will be thrown. - * A new profile is added only if no equal profile is missing. - * For more info, see \ref AdvMEDLoaderAPIFieldRW - * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored. - * \param [in] arrOfVals - the values of the field \a field used. - * \param [in] mesh - the supporting mesh of \a field. - * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES). - * \param [in] profile - ids of mesh entities on which corresponding field values lie. - * \throw If either \a field or \a mesh or \a profile has an empty name. - * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh. - * \throw If the data array of \a field is not set. - * \throw If the data array of \a this is already allocated but has different number of - * components than \a field. - * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. - * \sa setFieldNoProfileSBT() - */ -void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) -{ - MCAuto field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field)); - contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this); -} - -const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const -{ - const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content); - if(!pt) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !"); - const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast(pt); - if(!ret) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !"); - return ret; -} - -MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() -{ - MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content); - if(!pt) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !"); - MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast(pt); - if(!ret) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !"); - return ret; -} - -MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS() -{ - _content=new MEDFileIntFieldMultiTSWithoutSDA; -} - -MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent) -{ -} - -MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) -try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const -{ - return static_cast(contentNotNull()->getUndergroundDataArray(iteration,order)); -} - -MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const -{ - return MEDFileIntFieldMultiTS::New(); -} - //= MEDFileFields MEDFileFields *MEDFileFields::New() @@ -10778,9 +9187,14 @@ try:MEDFileFieldGlobsReal(fid) _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities); break; } + case MED_NODE://6432 + { + _fields[i]=MEDFileFloatFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities); + break; + } default: { - std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 40c0ecc4f..c39bfdafd 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -16,7 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) #ifndef __MEDFILEFIELD_HXX__ #define __MEDFILEFIELD_HXX__ @@ -153,9 +153,9 @@ namespace MEDCoupling std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildrenWithNull() 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 assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *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 MEDCouplingFieldTemplate *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob); void getCoarseData(TypeOfField& type, std::pair& dad, std::string& pfl, std::string& loc) const; void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const; const MEDFileFieldPerMeshPerTypeCommon *getFather() const; @@ -233,10 +233,10 @@ namespace MEDCoupling public: std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildrenWithNull() 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 assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *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 MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob); + void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); const MEDFileFieldPerMesh *getFather() const; void loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc); void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc); @@ -283,10 +283,10 @@ namespace MEDCoupling virtual void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const = 0; protected: void deepCopyElements(); - std::vector addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells); - std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells); - std::vector addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells); - std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells); + std::vector addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells); + std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells); + std::vector addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells); + std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells); private: MEDFileFieldPerMesh *_father; protected: @@ -346,10 +346,10 @@ namespace MEDCoupling MEDFileFieldPerMesh *deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const; void simpleRepr(int bkOffset,std::ostream& oss, int id) const; void copyTinyInfoFrom(const MEDCouplingMesh *mesh); - void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& code2, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); - void assignFieldNoProfileNoRenum(int& start, const std::vector& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); - void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob); - void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& code2, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignFieldNoProfileNoRenum(int& start, const std::vector& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob); + void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); 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; @@ -626,9 +626,9 @@ namespace MEDCoupling MEDLOADER_EXPORT void setInfo(const std::vector& infos); MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr); - MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); - MEDLOADER_EXPORT void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + MEDLOADER_EXPORT int copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr); + MEDLOADER_EXPORT void setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + MEDLOADER_EXPORT void setFieldProfile(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); MEDLOADER_EXPORT virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *deepCopy() const = 0; MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const = 0; @@ -688,7 +688,7 @@ namespace MEDCoupling { protected: MEDFileField1TSTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order):MEDFileAnyTypeField1TSWithoutSDA(fieldName,meshName,csit,iteration,order) { } - MEDFileField1TSTemplateWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA() { } + MEDFileField1TSTemplateWithoutSDA() { } public: MEDLOADER_EXPORT void setArray(DataArray *arr); MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const; @@ -726,10 +726,20 @@ namespace MEDCoupling static const char TYPE_STR[]; }; + template + class MEDFileField1TSNDTemplateWithoutSDA : public MEDFileField1TSTemplateWithoutSDA + { + public: + MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const; + protected: + MEDFileField1TSNDTemplateWithoutSDA() { } + MEDFileField1TSNDTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) { } + }; + /*! * SDA is for Shared Data Arrays such as profiles. */ - class MEDFileIntField1TSWithoutSDA : public MEDFileField1TSTemplateWithoutSDA + class MEDFileIntField1TSWithoutSDA : public MEDFileField1TSNDTemplateWithoutSDA { public: MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA(); @@ -739,7 +749,6 @@ namespace MEDCoupling MEDLOADER_EXPORT const char *getTypeStr() const; MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const; - MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const; protected: MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); public: @@ -749,7 +758,7 @@ namespace MEDCoupling /*! * SDA is for Shared Data Arrays such as profiles. */ - class MEDFileFloatField1TSWithoutSDA : public MEDFileField1TSTemplateWithoutSDA + class MEDFileFloatField1TSWithoutSDA : public MEDFileField1TSNDTemplateWithoutSDA { public: MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA(); @@ -759,7 +768,6 @@ namespace MEDCoupling MEDLOADER_EXPORT const char *getTypeStr() const; MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; MEDLOADER_EXPORT DataArrayFloat *getUndergroundDataArrayFloatExt(std::vector< std::pair,std::pair > >& entries) const; - MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const; protected: MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); public: @@ -826,6 +834,8 @@ namespace MEDCoupling MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector& levs) const; MEDLOADER_EXPORT void convertMedBallIntoClassic(); MEDLOADER_EXPORT void makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl); + MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const = 0; + MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *shallowCpy() const = 0; public: MEDLOADER_EXPORT void loadArrays(); MEDLOADER_EXPORT void loadArraysIfNecessary(); @@ -836,7 +846,7 @@ namespace MEDCoupling MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeField1TS > > splitMultiDiscrPerGeoTypes() const; MEDLOADER_EXPORT MEDFileAnyTypeField1TS *deepCopy() const; MEDLOADER_EXPORT int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr); - MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *shallowCpy() const = 0; + MEDLOADER_EXPORT int copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr); public: //! underground method see MEDFileField1TSWithoutSDA::setProfileNameOnLeaf MEDLOADER_EXPORT void setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false); @@ -853,8 +863,6 @@ namespace MEDCoupling public: MEDLOADER_EXPORT static int LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector& infos, std::string& dtunitOut, std::string& meshName); MEDLOADER_EXPORT static int LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector& infos, std::string& dtunitOut, std::string& meshName); - public: - MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const = 0; public: MEDLOADER_EXPORT virtual med_field_type getMEDFileFieldType() const = 0; MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase(); @@ -883,6 +891,19 @@ namespace MEDCoupling MEDLOADER_EXPORT typename Traits::ArrayType *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const; MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArray() const; MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT static MCAuto::FieldType> SetDataArrayInField(MEDCouplingFieldDouble *f, MCAuto& arr); + MEDLOADER_EXPORT static MCAuto ToFieldTemplateWithTime(const typename Traits::FieldType *f); + public: + MEDLOADER_EXPORT typename Traits::FieldType *field(const MEDFileMesh *mesh) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const; + MEDLOADER_EXPORT void setFieldNoProfileSBT(const typename Traits::FieldType *field); + MEDLOADER_EXPORT void setFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile); + MEDLOADER_EXPORT typename MLFieldTraits::F1TSType *extractPartImpl(const std::map >& extractDef, MEDFileMesh *mm) const; + MEDLOADER_EXPORT MEDFileAnyTypeField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const { return this->extractPartImpl(extractDef,mm); } protected: ~MEDFileTemplateField1TS() { } MEDFileTemplateField1TS(); @@ -902,26 +923,11 @@ namespace MEDCoupling friend class MEDFileTemplateField1TS; public: MEDLOADER_EXPORT MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const; - // - MEDLOADER_EXPORT MEDCouplingFieldDouble *field(const MEDFileMesh *mesh) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const; - // - MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field); - MEDLOADER_EXPORT void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile); - // direct forwarding to MEDFileField1TSWithoutSDA instance _content public: MEDLOADER_EXPORT MEDFileField1TS *shallowCpy() const; - MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, - std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; - public: - MEDLOADER_EXPORT static void SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto& arr); + std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; public: - MEDLOADER_EXPORT MEDFileField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const; private: med_field_type getMEDFileFieldType() const { return MED_FLOAT64; } private: @@ -933,48 +939,63 @@ namespace MEDCoupling MEDFileField1TS() { } }; - class MEDFileIntField1TS : public MEDFileTemplateField1TS + template + class MEDFileNDTemplateField1TS : public MEDFileTemplateField1TS { - friend class MEDFileTemplateField1TS; public: MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) 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; - MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const; - // - MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldInt *field); - MEDLOADER_EXPORT void setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile); + protected: + ~MEDFileNDTemplateField1TS() { } + MEDFileNDTemplateField1TS() { } + MEDFileNDTemplateField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,loadAll,ms) { } + MEDFileNDTemplateField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,fieldName,loadAll,ms) { } + MEDFileNDTemplateField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + MEDFileNDTemplateField1TS(const typename MLFieldTraits::F1TSWSDAType& other, bool shallowCopyOfContent):MEDFileTemplateField1TS(other,shallowCopyOfContent) { } + }; + + class MEDFileIntField1TS : public MEDFileNDTemplateField1TS + { + friend class MEDFileTemplateField1TS; public: - MEDLOADER_EXPORT static MCAuto SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto& arr); - MEDLOADER_EXPORT static MCAuto ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f); + MEDLOADER_EXPORT MEDFileIntField1TS *shallowCpy() const { return new MEDFileIntField1TS(*this); } public: - MEDLOADER_EXPORT MEDFileIntField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const; + MEDLOADER_EXPORT static MCAuto ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f); private: med_field_type getMEDFileFieldType() const { return MED_INT32; } private: ~MEDFileIntField1TS() { } MEDFileIntField1TS() { } - MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); - MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); - MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); - MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,loadAll,ms) { } + MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,loadAll,ms) { } + MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + /*! + * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied. + * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. + * + * \warning this is a shallow copy constructor + */ + MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateField1TS(other,shallowCopyOfContent) { } }; - class MEDFileFloatField1TS : public MEDFileTemplateField1TS + class MEDFileFloatField1TS : public MEDFileNDTemplateField1TS { friend class MEDFileTemplateField1TS; + private: + med_field_type getMEDFileFieldType() const { return MED_INT32; }//6432 + MEDLOADER_EXPORT MEDFileFloatField1TS *shallowCpy() const { return new MEDFileFloatField1TS(*this); } private: ~MEDFileFloatField1TS() { } MEDFileFloatField1TS() { } - MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); - MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); - MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); - MEDFileFloatField1TS(const MEDFileFloatField1TSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,loadAll,ms) { } + MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,loadAll,ms) { } + MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + /*! + * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied. + * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. + * + * \warning this is a shallow copy constructor + */ + MEDFileFloatField1TS(const MEDFileFloatField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateField1TS(other,shallowCopyOfContent) { } }; class MEDFileAnyTypeFieldMultiTSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope @@ -1061,43 +1082,77 @@ namespace MEDCoupling class MEDFileIntFieldMultiTSWithoutSDA; - class MEDFileFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA + template + class MEDFileTemplateFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA { public: - MEDLOADER_EXPORT static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& 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 static typename MLFieldTraits::FMTSWSDAType *New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, 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 MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const; + protected: + MEDFileTemplateFieldMultiTSWithoutSDA() { } + MEDFileTemplateFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName,meshName) { } + /** \param [in] fieldId field id in C mode */ + MEDFileTemplateFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDFileTemplateFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const; + }; + + class MEDFileFieldMultiTSWithoutSDA : public MEDFileTemplateFieldMultiTSWithoutSDA + { + friend class MEDFileTemplateFieldMultiTSWithoutSDA; + public: + MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA *convertToInt() const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileFieldMultiTSWithoutSDA(*this); } protected: - MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName); - MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } med_field_type getMEDFileFieldType() const { return MED_FLOAT64; } - MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const; - void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const; public: - MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(); + MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA() { } }; - class MEDFileIntFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA + template + class MEDFileNDTemplateFieldMultiTSWithoutSDA : public MEDFileTemplateFieldMultiTSWithoutSDA { public: - MEDLOADER_EXPORT static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& 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, const std::string& meshName); - MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDFileNDTemplateFieldMultiTSWithoutSDA() { } + MEDFileNDTemplateFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDFileNDTemplateFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileNDTemplateFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + }; + + class MEDFileIntFieldMultiTSWithoutSDA : public MEDFileNDTemplateFieldMultiTSWithoutSDA + { + friend class MEDFileTemplateFieldMultiTSWithoutSDA; + public: + MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileIntFieldMultiTSWithoutSDA(*this); } + protected: + MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } med_field_type getMEDFileFieldType() const { return MED_INT32; } - MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const; - void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const; public: - MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(); + MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA() { } + }; + + class MEDFileFloatFieldMultiTSWithoutSDA : public MEDFileNDTemplateFieldMultiTSWithoutSDA + { + friend class MEDFileTemplateFieldMultiTSWithoutSDA; + public: + MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileFloatFieldMultiTSWithoutSDA(*this); } + protected: + MEDFileFloatFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + med_field_type getMEDFileFieldType() const { return MED_INT32; }//6432 + public: + MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA() { } }; class MEDFileAnyTypeFieldMultiTSIterator; @@ -1176,7 +1231,7 @@ namespace MEDCoupling MEDLOADER_EXPORT MCAuto getContent(); public: MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *buildNewEmpty() const = 0; - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const; + MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const = 0; MEDLOADER_EXPORT static MCAuto Aggregate(const std::vector& fmtss, const std::vector< std::vector< std::pair > >& dts); public: MEDLOADER_EXPORT std::vector getPflsReallyUsed() const; @@ -1194,98 +1249,116 @@ namespace MEDCoupling MCAuto _content; }; + template + class MEDFileTemplateFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + { + public: + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(const std::string& fileName, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(med_idt fid, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(DataArrayByte *db) { return BuildFromMemoryChunk::FMTSType>(db); } + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(med_idt fid, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll=true); + MEDLOADER_EXPORT typename MLFieldTraits::FMTSType *extractPartImpl(const std::map >& extractDef, MEDFileMesh *mm) const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const { return this->extractPartImpl(extractDef,mm); } + // + MEDLOADER_EXPORT typename Traits::FieldType *field(int iteration, int order, const MEDFileMesh *mesh) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::ArrayType *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const; + // + MEDLOADER_EXPORT void appendFieldNoProfileSBT(const typename Traits::FieldType *field); + MEDLOADER_EXPORT void appendFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile); + // + MEDLOADER_EXPORT typename MLFieldTraits::F1TSType *getTimeStepAtPos(int pos) const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArray(int iteration, int order) const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT typename MLFieldTraits::FMTSType *buildNewEmptyImpl() const; + MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const; + protected: + const typename MLFieldTraits::FMTSWSDAType *contentNotNull() const; + typename MLFieldTraits::FMTSWSDAType *contentNotNull(); + protected: + ~MEDFileTemplateFieldMultiTS() { } + MEDFileTemplateFieldMultiTS(); + MEDFileTemplateFieldMultiTS(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent); + MEDFileTemplateFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + MEDFileTemplateFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + }; + class MEDFileIntFieldMultiTS; /*! * User class. */ - class MEDFileFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + class MEDFileFieldMultiTS : public MEDFileTemplateFieldMultiTS { + friend class MEDFileTemplateFieldMultiTS; public: - MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(); - MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const std::string& fileName, bool loadAll=true); - MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(med_idt fid, bool loadAll=true); - MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } - MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true); - MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(med_idt fid, const std::string& fieldName, bool loadAll=true); - MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); - MEDLOADER_EXPORT static MEDFileFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll=true); MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const; - MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const; MEDLOADER_EXPORT MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const; // - MEDLOADER_EXPORT MEDFileField1TS *getTimeStepAtPos(int pos) const; - MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const; - MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const; - // - MEDLOADER_EXPORT MEDCouplingFieldDouble *field(int iteration, int order, const MEDFileMesh *mesh) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const; - MEDLOADER_EXPORT DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const; - // - MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field); - MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile); MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; - MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArray(int iteration, int order) const; - MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT MEDFileFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } public: - MEDLOADER_EXPORT MEDFileFieldMultiTS *buildNewEmpty() const; - private: - const MEDFileFieldMultiTSWithoutSDA *contentNotNull() const; - MEDFileFieldMultiTSWithoutSDA *contentNotNull(); private: ~MEDFileFieldMultiTS() { } - MEDFileFieldMultiTS(); + 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 MEDFileEntities *entities=0); }; + template + class MEDFileNDTemplateFieldMultiTS : public MEDFileTemplateFieldMultiTS + { + public: + MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const; + protected: + ~MEDFileNDTemplateFieldMultiTS() { } + MEDFileNDTemplateFieldMultiTS() { } + MEDFileNDTemplateFieldMultiTS(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS(other,shallowCopyOfContent) { } + MEDFileNDTemplateFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateFieldMultiTS(fid,loadAll,ms) { } + MEDFileNDTemplateFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } + }; + /*! * User class. */ - class MEDFileIntFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + class MEDFileIntFieldMultiTS : public MEDFileNDTemplateFieldMultiTS { + friend class MEDFileTemplateFieldMultiTS; public: - MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(); - MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const std::string& fileName, bool loadAll=true); - MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(med_idt fid, bool loadAll=true); - MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } - MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true); - MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(med_idt fid, const std::string& fieldName, bool loadAll=true); - MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); - MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll=true); - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const; - MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const; - MEDLOADER_EXPORT MEDFileIntField1TS *getTimeStepAtPos(int pos) const; - MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const; - // - MEDLOADER_EXPORT MEDCouplingFieldInt *field(int iteration, int order, const MEDFileMesh *mesh) const; - MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const; - MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const; - MEDLOADER_EXPORT DataArrayInt *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const; - // - MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldInt *field); - MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile); - // - MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArray(int iteration, int order) const; - public: - MEDLOADER_EXPORT MEDFileIntFieldMultiTS *buildNewEmpty() const; - private: - const MEDFileIntFieldMultiTSWithoutSDA *contentNotNull() const; - MEDFileIntFieldMultiTSWithoutSDA *contentNotNull(); + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const { return new MEDFileIntFieldMultiTS(*this); } + MEDLOADER_EXPORT MEDFileIntFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } private: ~MEDFileIntFieldMultiTS() { } - 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 MEDFileEntities *entities=0); + MEDFileIntFieldMultiTS() { } + MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateFieldMultiTS(other,shallowCopyOfContent) { } + MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateFieldMultiTS(fid,loadAll,ms) { } + MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } + }; + + /*! + * User class. + */ + class MEDFileFloatFieldMultiTS : public MEDFileNDTemplateFieldMultiTS + { + friend class MEDFileTemplateFieldMultiTS; + public: + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const { return new MEDFileFloatFieldMultiTS(*this); } + MEDLOADER_EXPORT MEDFileFloatFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } + private: + ~MEDFileFloatFieldMultiTS() { } + MEDFileFloatFieldMultiTS() { } + MEDFileFloatFieldMultiTS(const MEDFileFloatFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateFieldMultiTS(other,shallowCopyOfContent) { } + MEDFileFloatFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateFieldMultiTS(fid,loadAll,ms) { } + MEDFileFloatFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } }; class MEDFileAnyTypeFieldMultiTSIterator diff --git a/src/MEDLoader/MEDFileField.txx b/src/MEDLoader/MEDFileField.txx index aaf738328..e3ba8eeb8 100644 --- a/src/MEDLoader/MEDFileField.txx +++ b/src/MEDLoader/MEDFileField.txx @@ -23,6 +23,10 @@ #include "MEDFileField.hxx" #include "MEDCouplingTraits.hxx" +#include "MEDCouplingFieldInt.hxx" +#include "MEDCouplingFieldFloat.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldTemplate.hxx" namespace MEDCoupling { @@ -195,6 +199,24 @@ namespace MEDCoupling } } + /////////////////////////////////////////////////////// + + template + MEDFileField1TSWithoutSDA *MEDFileField1TSNDTemplateWithoutSDA::convertToDouble() const + { + MCAuto ret(new MEDFileField1TSWithoutSDA); + ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this); + ret->deepCpyLeavesFrom(*this); + if(this->_arr.isNotNull()) + { + MCAuto arr2(this->_arr->convertToDblArr()); + ret->setArray(arr2); + } + return ret.retn(); + } + + /////////////////////////////////////////////////////// + template MEDFileTemplateField1TS::MEDFileTemplateField1TS() { @@ -386,6 +408,941 @@ namespace MEDCoupling { return contentNotNull()->getUndergroundDataArrayTemplateExt(entries); } + + template + MCAuto::FieldType> MEDFileTemplateField1TS::SetDataArrayInField(MEDCouplingFieldDouble *f, MCAuto& arr) + { + if(!f) + throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::SetDataArrayInField : input field is NULL !"); + if(arr.isNull()) + throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::SetDataArrayInField : no array !"); + int t1,t2; + double t0(f->getTime(t1,t2)); + std::string tu(f->getTimeUnit()); + MCAuto::ArrayType> arr2(DynamicCastSafe::ArrayType>(arr)); + MCAuto ft(MEDCouplingFieldTemplate::New(*f)); + MCAuto::FieldType> ret(Traits::FieldType::New(*ft)); + ret->setTime(t0,t1,t2); ret->setArray(arr2); ret->setTimeUnit(tu); + return ret.retn(); + } + + template + MCAuto MEDFileTemplateField1TS::ToFieldTemplateWithTime(const typename Traits::FieldType *f) + { + int t1,t2; + double t0(f->getTime(t1,t2)); + std::string tu(f->getTimeUnit()); + MCAuto ft(MEDCouplingFieldTemplate::NewWithoutCheck(*f)); + MCAuto ret(MEDCouplingFieldDouble::New(*ft)); + ret->setTime(t0,t1,t2); ret->setTimeUnit(tu); + return ret.retn(); + } + + /*! + * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance + * method should be called (getFieldOnMeshAtLevel for example). + * But for normal usage of field in MED file world this method is the most efficient to fetch data. + * + * \param [in] mesh - the mesh the field is lying on + * \return typename Traits::FieldType * - a new instance of typename Traits::FieldType. The + * caller is to delete this field using decrRef() as it is no more needed. + */ + template + typename Traits::FieldType *MEDFileTemplateField1TS::field(const MEDFileMesh *mesh) const + { + MCAuto arrOut; + MCAuto ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns a new typename Traits::FieldType of a given type lying on + * mesh entities of a given dimension of the first mesh in MED file. If \a this field + * has not been constructed via file reading, an exception is thrown. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of interest. + * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. + * \param [in] renumPol - specifies how to permute values of the result field according to + * the optional numbers of cells and nodes, if any. The valid values are + * - 0 - do not permute. + * - 1 - permute cells. + * - 2 - permute nodes. + * - 3 - permute cells and nodes. + * + * \return typename Traits::FieldType * - a new instance of typename Traits::FieldType. The + * caller is to delete this field using decrRef() as it is no more needed. + * \throw If \a this field has not been constructed via file reading. + * \throw If the MED file is not readable. + * \throw If there is no mesh in the MED file. + * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. + * \throw If no field values of the given \a type or given \a meshDimRelToMax are available. + * \sa getFieldOnMeshAtLevel() + */ + template + typename Traits::FieldType *MEDFileTemplateField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const + { + if(getFileName().empty()) + throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); + MCAuto arrOut; + MCAuto ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns a new typename Traits::FieldType of a given type lying on + * the top level cells of the first mesh in MED file. If \a this field + * has not been constructed via file reading, an exception is thrown. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of interest. + * \param [in] renumPol - specifies how to permute values of the result field according to + * the optional numbers of cells and nodes, if any. The valid values are + * - 0 - do not permute. + * - 1 - permute cells. + * - 2 - permute nodes. + * - 3 - permute cells and nodes. + * + * \return typename Traits::FieldType * - a new instance of typename Traits::FieldType. The + * caller is to delete this field using decrRef() as it is no more needed. + * \throw If \a this field has not been constructed via file reading. + * \throw If the MED file is not readable. + * \throw If there is no mesh in the MED file. + * \throw If no field values of the given \a type. + * \throw If no field values lying on the top level support. + * \sa getFieldAtLevel() + */ + template + typename Traits::FieldType *MEDFileTemplateField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const + { + if(getFileName().empty()) + throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !"); + MCAuto arrOut; + MCAuto ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns a new typename Traits::FieldType of given type lying on a given mesh. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of the new field. + * \param [in] mesh - the supporting mesh. + * \param [in] renumPol - specifies how to permute values of the result field according to + * the optional numbers of cells and nodes, if any. The valid values are + * - 0 - do not permute. + * - 1 - permute cells. + * - 2 - permute nodes. + * - 3 - permute cells and nodes. + * + * \return typename Traits::FieldType * - a new instance of typename Traits::FieldType. The + * caller is to delete this field using decrRef() as it is no more needed. + * \throw If no field of \a this is lying on \a mesh. + * \throw If the mesh is empty. + * \throw If no field values of the given \a type are available. + * \sa getFieldAtLevel() + * \sa getFieldOnMeshAtLevel() + */ + template + typename Traits::FieldType *MEDFileTemplateField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const + { + MCAuto arrOut; + MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns a new typename Traits::FieldType of a given type lying on a given support. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of interest. + * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. + * \param [in] mesh - the supporting mesh. + * \param [in] renumPol - specifies how to permute values of the result field according to + * the optional numbers of cells and nodes, if any. The valid values are + * - 0 - do not permute. + * - 1 - permute cells. + * - 2 - permute nodes. + * - 3 - permute cells and nodes. + * + * \return typename Traits::FieldType * - a new instance of typename Traits::FieldType. The + * caller is to delete this field using decrRef() as it is no more needed. + * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. + * \throw If no field of \a this is lying on \a mesh. + * \throw If no field values of the given \a type or given \a meshDimRelToMax are available. + * \sa getFieldAtLevel() + * \sa getFieldOnMeshAtLevel() + */ + template + typename Traits::FieldType *MEDFileTemplateField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const + { + MCAuto arrOut; + MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns a new typename Traits::FieldType of a given type lying on a given support. + * This method is called "Old" because in MED3 norm a field has only one meshName + * attached, so this method is for readers of MED2 files. If \a this field + * has not been constructed via file reading, an exception is thrown. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of interest. + * \param [in] mName - a name of the supporting mesh. + * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. + * \param [in] renumPol - specifies how to permute values of the result field according to + * the optional numbers of cells and nodes, if any. The valid values are + * - 0 - do not permute. + * - 1 - permute cells. + * - 2 - permute nodes. + * - 3 - permute cells and nodes. + * + * \return typename Traits::FieldType * - a new instance of typename Traits::FieldType. The + * caller is to delete this field using decrRef() as it is no more needed. + * \throw If the MED file is not readable. + * \throw If there is no mesh named \a mName in the MED file. + * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. + * \throw If \a this field has not been constructed via file reading. + * \throw If no field of \a this is lying on the mesh named \a mName. + * \throw If no field values of the given \a type or given \a meshDimRelToMax are available. + * \sa getFieldAtLevel() + */ + template + typename Traits::FieldType *MEDFileTemplateField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const + { + if(getFileName().empty()) + throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); + MCAuto arrOut; + MCAuto ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is + * checked if its elements are sorted suitable for writing to MED file ("STB" stands for + * "Sort By Type"), if not, an exception is thrown. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] field - the field to add to \a this. + * \throw If the name of \a field is empty. + * \throw If the data array of \a field is not set. + * \throw If the data array is already allocated but has different number of components + * than \a field. + * \throw If the underlying mesh of \a field has no name. + * \throw If elements in the mesh are not in the order suitable for writing to the MED file. + */ + template + void MEDFileTemplateField1TS::setFieldNoProfileSBT(const typename Traits::FieldType *field) + { + setFileName(""); + MCAuto ft(MEDCouplingFieldTemplate::New(*field)); + contentNotNull()->setFieldNoProfileSBT(field->timeDiscrSafe(),ft,field->getArray(),*this,*contentNotNull()); + } + + /*! + * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense + * can be an aggregation of several MEDCouplingFieldDouble instances. + * The mesh support of input parameter \a field is ignored here, it can be NULL. + * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax, + * and \a profile. + * + * This method will check that the field based on the computed support is coherent. If not an exception will be thrown. + * A new profile is added only if no equal profile is missing. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] field - the field to add to \a this. The mesh support of field is ignored. + * \param [in] mesh - the supporting mesh of \a field. + * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES). + * \param [in] profile - ids of mesh entities on which corresponding field values lie. + * \throw If either \a field or \a mesh or \a profile has an empty name. + * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh. + * \throw If the data array of \a field is not set. + * \throw If the data array of \a this is already allocated but has different number of + * components than \a field. + * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. + * \sa setFieldNoProfileSBT() + */ + template + void MEDFileTemplateField1TS::setFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) + { + setFileName(""); + MCAuto ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field)); + contentNotNull()->setFieldProfile(field->timeDiscrSafe(),ft,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull()); + } + + /*! + * Return an extraction of \a this using \a extractDef map to specify the extraction. + * The keys of \a extractDef is level relative to max ext of \a mm mesh. + * + * \return A new object that the caller is responsible to deallocate. + * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart + */ + template + typename MLFieldTraits::F1TSType *MEDFileTemplateField1TS::extractPartImpl(const std::map >& extractDef, MEDFileMesh *mm) const + { + if(!mm) + throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !"); + MCAuto::F1TSType> ret(MLFieldTraits::F1TSType::New()); + std::vector tof(getTypesOfFieldAvailable()); + for(std::vector::const_iterator it0=tof.begin();it0!=tof.end();it0++) + { + if((*it0)!=ON_NODES) + { + std::vector levs; + getNonEmptyLevels(mm->getName(),levs); + for(std::vector::const_iterator lev=levs.begin();lev!=levs.end();lev++) + { + std::map >::const_iterator it2(extractDef.find(*lev)); + if(it2!=extractDef.end()) + { + MCAuto t((*it2).second); + if(t.isNull()) + throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !"); + MCAuto::FieldType> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm)); + MCAuto::FieldType> fOut(f->buildSubPart(t)); + ret->setFieldNoProfileSBT(fOut); + } + } + } + else + { + std::map >::const_iterator it2(extractDef.find(1)); + if(it2==extractDef.end()) + throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !"); + MCAuto t((*it2).second); + if(t.isNull()) + throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !"); + MCAuto::FieldType> f(getFieldOnMeshAtLevel(ON_NODES,0,mm)); + MCAuto::FieldType> fOut(f->deepCopy()); + typename Traits::ArrayType *arr(f->getArray()); + MCAuto::ArrayType> newArr(arr->selectByTupleIdSafe(t->begin(),t->end())); + fOut->setArray(newArr); + ret->setFieldNoProfileSBT(fOut); + } + } + return ret.retn(); + } + + ////////////////////////// + + /*! + * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied + * following the given input policy. + * + * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) + * By default (true) the globals are deeply copied. + * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field. + */ + template + MEDFileField1TS *MEDFileNDTemplateField1TS::convertToDouble(bool isDeepCpyGlobs) const + { + MCAuto ret; + const MEDFileAnyTypeField1TSWithoutSDA *content(this->_content); + if(content) + { + const typename MLFieldTraits::F1TSWSDAType *contc(dynamic_cast::F1TSWSDAType *>(content)); + if(!contc) + { + std::ostringstream oss; oss << "MEDFileNDTemplateField1TS::convertToDouble : the content inside this is not " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " ! This is incoherent !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + MCAuto newc(contc->convertToDouble()); + ret=static_cast(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc)); + } + else + ret=MEDFileField1TS::New(); + if(isDeepCpyGlobs) + ret->deepCpyGlobs(*this); + else + ret->shallowCpyGlobs(*this); + return ret.retn(); + } + + ////////////////////////// + + template + typename MLFieldTraits::FMTSWSDAType *MEDFileTemplateFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) + { + return new typename MLFieldTraits::FMTSWSDAType(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities); + } + + template + void MEDFileTemplateFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const + { + if(!f1ts) + throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); + const typename MLFieldTraits::F1TSWSDAType *f1tsC(dynamic_cast::F1TSWSDAType *>(f1ts)); + if(!f1tsC) + { + std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " type !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + } + + template + const char *MEDFileTemplateFieldMultiTSWithoutSDA::getTypeStr() const + { + return MLFieldTraits::F1TSWSDAType::TYPE_STR; + } + + template + MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileTemplateFieldMultiTSWithoutSDA::createNew() const + { + return new typename MLFieldTraits::FMTSWSDAType; + } + + template + MEDFileAnyTypeField1TSWithoutSDA *MEDFileTemplateFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const + { + return new typename MLFieldTraits::F1TSWSDAType; + } + + ////////////////////////// + + template + MEDFileFieldMultiTSWithoutSDA *MEDFileNDTemplateFieldMultiTSWithoutSDA::convertToDouble() const + { + MCAuto ret(new MEDFileFieldMultiTSWithoutSDA); + ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this); + int i=0; + for(std::vector< MCAuto >::const_iterator it=this->_time_steps.begin();it!=this->_time_steps.end();it++,i++) + { + const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it); + if(eltToConv) + { + const typename MLFieldTraits::F1TSWSDAType *eltToConvC(dynamic_cast::F1TSWSDAType *>(eltToConv)); + if(!eltToConvC) + throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !"); + MCAuto elt(eltToConvC->convertToDouble()); + ret->setIteration(i,elt); + } + } + return ret.retn(); + } + + ////////////////////////// + + template + MEDFileTemplateFieldMultiTS::MEDFileTemplateFieldMultiTS() + { + _content=new typename MLFieldTraits::FMTSWSDAType; + } + + template + MEDFileTemplateFieldMultiTS::MEDFileTemplateFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms) + { + } + + template + MEDFileTemplateFieldMultiTS::MEDFileTemplateFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities) + { + } + + template + MEDFileTemplateFieldMultiTS::MEDFileTemplateFieldMultiTS(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent) + { + } + + /*! + * Return an extraction of \a this using \a extractDef map to specify the extraction. + * The keys of \a extractDef is level relative to max ext of \a mm mesh. + * + * \return A new object that the caller is responsible to deallocate. + */ + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::extractPartImpl(const std::map >& extractDef, MEDFileMesh *mm) const + { + if(!mm) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::extractPart : mesh is null !"); + MCAuto::FMTSType> fmtsOut(MLFieldTraits::FMTSType::New()); + int nbTS(getNumberOfTS()); + for(int i=0;i f1ts(getTimeStepAtPos(i)); + MCAuto::F1TSType> f1ts2(DynamicCastSafe::F1TSType>(f1ts)); + MCAuto::F1TSType> f1tsOut(f1ts2->extractPartImpl(extractDef,mm)); + fmtsOut->pushBackTimeStep(f1tsOut); + } + return fmtsOut.retn(); + } + + /*! + * Returns a new empty instance of MEDFileFieldMultiTS. + * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller + * is to delete this field using decrRef() as it is no more needed. + */ + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::New() + { + return new typename MLFieldTraits::FMTSType; + } + + /*! + * Returns a new instance of MEDFileTemplateFieldMultiTS holding data of the first field + * that has been read from a specified MED file. + * \param [in] fileName - the name of the MED file to read. + * \return MEDFileTemplateFieldMultiTS * - a new instance of MEDFileTemplateFieldMultiTS. The caller + * is to delete this field using decrRef() as it is no more needed. + * \throw If reading the file fails. + */ + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::New(const std::string& fileName, bool loadAll) + { + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,loadAll); + } + + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::New(med_idt fid, bool loadAll) + { + MCAuto::FMTSType> ret(new typename MLFieldTraits::FMTSType(fid,loadAll,0)); + ret->contentNotNull();//to check that content type matches with \a this type. + return ret.retn(); + } + + /*! + * Returns a new instance of MEDFileFieldMultiTS holding data of a given field + * that has been read from a specified MED file. + * \param [in] fileName - the name of the MED file to read. + * \param [in] fieldName - the name of the field to read. + * \return MEDFileTemplateFieldMultiTS * - a new instance of MEDFileTemplateFieldMultiTS. The caller + * is to delete this field using decrRef() as it is no more needed. + * \throw If reading the file fails. + * \throw If there is no field named \a fieldName in the file. + */ + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) + { + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,fieldName,loadAll); + } + + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll) + { + MCAuto::FMTSType> ret(new typename MLFieldTraits::FMTSType(fid,fieldName,loadAll,0)); + ret->contentNotNull();//to check that content type matches with \a this type. + return ret.retn(); + } + + /*! + * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied. + * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. + * + * Returns a new instance of MEDFileTemplateFieldMultiTS holding either a shallow copy + * of a given MEDFileTemplateFieldMultiTSWithoutSDA ( \a other ) or \a other itself. + * \warning this is a shallow copy constructor + * \param [in] other - a MEDFileField1TSWithoutSDA to copy. + * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created. + * \return MEDFileTemplateFieldMultiTS * - a new instance of MEDFileTemplateFieldMultiTS. The caller + * is to delete this field using decrRef() as it is no more needed. + */ + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::New(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent) + { + return new typename MLFieldTraits::FMTSType(other,shallowCopyOfContent); + } + + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll) + { + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + INTERP_KERNEL::AutoCppPtr ent(new MEDFileStaticEntities(entities)); + MCAuto::FMTSType> ret(new typename MLFieldTraits::FMTSType(fid,fieldName,loadAll,0,ent)); + ret->contentNotNull();//to check that content type matches with \a this type. + return ret.retn(); + } + + /*! + * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance + * method should be called (getFieldOnMeshAtLevel for example). + * But for normal usage of field in MED file world this method is the most efficient to fetch data. + * + * \param [in] iteration - the iteration number of a required time step. + * \param [in] order - the iteration order number of required time step. + * \param [in] mesh - the mesh the field is lying on + * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The + * caller is to delete this field using decrRef() as it is no more needed. + */ + template + typename Traits::FieldType *MEDFileTemplateFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const + { + const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); + MCAuto arrOut; + MCAuto ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on + * mesh entities of a given dimension of the first mesh in MED file. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of interest. + * \param [in] iteration - the iteration number of a required time step. + * \param [in] order - the iteration order number of required time step. + * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. + * \param [in] renumPol - specifies how to permute values of the result field according to + * the optional numbers of cells and nodes, if any. The valid values are + * - 0 - do not permute. + * - 1 - permute cells. + * - 2 - permute nodes. + * - 3 - permute cells and nodes. + * + * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The + * caller is to delete this field using decrRef() as it is no more needed. + * \throw If the MED file is not readable. + * \throw If there is no mesh in the MED file. + * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. + * \throw If no field values of the required parameters are available. + */ + template + typename Traits::FieldType *MEDFileTemplateFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const + { + const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); + const typename MLFieldTraits::F1TSWSDAType *myF1TSC(dynamic_cast::F1TSWSDAType *>(&myF1TS)); + if(!myF1TSC) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !"); + MCAuto arrOut; + MCAuto ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on + * the top level cells of the first mesh in MED file. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of interest. + * \param [in] iteration - the iteration number of a required time step. + * \param [in] order - the iteration order number of required time step. + * \param [in] renumPol - specifies how to permute values of the result field according to + * the optional numbers of cells and nodes, if any. The valid values are + * - 0 - do not permute. + * - 1 - permute cells. + * - 2 - permute nodes. + * - 3 - permute cells and nodes. + * + * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The + * caller is to delete this field using decrRef() as it is no more needed. + * \throw If the MED file is not readable. + * \throw If there is no mesh in the MED file. + * \throw If no field values of the required parameters are available. + */ + template + typename Traits::FieldType *MEDFileTemplateFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const + { + const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); + const typename MLFieldTraits::F1TSWSDAType *myF1TSC(dynamic_cast::F1TSWSDAType *>(&myF1TS)); + if(!myF1TSC) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !"); + MCAuto arrOut; + MCAuto ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on + * a given support. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of interest. + * \param [in] iteration - the iteration number of a required time step. + * \param [in] order - the iteration order number of required time step. + * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. + * \param [in] mesh - the supporting mesh. + * \param [in] renumPol - specifies how to permute values of the result field according to + * the optional numbers of cells and nodes, if any. The valid values are + * - 0 - do not permute. + * - 1 - permute cells. + * - 2 - permute nodes. + * - 3 - permute cells and nodes. + * + * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The + * caller is to delete this field using decrRef() as it is no more needed. + * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh. + * \throw If no field of \a this is lying on \a mesh. + * \throw If no field values of the required parameters are available. + */ + template + typename Traits::FieldType *MEDFileTemplateFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const + { + const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); + const typename MLFieldTraits::F1TSWSDAType *myF1TSC(dynamic_cast::F1TSWSDAType *>(&myF1TS)); + if(!myF1TSC) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !"); + MCAuto arrOut; + MCAuto ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a + * given support. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of the new field. + * \param [in] iteration - the iteration number of a required time step. + * \param [in] order - the iteration order number of required time step. + * \param [in] mesh - the supporting mesh. + * \param [in] renumPol - specifies how to permute values of the result field according to + * the optional numbers of cells and nodes, if any. The valid values are + * - 0 - do not permute. + * - 1 - permute cells. + * - 2 - permute nodes. + * - 3 - permute cells and nodes. + * + * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The + * caller is to delete this field using decrRef() as it is no more needed. + * \throw If no field of \a this is lying on \a mesh. + * \throw If no field values of the required parameters are available. + */ + template + typename Traits::FieldType *MEDFileTemplateFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const + { + const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); + const typename MLFieldTraits::F1TSWSDAType *myF1TSC(dynamic_cast::F1TSWSDAType *>(&myF1TS)); + if(!myF1TSC) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !"); + MCAuto arrOut; + MCAuto ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel. + * This method is called 'old' because the user should give the mesh name he wants to use for it's field. + * This method is useful for MED2 file format when field on different mesh was autorized. + */ + template + typename Traits::FieldType *MEDFileTemplateFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const + { + const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); + const typename MLFieldTraits::F1TSWSDAType *myF1TSC(dynamic_cast::F1TSWSDAType *>(&myF1TS)); + if(!myF1TSC) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !"); + MCAuto arrOut; + MCAuto ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase())); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); + return ret2.retn(); + } + + /*! + * Returns values and a profile of the field of a given type, of a given time step, + * lying on a given support. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] type - a spatial discretization of the field. + * \param [in] iteration - the iteration number of a required time step. + * \param [in] order - the iteration order number of required time step. + * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities. + * \param [in] mesh - the supporting mesh. + * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the + * field of interest lies on. If the field lies on all entities of the given + * dimension, all ids in \a pfl are zero. The caller is to delete this array + * using decrRef() as it is no more needed. + * \param [in] glob - the global data storing profiles and localization. + * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the + * field. The caller is to delete this array using decrRef() as it is no more needed. + * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh. + * \throw If no field of \a this is lying on \a mesh. + * \throw If no field values of the required parameters are available. + */ + template + typename Traits::ArrayType *MEDFileTemplateFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const + { + const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); + const typename MLFieldTraits::F1TSWSDAType *myF1TSC(dynamic_cast::F1TSWSDAType *>(&myF1TS)); + if(!myF1TSC) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::getFieldWithProfile : mismatch of type of field !"); + MCAuto ret(myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase())); + return MEDFileTemplateField1TS::ReturnSafelyTypedDataArray(ret); + } + + /*! + * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of + * the given field is checked if its elements are sorted suitable for writing to MED file + * ("STB" stands for "Sort By Type"), if not, an exception is thrown. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] field - the field to add to \a this. + * \throw If the name of \a field is empty. + * \throw If the data array of \a field is not set. + * \throw If existing time steps have different name or number of components than \a field. + * \throw If the underlying mesh of \a field has no name. + * \throw If elements in the mesh are not in the order suitable for writing to the MED file. + */ + template + void MEDFileTemplateFieldMultiTS::appendFieldNoProfileSBT(const typename Traits::FieldType *field) + { + const typename Traits::ArrayType *arr(NULL); + if(field) + arr=field->getArray(); + MCAuto field2(MEDFileTemplateField1TS::ToFieldTemplateWithTime(field)); + contentNotNull()->appendFieldNoProfileSBT(field2,arr,*this); + } + + /*! + * Adds a MEDCouplingFieldDouble to \a this as another time step. + * The mesh support of input parameter \a field is ignored here, it can be NULL. + * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax, + * and \a profile. + * + * This method will check that the field based on the computed support is coherent. If not an exception will be thrown. + * A new profile is added only if no equal profile is missing. + * For more info, see \ref AdvMEDLoaderAPIFieldRW + * \param [in] field - the field to add to \a this. The mesh support of field is ignored. + * \param [in] mesh - the supporting mesh of \a field. + * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES). + * \param [in] profile - ids of mesh entities on which corresponding field values lie. + * \throw If either \a field or \a mesh or \a profile has an empty name. + * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh. + * \throw If the data array of \a field is not set. + * \throw If the data array of \a this is already allocated but has different number of + * components than \a field. + * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. + * \sa setFieldNoProfileSBT() + */ + template + void MEDFileTemplateFieldMultiTS::appendFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) + { + const typename Traits::ArrayType *arr(NULL); + if(field) + arr=field->getArray(); + MCAuto field2(MEDFileTemplateField1TS::ToFieldTemplateWithTime(field)); + contentNotNull()->appendFieldProfile(field2,arr,mesh,meshDimRelToMax,profile,*this); + } + + template + const typename MLFieldTraits::FMTSWSDAType *MEDFileTemplateFieldMultiTS::contentNotNull() const + { + const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content); + if(!pt) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::contentNotNull : the content pointer is null !"); + const typename MLFieldTraits::FMTSWSDAType *ret=dynamic_cast::FMTSWSDAType *>(pt); + if(!ret) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !"); + return ret; + } + + template + typename MLFieldTraits::FMTSWSDAType *MEDFileTemplateFieldMultiTS::contentNotNull() + { + MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content); + if(!pt) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::contentNotNull : the non const content pointer is null !"); + typename MLFieldTraits::FMTSWSDAType *ret(dynamic_cast::FMTSWSDAType *>(pt)); + if(!ret) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !"); + return ret; + } + + /*! + * Returns a new MEDFileField1TS holding data of a given time step of \a this field. + * \param [in] pos - a time step id. + * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to + * delete this field using decrRef() as it is no more needed. + * \throw If \a pos is not a valid time step id. + */ + template + typename MLFieldTraits::F1TSType *MEDFileTemplateFieldMultiTS::getTimeStepAtPos(int pos) const + { + const MEDFileAnyTypeField1TSWithoutSDA *item(contentNotNullBase()->getTimeStepAtPos2(pos)); + if(!item) + { + std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + const typename MLFieldTraits::F1TSWSDAType *itemC=dynamic_cast::F1TSWSDAType *>(item); + if(itemC) + { + MCAuto::F1TSType> ret(MLFieldTraits::F1TSType::New(*itemC,false)); + ret->shallowCpyGlobs(*this); + return ret.retn(); + } + std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + + template + typename Traits::ArrayType *MEDFileTemplateFieldMultiTS::getUndergroundDataArray(int iteration, int order) const + { + DataArray *ret(contentNotNull()->getUndergroundDataArray(iteration,order)); + if(!ret) + return NULL; + typename Traits::ArrayType *ret2(dynamic_cast::ArrayType *>(ret)); + if(!ret2) + { + std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS::getUndergroundDataArray : invalid type of data dectected ! Expecting " << MLFieldTraits::F1TSWSDAType::TYPE_STR; + throw INTERP_KERNEL::Exception(oss.str()); + } + return ret2; + } + + template + typename Traits::ArrayType *MEDFileTemplateFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const + { + DataArray *ret(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries)); + if(!ret) + return NULL; + typename Traits::ArrayType *ret2(dynamic_cast::ArrayType *>(ret)); + if(!ret2) + { + std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS::getUndergroundDataArrayExt : invalid type of data dectected ! Expecting " << MLFieldTraits::F1TSWSDAType::TYPE_STR; + throw INTERP_KERNEL::Exception(oss.str()); + } + return ret2; + } + + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::buildNewEmptyImpl() const + { + return MLFieldTraits::FMTSType::New(); + } + + template + void MEDFileTemplateFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const + { + if(!f1ts) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); + const typename MLFieldTraits::F1TSType *f1tsC=dynamic_cast::F1TSType *>(f1ts); + if(!f1tsC) + { + std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS::checkCoherencyOfType : the input field1TS is not a " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " type !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + } + + ////////////////////////// + + /*! + * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied + * following the given input policy. + * + * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) + * By default (true) the globals are deeply copied. + * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field. + */ + template + MEDFileFieldMultiTS *MEDFileNDTemplateFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const + { + MCAuto ret; + const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(this->_content); + if(content) + { + const typename MLFieldTraits::FMTSWSDAType *contc=dynamic_cast::FMTSWSDAType *>(content); + if(!contc) + throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !"); + MCAuto newc(contc->convertToDouble()); + ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc)); + } + else + ret=MEDFileFieldMultiTS::New(); + if(isDeepCpyGlobs) + ret->deepCpyGlobs(*this); + else + ret->shallowCpyGlobs(*this); + return ret.retn(); + } } #endif diff --git a/src/MEDLoader/MEDLoaderTraits.hxx b/src/MEDLoader/MEDLoaderTraits.hxx index 60617cd47..c9af424fb 100644 --- a/src/MEDLoader/MEDLoaderTraits.hxx +++ b/src/MEDLoader/MEDLoaderTraits.hxx @@ -35,14 +35,19 @@ namespace MEDCoupling class MEDFileField1TS; class MEDFileIntFieldMultiTS; class MEDFileIntField1TS; + class MEDFileFloatFieldMultiTS; class MEDFileFloatField1TS; class MEDFileField1TSWithoutSDA; class MEDFileIntField1TSWithoutSDA; class MEDFileFloatField1TSWithoutSDA; + class MEDFileFieldMultiTSWithoutSDA; + class MEDFileIntFieldMultiTSWithoutSDA; + class MEDFileFloatFieldMultiTSWithoutSDA; template<> struct MEDLOADER_EXPORT MLFieldTraits { + typedef MEDFileFieldMultiTSWithoutSDA FMTSWSDAType; typedef MEDFileFieldMultiTS FMTSType; typedef MEDFileField1TS F1TSType; typedef MEDFileField1TSWithoutSDA F1TSWSDAType; @@ -51,7 +56,8 @@ namespace MEDCoupling template<> struct MEDLOADER_EXPORT MLFieldTraits { - //typedef MEDFileFloatFieldMultiTS FMTSType; + typedef MEDFileFloatFieldMultiTSWithoutSDA FMTSWSDAType; + typedef MEDFileFloatFieldMultiTS FMTSType; typedef MEDFileFloatField1TS F1TSType; typedef MEDFileFloatField1TSWithoutSDA F1TSWSDAType; }; @@ -59,6 +65,7 @@ namespace MEDCoupling template<> struct MEDLOADER_EXPORT MLFieldTraits { + typedef MEDFileIntFieldMultiTSWithoutSDA FMTSWSDAType; typedef MEDFileIntFieldMultiTS FMTSType; typedef MEDFileIntField1TS F1TSType; typedef MEDFileIntField1TSWithoutSDA F1TSWSDAType; diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 65365882a..d2498bbe3 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -189,6 +189,12 @@ def MEDCouplingMEDFileIntField1TSnew(cls,*args): def MEDCouplingMEDFileIntFieldMultiTSnew(cls,*args): import _MEDLoader return _MEDLoader.MEDFileIntFieldMultiTS____new___(cls,args) +def MEDCouplingMEDFileFloatField1TSnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDFileFloatField1TS____new___(cls,args) +def MEDCouplingMEDFileFloatFieldMultiTSnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDFileFloatFieldMultiTS____new___(cls,args) def MEDCouplingMEDFileParametersnew(cls,*args): import _MEDLoader return _MEDLoader.MEDFileParameters____new___(cls,args) @@ -217,6 +223,10 @@ MEDFileIntField1TS.__new__=classmethod(MEDCouplingMEDFileIntField1TSnew) del MEDCouplingMEDFileIntField1TSnew MEDFileIntFieldMultiTS.__new__=classmethod(MEDCouplingMEDFileIntFieldMultiTSnew) del MEDCouplingMEDFileIntFieldMultiTSnew +MEDFileFloatField1TS.__new__=classmethod(MEDCouplingMEDFileFloatField1TSnew) +del MEDCouplingMEDFileFloatField1TSnew +MEDFileFloatFieldMultiTS.__new__=classmethod(MEDCouplingMEDFileFloatFieldMultiTSnew) +del MEDCouplingMEDFileFloatFieldMultiTSnew MEDFileParameters.__new__=classmethod(MEDCouplingMEDFileParametersnew) del MEDCouplingMEDFileParametersnew %} diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index e1b20cdbd..219e502e3 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -16,7 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) %module MEDLoader @@ -182,6 +182,7 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileFieldMultiTS::getFieldAtLevelOld; %newobject MEDCoupling::MEDFileFieldMultiTS::getUndergroundDataArray; %newobject MEDCoupling::MEDFileFieldMultiTS::convertToInt; + %newobject MEDCoupling::MEDFileIntFieldMultiTS::New; %newobject MEDCoupling::MEDFileIntFieldMultiTS::field; %newobject MEDCoupling::MEDFileIntFieldMultiTS::LoadSpecificEntities; @@ -192,6 +193,16 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel; %newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldAtLevelOld; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::New; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::field; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::LoadSpecificEntities; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getUndergroundDataArray; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::convertToDouble; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldAtLevel; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldAtTopLevel; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldOnMeshAtLevel; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldAtLevelOld; + %newobject MEDCoupling::MEDFileAnyTypeField1TS::New; %newobject MEDCoupling::MEDFileAnyTypeField1TS::NewAdv; %newobject MEDCoupling::MEDFileAnyTypeField1TS::shallowCpy; @@ -215,6 +226,15 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileIntField1TS::getUndergroundDataArray; %newobject MEDCoupling::MEDFileIntField1TS::convertToDouble; +%newobject MEDCoupling::MEDFileFloatField1TS::New; +%newobject MEDCoupling::MEDFileFloatField1TS::field; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldAtLevel; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldAtTopLevel; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldOnMeshAtLevel; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldAtLevelOld; +%newobject MEDCoupling::MEDFileFloatField1TS::getUndergroundDataArray; +%newobject MEDCoupling::MEDFileFloatField1TS::convertToDouble; + %newobject MEDCoupling::MEDFileData::New; %newobject MEDCoupling::MEDFileData::deepCopy; %newobject MEDCoupling::MEDFileData::getMeshes; @@ -285,9 +305,11 @@ using namespace MEDCoupling; %feature("unref") MEDFileAnyTypeField1TS "$this->decrRef();" %feature("unref") MEDFileField1TS "$this->decrRef();" %feature("unref") MEDFileIntField1TS "$this->decrRef();" +%feature("unref") MEDFileFloatField1TS "$this->decrRef();" %feature("unref") MEDFileAnyTypeFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileIntFieldMultiTS "$this->decrRef();" +%feature("unref") MEDFileFloatFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileMeshSupports "$this->decrRef();" %feature("unref") MEDFileStructureElements "$this->decrRef();" %feature("unref") MEDFileFields "$this->decrRef();" @@ -2473,6 +2495,82 @@ namespace MEDCoupling } }; + class MEDFileFloatField1TS : public MEDFileAnyTypeField1TS + { + public: + static MEDFileFloatField1TS *New(); + static MEDFileFloatField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatField1TS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); + static MEDFileFloatField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); + MEDCoupling::MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + // + void setFieldNoProfileSBT(const MEDCouplingFieldFloat *field) throw(INTERP_KERNEL::Exception); + void setFieldProfile(const MEDCouplingFieldFloat *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileFloatField1TS() throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(); + } + + MEDFileFloatField1TS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(fileName,loadAll); + } + + MEDFileFloatField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(fileName,fieldName,loadAll); + } + + MEDFileFloatField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(fileName,fieldName,iteration,order,loadAll); + } + + MEDFileFloatField1TS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(db); + } + + // serialization + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFloatField1TS"); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + + PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret1=0; + DataArrayFloat *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayFloat, SWIG_POINTER_OWN | 0 )); + return ret; + } + + DataArrayFloat *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) + { + DataArrayFloat *ret=self->getUndergroundDataArray(); + if(ret) + ret->incrRef(); + return ret; + } + } + }; + class MEDFileAnyTypeFieldMultiTSIterator { public: @@ -2863,6 +2961,8 @@ namespace MEDCoupling } }; + class MEDFileIntFieldMultiTS; + class MEDFileFieldMultiTS : public MEDFileAnyTypeFieldMultiTS { public: @@ -2876,11 +2976,11 @@ namespace MEDCoupling MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); // void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); - MEDCoupling::MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); %extend { MEDFileFieldMultiTS() @@ -3074,13 +3174,7 @@ namespace MEDCoupling static MEDFileIntFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { std::vector > tmp(convertTimePairIdsFromPy(entities)); - std::size_t sz(tmp.size()); - std::vector< std::pair > entitiesCpp(sz); - for(std::size_t i=0;i > entitiesCpp(convertVecPairIntToVecPairTOFCT(tmp)); return MEDFileIntFieldMultiTS::LoadSpecificEntities(fileName,fieldName,entitiesCpp,loadAll); } @@ -3108,6 +3202,83 @@ namespace MEDCoupling } } }; + + class MEDFileFloatFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + { + public: + static MEDFileFloatFieldMultiTS *New(); + static MEDFileFloatFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatFieldMultiTS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); + // + void appendFieldNoProfileSBT(const MEDCouplingFieldFloat *field) throw(INTERP_KERNEL::Exception); + void appendFieldProfile(const MEDCouplingFieldFloat *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + MEDCoupling::MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *field(int iteration, int order, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileFloatFieldMultiTS() + { + return MEDFileFloatFieldMultiTS::New(); + } + + MEDFileFloatFieldMultiTS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatFieldMultiTS::New(fileName,loadAll); + } + + MEDFileFloatFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatFieldMultiTS::New(fileName,fieldName,loadAll); + } + + MEDFileFloatFieldMultiTS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatFieldMultiTS::New(db); + } + + // serialization + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFloatFieldMultiTS"); + } + + static MEDFileFloatFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) + { + std::vector > tmp(convertTimePairIdsFromPy(entities)); + std::vector< std::pair > entitiesCpp(convertVecPairIntToVecPairTOFCT(tmp)); + return MEDFileFloatFieldMultiTS::LoadSpecificEntities(fileName,fieldName,entitiesCpp,loadAll); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + + PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret1=0; + DataArrayFloat *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayFloat, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + DataArrayFloat *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception) + { + DataArrayFloat *ret=self->getUndergroundDataArray(iteration,order); + if(ret) + ret->incrRef(); + return ret; + } + } + }; class MEDFileMeshSupports : public RefCountObject, public MEDFileWritableStandAlone { diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 55fd117f1..3a542631a 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -17,7 +17,7 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# Author : Anthony Geay (CEA/DEN) +# Author : Anthony Geay (EDF R&D) from MEDLoader import * import unittest diff --git a/src/MEDLoader/Swig/MEDLoaderTypemaps.i b/src/MEDLoader/Swig/MEDLoaderTypemaps.i index 0cf84bc09..27eae0a2d 100644 --- a/src/MEDLoader/Swig/MEDLoaderTypemaps.i +++ b/src/MEDLoader/Swig/MEDLoaderTypemaps.i @@ -68,6 +68,8 @@ static PyObject *convertMEDFileField1TS(MEDCoupling::MEDFileAnyTypeField1TS *p, ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileField1TS,owner); if(dynamic_cast(p)) ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileIntField1TS,owner); + if(dynamic_cast(p)) + ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileFloatField1TS,owner); if(!ret) throw INTERP_KERNEL::Exception("Not recognized type of MEDFileAnyTypeField1TS on downcast !"); return ret; @@ -85,6 +87,8 @@ static PyObject *convertMEDFileFieldMultiTS(MEDCoupling::MEDFileAnyTypeFieldMult ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileFieldMultiTS,owner); if(dynamic_cast(p)) ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileIntFieldMultiTS,owner); + if(dynamic_cast(p)) + ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileFloatFieldMultiTS,owner); if(!ret) throw INTERP_KERNEL::Exception("Not recognized type of MEDFileAnyTypeFieldMultiTS on downcast !"); return ret; @@ -146,6 +150,18 @@ static std::vector > convertTimePairIdsFromPy(PyObject *pyLi) return ret; } +static std::vector< std::pair > convertVecPairIntToVecPairTOFCT(const std::vector >& tmp) +{ + std::size_t sz(tmp.size()); + std::vector< std::pair > entitiesCpp(sz); + for(std::size_t i=0;i& v) { if(PyList_Check(pyLi)) -- 2.39.2