]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
[EDF29571] : Fix problem of performance of MEDCoupling1GTUMesh::getCellsContainingPoints
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 16 Aug 2024 15:47:35 +0000 (17:47 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 16 Aug 2024 15:47:35 +0000 (17:47 +0200)
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCoupling1GTUMesh.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py

index d55be5584f42b220d4fbf47833bd945666dbd5fb..cdcb076825fb791c83c264c6da9d3e286afdc7ca 100644 (file)
@@ -344,6 +344,15 @@ void MEDCoupling1GTUMesh::getCellsContainingPoint(const double *pos, double eps,
   return m->getCellsContainingPoint(pos,eps,elts);
 }
 
+/*!
+ * to improve perf !
+ */
+void MEDCoupling1GTUMesh::getCellsContainingPoints(const double *pos, mcIdType nbOfPoints, double eps, MCAuto<DataArrayIdType>& elts, MCAuto<DataArrayIdType>& eltsIndex) const
+{// See EDF29571
+  MCAuto<MEDCouplingUMesh> m(buildUnstructured());
+  m->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
+}
+
 MEDCouplingFieldDouble *MEDCoupling1GTUMesh::buildOrthogonalField() const
 {
   MCAuto<MEDCouplingUMesh> m=buildUnstructured();
index 97329f11e287cfe5c6f72d7154ef108fd335e3e3..1e637c670e729aa85a59e1232e6a41ea62609370 100644 (file)
@@ -61,7 +61,8 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
     MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const;
-    MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<mcIdType>& elts) const;
+    MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<mcIdType>& elts) const override;
+    MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, mcIdType nbOfPoints, double eps, MCAuto<DataArrayIdType>& elts, MCAuto<DataArrayIdType>& eltsIndex) const override;
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
     MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const double *bbox, double eps) const;
     MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps);
index 4ce8081f213b86d2aea742c5c866ac6393ca3ba1..e7202640f881fe05b21d008f549681aebb4794aa 100644 (file)
@@ -1471,6 +1471,26 @@ class MEDCouplingBasicsTest7(unittest.TestCase):
       # only the third point is inside
       self.assertTrue(b.isEqual(DataArrayInt([0,0,0,1])))
 
+    def testSGTUMeshGetCellsContainingPts1(self):
+      """
+      EDF29571 : Fix problem of perfomance of GTUMesh::getCellsContainingPts
+      """
+      arr = DataArrayDouble(31) ; arr.iota()
+      m = MEDCouplingCMesh() ; m.setCoords(arr,arr,arr)
+      m = m.buildUnstructured()
+      m2 = MEDCoupling1SGTUMesh( m )
+      pts = m[:100].computeCellCenterOfMass()
+      a = datetime.now()
+      a1,b1 = m.getCellsContainingPoints(pts,1e-5)
+      b = datetime.now()
+      a2,b2 = m2.getCellsContainingPoints(pts,1e-5)
+      c = datetime.now()
+      ref = b-a
+      toTest = c-a
+      self.assertTrue( toTest < 10*ref )
+
+
+
 
 if __name__ == '__main__':
     unittest.main()