]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
compute_interpolation_P0P0_matrix_with_geom method to check medcoupling matrix
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 24 Mar 2021 16:24:17 +0000 (17:24 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 24 Mar 2021 16:24:17 +0000 (17:24 +0100)
src/MEDCoupling_Swig/geom2medcoupling.py

index 44a3a7e09a215c8fde7f5cac3673f5be30e72c88..c9259627799a27e8dbf619d7a8e3efc245a5a927 100644 (file)
@@ -71,3 +71,29 @@ def to_geomshape(mcmesh):
     if mcmesh.getSpaceDimension() != 3:
         mcmesh.changeSpaceDimension(3,0.0)
     return (dico[mdim])(mcmesh)
+
+def compute_interpolation_P0P0_matrix_with_geom(srcMesh,trgMesh):
+    """
+    Method computing interpolation matrix P0P0 using GEOM/OCCT engine.
+    This method is normaly slower than mc.MEDCouplingRemapper.prepare method but it may be used to check values.
+
+    :return: a matrix with the same format than mc.MEDCouplingRemapper.getCrudeMatrix (use mc.MEDCouplingRemapper.ToCSRMatrix to convert it into scipy sparse format)
+    """
+    mat_geom = trgMesh.getNumberOfCells()*[{}]
+    for j in range(trgMesh.getNumberOfCells()):
+        for i in range(srcMesh.getNumberOfCells()):
+            mc_src_mesh = srcMesh[i]
+            src_geom = to_geomshape(mc_src_mesh)
+            mc_trg_mesh = trgMesh[j]
+            trg_geom = to_geomshape(mc_trg_mesh)
+
+            from salome.geom import geomBuilder
+            geompy = geomBuilder.New()
+            import GEOM
+            geompy.ExportBREP(src_geom, "src.brep")
+            geompy.ExportBREP(trg_geom, "trg.brep")
+            Common_1 = geompy.MakeCommonList([src_geom, trg_geom], True)
+            _,_,volume = geompy.BasicProperties(Common_1)
+            if volume > 0.:
+                mat_geom[j][i] = volume
+    return mat_geom
\ No newline at end of file