Salome HOME
On the road of fields on AMR meshes
authorgeay <anthony.geay@cea.fr>
Wed, 28 May 2014 12:54:31 +0000 (14:54 +0200)
committergeay <anthony.geay@cea.fr>
Wed, 28 May 2014 12:54:31 +0000 (14:54 +0200)
src/MEDCoupling/CMakeLists.txt
src/MEDCoupling/MEDCouplingAMRAttribute.cxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingAMRAttribute.hxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx
src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx
src/MEDCoupling/MEDCouplingTimeLabel.cxx
src/MEDCoupling/MEDCouplingTimeLabel.hxx
src/MEDCoupling_Swig/MEDCouplingCommon.i

index 5a3aef6b736b6d81076fed3982ff4107ad5afaa4..5c462b1e4ec62538f838ef8f8eef74afa32e2e4f 100644 (file)
@@ -56,6 +56,7 @@ SET(medcoupling_SOURCES
   MEDCouplingDefinitionTime.cxx
   MEDCouplingFieldOverTime.cxx
   MEDCouplingCartesianAMRMesh.cxx
+  MEDCouplingAMRAttribute.cxx
   MEDCouplingMatrix.cxx
   )
 
diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx
new file mode 100644 (file)
index 0000000..875281b
--- /dev/null
@@ -0,0 +1,142 @@
+// Copyright (C) 2007-2014  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay
+
+#include "MEDCouplingAMRAttribute.hxx"
+#include "MEDCouplingMemArray.hxx"
+
+using namespace ParaMEDMEM;
+
+DataArrayDoubleCollection *DataArrayDoubleCollection::New(const std::vector< std::pair<std::string,int> >& fieldNames)
+{
+  return new DataArrayDoubleCollection(fieldNames);
+}
+
+void DataArrayDoubleCollection::allocTuples(int nbOfTuples)
+{
+  std::size_t sz(_arrs.size());
+  for(std::size_t i=0;i<sz;i++)
+    _arrs[i]->reAlloc(nbOfTuples);
+}
+
+void DataArrayDoubleCollection::dellocTuples()
+{
+  std::size_t sz(_arrs.size());
+  for(std::size_t i=0;i<sz;i++)
+    _arrs[i]->reAlloc(0);
+}
+
+DataArrayDoubleCollection::DataArrayDoubleCollection(const std::vector< std::pair<std::string,int> >& fieldNames):_arrs(fieldNames.size())
+{
+  std::size_t sz(fieldNames.size());
+  std::vector<std::string> names(sz);
+  for(std::size_t i=0;i<sz;i++)
+    {
+      const std::pair<std::string,int>& info(fieldNames[i]);
+      _arrs[i]=DataArrayDouble::New();
+      _arrs[i]->alloc(0,info.second);
+      _arrs[i]->setName(info.first);
+      names[i]=info.second;
+    }
+  CheckDiscriminantNames(names);
+}
+
+std::size_t DataArrayDoubleCollection::getHeapMemorySizeWithoutChildren() const
+{
+  std::size_t ret(sizeof(DataArrayDoubleCollection));
+  ret+=_arrs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>);
+  return ret;
+}
+
+std::vector<const BigMemoryObject *> DataArrayDoubleCollection::getDirectChildren() const
+{
+  std::vector<const BigMemoryObject *> ret;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> >::const_iterator it=_arrs.begin();it!=_arrs.end();it++)
+    {
+      const DataArrayDouble *pt(*it);
+      if(pt)
+        ret.push_back(pt);
+    }
+  return ret;
+}
+
+void DataArrayDoubleCollection::CheckDiscriminantNames(const std::vector<std::string>& names)
+{
+  std::set<std::string> s(names.begin(),names.end());
+  if(s.size()!=names.size())
+    throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::CheckDiscriminantNames : The names of fields must be different each other ! It is not the case !");
+}
+
+std::size_t MEDCouplingGridCollection::getHeapMemorySizeWithoutChildren() const
+{
+  std::size_t ret(sizeof(MEDCouplingGridCollection));
+  ret+=_map_of_dadc.capacity()*sizeof(std::pair<MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> >);
+  return ret;
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingGridCollection::getDirectChildren() const
+{
+  std::vector<const BigMemoryObject *> ret;
+  for(std::vector< std::pair<MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++)
+    {
+      const DataArrayDoubleCollection *col((*it).second);
+      if(col)
+        ret.push_back(col);
+    }
+  return ret;
+}
+
+MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames)
+{
+  return new MEDCouplingAMRAttribute(gf,fieldNames);
+}
+
+void MEDCouplingAMRAttribute::alloc()
+{
+  _tlc.resetState();
+}
+
+void MEDCouplingAMRAttribute::dealloc()
+{//tony
+}
+
+bool MEDCouplingAMRAttribute::changeGodFather(MEDCouplingCartesianAMRMesh *gf)
+{
+  bool ret(MEDCouplingDataForGodFather::changeGodFather(gf));
+  return ret;
+}
+
+std::size_t MEDCouplingAMRAttribute::getHeapMemorySizeWithoutChildren() const
+{
+  std::size_t ret(sizeof(MEDCouplingAMRAttribute));
+  return ret;
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingAMRAttribute::getDirectChildren() const
+{//tony
+  return std::vector<const BigMemoryObject *>();
+}
+
+void MEDCouplingAMRAttribute::updateTime() const
+{//tony
+}
+
+MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames):MEDCouplingDataForGodFather(gf)
+{
+}
diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx
new file mode 100644 (file)
index 0000000..2120a5b
--- /dev/null
@@ -0,0 +1,74 @@
+// Copyright (C) 2007-2014  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay
+
+#ifndef __MEDCOUPLINGAMRATTRIBUTE_HXX__
+#define __MEDCOUPLINGAMRATTRIBUTE_HXX__
+
+#include "MEDCoupling.hxx"
+#include "MEDCouplingCartesianAMRMesh.hxx"
+
+namespace ParaMEDMEM
+{
+  /// @cond INTERNAL
+  class DataArrayDoubleCollection : public RefCountObject
+  {
+  public:
+    static DataArrayDoubleCollection *New(const std::vector< std::pair<std::string,int> >& fieldNames);
+    void allocTuples(int nbOfTuples);
+    void dellocTuples();
+  private:
+    DataArrayDoubleCollection(const std::vector< std::pair<std::string,int> >& fieldNames);
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<const BigMemoryObject *> getDirectChildren() const;
+    static void CheckDiscriminantNames(const std::vector<std::string>& names);
+  private:
+    std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > _arrs;
+  };
+
+  class MEDCouplingGridCollection : public RefCountObject
+  {
+  private:
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<const BigMemoryObject *> getDirectChildren() const;
+  private:
+    std::vector< std::pair<MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > > _map_of_dadc;
+  };
+  /// @endcond
+
+  class MEDCouplingAMRAttribute : public MEDCouplingDataForGodFather, public TimeLabel
+  {
+  public:
+    MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames);
+    //
+    MEDCOUPLING_EXPORT void alloc();
+    MEDCOUPLING_EXPORT void dealloc();
+    MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMesh *gf);
+    //
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
+    MEDCOUPLING_EXPORT void updateTime() const;
+  private:
+    MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames);
+  private:
+    std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> > _levs;
+  };
+}
+
+#endif
index 8aa50804e9a7682d86e44dc346085a5495a9c89d..c4d9a38af1527e150a86f4f445b02f943ddc6229 100644 (file)
@@ -156,6 +156,28 @@ std::size_t MEDCouplingCartesianAMRPatchGF::getHeapMemorySizeWithoutChildren() c
   return sizeof(MEDCouplingCartesianAMRPatchGF);
 }
 
+MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMesh *gf):_gf(gf),_tlc(gf)
+{
+  if(!_gf)
+    throw INTERP_KERNEL::Exception("MEDCouplingDataForGodFather constructor : A data has to be attached to a AMR Mesh instance !");
+  _gf->setData(this);
+}
+
+void MEDCouplingDataForGodFather::checkGodFatherFrozen() const
+{
+  _tlc.checkConst();
+}
+
+bool MEDCouplingDataForGodFather::changeGodFather(MEDCouplingCartesianAMRMesh *gf)
+{
+  bool ret(_tlc.keepTrackOfNewTL(gf));
+  if(ret)
+    {
+      _gf=gf;
+    }
+  return ret;
+}
+
 /// @endcond
 
 int MEDCouplingCartesianAMRMeshGen::getSpaceDimension() const
@@ -177,6 +199,7 @@ void MEDCouplingCartesianAMRMeshGen::setFactors(const std::vector<int>& newFacto
   if(!_patches.empty())
     throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::setFactors : modification of factors is not allowed when presence of patches !");
   _factors=newFactors;
+  declareAsNew();
 }
 
 int MEDCouplingCartesianAMRMeshGen::getMaxNumberOfLevelsRelativeToThis() const
@@ -262,6 +285,7 @@ std::vector<MEDCouplingCartesianAMRPatchGen *> MEDCouplingCartesianAMRMeshGen::r
 void MEDCouplingCartesianAMRMeshGen::detachFromFather()
 {
   _father=0;
+  declareAsNew();
 }
 
 /*!
@@ -277,6 +301,7 @@ void MEDCouplingCartesianAMRMeshGen::addPatch(const std::vector< std::pair<int,i
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMeshSub> zeMesh(new MEDCouplingCartesianAMRMeshSub(this,mesh));
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> elt(new MEDCouplingCartesianAMRPatch(zeMesh,bottomLeftTopRight));
   _patches.push_back(elt);
+  declareAsNew();
 }
 
 /// @cond INTERNAL
@@ -591,6 +616,7 @@ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KER
     }
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<InternalPatch> >::const_iterator it=listOfPatchesOK.begin();it!=listOfPatchesOK.end();it++)
     addPatch((*it)->getConstPart(),factors);
+  declareAsNew();
 }
 
 /*!
@@ -602,6 +628,7 @@ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KER
     throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::createPatchesFromCriterion : the criterion DataArrayByte instance must be allocated and not NULL !");
   std::vector<bool> crit(criterion->toVectorOfBool());//check that criterion has one component.
   createPatchesFromCriterion(bso,crit,factors);
+  declareAsNew();
 }
 
 void MEDCouplingCartesianAMRMeshGen::removeAllPatches()
@@ -728,10 +755,12 @@ void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchGhost(int patchId, cons
  * \param [in,out] cellFieldOnPatch - The array of the cell field on the requested patch to be filled.
  * \param [in] ghostLev - The size of the ghost zone (must be >=0 !)
  * \param [in] arrsOnPatches - \b WARNING arrsOnPatches[patchId] is \b NOT \b const. All others are const.
+ *
+ * \sa fillCellFieldOnPatchOnlyGhostAdv
  */
 void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchGhostAdv(int patchId, const DataArrayDouble *cellFieldOnThis, int ghostLev, const std::vector<const DataArrayDouble *>& arrsOnPatches) const
 {
-  int nbp(getNumberOfPatches()),dim(getSpaceDimension());
+  int nbp(getNumberOfPatches());
   if(nbp!=(int)arrsOnPatches.size())
     {
       std::ostringstream oss; oss << "MEDCouplingCartesianAMRMesh::fillCellFieldOnPatchGhostAdv : there are " << nbp << " patches in this and " << arrsOnPatches.size() << " arrays in the last parameter !";
@@ -740,7 +769,18 @@ void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchGhostAdv(int patchId, c
   DataArrayDouble *theFieldToFill(const_cast<DataArrayDouble *>(arrsOnPatches[patchId]));
   // first, do as usual
   fillCellFieldOnPatchGhost(patchId,cellFieldOnThis,theFieldToFill,ghostLev);
-  // all reference patch stuff
+  fillCellFieldOnPatchOnlyGhostAdv(patchId,ghostLev,arrsOnPatches);
+}
+
+void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchOnlyGhostAdv(int patchId, int ghostLev, const std::vector<const DataArrayDouble *>& arrsOnPatches) const
+{
+  int nbp(getNumberOfPatches()),dim(getSpaceDimension());
+  if(nbp!=(int)arrsOnPatches.size())
+    {
+      std::ostringstream oss; oss << "MEDCouplingCartesianAMRMesh::fillCellFieldOnPatchOnlyGhostAdv : there are " << nbp << " patches in this and " << arrsOnPatches.size() << " arrays in the last parameter !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  DataArrayDouble *theFieldToFill(const_cast<DataArrayDouble *>(arrsOnPatches[patchId]));
   const MEDCouplingCartesianAMRPatch *refP(getPatch(patchId));
   const std::vector< std::pair<int,int> >& refBLTR(refP->getBLTRRange());//[(1,4),(2,4)]
   std::vector<int> dimsCoarse(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(refBLTR));//[3,2]
@@ -1062,7 +1102,26 @@ MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::New(const std::string&
 
 void MEDCouplingCartesianAMRMesh::setData(MEDCouplingDataForGodFather *data)
 {
+  MEDCouplingDataForGodFather *myData(_data);
+  if(myData==data)
+    return ;
+  if(myData)
+    myData->changeGodFather(0);
   _data=data;
+  if(data)
+    data->incrRef();
+}
+
+void MEDCouplingCartesianAMRMesh::allocData() const
+{
+  checkData();
+  _data->alloc();
+}
+
+void MEDCouplingCartesianAMRMesh::deallocData() const
+{
+  checkData();
+  _data->dealloc();
 }
 
 MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
@@ -1078,3 +1137,17 @@ std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRMesh::getDirectChild
     ret.push_back(pt);
   return ret;
 }
+
+void MEDCouplingCartesianAMRMesh::checkData() const
+{
+  const MEDCouplingDataForGodFather *data(_data);
+  if(!data)
+    throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::checkData : no data set !");
+}
+
+MEDCouplingCartesianAMRMesh::~MEDCouplingCartesianAMRMesh()
+{
+  MEDCouplingDataForGodFather *data(_data);
+  if(!data)
+    data->changeGodFather(0);
+}
index bd38f61d28539b3f05230a7ec92546d341fd4b6c..6d6191c30171616089d96b3bbb9150d4463fdc88 100644 (file)
@@ -42,6 +42,9 @@ namespace ParaMEDMEM
 
   /// @cond INTERNAL
 
+  /*!
+   * This class does not inherit from TimeLabel so only const method should exist.
+   */
   class MEDCouplingCartesianAMRPatchGen : public RefCountObject
   {
   public:
@@ -59,6 +62,9 @@ namespace ParaMEDMEM
     MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMeshGen> _mesh;
   };
 
+  /*!
+   * This class does not inherit from TimeLabel so only const method should exist.
+   */
   class MEDCouplingCartesianAMRPatch : public MEDCouplingCartesianAMRPatchGen
   {
   public:
@@ -77,6 +83,9 @@ namespace ParaMEDMEM
     std::vector< std::pair<int,int> > _bl_tr;
   };
 
+  /*!
+   * This class does not inherit from TimeLabel so only const method should exist.
+   */
   class MEDCouplingCartesianAMRPatchGF : public MEDCouplingCartesianAMRPatchGen
   {
   public:
@@ -87,6 +96,18 @@ namespace ParaMEDMEM
 
   class MEDCouplingDataForGodFather : public RefCountObject
   {
+    friend class MEDCouplingCartesianAMRMesh;
+  public:
+    MEDCOUPLING_EXPORT virtual void alloc() = 0;
+    MEDCOUPLING_EXPORT virtual void dealloc() = 0;
+  protected:
+    MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMesh *gf);
+    void checkGodFatherFrozen() const;
+  protected:
+    virtual bool changeGodFather(MEDCouplingCartesianAMRMesh *gf);
+  protected:
+    MEDCouplingCartesianAMRMesh *_gf;
+    TimeLabelConstOverseer _tlc;
   };
   /// @endcond
 
@@ -124,6 +145,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void fillCellFieldOnPatch(int patchId, const DataArrayDouble *cellFieldOnThis, DataArrayDouble *cellFieldOnPatch) const;
     MEDCOUPLING_EXPORT void fillCellFieldOnPatchGhost(int patchId, const DataArrayDouble *cellFieldOnThis, DataArrayDouble *cellFieldOnPatch, int ghostLev) const;
     MEDCOUPLING_EXPORT void fillCellFieldOnPatchGhostAdv(int patchId, const DataArrayDouble *cellFieldOnThis, int ghostLev, const std::vector<const DataArrayDouble *>& arrsOnPatches) const;
+    MEDCOUPLING_EXPORT void fillCellFieldOnPatchOnlyGhostAdv(int patchId, int ghostLev, const std::vector<const DataArrayDouble *>& arrsOnPatches) const;
     MEDCOUPLING_EXPORT void fillCellFieldComingFromPatch(int patchId, const DataArrayDouble *cellFieldOnPatch, DataArrayDouble *cellFieldOnThis) const;
     MEDCOUPLING_EXPORT void fillCellFieldComingFromPatchGhost(int patchId, const DataArrayDouble *cellFieldOnPatch, DataArrayDouble *cellFieldOnThis, int ghostLev) const;
     MEDCOUPLING_EXPORT DataArrayInt *findPatchesInTheNeighborhoodOf(int patchId, int ghostLev) const;
@@ -166,12 +188,16 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT const MEDCouplingDataForGodFather *getDataConst() const { return _data; }
     MEDCOUPLING_EXPORT MEDCouplingDataForGodFather *getData() { return _data; }
     MEDCOUPLING_EXPORT void setData(MEDCouplingDataForGodFather *data);
+    MEDCOUPLING_EXPORT void allocData() const;
+    MEDCOUPLING_EXPORT void deallocData() const;
   private:
     MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
                                 const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
+    void checkData() const;
+    ~MEDCouplingCartesianAMRMesh();
   private:
-    MEDCouplingAutoRefCountObjectPtr<MEDCouplingDataForGodFather> _data;
+    mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingDataForGodFather> _data;
   };
 }
 
index a827585315fc5807508bf7a1f89a9846b5139db8..66b495b8c32f050269dd0fe925514e42fe85a9bd 100644 (file)
 
 #include "MEDCouplingTimeLabel.hxx"
 
+#include "InterpKernelException.hxx"
+
+#include <limits>
+
 using namespace ParaMEDMEM;
 
 std::size_t TimeLabel::GLOBAL_TIME=0;
@@ -57,3 +61,52 @@ void TimeLabel::forceTimeOfThis(const TimeLabel& other) const
 {
   _time=other._time;
 }
+
+TimeLabelConstOverseer::TimeLabelConstOverseer(const TimeLabel *tl):_tl(tl),_ref_time(std::numeric_limits<std::size_t>::max())
+{
+  if(!_tl)
+    throw INTERP_KERNEL::Exception("TimeLabelConstOverseer constructor : input instance must be not NULL !");
+  _tl->updateTime();
+  _ref_time=tl->getTimeOfThis();
+}
+
+/*!
+ * This method checks that the tracked instance is not NULL and if not NULL that its internal state has not changed.
+ */
+void TimeLabelConstOverseer::checkConst() const
+{
+  if(!_tl)
+    throw INTERP_KERNEL::Exception("TimeLabelConstOverseer::checkConst : NULL tracked instance !");
+  _tl->updateTime();
+  if(_ref_time!=_tl->getTimeOfThis())
+    throw INTERP_KERNEL::Exception("TimeLabelConstOverseer::checkConst : the state of the controlled instance of TimeLable has changed !");
+}
+
+bool TimeLabelConstOverseer::resetState()
+{
+  if(_tl)
+    {
+      _tl->updateTime();
+      _ref_time=_tl->getTimeOfThis();
+      return true;
+    }
+  else
+    return false;
+}
+
+bool TimeLabelConstOverseer::keepTrackOfNewTL(const TimeLabel *tl)
+{
+  if(_tl==tl)
+    return false;
+  _tl=tl;
+  if(_tl)
+    {
+      _tl->updateTime();
+      _ref_time=_tl->getTimeOfThis();
+    }
+  else
+    {
+      _ref_time=std::numeric_limits<std::size_t>::max();
+    }
+  return true;
+}
index cd5f1396907a870430b317f4ec3fddb798d41dc1..799ade98bf9614d6ba9216e6183b5f3010a435e9 100644 (file)
@@ -49,6 +49,18 @@ namespace ParaMEDMEM
     static std::size_t GLOBAL_TIME;
     mutable std::size_t _time;
   };
+
+  class TimeLabelConstOverseer
+  {
+  public:
+    MEDCOUPLING_EXPORT TimeLabelConstOverseer(const TimeLabel *tl);
+    MEDCOUPLING_EXPORT void checkConst() const;
+    MEDCOUPLING_EXPORT bool resetState();
+    MEDCOUPLING_EXPORT bool keepTrackOfNewTL(const TimeLabel *tl);
+  private:
+    const TimeLabel *_tl;
+    std::size_t _ref_time;
+  };
 }
 
 #endif
