# Extract finite mesh connectivity?

Posted 11 months ago
1063 Views
|
7 Replies
|
6 Total Likes
|
 Hello All:I used the command: DelaunayMesh[SpherePoints[12]] (* Create a concave mesh given 12 points on a sphere*) to generate a finite element mesh on a spherical surface. Now, how I can extract this mesh vertices coordinates and elements connectivities:for mesh coordinates, I should have for each point, something like x,y,z for mesh connectivities, I should have for each element, something like 1-2-3I am new to the Mathematica software, So, I tried to search in the library to make these two tasks, but unfortunately, I cannot solve this issue. I think I need to use the command: ToElementMesh or ElementMesh.Can anyone help with these tasks?
7 Replies
Sort By:
Posted 11 months ago
 Hello Hassan,what you asking for is MeshPrimitives: delaunay = DelaunayMesh[SpherePoints[12]]; points = MeshPrimitives[delaunay, 0]; lines = MeshPrimitives[delaunay, 1]; polygons2D = MeshPrimitives[delaunay, 2]; polygons3D = MeshPrimitives[delaunay, 3]; With this you can do things like: Graphics3D[{Red, PointSize[.03], points, Blue, Thick, lines, Green, polygons2D}] or: polygons3D = SortBy[polygons3D, Last[Mean @@ #] &]; Manipulate[Graphics3D[{p3D[[1 ;; n]]}, PlotRange -> {{-1, 1}}], {n, 1, Length[polygons3D], 1}] Hope this helps, regards -- Henrik
Posted 11 months ago
 Thanks Henrik for this clarification. But again, How to extract/display the vertices coordinates and triangles connectivities as: for mesh coordinates, I should have for each point, something like x,y,z for mesh connectivities, I should have for each element, something like 1-2-3Thanks
Posted 10 months ago
 Well, if you have an explicite look into my polygons2D data, you see how points are related in terms of trinangles. Or likewise, if you want to have your points indexed, try (using the above code): indxRules = MapIndexed[#1 -> First[#2] &, First /@ points]; triConns = First /@ polygons2D /. indxRules Regards -- Henrik
Posted 10 months ago
 mesh = DelaunayMesh[SpherePoints[12]] Get the coordinates like this: MeshCoordinates[mesh] {{1., 0., 0.}, {-1., 0., 0.}, {0.447214, 0., 0.894427}, {-0.447214, 0., -0.894427}, {0.447214, 0.525731, -0.723607}, {0.447214, -0.525731, -0.723607}, {-0.447214, 0.525731, 0.723607}, {-0.447214, -0.525731, 0.723607}, {0.447214, 0.850651, 0.276393}, {0.447214, -0.850651, 0.276393}, {-0.447214, 0.850651, -0.276393}, {-0.447214, -0.850651, -0.276393}} Get the edges like this: MeshCells[mesh, 1] {Line[{12, 11}], Line[{11, 2}], Line[{2, 12}], Line[{12, 4}], Line[{4, 11}], Line[{2, 4}], Line[{9, 3}], Line[{3, 10}], Line[{10, 9}], Line[{9, 7}], Line[{7, 3}], Line[{10, 7}], Line[{5, 6}], Line[{6, 12}], Line[{12, 5}], Line[{5, 10}], Line[{10, 6}], Line[{12, 10}], Line[{12, 9}], Line[{9, 5}], Line[{12, 8}], Line[{8, 2}], Line[{12, 7}], Line[{7, 8}], Line[{2, 7}], Line[{5, 11}], Line[{11, 9}], Line[{10, 1}], Line[{1, 3}], Line[{9, 1}], Line[{5, 1}], Line[{6, 1}], Line[{7, 11}], Line[{3, 8}], Line[{8, 10}], Line[{5, 4}], Line[{6, 4}]} You might want this in the form MeshCells[mesh, 1][[All,1]]{12,11} means that the 12th and 11th points are connected by an edge.If you wanted the connectivity as a Graph, the IGraph/M package has convenience functions for that. << IGraphM IGMeshGraph[mesh] But this function really just uses the above mentioned builtins.
Posted 10 months ago
 Thanks a lot Henrik and Horvát:Both are working. However, the number of cells/connectivities, in case of using MeshCells[mesh, 2], is giving 42 connectivity: {{12, 11, 2}, {11, 12, 4}, {12, 2, 4}, {2, 11, 4}, {9, 3, 10}, {3, 9, 7}, {9, 10, 7}, {10, 3, 7}, {5, 6, 12}, {6, 5, 10}, {5, 12, 10}, {12, 6, 10}, {12, 9, 5}, {9, 12, 10}, {5, 9, 10}, {12, 8, 2}, {8, 12, 7}, {12, 2, 7}, {2, 8, 7}, {9, 5, 11}, {5, 12, 11}, {12, 9, 11}, {3, 10, 1}, {10, 9, 1}, {9, 3, 1}, {10, 5, 1}, {5, 9, 1}, {10, 6, 1}, {6, 5, 1}, {11, 2, 7}, {12, 11, 7}, {3, 8, 10}, {8,3, 7}, {10, 8, 7}, {11, 5, 4}, {5, 12, 4}, {5, 6, 4}, {6, 12,4}, {12, 9, 7}, {9, 11, 7}, {12, 10, 7}, {10, 8, 12}} and the number of triangles on the surface for 12-vertex is 20.I am using the command (MeshCells) to display the vertex indices to understand what are the extra triangles.I anticipated these results are due to making all possible connectivities of tree vertices without restricting these triangular elements on the surface of the sphere.Thank you very much
 The Delaunay tesselation consists of tetrahedra. All tetrahedron faces are included. If you only want the surface, use ConvexHullMesh`