I'm building a mesh of a pit storage in Mathematica which I then export to another FEM-software. I follow the workflow for creating a ElementMesh from the documentation, but it won't work in the way it should. I start with creating my BoundaryMesh, which works perfectly well:
boundary = ToBoundaryMesh["Coordinates" -> boundaryPoints,"BoundaryElements" enter code here-> {QuadElement[elements]}];
boundary["Wireframe"]
This is the exported BoundaryMesh, which contains the Coordinates and the Elements:
I now want to create the mesh with special focus on the center area. The center should be refined and the boundary areas inside the pit (center hole) should be preserved, because i want to apply different boundary conditions for each segment.
refinementFunction =
With[{damOuterWidthX = 96, damOuterWidthY = 106, pitDepth = 10},
Compile[{{coordinates, _Real, 2}, {vol, _Real, 0}},
Block[{pos}, pos = Mean[coordinates];
If[((-(damOuterWidthX/2 + 10) <=
pos[[1]] < (damOuterWidthX/2 +
10)) && (-(damOuterWidthY/2 + 10) <=
pos[[2]] < (damOuterWidthY/2 + 10)) && (-(pitDepth + 10) <=
pos[[3]])) && Volume[Tetrahedron[coordinates]] > 3, True,
False]
]]];
mesh = ToElementMesh[
boundary,
"MeshOrder" -> 1,
MeshRefinementFunction -> refinementFunction,
AccuracyGoal -> 10
];
mesh["Wireframe"[
"ElementMeshDirective" ->
Directive[EdgeForm[Thin], FaceForm[RGBColor[0.16, 1., 0.97]]]]]
This is the top view of the resulting mesh. As one can see, only the geometry is maintained, but the boundary areas got lost on the way and the refinement, which should go beyond the center area doesn't apply everywhere inside the refinement area. Here is a picture from my FEM software, which makes this more clear:
This is a side view of the pit (cut in half), where the colors show the volume size. My volume constraint was set to 3 in the center region. Below the pit this works fine, but it fails at the pit walls. Something else one can see, in this picture is the following. The bottom and the wall of the pit are of a different material and thus I considered this geometry in the BoundaryMesh and in contrast to the divison of the pit wall into different areas, it was maintained.
I played around alot with all the options of ToElementMesh
and my RefinementFunction
but I can't get it right. If someone has an idea or a solution I would be very grateful.
Update: @user21: Sorry, here are the complete points and faces of my problem: Complete faces and points. I created a more simple case, that basically shows the problem with the ignored Boundaries: Simple case Here as well, an internal Boundary is dropped when the mesh is converted to the ElementMesh:
{easyPoints, easyFaces} =
Import[NotebookDirectory[] <> "pointsNelementsEasy.mx"];
{ToBoundaryMesh["Coordinates" -> easyPoints,
"BoundaryElements" -> (QuadElement[{#}] & /@ easyFaces)][
"Wireframe"],
ToElementMesh[
ToBoundaryMesh["Coordinates" -> easyPoints,
"BoundaryElements" -> (QuadElement[{#}] & /@ easyFaces)]][
"Wireframe"["MeshElement" -> "MeshElements",
"ElementMeshDirective" -> Directive[FaceForm[Red]] ]]}