I have been trying to refine a cylindrical mesh that i have generated but somehow the refinement that i visualize is not exactly that i prescribed. Here is the piece of code for it.
<< NDSolve`FEM`;
lsub0 = 0.1;
R = 0.5;
L = 8;
COD = 0.1;
aDim = 0.2;
reg1 = Cylinder[{{0, 0, 0}, {0, 0, L}}, R];
p1 = {-R, -aDim, L/2}; p2 = {-R, -R, L/2 + COD}; p3 = {-R, -R,
L/2 - COD};
p4 = {R, -aDim, L/2}; p5 = {R, -R, L/2 + COD}; p6 = {R, -R, L/2 - COD};
reg2 = Prism[{p1, p2, p3, p4, p5, p6}];
reg3 = RegionDifference[reg1, reg2];
elVol = (lsub0/2)^3/(6 \[Sqrt]2);
Omegasuph =
ToElementMesh[reg3, {{-R, R}, {-R, R}, {0, L}},
MaxCellMeasure -> {"Volume" -> 0.5}, "MeshOrder" -> 1,
MeshRefinementFunction ->
Function[{vertices, Vol},
Block[{x, y, z, tol}, {x, y, z} = Mean[vertices]; tol = 0.05;
If[(z <= L/2 + tol && z >= L/2 - tol) , Vol > elVol, Vol > 5]]]]
I am trying to refine the region at z = L/2, where L is the length of the cylinder. The mesh after refinement is shown below.The mesh doesn't get refined all the way to the top. In the mesh refinement function, i have not prescribed any bounds on x and y as i would like to refine it for all x and y between z = L/2-tol and z = L/2+tol. I would really appreciate any pointers on what am i doing wrong here. My apologies for the long description of the problem. Thanks.
Omegasuph[
"Wireframe"["MeshElement" -> "MeshElements",
PlotRange -> {All, All, {L/2 - 0.2, L/2 + 0.2}}]]