Salome HOME
[EDF26877] : management of computation of measure field on field on Gauss Point in...
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingTimeDiscretization.txx
index a53e36db243b5d74bb008c630dfd8e7856497145..0af09e5d901dbf224c1a8d5680744dc4677289ad 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2022  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
@@ -60,14 +60,14 @@ namespace MEDCoupling
   template<class T>
   void MEDCouplingTimeDiscretizationTemplate<T>::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<T>& other)
   {
+    TimeHolder::copyTinyAttrFrom(other);
     _time_tolerance=other._time_tolerance;
-    _time_unit=other._time_unit;
   }
   
   template<class T>
   void MEDCouplingTimeDiscretizationTemplate<T>::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<T>& other)
   {
-    _time_unit=other._time_unit;
+    TimeHolder::copyTinyAttrFrom(other);
     if(_array && other._array)
       _array->copyStringInfoFrom(*other._array);
   }
@@ -75,7 +75,7 @@ namespace MEDCoupling
   template<class T>
   std::size_t MEDCouplingTimeDiscretizationTemplate<T>::getHeapMemorySizeWithoutChildren() const
   {
-    return _time_unit.capacity();
+    return getTimeUnit().capacity();
   }
   
   template<class T>
@@ -99,9 +99,9 @@ namespace MEDCoupling
   bool MEDCouplingTimeDiscretizationTemplate<T>::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<T> *other, std::string& reason) const
   {
     std::ostringstream oss; oss.precision(15);
-    if(_time_unit!=other->_time_unit)
+    if(getTimeUnit()!=other->getTimeUnit())
       {
-        oss << "Field discretizations differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !";
+        oss << "Field discretizations differ : this time unit = \"" << getTimeUnit() << "\" and other time unit = \"" << other->getTimeUnit() << "\" !";
         reason=oss.str();
         return false;
       }
@@ -148,8 +148,8 @@ namespace MEDCoupling
       return true;
     if(_array==0 || other->_array==0)
       return false;
-    int nbC1(_array->getNumberOfComponents()),nbC2(other->_array->getNumberOfComponents());
-    int nbMin(std::min(nbC1,nbC2));
+    std::size_t nbC1(_array->getNumberOfComponents()),nbC2(other->_array->getNumberOfComponents());
+    std::size_t nbMin(std::min(nbC1,nbC2));
     if(nbC1!=nbC2 && nbMin!=1)
       return false;
     return true;
@@ -164,7 +164,7 @@ namespace MEDCoupling
       return true;
     if(_array==0 || other->_array==0)
       return false;
-    int nbC1(_array->getNumberOfComponents()),nbC2(other->_array->getNumberOfComponents());
+    std::size_t nbC1(_array->getNumberOfComponents()),nbC2(other->_array->getNumberOfComponents());
     if(nbC1!=nbC2 && nbC2!=1)
       return false;
     return true;
@@ -176,7 +176,7 @@ namespace MEDCoupling
   }
 
   template<class T>
-  MEDCouplingTimeDiscretizationTemplate<T>::MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate<T>& other, bool deepCopy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance)
+  MEDCouplingTimeDiscretizationTemplate<T>::MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate<T>& other, bool deepCopy):TimeHolder(other),_time_tolerance(other._time_tolerance)
   {
     if(other._array)
       _array=other._array->performCopyOrIncrRef(deepCopy);
@@ -225,12 +225,12 @@ namespace MEDCoupling
   }
   
   template<class T>
-  void MEDCouplingTimeDiscretizationTemplate<T>::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+  void MEDCouplingTimeDiscretizationTemplate<T>::getTinySerializationIntInformation(std::vector<mcIdType>& tinyInfo) const
   {
     if(_array)
       {
         tinyInfo.push_back(_array->getNumberOfTuples());
-        tinyInfo.push_back(_array->getNumberOfComponents());
+        tinyInfo.push_back(ToIdType(_array->getNumberOfComponents()));
       }
     else
       {
@@ -248,13 +248,13 @@ namespace MEDCoupling
   template<class T>
   void MEDCouplingTimeDiscretizationTemplate<T>::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
   {
-    int nbOfCompo(_array->getNumberOfComponents());
-    for(int i=0;i<nbOfCompo;i++)
+    std::size_t nbOfCompo(_array->getNumberOfComponents());
+    for(std::size_t i=0;i<nbOfCompo;i++)
       tinyInfo.push_back(_array->getInfoOnComponent(i));
   }
   
   template<class T>
-  void MEDCouplingTimeDiscretizationTemplate<T>::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<typename Traits<T>::ArrayType *>& arrays)
+  void MEDCouplingTimeDiscretizationTemplate<T>::resizeForUnserialization(const std::vector<mcIdType>& tinyInfoI, std::vector<typename Traits<T>::ArrayType *>& arrays)
   {
     arrays.resize(1);
     if(_array!=0)
@@ -270,7 +270,7 @@ namespace MEDCoupling
   }
   
   template<class T>
-  void MEDCouplingTimeDiscretizationTemplate<T>::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<typename Traits<T>::ArrayType *>& arrays)
+  void MEDCouplingTimeDiscretizationTemplate<T>::checkForUnserialization(const std::vector<mcIdType>& tinyInfoI, const std::vector<typename Traits<T>::ArrayType *>& arrays)
   {
     static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size one !";
     if(arrays.size()!=1)
@@ -289,11 +289,11 @@ namespace MEDCoupling
   }
   
   template<class T>
-  void MEDCouplingTimeDiscretizationTemplate<T>::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+  void MEDCouplingTimeDiscretizationTemplate<T>::finishUnserialization(const std::vector<mcIdType>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
   {
     _time_tolerance=tinyInfoD[0];
-    int nbOfCompo=_array->getNumberOfComponents();
-    for(int i=0;i<nbOfCompo;i++)
+    std::size_t nbOfCompo=_array->getNumberOfComponents();
+    for(std::size_t i=0;i<nbOfCompo;i++)
       _array->setInfoOnComponent(i,tinyInfoS[i]);
   }
   
@@ -304,7 +304,7 @@ namespace MEDCoupling
   {
     std::ostringstream stream;
     stream << REPR << " Time is defined by iteration=" << _tk.getIteration() << " order=" << _tk.getOrder() << " and time=" << _tk.getTimeValue() << ".";
-    stream << "\nTime unit is : \"" << this->_time_unit << "\"";
+    stream << "\nTime unit is : \"" << this->getTimeUnit() << "\"";
     return stream.str();
   }