I'm doing some FEM on a rectangular region with a spherical cavity:
myRegion = ImplicitRegion[X^2 + Y^2 + (Z - 1.05)^2 >= 1, {{X, 0, 1.5},{Y,0,1.5}, {Z, 0, 1.05}}];
RegionPlot3D[myRegion, Boxed -> False]
The most important part of the region is that in the bottom right (where the cavity is nearly reaching the bottom), so I'd like to selectively refine in that region. I do this with a function that refines when the mesh points are close to the z-axis:
Needs["NDSolve`FEM`"]
meshRefine = Function[{vertices, volume}, Block[{x, y, z}, {x, y, z} = Mean[vertices]; If[Sqrt[x^2 + y^2] <= 0.5, volume > 0.000005, False]]];
Now for the mesh. I have found that "ImproveBoundaryPosition" is necessary for applying boundary conditions to NDSolve, and that applying DiscretizeRegion before ToElementMesh avoids a "femimq: The element mesh has insufficient quality..." error.
myMesh=ToElementMesh[DiscretizeRegion@myRegion, "ImproveBoundaryPosition" -> True,MeshRefinementFunction -> meshRefine];
myMesh["Wireframe"["MeshElementStyle" -> FaceForm[White]]]
These two images show the result with and without the refinement function (from below):
As you can see, the MeshRefinementFunction gets some (but not all) of the points near the thinnest part. It seems that when the initial mesh connects the spherical boundary to the bottom, MeshRefinementFunction does not apply. Any ideas for a better way to refine that region? Thanks in advance.
Comments
Post a Comment