I am trying to make a finite element mesh in 2D. The features are not found by ToElementMesh
. This is a shelf bracket with nails. I build the region using RegionDifference
and RegionUnion
and the result is clear.
Needs["NDSolve`FEM`"]
L = 0.2; (* Bracket side length *)
d = 0.02; (* End edge lenght *)
r = L - d; (* radius of curved edge *)
r1 = d; (* radius of hole *)
L2 = 0.004; (* nail thickness *)
L3 = 0.04; (* nail length *)
L4 = L/8; (* location of nail from bottom *)
Y = 10^3; (* modulus of elasticity *)
ν = 33/100; (* Poisson ratio *)
reg = RegionDifference[
RegionUnion[
Rectangle[{0, 0}, {L, L}],
Rectangle[{-L3, L4 - L2/2}, {0, L4 + L2/2}],
Rectangle[{-L3, (L - L4) - L2/2}, {0, (L - L4) + L2/2}]
],
RegionUnion[
Disk[{L, 0}, r],
Disk[{2 d, L - 2 d}, r1]]
];
Show[Region[reg], PlotRange -> All, Frame -> True]
This region looks good. Now I try to mesh.
mesh = ToElementMesh[reg, "BoundaryMeshGenerator" -> "Continuation",
"MaxBoundaryCellMeasure" -> 0.001, "MaxCellMeasure" -> 0.0001];
Show[mesh["Wireframe"], PlotRange -> All]
The nails have been lost and the edges are very poorly represented. I have tried different options for ToElementMesh
but have not hit on one that works. What is happening? Version 11.1 for Windows. Thanks
Edit
Helpful user21 gave a solution below which works for the resolution in his example. I have tried to increase the resolution and this is what happens.
mesh = ToElementMesh[reg, {{-0.04`, 0.2`}, {0.`, 0.2`}},
"MaxBoundaryCellMeasure" -> 0.001,
"BoundaryMeshGenerator" -> {"RegionPlot", "SamplePoints" -> 200} ];
Show[mesh["Wireframe"], PlotRange -> All]
The curved boundaries and the lower part of the vertical straight boundary are badly formed. I would like a high resolution because when doing stress calculations gradients of the solution are needed. Any more thoughts?