Salome HOME
stash 3
authorgeay <anthony.geay@cea.fr>
Tue, 3 Jun 2014 11:12:58 +0000 (13:12 +0200)
committergeay <anthony.geay@cea.fr>
Tue, 3 Jun 2014 11:12:58 +0000 (13:12 +0200)
src/MEDCoupling/MEDCouplingAMRAttribute.cxx
src/MEDCoupling/MEDCouplingAMRAttribute.hxx
src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx
src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx
src/MEDCoupling_Swig/MEDCouplingCommon.i

index 43362076056f4524686fb14e8580dc00f861132b..1a91be1b9e21a44a3d94f2fbc630cd3a4ae98f63 100644 (file)
@@ -70,7 +70,7 @@ std::vector<DataArrayDouble *> DataArrayDoubleCollection::retrieveFields() const
   return ret;
 }
 
-DataArrayDouble *DataArrayDoubleCollection::retrieveFieldWithName(const std::string& name) const
+const DataArrayDouble *DataArrayDoubleCollection::getFieldWithName(const std::string& name) const
 {
   std::vector<std::string> vec;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> >::const_iterator it=_arrs.begin();it!=_arrs.end();it++)
@@ -79,19 +79,12 @@ DataArrayDouble *DataArrayDoubleCollection::retrieveFieldWithName(const std::str
       if(obj)
         {
           if(obj->getName()==name)
-            {
-              DataArrayDouble *ret(const_cast<DataArrayDouble *>(obj));
-              if(ret)
-                ret->incrRef();
-              return ret;
-            }
+            return obj;
           else
-            {
-              vec.push_back(obj->getName());
-            }
+            vec.push_back(obj->getName());
         }
     }
-  std::ostringstream oss; oss << "DataArrayDoubleCollection::retrieveFieldWithName : fieldName \"" << name << "\" does not exist in this ! Possibilities are :";
+  std::ostringstream oss; oss << "DataArrayDoubleCollection::getFieldWithName : fieldName \"" << name << "\" does not exist in this ! Possibilities are :";
   std::copy(vec.begin(),vec.end(),std::ostream_iterator<std::string>(oss," "));
   throw INTERP_KERNEL::Exception(oss.str().c_str());
 }
@@ -371,6 +364,19 @@ void MEDCouplingGridCollection::SynchronizeCoarseToFineOnlyInGhostZone(int ghost
     }
 }
 
