X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileFieldMultiTS.cxx;h=74bc171d60483120da92f818676099f46000f145;hb=e95ee11e7df126315ffd11c2518b648a6915ad51;hp=00c118f746d213368026f7986b89a60a7c7fc954;hpb=7ef17c68f4eb099188320b9b217b8bf6f85e4437;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileFieldMultiTS.cxx b/src/MEDLoader/MEDFileFieldMultiTS.cxx index 00c118f74..74bc171d6 100644 --- a/src/MEDLoader/MEDFileFieldMultiTS.cxx +++ b/src/MEDLoader/MEDFileFieldMultiTS.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2019 CEA/DEN, EDF R&D +// Copyright (C) 2017-2021 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -31,15 +31,19 @@ using namespace MEDCoupling; -template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; -template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; -template class MEDCoupling::MEDFileTemplateFieldMultiTS; +template class MEDCoupling::MEDFileTemplateFieldMultiTS; +template class MEDCoupling::MEDFileTemplateFieldMultiTS; template class MEDCoupling::MEDFileTemplateFieldMultiTS; template class MEDCoupling::MEDFileTemplateFieldMultiTS; -template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; extern INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type geotype); @@ -143,7 +147,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buil std::size_t j=bg; for(int i=0;i=0 && j tse2; @@ -414,7 +418,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream int i=0; for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++) { - std::string chapter(17,'0'+i); + std::string chapter(17,(char)('0'+i)); oss << startLine << chapter << std::endl; const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it); if(cur) @@ -492,18 +496,18 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR MEDFileCapability mfcap(fid); if( ( !entities || entities->areAllStaticPresentAndNoDyn() ) && mfcap.isFastReader()) {// no entities - int nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT)); + med_int nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT)); INTERP_KERNEL::AutoPtr types(new med_entity_type[nentitype]); med_int usedbyncs; MEDFILESAFECALLERRD0(MEDfieldEntityType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types,&usedbyncs)); std::vector< std::pair > entitiesFastP; for(int i=0;i geotypes(new med_geometry_type[ngeotype]); med_int geousedbyncs; MEDFILESAFECALLERRD0(MEDfieldGeometryType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i],geotypes,&geousedbyncs)); - for(int j=0;j p(MEDFileMesh::ConvertFromMEDFileEntity(types[i]),ConvertGeometryType(geotypes[j])); entitiesFastP.push_back(p); @@ -527,7 +531,12 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR } case MED_INT32: { - _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt(numdt),FromMedInt(numo),_infos); + _time_steps[i]=MEDFileInt32Field1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt(numdt),FromMedInt(numo),_infos); + break; + } + case MED_INT64: + { + _time_steps[i]=MEDFileInt64Field1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt(numdt),FromMedInt(numo),_infos); break; } case MED_FLOAT32: @@ -539,12 +548,12 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR { if(sizeof(med_int)==sizeof(int)) { - _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt(numdt),FromMedInt(numo),_infos); + _time_steps[i]=MEDFileInt32Field1TSWithoutSDA::New(getName(),getMeshName(),i+1,FromMedInt(numdt),FromMedInt(numo),_infos); break; } } default: - throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !"); + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32, INT64 !"); } if(loadAll) _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entitiesForSubInstances); @@ -1080,7 +1089,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCoup void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile, MEDFileFieldGlobsReal& glob, bool smartPflKiller) { if(!field) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !"); + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !"); if(!_time_steps.empty()) checkCoherencyOfTinyInfo(field,arr); MCAuto obj(createNew1TSWithoutSDAEmptyInstance()); @@ -1128,9 +1137,9 @@ std::vector< std::vector > MEDFileFieldMultiTSWithoutSDA::get return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs); } -MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const +MEDFileInt32FieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const { - MCAuto ret(new MEDFileIntFieldMultiTSWithoutSDA); + MCAuto ret(new MEDFileInt32FieldMultiTSWithoutSDA); ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this); int i=0; for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++) @@ -1148,6 +1157,36 @@ MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() return ret.retn(); } +MCAuto MEDFileFieldMultiTSWithoutSDA::createNewWithSDA() const +{ + MCAuto ret(MEDFileFieldMultiTS::New()); + return DynamicCast(ret); +} + +//= + +MCAuto MEDFileInt32FieldMultiTSWithoutSDA::createNewWithSDA() const +{ + MCAuto ret(MEDFileInt32FieldMultiTS::New()); + return DynamicCast(ret); +} + +//= + +MCAuto MEDFileInt64FieldMultiTSWithoutSDA::createNewWithSDA() const +{ + MCAuto ret(MEDFileInt64FieldMultiTS::New()); + return DynamicCast(ret); +} + +//= + +MCAuto MEDFileFloatFieldMultiTSWithoutSDA::createNewWithSDA() const +{ + MCAuto ret(MEDFileFloatFieldMultiTS::New()); + return DynamicCast(ret); +} + //= MEDFileAnyTypeFieldMultiTS MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS() @@ -1183,7 +1222,12 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr } case MED_INT32: { - ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); + ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); + break; + } + case MED_INT64: + { + ret=new MEDFileInt64FieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); break; } case MED_FLOAT32: @@ -1195,13 +1239,13 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr { if(sizeof(med_int)==sizeof(int)) { - ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); + ret=new MEDFileInt32FieldMultiTSWithoutSDA(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, MED_FLOAT32] !"; + 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, MED_INT64] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -1227,7 +1271,12 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr } case MED_INT32: { - ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + break; + } + case MED_INT64: + { + ret=new MEDFileInt64FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); break; } case MED_FLOAT32: @@ -1239,13 +1288,13 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr { if(sizeof(med_int)==sizeof(int)) { - ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + ret=new MEDFileInt32FieldMultiTSWithoutSDA(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, MED_FLOAT32] !"; + 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, MED_INT64] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -1264,9 +1313,15 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromCont ret->_content=c; c->incrRef(); return ret.retn(); } - if(dynamic_cast(c)) + if(dynamic_cast(c)) + { + MCAuto ret(MEDFileInt32FieldMultiTS::New()); + ret->_content=c; c->incrRef(); + return ret.retn(); + } + if(dynamic_cast(c)) { - MCAuto ret(MEDFileIntFieldMultiTS::New()); + MCAuto ret(MEDFileInt64FieldMultiTS::New()); ret->_content=c; c->incrRef(); return ret.retn(); } @@ -1301,10 +1356,10 @@ catch(INTERP_KERNEL::Exception& e) //= MEDFileAnyTypeFieldMultiTS /*! - * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field + * Returns a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS 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 or MEDFileIntFieldMultiTS. The caller + * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS. The caller * is to delete this field using decrRef() as it is no more needed. * \throw If reading the file fails. */ @@ -1323,11 +1378,11 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool lo } /*! - * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field + * Returns a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS 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 or MEDFileIntFieldMultiTS. The caller + * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileInt32FieldMultiTS. 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. @@ -1741,10 +1796,10 @@ MCAuto MEDFileAnyTypeFieldMultiTS::getCont } /*! - * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field. + * Returns a new MEDFileField1TS or MEDFileInt32Field1TS holding data of a given time step of \a this field. * \param [in] iteration - the iteration number of a required time step. * \param [in] order - the iteration order number of required time step. - * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to + * \return MEDFileField1TS * or MEDFileInt32Field1TS *- a new instance of MEDFileField1TS or MEDFileInt32Field1TS. The caller is to * delete this field using decrRef() as it is no more needed. * \throw If there is no required time step in \a this field. */ @@ -1755,7 +1810,7 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, i } /*! - * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field. + * Returns a new MEDFileField1TS or MEDFileInt32Field1TS holding data of a given time step of \a this field. * \param [in] time - the time of the time step of interest. * \param [in] eps - a precision used to compare time values. * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to @@ -2034,6 +2089,7 @@ MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< type /*! * \a dts and \a ftmss are expected to have same size. + * see MEDFileFieldPerMeshPerTypePerDisc::Aggregate for description of \a dts. */ MCAuto MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector& fmtss, const std::vector< std::vector< std::pair > >& dts) { @@ -2041,7 +2097,8 @@ MCAuto MEDFileAnyTypeFieldMultiTS::Aggregate(const s throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !"); std::size_t sz(fmtss.size()); std::vector fmtss1; - std::vector fmtss2; + std::vector fmtss2; + std::vector fmtss3; for(std::vector::const_iterator it=fmtss.begin();it!=fmtss.end();it++) { if(!(*it)) @@ -2052,20 +2109,28 @@ MCAuto MEDFileAnyTypeFieldMultiTS::Aggregate(const s fmtss1.push_back(elt1); continue; } - const MEDFileIntFieldMultiTS *elt2(dynamic_cast(*it)); + const MEDFileInt32FieldMultiTS *elt2(dynamic_cast(*it)); if(elt2) { fmtss2.push_back(elt2); continue; } + const MEDFileInt64FieldMultiTS *elt3(dynamic_cast(*it)); + if(elt3) + { + fmtss3.push_back(elt3); + continue; + } throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !"); } - if(fmtss1.size()!=sz && fmtss2.size()!=sz) + if(fmtss1.size()!=sz && fmtss2.size()!=sz && fmtss3.size()!=sz) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !"); if(fmtss1.size()==sz) return AggregateHelperFMTS(fmtss1,dts); if(fmtss2.size()!=sz) - return AggregateHelperFMTS(fmtss2,dts); + return AggregateHelperFMTS(fmtss2,dts); + if(fmtss3.size()!=sz) + return AggregateHelperFMTS(fmtss3,dts); throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !"); } @@ -2087,22 +2152,22 @@ MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const * * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) * By default (true) the globals are deeply copied. - * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field. + * \return MEDFileInt32FieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field. */ -MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const +MEDFileInt32FieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const { - MCAuto ret; + MCAuto ret; const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content); if(content) { const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast(content); if(!contc) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !"); - MCAuto newc(contc->convertToInt()); - ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc)); + MCAuto newc(contc->convertToInt()); + ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileInt32FieldMultiTSWithoutSDA *)newc)); } else - ret=MEDFileIntFieldMultiTS::New(); + ret=MEDFileInt32FieldMultiTS::New(); if(isDeepCpyGlobs) ret->deepCpyGlobs(*this); else @@ -2162,4 +2227,4 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() return 0; } -//= MEDFileIntFieldMultiTS +//= MEDFileInt32FieldMultiTS