index 24a60c9c4d9e82fe60e34dd5175919a624fd8fc1..ff8136716e5b133353e558840f7be0c064ce7263 100644 (file)
@@ -4837,6 +4837,9 @@ namespace ParaMEDMEM
 
   class MEDCouplingDataForGodFather : public RefCountObject
   {
+  public:
+    virtual void alloc() throw(INTERP_KERNEL::Exception);
+    virtual void dealloc() throw(INTERP_KERNEL::Exception);
   };
   
   class MEDCouplingCartesianAMRMeshGen : public RefCountObject, public TimeLabel
@@ -4939,6 +4942,13 @@ namespace ParaMEDMEM
         self->fillCellFieldOnPatchGhostAdv(patchId,cellFieldOnThis,ghostLev,arrsOnPatches2);
       }
 
+      void fillCellFieldOnPatchOnlyGhostAdv(int patchId, int ghostLev, PyObject *arrsOnPatches) const
+      {
+        std::vector<const ParaMEDMEM::DataArrayDouble *> arrsOnPatches2;
+        convertFromPyObjVectorOfObj<const ParaMEDMEM::DataArrayDouble *>(arrsOnPatches,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,"DataArrayDouble",arrsOnPatches2);
+        self->fillCellFieldOnPatchOnlyGhostAdv(patchId,ghostLev,arrsOnPatches2);
+      }
+
       void __delitem__(int patchId) throw(INTERP_KERNEL::Exception)
       {
         self->removePatch(patchId);
@@ -4959,6 +4969,8 @@ namespace ParaMEDMEM
   {
   public:
     void setData(MEDCouplingDataForGodFather *data) throw(INTERP_KERNEL::Exception);
+    void allocData() const throw(INTERP_KERNEL::Exception);
+    void deallocData() const throw(INTERP_KERNEL::Exception);
     %extend
     {
       static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)