-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020 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
* \sa getUndergroundDataArrayTemplate()
*/
template<class T>
- typename Traits<T>::ArrayType *MEDFileField1TSTemplateWithoutSDA<T>::getUndergroundDataArrayTemplateExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
+ typename Traits<T>::ArrayType *MEDFileField1TSTemplateWithoutSDA<T>::getUndergroundDataArrayTemplateExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
{
if(this->_field_per_mesh.size()!=1)
throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
}
template<class T>
- void MEDFileField1TSTemplateWithoutSDA<T>::aggregate(const std::vector<typename MLFieldTraits<T>::F1TSWSDAType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
+ void MEDFileField1TSTemplateWithoutSDA<T>::aggregate(const std::vector<typename MLFieldTraits<T>::F1TSWSDAType const *>& f1tss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
{
if(f1tss.empty())
throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::aggregate : empty vector !");
setName(refPt->getName());
const DataArray *arr(refPt->getUndergroundDataArray());
- int nbCompo(arr->getNumberOfComponents());
+ std::size_t nbCompo(arr->getNumberOfComponents());
for(typename std::vector<typename MLFieldTraits<T>::F1TSWSDAType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++)
{
const typename Traits<T>::ArrayType *myArr((*it)->getUndergroundDataArrayTemplate());
if(myArr->getNumberOfComponents()!=nbCompo)
throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::aggregate : arrays must have same number of components !");
}
- std::vector<std::pair< int, std::pair<int,int> > > extractInfo;
- int start(0);
+ std::vector<std::pair< int, std::pair<mcIdType,mcIdType> > > extractInfo;
+ mcIdType start(0);
MCAuto<MEDFileFieldPerMesh> fpm(MEDFileFieldPerMesh::Aggregate(start,pms,dts,this,extractInfo));
_field_per_mesh.push_back(fpm);
int iteration,order;
_arr=Traits<T>::ArrayType::New();
_arr->alloc(start,nbCompo); _arr->copyStringInfoFrom(*arr);
start=0;
- for(std::vector<std::pair< int, std::pair<int,int> > >::const_iterator it=extractInfo.begin();it!=extractInfo.end();it++)
+ for(std::vector<std::pair< int, std::pair<mcIdType,mcIdType> > >::const_iterator it=extractInfo.begin();it!=extractInfo.end();it++)
{
const DataArray *zeArr(das[(*it).first]);
_arr->setContigPartOfSelectedValuesSlice(start,zeArr,(*it).second.first,(*it).second.second,1);
}
}
+ template<class T>
+ void MEDFileField1TSTemplateWithoutSDA<T>::copyTimeInfoFrom(const typename Traits<T>::FieldType *mcf)
+ {
+ if(!mcf)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA<T>::copyTimeInfoFrom : input field is nullptr !");
+ int b(0),c(0);
+ double a(mcf->getTime(b,c));
+ setTime(b,c,a);
+ }
+
///////////////////////////////////////////////////////
template<class T>
* \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
*/
template<class T>
- typename Traits<T>::ArrayType *MEDFileTemplateField1TS<T>::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
+ typename Traits<T>::ArrayType *MEDFileTemplateField1TS<T>::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayIdType *&pfl) const
{
MCAuto<DataArray> arr(contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull()));
return ReturnSafelyTypedDataArray(arr);
}
+ template<class T>
+ void MEDFileTemplateField1TS<T>::setArray(DataArray *arr)
+ {
+ return contentNotNull()->setArray(arr);
+ }
+
template<class T>
typename Traits<T>::ArrayType *MEDFileTemplateField1TS<T>::getUndergroundDataArray() const
{
}
template<class T>
- typename Traits<T>::ArrayType *MEDFileTemplateField1TS<T>::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
+ typename Traits<T>::ArrayType *MEDFileTemplateField1TS<T>::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
{
return contentNotNull()->getUndergroundDataArrayTemplateExt(entries);
}
return ret.retn();
}
+ template<class T>
+ void MEDFileTemplateField1TS<T>::copyTimeInfoFrom(const typename Traits<T>::FieldType *mcf)
+ {
+ contentNotNull()->copyTimeInfoFrom(mcf);
+ }
+
/*!
* 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).
* \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()
+ * \sa setFieldNoProfileSBT, setFieldProfileFlatly
*/
template<class T>
- void MEDFileTemplateField1TS<T>::setFieldProfile(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
+ void MEDFileTemplateField1TS<T>::setFieldProfile(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile)
+ {
+ setFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,true);
+ }
+
+ /*!
+ * Same as setFieldProfile except that here profile will be created unconditionally
+ * \sa setFieldProfile
+ */
+ template<class T>
+ void MEDFileTemplateField1TS<T>::setFieldProfileFlatly(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile)
+ {
+ setFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,false);
+ }
+
+ template<class T>
+ void MEDFileTemplateField1TS<T>::setFieldProfileGeneral(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile, bool smartPflKiller)
{
setFileName("");
MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field));
- contentNotNull()->setFieldProfile(field->timeDiscrSafe(),ft,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
+ contentNotNull()->setFieldProfile(field->timeDiscrSafe(),ft,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull(),smartPflKiller);
}
-
+
/*!
* 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.
* \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
*/
template<class T>
- typename MLFieldTraits<T>::F1TSType *MEDFileTemplateField1TS<T>::extractPartImpl(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
+ typename MLFieldTraits<T>::F1TSType *MEDFileTemplateField1TS<T>::extractPartImpl(const std::map<int, MCAuto<DataArrayIdType> >& extractDef, MEDFileMesh *mm) const
{
if(!mm)
throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
getNonEmptyLevels(mm->getName(),levs);
for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
{
- std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
+ std::map<int, MCAuto<DataArrayIdType> >::const_iterator it2(extractDef.find(*lev));
if(it2!=extractDef.end())
{
- MCAuto<DataArrayInt> t((*it2).second);
+ MCAuto<DataArrayIdType> t((*it2).second);
if(t.isNull())
throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
MCAuto<typename Traits<T>::FieldType> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
}
else
{
- std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
+ std::map<int, MCAuto<DataArrayIdType> >::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<DataArrayInt> t((*it2).second);
+ MCAuto<DataArrayIdType> t((*it2).second);
if(t.isNull())
throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
MCAuto<typename Traits<T>::FieldType> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
* \return A new object that the caller is responsible to deallocate.
*/
template<class T>
- typename MLFieldTraits<T>::FMTSType *MEDFileTemplateFieldMultiTS<T>::extractPartImpl(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
+ typename MLFieldTraits<T>::FMTSType *MEDFileTemplateFieldMultiTS<T>::extractPartImpl(const std::map<int, MCAuto<DataArrayIdType> >& extractDef, MEDFileMesh *mm) const
{
if(!mm)
throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS<T>::extractPart : mesh is null !");
* \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
+ * \param [out] pfl - a new instance of DataArrayIdType 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.
* \throw If no field values of the required parameters are available.
*/
template<class T>
- typename Traits<T>::ArrayType *MEDFileTemplateFieldMultiTS<T>::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
+ typename Traits<T>::ArrayType *MEDFileTemplateFieldMultiTS<T>::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayIdType *&pfl) const
{
const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
const typename MLFieldTraits<T>::F1TSWSDAType *myF1TSC(dynamic_cast<const typename MLFieldTraits<T>::F1TSWSDAType *>(&myF1TS));
* \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()
+ * \sa setFieldNoProfileSBT, appendFieldProfileFlatly
+ */
+ template<class T>
+ void MEDFileTemplateFieldMultiTS<T>::appendFieldProfile(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile)
+ {
+ appendFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,true);
+ }
+
+ /*!
+ * same as appendFieldProfile except that here profile is created unconditionaly
*/
template<class T>
- void MEDFileTemplateFieldMultiTS<T>::appendFieldProfile(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
+ void MEDFileTemplateFieldMultiTS<T>::appendFieldProfileFlatly(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile)
+ {
+ appendFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,false);
+ }
+
+ template<class T>
+ void MEDFileTemplateFieldMultiTS<T>::appendFieldProfileGeneral(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile, bool smartPflKiller)
{
const typename Traits<T>::ArrayType *arr(NULL);
if(field)
arr=field->getArray();
MCAuto<MEDCouplingFieldDouble> field2(MEDFileTemplateField1TS<T>::ToFieldTemplateWithTime(field));
- contentNotNull()->appendFieldProfile(field2,arr,mesh,meshDimRelToMax,profile,*this);
+ contentNotNull()->appendFieldProfile(field2,arr,mesh,meshDimRelToMax,profile,*this,smartPflKiller);
}
-
+
template<class T>
const typename MLFieldTraits<T>::FMTSWSDAType *MEDFileTemplateFieldMultiTS<T>::contentNotNull() const
{
typename Traits<T>::ArrayType *ret2(dynamic_cast<typename Traits<T>::ArrayType *>(ret));
if(!ret2)
{
- std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS<T>::getUndergroundDataArray : invalid type of data dectected ! Expecting " << MLFieldTraits<T>::F1TSWSDAType::TYPE_STR;
+ std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS<T>::getUndergroundDataArray : invalid type of data detected ! Expecting " << MLFieldTraits<T>::F1TSWSDAType::TYPE_STR;
throw INTERP_KERNEL::Exception(oss.str());
}
return ret2;
}
template<class T>
- typename Traits<T>::ArrayType *MEDFileTemplateFieldMultiTS<T>::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
+ typename Traits<T>::ArrayType *MEDFileTemplateFieldMultiTS<T>::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
{
DataArray *ret(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
if(!ret)
typename Traits<T>::ArrayType *ret2(dynamic_cast<typename Traits<T>::ArrayType *>(ret));
if(!ret2)
{
- std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS<T>::getUndergroundDataArrayExt : invalid type of data dectected ! Expecting " << MLFieldTraits<T>::F1TSWSDAType::TYPE_STR;
+ std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS<T>::getUndergroundDataArrayExt : invalid type of data detected ! Expecting " << MLFieldTraits<T>::F1TSWSDAType::TYPE_STR;
throw INTERP_KERNEL::Exception(oss.str());
}
return ret2;