I use an external software (Amira) to segment X-ray tomography images and then create a surface mesh which I can then import into Mathematica as an STL file. This file has two enclosed regions, separated by a common boundary. I would like to be able to assign different material properties to the two regions for mechanical finite element simulations. How can this be done efficiently?
I guess as long as I know the coordinates of a point that lies within each region then I should be able to define region markers that could help me here.
As a minimum working example I have created the following mesh, which consists of a rectangular prism of dimensions 1 x 1 x 2, which is separated into 2 cubic regions of equal size (1x 1x 1).
Needs["NDSolve`FEM`"]
bmesh = ToBoundaryMesh["Coordinates" -> {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}, {1.0, 0.0, 1.0}, {1.0, 1.0, 1.0}, {0.0, 1.0, 1.0}, {0.0, 0.0, 2.0}, {1.0, 0.0,2.0}, {1.0, 1.0, 2.0}, {0.0, 1.0, 2.0}},"BoundaryElements" -> {TriangleElement[{{1, 3, 2}, {1, 3, 4}, {1, 2, 6}, {1, 6, 5}, {2, 3, 7}, {2, 7, 6}, {3, 4, 8}, {3, 8, 7}, {4,1, 5}, {4, 5, 8}, {8, 5, 6}, {8, 6, 7}, {5, 6, 10}, {5, 10, 9}, {6, 7, 11}, {6, 11, 10}, {7, 8, 12}, {7, 12, 11}, {8, 5,9}, {8, 9, 12}, {12, 9, 10}, {12, 10, 11}}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22}]}]
Show[bmesh["Wireframe"], bmesh["Wireframe"[ "MeshElement" -> "PointElements", "MeshElementIDStyle" -> Blue]], bmesh["Wireframe"["MeshElementIDStyle" -> Red]]]
Following the documentation for ToElementMesh I naively thought that we could just add region markers.
mesh = ToElementMesh[bmesh, "RegionMarker" -> {{{0.5, 0.5, 0.5}, 10}, {{0.5, 0.5, 1.5}, 20}}, MaxCellMeasure -> 0.1]
mesh["Wireframe"[
"MeshElementStyle" -> {Directive[FaceForm[Green]],Directive[FaceForm[Red]]}]]
Any hint as to what I am doing wrong here?
bmesh
contains a triangelelement of all pointsTriangleElement[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22}]
, is this intended? $\endgroup$TriangleElement[{...,{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22}}]
$\endgroup$