From: Anthony Geay Date: Wed, 17 May 2017 15:37:42 +0000 (+0200) Subject: Facto MultiTS 3/4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=76619f2156ff08d1b311520e2d7fad9acce59601;p=tools%2Fmedcoupling.git Facto MultiTS 3/4 --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 906283854..71bc8fcb5 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -9159,77 +9159,6 @@ MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw INTERP_KERNEL::Exception(oss.str()); } -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(med_idt fid, bool loadAll, const MEDFileMeshes *ms) try:MEDFileTemplateFieldMultiTS(fid,loadAll,ms) { @@ -9368,74 +9297,6 @@ MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const 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(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS(other,shallowCopyOfContent) { } diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index f47b0162e..0f75439df 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -883,7 +883,8 @@ 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> SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto& arr); + 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; @@ -1203,6 +1204,12 @@ namespace MEDCoupling 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); + protected: + const typename MLFieldTraits::FMTSWSDAType *contentNotNull() const; + typename MLFieldTraits::FMTSWSDAType *contentNotNull(); protected: ~MEDFileTemplateFieldMultiTS() { } MEDFileTemplateFieldMultiTS(); @@ -1228,16 +1235,11 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const; MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) 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; public: MEDLOADER_EXPORT MEDFileFieldMultiTS *buildNewEmpty() const; - private: - const MEDFileFieldMultiTSWithoutSDA *contentNotNull() const; - MEDFileFieldMultiTSWithoutSDA *contentNotNull(); private: ~MEDFileFieldMultiTS() { } MEDFileFieldMultiTS() { } @@ -1258,15 +1260,9 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileIntField1TS *getTimeStepAtPos(int pos) const; MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) 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(); private: ~MEDFileIntFieldMultiTS() { } MEDFileIntFieldMultiTS() { } diff --git a/src/MEDLoader/MEDFileField.txx b/src/MEDLoader/MEDFileField.txx index b725061ad..7f21da526 100644 --- a/src/MEDLoader/MEDFileField.txx +++ b/src/MEDLoader/MEDFileField.txx @@ -392,12 +392,12 @@ namespace MEDCoupling } template - MCAuto::FieldType> MEDFileTemplateField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto& arr) + MCAuto::FieldType> MEDFileTemplateField1TS::SetDataArrayInField(MEDCouplingFieldDouble *f, MCAuto& arr) { if(!f) - throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::SetDataArrayDoubleInField : input field is NULL !"); + throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::SetDataArrayInField : input field is NULL !"); if(arr.isNull()) - throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::SetDataArrayDoubleInField : no array !"); + throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::SetDataArrayInField : no array !"); int t1,t2; double t0(f->getTime(t1,t2)); std::string tu(f->getTimeUnit()); @@ -408,6 +408,18 @@ namespace MEDCoupling 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). @@ -422,7 +434,7 @@ namespace MEDCoupling { MCAuto arrOut; MCAuto ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull())); - MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -456,7 +468,7 @@ namespace MEDCoupling 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::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -489,7 +501,7 @@ namespace MEDCoupling 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::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -518,7 +530,7 @@ namespace MEDCoupling { MCAuto arrOut; MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull())); - MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -548,7 +560,7 @@ namespace MEDCoupling { MCAuto arrOut; MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull())); - MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -585,7 +597,7 @@ namespace MEDCoupling 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::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -843,7 +855,7 @@ namespace MEDCoupling const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); MCAuto arrOut; MCAuto ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase())); - MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -878,7 +890,7 @@ namespace MEDCoupling 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::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -911,7 +923,7 @@ namespace MEDCoupling 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::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -946,7 +958,7 @@ namespace MEDCoupling 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::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -979,7 +991,7 @@ namespace MEDCoupling 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::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -997,7 +1009,7 @@ namespace MEDCoupling 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::SetDataArrayDoubleInField(ret,arrOut)); + MCAuto::FieldType> ret2(MEDFileTemplateField1TS::SetDataArrayInField(ret,arrOut)); return ret2.retn(); } @@ -1031,6 +1043,83 @@ namespace MEDCoupling 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; + } } #endif