The problem is that your Cuboid
is very thin. When you submit a Cuboid
to ToElementMesh
, it will by default create a hexahedral mesh: That pretty easy: Only one layer of hexahedral elements is created.
However, when you employ ImplicitRegion
, by default a tetrahedral mesh is created. For discretizations of general volumetric domains, Mathematica employs the external library TetGen. And by default TetGen tries to subdivide and subdivide further and further until all tetrahedra have good aspect ratios. For your very thin layer, this means that it has to create bazillions of tetrahedra which must be why it takes so long and won't finish.
You can observe that by increasing \[CapitalDelta]z
, so that TetGen is able to finish in "finite" time:
Needs["NDSolve`FEM`"]
\[CapitalDelta]z = 0.05 10;
R = 40;
a = 2*R;
b = 2*R*1.2;
meshcuboid = ToElementMesh[Cuboid[{0, 0, 0}, {a, b, \[CapitalDelta]z}]];
layer = ImplicitRegion[-a/2 <= x <= a/2 && -b/2 <= y <=
b/2 && -\[CapitalDelta]z <= z <= 0, {x, y, z}];
meshLoRes = ToElementMesh[layer, "PerformanceGoal" -> "Speed", "CheckQuality" -> False];
meshHiRes = ToElementMesh[layer];
Now, let's see how many mesh elements we have in our meshes:
Length@meshcuboid["MeshElements"][[1, 1]]
Length@meshLoRes["MeshElements"][[1, 1]]
Length@meshHiRes["MeshElements"][[1, 1]]
12669
99025
138999
You see, TetGen produces about ten times as many tets (for this particular thickness) and does so with a method that has considerable higher computational complexity than just subdividing a cuboid into small once. You can try to fiddle around a bit with the discretization options of ToElementMesh
, but I don't expect that this will help much for your particular choice of $\Delta z$. =/
I am not sure what you are about to do with the meshes. If you are going to solve PDEs on them, then it is not guaranteed that meshcuboid
will lead to good results, because its elements have probably too bad an aspect ratio for supporting a good numerical accuracy.
That is the reason why PDE on thin layers are abstracted to PDE on surfaces. By getting rid of the third dimension, one circumvents the need for overly fine discretizations. However, one has to be sure that the 3D PDE (or rather its solutions) "converges" in a sufficiently strong sense to a well-posed PDE on the limiting 2D surfaces in the limit of $\Delta z \to 0$. When the PDE stems from a minimization problem, such is usually proven in the language of $\Gamma$-convergence.
CuboidMesh
function. Or alternative path through 2D triangular mesh and then usingTriangleToQuadMesh
->SmoothenMesh
->ExtrudeMesh
. $\endgroup$