Suppose you have a region
composed of two materials. You define the inclusions
of material 1 through, e.g., disks, ellipsoids, rectangle and so on. Material 2 is the region
minus the inclusions
. The inclusions may touch the boundary of the region
, see following example.
region = Rectangle[{0, 0}, {10, 5}];
inclusions =
RegionUnion[Disk[{3, 2}, 1.5], Rectangle[{9, 4}, {10, 5}]];
Show[{RegionPlot@region, RegionPlot[inclusions, PlotStyle -> Orange]},
AspectRatio -> Automatic]
How do you mesh such a region? By that I mean creating a mesh for the whole region with a "nice" boundary mesh for the inclusions of material 1 (inclusions
). I have been trying to read through the meshing tutorials but I do not understand which functions are to be used. Later on I want to compute the solution of a PDE with FEM with varying coefficients, e.g.,
c[x_, y_] :=
If[Element[{x, y}, inclusions], DiagonalMatrix@{100, 20},
DiagonalMatrix@{3, 2}]
pde = Inactive[Div][
c[x, y].Inactive[Grad][u[x, y], {x, y}], {x, y}] == 0;
bc = {
DirichletCondition[u[x, y] == 0, x == 0]
, DirichletCondition[u[x, y] == 100, x == 10]
};
usol = NDSolveValue[{pde, bc}, u, Element[{x, y}, region]];
ContourPlot[usol[x, y], Element[{x, y}, region],
AspectRatio -> Automatic]
I know I can immediately put the coefficient function c[x,y]
into the FEM formulation in Mathematica (as in the code above), but I can surely imagine, that the results will improve if a better, geometry coherent mesh is provided. Thank you!
edit:
sorry, I should have pointed out, that I tried DiscretizeRegion
but I do not understand how to combine the individual discretized region to a good mesh. For example
di = DiscretizeRegion[inclusions]
dr = DiscretizeRegion[RegionDifference[region, inclusions]]
RegionUnion[di, dr]
is a viable solution but I think that the mesh quality of the region union is not a good one.
DiscretizeRegion[inclusions]
andDiscretizeRegion[RegionDifference[region, inclusions]]
? $\endgroup$Show[di, dr]
preserves the meshing ofdi
anddr
. $\endgroup$