I am trying to solve the Stokes equation for fluid flow in a 3d cylinder. All boundaries are no-slip, apart from the top boundary, which enforces flow in the x-direction.
My problem is that I can't enforce periodic boundary conditions at -pi and pi in the azimuthal direction for the pressure. Instead of a solution, I get the errors:
NDSolve: DirichletCondition can not be present on the target boundary of a PeriodicBoundaryConditon. NDSolve: The boundary condition discretization failed.
When I omit the periodic pressure condition, NDSolve finishes, but the solution has a problem around the origin. Also the flows should be mirror-symmetric across the x-axis due to the top boundary condition, but they are not as can be seen in the x-component of the flow field.
I already incorporated the trick of extending the domain in azimuthal direction from here: Solve Laplace equation in Cylindrical - Polar Coordinates. But that did not seem to help.
What can I do to get a good solution out of NDSolve?
Below is a minimal working example.
(** PDE **)
cs = "Cylindrical";
stokesEqns = {
Simplify[
Laplacian[{ur[r, \[Phi], z], u\[Phi][r, \[Phi], z],
uz[r, \[Phi], z]}, {r, \[Phi], z}, cs]] -
Simplify[Grad[pp[r, \[Phi], z], {r, \[Phi], z}, cs]] == {0, 0, 0},
Simplify[
Div[{ur[r, \[Phi], z], u\[Phi][r, \[Phi], z],
uz[r, \[Phi], z]}, {r, \[Phi], z}, cs]] == 0
};
(** boundary conditions **)
{u0r, u0\[Phi], u0z} =
TransformedField[
"Cartesian" -> cs, {1, 0, 0}, {xx, yy, zz} -> {r, \[Phi], z}] /.
z -> 1;
boundaryConditions = {
DirichletCondition[{ur[r, \[Phi], z] == u0r,
u\[Phi][r, \[Phi], z] == u0\[Phi], uz[r, \[Phi], z] == u0z},
z == 1 \[And] -\[Pi] < \[Phi] < \[Pi]],
DirichletCondition[{ur[r, \[Phi], z] == 0,
u\[Phi][r, \[Phi], z] == 0, uz[r, \[Phi], z] == 0,
pp[r, \[Phi], z] == 0}, z == -1 \[And] -\[Pi] < \[Phi] < \[Pi]],
DirichletCondition[{ur[r, \[Phi], z] == 0,
u\[Phi][r, \[Phi], z] == 0, uz[r, \[Phi], z] == 0,
pp[r, \[Phi], z] == 0}, r == 1 \[And] -\[Pi] < \[Phi] < \[Pi]],
PeriodicBoundaryCondition[ur[r, \[Phi], z], \[Phi] == -\[Pi],
TranslationTransform[{0, 2 \[Pi], 0}]],
PeriodicBoundaryCondition[u\[Phi][r, \[Phi], z], \[Phi] == -\[Pi],
TranslationTransform[{0, 2 \[Pi], 0}]],
PeriodicBoundaryCondition[uz[r, \[Phi], z], \[Phi] == -\[Pi],
TranslationTransform[{0, 2 \[Pi], 0}]],
PeriodicBoundaryCondition[pp[r, \[Phi], z], \[Phi] == -\[Pi],
TranslationTransform[{0, 2 \[Pi], 0}]]
};
(** solve **)
AbsoluteTiming[
solFEM =
NDSolve[{stokesEqns, boundaryConditions}, {ur, u\[Phi], uz,
pp}, {r, 0, 1}, {\[Phi], -\[Pi], \[Pi] + \[Pi]/4}, {z, -1, 1},
Method -> {"FiniteElement",
"InterpolationOrder" -> {ur -> 2, u\[Phi] -> 2, uz -> 2,
pp -> 1}}][[1]];
][[1]]
(** plot **)
field[xx_, yy_, zz_] =
TransformedField[
cs -> "Cartesian", {ur[r, \[Phi], z], u\[Phi][r, \[Phi], z],
uz[r, \[Phi], z]} /. solFEM, {r, \[Phi], z} -> {xx, yy, zz}];
ppCart[xx_, yy_, zz_] =
TransformedField[cs -> "Cartesian",
pp[r, \[Phi], z] /. solFEM, {r, \[Phi], z} -> {xx, yy, zz}];
DensityPlot3D[
field[x, y, z][[1]]
, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}
, PlotRange -> All, PlotLegends -> Automatic,
AxesLabel -> {"x", "y", "z"}, PlotLabel -> "x-component of flow"]




DirichletConditionpresent at the target can be very subtle. Make sure that the specification for theDirichletConditionpredicate and the target do not overlap at any point. Initially try to reduce the position of theDirichletConditionas much as possible (even to a smaller space then what you finally want) and then to get the PBCs working then enlarge to find where the problem is. – user21 Jun 04 '20 at 06:51