Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RegionCapillary =
- RegionUnion[Rectangle[{0, 0.1}, {0.9, 0.2}],
- Rectangle[{0, 0.8}, {0.9, 0.9}],
- Rectangle[{0.8, 0.2}, {0.9, 0.9}] ];
- RegionShell = Rectangle[{0, 0}, {1, 1}];
- << NDSolve`FEM`
- StokesOp := {
- -Inactive[Laplacian][ u[x, y], {x, y}] + D[ p[x, y], x],
- -Inactive[Laplacian][ v[x, y], {x, y}] + D[ p[x, y], y],
- (* incompressibility div u = 0 *)
- Div[{u[x, y], v[x, y]}, {x, y}]
- } ;
- bcs := {
- DirichletCondition[p[x, y] == 10^3, x == 0 && y > 0.5],
- DirichletCondition[p[x, y] == 0, x == 0 && y < 0.5],
- DirichletCondition[{u[x, y] == 0., v[x, y] == 0.}, True]
- };
- Clear[xVel, yVel, pressure];
- AbsoluteTiming[{xVel, yVel, pressure} =
- NDSolveValue[{StokesOp == {0, 0, 0}, bcs}, {u, v,
- p}, {x, y} [Element] RegionCapillary,
- Method -> {"FiniteElement",
- "InterpolationOrder" -> {u -> 2, v -> 2, p -> 1},
- "MeshOptions" -> {"MaxCellMeasure" -> 10^-4}}
- ]];
- DensityPlot[Sqrt[
- xVel[x, y]^2 + yVel[x, y]^2], {x, y} [Element]
- RegionCapillary,
- PlotRange -> All, PlotLabel -> "velocity magnitude",
- PlotPoints -> 30] // Quiet
- em = First@pressure["Coordinates"];
- (*em["Wireframe"]*)
- mr = MeshRegion[em];
- Pe = 10^2;
- advectionOp :=
- If[{x, y} [Element] mr,
- Pe {xVel[x, y], yVel[x, y]}.Inactive[Grad][c[x, y], {x, y}], 0] -
- Inactive[Laplacian][c[x, y], {x, y}]
- bcs := {
- DirichletCondition[c[x, y] == 0, x == 0 && 0.8 < y < 0.9],
- DirichletCondition[c[x, y] == 1, x > 0]
- };
- AbsoluteTiming[
- csol = NDSolveValue[{advectionOp ==
- NeumannValue[0, x == 0 && ((0 < y < 0.8) || (0.9 < y < 1))],
- bcs}, c, {x, y} [Element] RegionShell,
- Method -> {"FiniteElement", "InterpolationOrder" -> {c -> 2},
- "MeshOptions" -> {"MaxCellMeasure" -> 10^-5}}
- ]];
- DensityPlot[csol[x, y], {x, y} [Element] RegionShell,
- PlotRange -> All, PlotLabel -> "x velocity", PlotPoints -> 30]
- advectionOp :=
- If[{x, y} [Element] mr,
- Pe {xVel[x, y], yVel[x, y]}.Inactive[Grad][c[x, y], {x, y}], 0] -
- Inactive[Laplacian][c[x, y], {x, y}]
Add Comment
Please, Sign In to add comment