I have a region defined like this:
circle = Disk[{4.5, 3}, 0.5];
pin = Rectangle[{4, 0}, {5, 3}];
square = Rectangle[{0, 0}, {9, 9}];
region = RegionDifference[square, RegionUnion[circle, pin]];
Applying RegionPlot[region] gives this:
Now I need to setup boundary conditions for this region the following way:
Top, left, right walls: u[x,y] == 0
Bottom wall 0 <= x < 4: u[x,y] == 0
Bottom wall 5 < x <= 0: u[x,y] == 0
Wall at x = 4, for 0 <= y < 3: u[x,y] == 10
Wall at x = 5, for 0 <= y < 3: u[x,y] == 10
Semicircle with the center at x = 4.5 and y = 3 (radius = 0.5): u[x,y] == 10
These boundary conditions should be applied to a Laplace equation:
sol = NDSolveValue[{D[u[x, y], x, x] + D[u[x, y], y, y] == 0,
bc},
u, {x, y} \[Element] region]
DensityPlot[sol[x, y], {x, y} \[Element] region, Mesh -> None,
ColorFunction -> "Rainbow", PlotRange -> All,
PlotLegends -> Automatic]
Update: the result should be something like this:
That is what I received when I ran the code provided by user21 on Mathematica 10.3. I introduced:
mesh = ToElementMesh[DiscretizeRegion[region], MaxCellMeasure -> 0.01];
and in plotting I changed Mesh -> All
(for the picture on the left)