Salome HOME
Make WriteField and WriteFieldUsingAlreadyWrittenMesh accessible for INT32, FLOAT32...
[tools/medcoupling.git] / src / ParaMEDMEM / ElementLocator.cxx
index e7dcfd755ef20fc25d9d110ba94fa4e314c628f5..3c1f9d4264a9e986ccc338d9991dfe60e8352f42 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016  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
@@ -27,7 +27,7 @@
 #include "ProcessorGroup.hxx"
 #include "MPIProcessorGroup.hxx"
 #include "MEDCouplingFieldDouble.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MCAuto.hxx"
 #include "DirectedBoundingBox.hxx"
 
 #include <map>
@@ -38,7 +38,7 @@ using namespace std;
 
 //#define USE_DIRECTED_BB
 
-namespace ParaMEDMEM 
+namespace MEDCoupling 
 { 
   ElementLocator::ElementLocator(const ParaFIELD& sourceField,
                                  const ProcessorGroup& distant_group,
@@ -71,14 +71,14 @@ namespace ParaMEDMEM
     return _local_para_field.getField()->getNature();
   }
 
-  // ==========================================================================
-  // Procedure for exchanging mesh between a distant proc and a local processor
-  // param idistantrank  proc id on distant group
-  // param distant_mesh on return , points to a local reconstruction of
-  //  the distant mesh
-  // param distant_ids on return, contains a vector defining a correspondence
-  // between the distant ids and the ids of the local reconstruction 
-  // ==========================================================================
+
+  /*! Procedure for exchanging a mesh between a distant proc and a local processor
+   \param idistantrank  proc id on distant group
+   \param distant_mesh on return , points to a local reconstruction of
+          the distant mesh
+   \param distant_ids on return, contains a vector defining a correspondence
+          between the distant ids and the ids of the local reconstruction
+  */
   void ElementLocator::exchangeMesh(int idistantrank,
                                     MEDCouplingPointSet*& distant_mesh,
                                     int*& distant_ids)
@@ -88,7 +88,7 @@ namespace ParaMEDMEM
     if (find(_distant_proc_ids.begin(), _distant_proc_ids.end(),rank)==_distant_proc_ids.end())
       return;
    
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> elems;
+    MCAuto<DataArrayInt> elems;
 #ifdef USE_DIRECTED_BB
     INTERP_KERNEL::DirectedBoundingBox dbb;
     double* distant_bb = _domain_bounding_boxes+rank*dbb.dataSize(_local_cell_mesh_space_dim);
@@ -127,10 +127,10 @@ namespace ParaMEDMEM
   }
 
 
-  // ======================
-  // Compute bounding boxes
-  // ======================
 
+  /*!
+   Compute bounding boxes
+  */
   void ElementLocator::_computeBoundingBoxes()
   {
     CommInterface comm_interface =_union_group->getCommInterface();
@@ -194,9 +194,10 @@ namespace ParaMEDMEM
   }
 
 
-  // =============================================
-  // Intersect Bounding Box (with a given "irank")
-  // =============================================
+
+  /*!
+   * Intersect local bounding box with a given distant bounding box on "irank"
+   */
   bool ElementLocator::_intersectsBoundingBox(int irank)
   {
 #ifdef USE_DIRECTED_BB
@@ -208,9 +209,9 @@ namespace ParaMEDMEM
     double*  local_bb = _domain_bounding_boxes+_union_group->myRank()*2*_local_cell_mesh_space_dim;
     double*  distant_bb =  _domain_bounding_boxes+irank*2*_local_cell_mesh_space_dim;
 
+    const double eps = 1e-12;
     for (int idim=0; idim < _local_cell_mesh_space_dim; idim++)
       {
-        const double eps =  1e-12;
         bool intersects = (distant_bb[idim*2]<local_bb[idim*2+1]+eps)
           && (local_bb[idim*2]<distant_bb[idim*2+1]+eps);
         if (!intersects) return false; 
@@ -219,9 +220,10 @@ namespace ParaMEDMEM
 #endif
   } 
 
-  // ======================
-  // Exchanging meshes data
-  // ======================
+
+  /*!
+   *  Exchange mesh data
+   */
   void ElementLocator::_exchangeMesh( MEDCouplingPointSet* local_mesh,
                                       MEDCouplingPointSet*& distant_mesh,
                                       int iproc_distant,
@@ -694,7 +696,7 @@ namespace ParaMEDMEM
     CommInterface comm;
     DataArrayInt *globalIds=_local_para_field.returnGlobalNumbering();
     const int *globalIdsC=globalIds->getConstPointer();
-    MEDCouplingAutoRefCountObjectPtr<DataArrayInt> candidates=_local_para_field.getSupport()->getCellMesh()->findBoundaryNodes();
+    MCAuto<DataArrayInt> candidates=_local_para_field.getSupport()->getCellMesh()->findBoundaryNodes();
     for(int *iter1=candidates->getPointer();iter1!=candidates->getPointer()+candidates->getNumberOfTuples();iter1++)
       (*iter1)=globalIdsC[*iter1];
     std::set<int> candidatesS(candidates->begin(),candidates->end());