+
+ ## Adding skin + transfering groups on faces from tetras mesh
+ mesh2d = polyh.buildUnstructured().computeSkin()
+ mesh2d.setName(mesh_name)
+ myfile.setMeshAtLevel(-1, mesh2d)
+
+
+ for grp_name in mc_mesh_file.getGroupsOnSpecifiedLev(-1):
+ # This group is created by the export
+ if grp_name == "Group_Of_All_Faces":
+ logger.debug("Skipping group: "+ grp_name)
+ continue
+ logger.debug("Transferring group: "+ grp_name)
+
+ grp_tria = mc_mesh_file.getGroup(-1, grp_name)
+ # Retrieve the nodes in group
+ grp_nodes = grp_tria.computeFetchedNodeIds()
+ # Find all the cells lying on one of the nodes
+ id_grp_poly = mesh2d.getCellIdsLyingOnNodes(grp_nodes, False)
+
+ grp_poly = mesh2d[id_grp_poly]
+
+ # We use the interpolation to remove the element that are not really in
+ # the group (the ones that are next to a nodes nut not in the group
+ # will have the sum of their column in the enterpolation matrix equal
+ # to zero)
+ rem = mc.MEDCouplingRemapper()
+
+ rem.prepare(grp_poly, grp_tria, "P0P0")
+ m = rem.getCrudeCSRMatrix()
+ _, id_to_keep = np.where(m.sum(dtype=np.int64, axis=0) >= 1e-07)
+
+ id_grp_poly = id_grp_poly[id_to_keep.tolist()]
+ id_grp_poly.setName(grp_name)
+
+ myfile.addGroup(-1, id_grp_poly)