Here is my problem: I want to solve a Laplacian equation in a 2D geometry with multiple interfaces, each interface presenting a different boundary condition.
As for an example, I am working on a ring with BC1 on the outside and BC2 on the inside. I would like Mathematica to identify these two interfaces automatically (which I do manually for now, thanks to easy geometry).
Here is my code:
Needs["NDSolve`FEM`"]
rego = RegionDifference[Disk[{0, 0}, 10], Disk[{0, 0}, 4]];
mesh = ToElementMesh[rego];
mesh["Wireframe"]
sol = NDSolve[{-Laplacian[u[x, y], {x, y}] == 0,
DirichletCondition[u[x, y] == 0, x^2 + y^2 == 16],
DirichletCondition[u[x, y] == 1, x^2 + y^2 == 100]},
u, {x, y} \[Element] mesh];
Plot3D[u[x, y] /. sol, {x, y} \[Element] mesh, PlotRange -> All,
AxesLabel -> {x, y, u}]
which gives this nice plot:
The trick is that I want to automize the selection of the boundaries in the Dirichlet conditions, because analytical expressions are easy to derive only in simple geometries.
I have had a look on other answers without being truly statisfied... must miss something.
Idea: use ToBoundaryMesh[]
?
Thanks.