+void MEDCouplingGridCollection::fillIfInTheProgenyOf(const std::string& fieldName, const MEDCouplingCartesianAMRMeshGen *head, std::vector<const DataArrayDouble *>& recurseArrs) const
+{
+  for(std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++)
+    {
+      const MEDCouplingCartesianAMRMeshGen *a((*it).first);
+      if(head==a || head->isObjectInTheProgeny(a))
+        {
+          const DataArrayDoubleCollection *gc((*it).second);
+          recurseArrs.push_back(gc->getFieldWithName(fieldName));
+        }
+    }
+}
+
 MEDCouplingGridCollection::MEDCouplingGridCollection(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames):_map_of_dadc(ms.size())
 {
   std::size_t sz(ms.size());
@@ -476,18 +482,67 @@ std::vector<DataArrayDouble *> MEDCouplingAMRAttribute::retrieveFieldsOn(MEDCoup
 /*!
  * \sa retrieveFieldsOn
  */
-DataArrayDouble *MEDCouplingAMRAttribute::retrieveFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const
+const DataArrayDouble *MEDCouplingAMRAttribute::getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const
+{
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> >::const_iterator it=_levs.begin();it!=_levs.end();it++)
+    {
+      int tmp(-1);
+      if((*it)->presenceOf(mesh,tmp))
+        {
+          const DataArrayDoubleCollection& ddc((*it)->retrieveFieldsAt(tmp));
+          return ddc.getFieldWithName(fieldName);
+        }
+    }
+  throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::retrieveFieldOn : the mesh specified is not in the progeny of this !");
+}
+
+/*!
+ * This method returns a field on an unstructured mesh the most refined as possible without overlap.
+ * Ghost part are not visible here.
+ *
+ * \return MEDCouplingFieldDouble * - a field on cells that the caller has to deal with (deallocate it).
+ */
+MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnRecurseWithoutOverlapWithoutGhost(int ghostLev, MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const
+{
+  std::vector<const DataArrayDouble *> recurseArrs;
+  std::size_t lev(0);
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> >::const_iterator it=_levs.begin();it!=_levs.end();it++,lev++)
+    {
+      int tmp(-1);
+      if((*it)->presenceOf(mesh,tmp))
+        {
+          const DataArrayDoubleCollection& ddc((*it)->retrieveFieldsAt(tmp));
+          recurseArrs.push_back(ddc.getFieldWithName(fieldName));
+          break;
+        }
+    }
+  lev++;
+  for(std::size_t i=lev;i<_levs.size();i++)
+    {
+      const MEDCouplingGridCollection *gc(_levs[i]);
+      gc->fillIfInTheProgenyOf(fieldName,mesh,recurseArrs);
+    }
+  return mesh->buildCellFieldOnRecurseWithoutOverlapWithoutGhost(ghostLev,recurseArrs);
+}
+
+/*!
+ * This method builds a newly created field on cell just lying on mesh \a mesh without its eventual refinement.
+ *
+ * \return MEDCouplingFieldDouble * - a field on cells that the caller has to deal with (deallocate it).
+ *
+ */
+MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithGhost(int ghostLev, MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const
 {
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> >::const_iterator it=_levs.begin();it!=_levs.end();it++)
-      {
-        int tmp(-1);
-        if((*it)->presenceOf(mesh,tmp))
-          {
-            const DataArrayDoubleCollection& ddc((*it)->retrieveFieldsAt(tmp));
-            return ddc.retrieveFieldWithName(fieldName);
-          }
-      }
-    throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::retrieveFieldOn : the mesh specified is not in the progeny of this !");
+    {
+      int tmp(-1);
+      if((*it)->presenceOf(mesh,tmp))
+        {
+          const DataArrayDoubleCollection& ddc((*it)->retrieveFieldsAt(tmp));
+          const DataArrayDouble *arr(ddc.getFieldWithName(fieldName));
+        }
+    }
+  throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::buildCellFieldOnWithGhost : the mesh specified is not in the progeny of this !");
 }
 
 /*!
@@ -630,8 +685,8 @@ void MEDCouplingAMRAttribute::updateTime() const
 MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames):MEDCouplingDataForGodFather(gf)
 {
   //gf non empty, checked by constructor
-  int maxLev(gf->getMaxNumberOfLevelsRelativeToThis()+1);
-  _levs.resize(maxLev+1);
+  int maxLev(gf->getMaxNumberOfLevelsRelativeToThis());
+  _levs.resize(maxLev);
   for(int i=0;i<maxLev;i++)
     {
       std::vector<MEDCouplingCartesianAMRPatchGen *> patches(gf->retrieveGridsAt(i));
index 2fe0fdda39903618e97965004b17df5962ba8ff2..726aac1e92bf21330bd274d4e4bd259302b96866 100644 (file)
@@ -35,7 +35,7 @@ namespace ParaMEDMEM
     void dellocTuples();
     void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
     std::vector<DataArrayDouble *> retrieveFields() const;
-    DataArrayDouble *retrieveFieldWithName(const std::string& name) const;
+    const DataArrayDouble *getFieldWithName(const std::string& name) const;
     static void SynchronizeFineToCoarse(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *fine, DataArrayDoubleCollection *coarse);
     static void SynchronizeCoarseToFine(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *coarse, DataArrayDoubleCollection *fine);
     static void SynchronizeFineEachOther(int patchId, int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, const std::vector<const MEDCouplingCartesianAMRMeshGen *>& children, const std::vector<DataArrayDoubleCollection *>& fieldsOnFine);
@@ -63,6 +63,7 @@ namespace ParaMEDMEM
     static void SynchronizeCoarseToFine(int ghostLev, const MEDCouplingGridCollection *coarse, const MEDCouplingGridCollection *fine);
     void synchronizeFineEachOther(int ghostLev) const;
     static void SynchronizeCoarseToFineOnlyInGhostZone(int ghostLev, const MEDCouplingGridCollection *coarse, const MEDCouplingGridCollection *fine);
+    void fillIfInTheProgenyOf(const std::string& fieldName, const MEDCouplingCartesianAMRMeshGen *head, std::vector<const DataArrayDouble *>& recurseArrs) const;
   private:
     MEDCouplingGridCollection(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames);
     std::size_t getHeapMemorySizeWithoutChildren() const;
@@ -71,6 +72,7 @@ namespace ParaMEDMEM
   private:
     std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > > _map_of_dadc;
   };
+
   /// @endcond
 
   class MEDCouplingAMRAttribute : public MEDCouplingDataForGodFather, public TimeLabel
@@ -80,7 +82,9 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string, std::vector<std::string> > >& fieldNames);
     MEDCOUPLING_EXPORT void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
     MEDCOUPLING_EXPORT std::vector<DataArrayDouble *> retrieveFieldsOn(MEDCouplingCartesianAMRMeshGen *mesh) const;
-    MEDCOUPLING_EXPORT DataArrayDouble *retrieveFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
+    MEDCOUPLING_EXPORT const DataArrayDouble *getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
+    MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnRecurseWithoutOverlapWithoutGhost(int ghostLev, MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
+    MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithGhost(int ghostLev, MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
     //
     MEDCOUPLING_EXPORT void synchronizeFineToCoarse(int ghostLev);
     MEDCOUPLING_EXPORT void synchronizeCoarseToFine(int ghostLev);
index 34aec97117d2ad35070f4a647db6f464ee87ff08..719dd06469f44e31c27abcc5666a0e3cfb516f58 100644 (file)
@@ -19,6 +19,7 @@
 // Author : Anthony Geay
 
 #include "MEDCouplingCartesianAMRMesh.hxx"
+#include "MEDCouplingFieldDouble.hxx"
 #include "MEDCoupling1GTUMesh.hxx"
 #include "MEDCouplingIMesh.hxx"
 #include "MEDCouplingUMesh.hxx"
@@ -695,6 +696,15 @@ int MEDCouplingCartesianAMRMeshGen::getPatchIdFromChildMesh(const MEDCouplingCar
   throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getPatchIdFromChildMesh : no such a mesh in my direct progeny !");
 }
 
+std::vector< const MEDCouplingCartesianAMRPatch *> MEDCouplingCartesianAMRMeshGen::getPatches() const
+{
+  std::size_t sz(_patches.size());
+  std::vector< const MEDCouplingCartesianAMRPatch *> ret(sz);
+  for(std::size_t i=0;i<sz;i++)
+    ret[i]=_patches[i];
+  return ret;
+}
+
 const MEDCouplingCartesianAMRPatch *MEDCouplingCartesianAMRMeshGen::getPatch(int patchId) const
 {
   checkPatchId(patchId);
@@ -996,6 +1006,59 @@ MEDCoupling1SGTUMesh *MEDCouplingCartesianAMRMeshGen::buildMeshOfDirectChildrenO
     return MEDCoupling1SGTUMesh::Merge1SGTUMeshes(patches);
 }
 
+/*!
+ * This method works same as buildUnstructured except that arrays are given in input to build a field on cell in output.
+ * \return MEDCouplingFieldDouble * - a newly created instance the caller has reponsability to deal with.
+ * \sa buildUnstructured
+ */
+MEDCouplingFieldDouble *MEDCouplingCartesianAMRMeshGen::buildCellFieldOnRecurseWithoutOverlapWithoutGhost(int ghostSz, const std::vector<const DataArrayDouble *>& recurseArrs) const
+{
+  if(recurseArrs.empty())
+    throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::buildCellFieldOnRecurseWithoutOverlapWithoutGhost : array is empty ! Should never happen !");
+  //
+  std::vector<bool> bs(_mesh->getNumberOfCells(),false);
+  std::vector<int> cgs(_mesh->getCellGridStructure());
+  std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> > msSafe(_patches.size()+1);
+  std::size_t ii(0);
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++,ii++)
+    {
+      MEDCouplingStructuredMesh::SwitchOnIdsFrom(cgs,(*it)->getBLTRRange(),bs);
+      std::vector<const DataArrayDouble *> tmpArrs(extractSubTreeFromGlobalFlatten((*it)->getMesh(),recurseArrs));
+      msSafe[ii+1]=(*it)->getMesh()->buildCellFieldOnRecurseWithoutOverlapWithoutGhost(ghostSz,tmpArrs);
+    }
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsOff(DataArrayInt::BuildListOfSwitchedOff(bs));
+  //
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(ON_CELLS));
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(extractGhostFrom(ghostSz,recurseArrs[0]));
+  arr2=arr2->selectByTupleIdSafe(eltsOff->begin(),eltsOff->end());
+  ret->setArray(arr2);
+  ret->setName(arr2->getName());
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> part(_mesh->buildUnstructured());
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh(part->buildPartOfMySelf(eltsOff->begin(),eltsOff->end(),false));
+  ret->setMesh(mesh);
+  msSafe[0]=ret;
+  //
+  std::vector< const MEDCouplingFieldDouble * > ms(msSafe.size());
+  for(std::size_t i=0;i<msSafe.size();i++)
+    ms[i]=msSafe[i];
+  //
+  return MEDCouplingFieldDouble::MergeFields(ms);
+}
+
+/*!
+ * This method extracts from \arr arr the part inside \a arr by cutting the \a ghostSz external part.
+ * \arr is expected to be an array having a number of tuples equal to \c getImageMesh()->buildWithGhost(ghostSz).
+ */
+DataArrayDouble *MEDCouplingCartesianAMRMeshGen::extractGhostFrom(int ghostSz, const DataArrayDouble *arr) const
+{
+  std::vector<int> st(_mesh->getCellGridStructure());
+  std::vector< std::pair<int,int> > p(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(st));
+  std::transform(st.begin(),st.end(),st.begin(),std::bind2nd(std::plus<int>(),2*ghostSz));
+  ApplyGhostOnCompactFrmt(p,ghostSz);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(st,arr,p));
+  return ret.retn();
+}
+
 MEDCouplingCartesianAMRMeshGen::MEDCouplingCartesianAMRMeshGen(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
                                                                const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0)
 {
@@ -1101,7 +1164,7 @@ void MEDCouplingCartesianAMRMeshGen::ApplyGhostOnCompactFrmt(std::vector< std::p
 }
 
 /*!
- * This method is different than ApplyGhostOnCompactFrmt
+ * This method is different than ApplyGhostOnCompactFrmt. The \a partBeforeFact parameter is enlarger contrary to ApplyGhostOnCompactFrmt.
  *
  * \param [in,out] partBeforeFact - the part of a image mesh in compact format that will be put in ghost reference.
  * \param [in] ghostSize - the ghost size of zone for all axis.
@@ -1118,6 +1181,38 @@ void MEDCouplingCartesianAMRMeshGen::ApplyAllGhostOnCompactFrmt(std::vector< std
     }
 }
 
+/*!
+ * This method returns a sub set of \a all. The subset is defined by the \a head in the tree defined by \a this.
+ * Elements in \a all are expected to be sorted from god father to most refined structure.
+ */
+std::vector<const DataArrayDouble *> MEDCouplingCartesianAMRMeshGen::extractSubTreeFromGlobalFlatten(const MEDCouplingCartesianAMRMeshGen *head, const std::vector<const DataArrayDouble *>& all) const
+{
+  int maxLev(getMaxNumberOfLevelsRelativeToThis());
+  std::vector<const DataArrayDouble *> ret;
+  std::vector<const MEDCouplingCartesianAMRMeshGen *> meshes(1,this);
+  std::size_t kk(0);
+  for(int i=0;i<maxLev;i++)
+    {
+      std::vector<const MEDCouplingCartesianAMRMeshGen *> meshesTmp;
+      for(std::vector<const MEDCouplingCartesianAMRMeshGen *>::const_iterator it=meshes.begin();it!=meshes.end();it++)
+        {
+          if((*it)==head || head->isObjectInTheProgeny(*it))
+            ret.push_back(all[kk]);
+          kk++;
+          std::vector< const MEDCouplingCartesianAMRPatch *> ps((*it)->getPatches());
+          for(std::vector< const MEDCouplingCartesianAMRPatch *>::const_iterator it0=ps.begin();it0!=ps.end();it0++)
+            {
+              const MEDCouplingCartesianAMRMeshGen *mesh((*it0)->getMesh());
+              meshesTmp.push_back(mesh);
+            }
+        }
+      meshes=meshesTmp;
+    }
+  if(kk!=all.size())
+    throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::extractSubTreeFromGlobalFlatten : the size of input vector is not compatible with number of leaves in this !");
+  return ret;
+}
+
 std::size_t MEDCouplingCartesianAMRMeshGen::getHeapMemorySizeWithoutChildren() const
 {
   return sizeof(MEDCouplingCartesianAMRMeshGen);
index 6fbb657baddd90a8685fe6bc3ffab2d01e1bdca1..7905f68808790e0fd057a37c14b6eb0f3fe12d2a 100644 (file)
@@ -37,6 +37,7 @@ namespace ParaMEDMEM
   class DataArrayByte;
   class DataArrayDouble;
   class MEDCoupling1SGTUMesh;
+  class MEDCouplingFieldDouble;
   class MEDCouplingCartesianAMRMesh;
   class MEDCouplingCartesianAMRMeshGen;
 
@@ -145,6 +146,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void removePatch(int patchId);
     MEDCOUPLING_EXPORT int getNumberOfPatches() const;
     MEDCOUPLING_EXPORT int getPatchIdFromChildMesh(const MEDCouplingCartesianAMRMeshGen *mesh) const;
+    MEDCOUPLING_EXPORT std::vector< const MEDCouplingCartesianAMRPatch *> getPatches() const;
     MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRPatch *getPatch(int patchId) const;
     MEDCOUPLING_EXPORT bool isPatchInNeighborhoodOf(int patchId1, int patchId2, int ghostLev) const;
     MEDCOUPLING_EXPORT DataArrayDouble *createCellFieldOnPatch(int patchId, const DataArrayDouble *cellFieldOnThis) const;
@@ -165,6 +167,8 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
     MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *buildMeshFromPatchEnvelop() const;
     MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *buildMeshOfDirectChildrenOnly() const;
+    MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnRecurseWithoutOverlapWithoutGhost(int ghostSz, const std::vector<const DataArrayDouble *>& recurseArrs) const;
+    MEDCOUPLING_EXPORT DataArrayDouble *extractGhostFrom(int ghostSz, const DataArrayDouble *arr) const;
   protected:
     MEDCouplingCartesianAMRMeshGen(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
                                    const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
@@ -175,6 +179,7 @@ namespace ParaMEDMEM
     static void ApplyFactorsOnCompactFrmt(std::vector< std::pair<int,int> >& partBeforeFact, const std::vector<int>& factors);
     static void ApplyGhostOnCompactFrmt(std::vector< std::pair<int,int> >& partBeforeFact, int ghostSize);
     static void ApplyAllGhostOnCompactFrmt(std::vector< std::pair<int,int> >& partBeforeFact, int ghostSize);
+    std::vector<const DataArrayDouble *> extractSubTreeFromGlobalFlatten(const MEDCouplingCartesianAMRMeshGen *head, const std::vector<const DataArrayDouble *>& all) const;
   protected:
     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
index 3fa76fadb578c10818ef40ab0cae389d8bd7e77e..3a9582be54185e3160039f4787be845b53bd810f 100644 (file)
@@ -340,6 +340,7 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingCartesianAMRPatchGen::getMesh;
 %newobject ParaMEDMEM::MEDCouplingCartesianAMRPatchGen::__getitem__;
 %newobject ParaMEDMEM::MEDCouplingCartesianAMRMeshGen::buildUnstructured;
+%newobject ParaMEDMEM::MEDCouplingCartesianAMRMeshGen::extractGhostFrom;
 %newobject ParaMEDMEM::MEDCouplingCartesianAMRMeshGen::buildMeshFromPatchEnvelop;
 %newobject ParaMEDMEM::MEDCouplingCartesianAMRMeshGen::buildMeshOfDirectChildrenOnly;
 %newobject ParaMEDMEM::MEDCouplingCartesianAMRMeshGen::getImageMesh;
@@ -353,7 +354,9 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::getDataConst;
 %newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::getData;
 %newobject ParaMEDMEM::MEDCouplingAMRAttribute::New;
-%newobject ParaMEDMEM::MEDCouplingAMRAttribute::retrieveFieldOn;
+%newobject ParaMEDMEM::MEDCouplingAMRAttribute::getFieldOn;
+%newobject ParaMEDMEM::MEDCouplingAMRAttribute::buildCellFieldOnRecurseWithoutOverlapWithoutGhost;
+%newobject ParaMEDMEM::MEDCouplingAMRAttribute::buildCellFieldOnWithGhost;
 %newobject ParaMEDMEM::DenseMatrix::New;
 %newobject ParaMEDMEM::DenseMatrix::deepCpy;
 %newobject ParaMEDMEM::DenseMatrix::shallowCpy;
@@ -4881,6 +4884,7 @@ namespace ParaMEDMEM
     int getNumberOfPatches() const throw(INTERP_KERNEL::Exception);
     int getPatchIdFromChildMesh(const MEDCouplingCartesianAMRMeshGen *mesh) const throw(INTERP_KERNEL::Exception);
     MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
+    DataArrayDouble *extractGhostFrom(int ghostSz, const DataArrayDouble *arr) const throw(INTERP_KERNEL::Exception);
     MEDCoupling1SGTUMesh *buildMeshFromPatchEnvelop() const throw(INTERP_KERNEL::Exception);
     MEDCoupling1SGTUMesh *buildMeshOfDirectChildrenOnly() const throw(INTERP_KERNEL::Exception);
     void removeAllPatches() throw(INTERP_KERNEL::Exception);
@@ -4903,6 +4907,21 @@ namespace ParaMEDMEM
         self->addPatch(inp,factors);
       }
 
+      PyObject *getPatches() const throw(INTERP_KERNEL::Exception)
+      {
+        std::vector< const MEDCouplingCartesianAMRPatch *> ps(self->getPatches());
+        int sz(ps.size());
+        PyObject *ret = PyList_New(sz);
+        for(int i=0;i<sz;i++)
+          {
+            MEDCouplingCartesianAMRPatch *elt(const_cast<MEDCouplingCartesianAMRPatch *>(ps[i]));
+            if(elt)
+              elt->incrRef();
+            PyList_SetItem(ret,i,convertCartesianAMRPatch(elt, SWIG_POINTER_OWN | 0 ));
+          }
+        return ret;
+      }
+
       PyObject *retrieveGridsAt(int absoluteLev) const throw(INTERP_KERNEL::Exception)
       {
         std::vector<MEDCouplingCartesianAMRPatchGen *> ps(self->retrieveGridsAt(absoluteLev));
@@ -5043,7 +5062,8 @@ namespace ParaMEDMEM
   class MEDCouplingAMRAttribute : public MEDCouplingDataForGodFather, public TimeLabel
   {
   public:
-    DataArrayDouble *retrieveFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *buildCellFieldOnRecurseWithoutOverlapWithoutGhost(int ghostLev, MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
+    MEDCouplingFieldDouble *buildCellFieldOnWithGhost(int ghostLev, MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
     bool changeGodFather(MEDCouplingCartesianAMRMesh *gf) throw(INTERP_KERNEL::Exception);
     %extend
     {
@@ -5070,6 +5090,15 @@ namespace ParaMEDMEM
         return ParaMEDMEM_MEDCouplingAMRAttribute_New(gf,fieldNames);
       }
       
+      DataArrayDouble *getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const throw(INTERP_KERNEL::Exception)
+      {
+        const DataArrayDouble *ret(self->getFieldOn(mesh,fieldName));
+        DataArrayDouble *ret2(const_cast<DataArrayDouble *>(ret));
+        if(ret2)
+          ret2->incrRef();
+        return ret2;
+      }
+
       void spillInfoOnComponents(PyObject *compNames) throw(INTERP_KERNEL::Exception)
       {
         std::vector< std::vector<std::string> > compNamesCpp;