Mathematica does not require a one-to-one nodal correspondence for the PeriodicBoundaryCondition
to work. However, care must be taken to ensure that PeriodicBoundaryCondition
does not share nodes with a DirichletCondition
.
Here is an example adapted for an inclusion taken from the documentation for PeriodicBoundaryCondition
. Please note that there can be artefacts introduced due to implied NeumannConditions on the "source" boundary as discussed in this MSE post. That is why I applied forward and reverse PBC's. It seemed to work.
Needs["NDSolve`FEM`"]
{length, height, xc, yc, r} = {1, 2, 0, 0, 1/8};
{sx, sy, fx, fy} = {-length/2, -height/2, length/2, height/2};
disk = Region@Disk[{xc, yc}, r];
Ω =
RegionDifference[Rectangle[{sx, sy}, {fx, fy}], disk];
mesh = ToElementMesh[Ω, MaxCellMeasure -> 0.0005,
AccuracyGoal -> 5];
pde = ((Inactive[
Div][(-{{1, 0}, {0, 1}}.Inactive[Grad][u[x, y], {x, y}]), {x,
y}]) - If[1/4 fx <= x <= 3/4 fx && sy/4 <= y <= fy/4, 1.,
0.] == 0)
Subscript[Γ, D] =
DirichletCondition[
u[x, y] == 0, (y <= sy || y >= fy) && sx < x <= fx];
pbcf = PeriodicBoundaryCondition[u[x, y], x == sx && sy <= y <= fy,
TranslationTransform[{length, 0}]];
pbcr = PeriodicBoundaryCondition[u[x, y], x == fx && sy <= y <= fy,
TranslationTransform[{-length, 0}]];
ufun = NDSolveValue[{pde, pbcf, pbcr, Subscript[Γ, D]},
u, {x, y} ∈ mesh];
cp = ContourPlot[ufun[x, y], {x, y} ∈ mesh,
ColorFunction -> "TemperatureMap", AspectRatio -> Automatic]
Show[MapAt[Translate[#, {length, 0}] &, cp, 1], cp,
MapAt[Translate[#, {-length, 0}] &, cp, 1], PlotRange -> All]

For completeness, I show the artefact with specifying only one PBC resulting in a no flux condition on the source wall.
pbc = PeriodicBoundaryCondition[u[x, y], x == sx && sy <= y <= fy,
TranslationTransform[{length, 0}]];
ufun = NDSolveValue[{pde, pbc, Subscript[Γ, D]},
u, {x, y} ∈ mesh];
cp = ContourPlot[ufun[x, y], {x, y} ∈ mesh,
ColorFunction -> "TemperatureMap", AspectRatio -> Automatic]
Show[MapAt[Translate[#, {length, 0}] &, cp, 1], cp,
MapAt[Translate[#, {-length, 0}] &, cp, 1], PlotRange -> All]

PeriodicBoundaryCondition
. $\endgroup$