3
$\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 Answers 2

3
$\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$
1
  • $\begingroup$ Thanks for this helpful tool, I'll try to select the side mesh. $\endgroup$ Commented Oct 17, 2019 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$
1
  • $\begingroup$ Thank you, very interesting ideas. I hoped to find a function which easily creates a submesh. $\endgroup$ Commented Oct 17, 2019 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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