Salome HOME
Merge branch 'master' of https://git.salome-platform.org/git/modules/med
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingTimeDiscretization.cxx
index acb73dc7717f88b6ff192cec42d90d030ba068c4..6cff3a51b7b0ca1c76445510b4b0b66cff9a3ae2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015  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
@@ -52,7 +52,7 @@ const char MEDCouplingLinearTime::REPR[]="Linear time between 2 time steps.";
 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type)
 {
   switch(type)
-    {
+  {
     case MEDCouplingNoTimeLabel::DISCRETIZATION:
       return new MEDCouplingNoTimeLabel;
     case MEDCouplingWithTimeStep::DISCRETIZATION:
@@ -63,7 +63,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDisc
       return new MEDCouplingLinearTime;
     default:
       throw INTERP_KERNEL::Exception("Time discretization not implemented yet");
-    }
+  }
 }
 
 void MEDCouplingTimeDiscretization::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
@@ -99,11 +99,10 @@ std::size_t MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren() co
   return ret;
 }
 
-std::vector<const BigMemoryObject *> MEDCouplingTimeDiscretization::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDCouplingTimeDiscretization::getDirectChildrenWithNull() const
 {
   std::vector<const BigMemoryObject *> ret;
-  if(_array)
-    ret.push_back(_array);
+  ret.push_back(_array);
   return ret;
 }
 
@@ -697,6 +696,17 @@ void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
     }
 }
 
+void MEDCouplingTimeDiscretization::applyLin(double a, double b)
+{
+  std::vector<DataArrayDouble *> arrays;
+  getArrays(arrays);
+  for(std::size_t j=0;j<arrays.size();j++)
+    {
+      if(arrays[j])
+        arrays[j]->applyLin(a,b);
+    }
+}
+
 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func)
 {
   std::vector<DataArrayDouble *> arrays;
@@ -1251,7 +1261,7 @@ void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tiny
 }
 
 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
-                                                                                                     _time(other._time),_iteration(other._iteration),_order(other._order)
+    _time(other._time),_iteration(other._iteration),_order(other._order)
 {
 }
 
@@ -1773,8 +1783,8 @@ void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<in
 }
 
 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy):
-  MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration),
-  _end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order)
+      MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration),
+      _end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order)
 {
 }
 
@@ -2079,7 +2089,7 @@ void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretizatio
     throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractaddEqual : Data Array is NULL !");
   getArray()->addEqual(other->getArray());
 }
+
 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
 {
   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
@@ -2185,9 +2195,9 @@ void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretizatio
 }
 
 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
-                                                                                                     _start_time(other._start_time),_end_time(other._end_time),
-                                                                                                     _start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
-                                                                                                     _start_order(other._start_order),_end_order(other._end_order)
+    _start_time(other._start_time),_end_time(other._end_time),
+    _start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
+    _start_order(other._start_order),_end_order(other._end_order)
 {
   if(other._end_array)
     _end_array=other._end_array->performCpy(deepCpy);
@@ -2219,11 +2229,10 @@ std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySizeWithoutChildren() const
   return MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren();
 }
 
-std::vector<const BigMemoryObject *> MEDCouplingTwoTimeSteps::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDCouplingTwoTimeSteps::getDirectChildrenWithNull() const
 {
-  std::vector<const BigMemoryObject *> ret(MEDCouplingTimeDiscretization::getDirectChildren());
-  if(_end_array)
-    ret.push_back(_end_array);
+  std::vector<const BigMemoryObject *> ret(MEDCouplingTimeDiscretization::getDirectChildrenWithNull());
+  ret.push_back(_end_array);
   return ret;
 }
 
@@ -2506,7 +2515,7 @@ void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tin
 
 std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const
 {
-   if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
+  if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
     {
       std::vector< const DataArrayDouble *> ret(2);
       ret[0]=_array;