I would like to pick a part of a boundary mesh, for example
bm=BoundaryMesh[Cuboid[]]
Is it possible to select the part(side) x==1
of the cuboid and define a new 2D-mesh of this side?
Thanks!
MeshTools package can help you with SelectElements
function and some manual postprocessing.
Needs["MeshTools`"]
bm = ToBoundaryMesh[Cuboid[]]
side = SelectElements[bm, #1 == 1 &]
This "projects" 3D mesh with "BoundaryElements"
to 2D mesh with "MeshElements"
. Reverse
on element incidents is necessary to avoid warning messages about bad their quality (inverted elements).
mesh2D = ToElementMesh[
"Coordinates" -> side["Coordinates"][[All, {2, 3}]],
"MeshElements" -> MapAt[Reverse, side["BoundaryElements"], {All, 1, All}]
]
mesh2D["Wireframe"["MeshElementStyle" -> FaceForm@LightBlue]]
You can extract information about meshes using functions like MeshCells
and MeshCoordinates
.
bm = BoundaryMesh[Cuboid[]]
sel = Select[MeshCoordinates[bm], #[[1]] == 1&]
hull = ConvexHullMesh[sel[[All, 2;;3]]]
You might also be able to get away with using Polygon
instead of ConvexHullMesh
if your 2D mesh isn't always convex, but you'd have to be able to order the points of sel
first.