Skip to main content
3 of 4
added 381 characters in body

Boundary condition setup for the region defined with basic geometry

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:

Region

Now I need to setup boundary conditions for this region the following way:

  1. Top, left, right walls: u[x,y] == 0

  2. Bottom wall 0 <= x < 4: u[x,y] == 0

  3. Bottom wall 5 < x <= 0: u[x,y] == 0

  4. Wall at x = 4, for 0 <= y < 3: u[x,y] == 10

  5. Wall at x = 5, for 0 <= y < 3: u[x,y] == 10

  6. 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:

image2

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)