2
$\begingroup$

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!

$\endgroup$
2
$\begingroup$

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]]

mesh2D

$\endgroup$
  • $\begingroup$ Thanks for this helpful tool, I'll try to select the side mesh. $\endgroup$ – Ulrich Neumann Oct 17 at 19:27
1
$\begingroup$

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]]]

Output of convex hull.

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.

$\endgroup$
  • $\begingroup$ Thank you, very interesting ideas. I hoped to find a function which easily creates a submesh. $\endgroup$ – Ulrich Neumann Oct 17 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.