I'm trying to create a finite element mesh with some spherical holes.
To my mind the behavior is erratic but generally fails. I'm using MMA 10.0.2. In the following 3 different sets of holes are defined by coords3Da etc. By setting coords3D to coords3Da (or coords3Db or coords3Dc) and running the code you will see that it generates a mesh for b and c but fails for a. I haven't been able to generate a mesh for any 3-hole version. I also tried a second version in which I used MMA's defined functions "Cylinder" and "Ball." That attempt fails to generate a mesh with a single hole. (It does generate a mesh if the RegionHoles option is removed.)
Is there any way to tweak one of these to get it to generate meshes for a few tens of holes? I should mention that this code was morphed from the code here: How to create subregions for the NDSolve FEM Solver
EDITED TO ADD:
I've since succeeded in generating meshes with as many as six holes but it's all hit and miss. I'm after a robust way to generate meshes.
<< NDSolve`FEM`;
cylinder[x_, y_, z_, h_, r_] := x^2 + y^2 <= r^2 && 0 <= z <= h;
holes3D[{x0_, y0_, z0_}, r_] := ((x - x0)^2 + (y - y0)^2 + (z - z0)^2 >= r^2);
coords3Da = {{-0.5, 0, .5}, {0, 0.5, 3.5}};
coords3Db = {{0, 0, 2.5}, {1/2, 0, 1.5}};
coords3Dc = {{0, 0, 2.5}}
coords3D = coords3Db;
sd3D = And @@ (holes3D[#, 3/25] & /@ coords3D);
regions = And[cylinder[x, y, z, 5, 1], sd3D];
Ω2cyl = ImplicitRegion[regions, {x, y, z}]
mesh = ToElementMesh[Ω2cyl, "BoundaryMeshGenerator" ->{"Continuation"},"RegionHoles" -> coords3D];
Show[mesh["Wireframe"]]
SECOND VERSION USING Cylinder and Ball
ToElementMesh[RegionUnion[Cylinder[{{0, 0, 0}, {0, 0, 5}}], Ball[{0, 0, 2.5}, 1/8]], "BoundaryMeshGenerator" -> {"Continuation"}, "RegionHoles" -> {0, 0, 2.5}]["Wireframe"]
RegionUnion
here; at least that's not the same as the examples above. $\endgroup$