Guest User

Untitled

a guest
Oct 24th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. RegionCapillary =
  2. RegionUnion[Rectangle[{0, 0.1}, {0.9, 0.2}],
  3. Rectangle[{0, 0.8}, {0.9, 0.9}],
  4. Rectangle[{0.8, 0.2}, {0.9, 0.9}] ];
  5. RegionShell = Rectangle[{0, 0}, {1, 1}];
  6.  
  7. << NDSolve`FEM`
  8. StokesOp := {
  9. -Inactive[Laplacian][ u[x, y], {x, y}] + D[ p[x, y], x],
  10. -Inactive[Laplacian][ v[x, y], {x, y}] + D[ p[x, y], y],
  11. (* incompressibility div u = 0 *)
  12. Div[{u[x, y], v[x, y]}, {x, y}]
  13. } ;
  14.  
  15. bcs := {
  16. DirichletCondition[p[x, y] == 10^3, x == 0 && y > 0.5],
  17. DirichletCondition[p[x, y] == 0, x == 0 && y < 0.5],
  18. DirichletCondition[{u[x, y] == 0., v[x, y] == 0.}, True]
  19. };
  20.  
  21. Clear[xVel, yVel, pressure];
  22. AbsoluteTiming[{xVel, yVel, pressure} =
  23. NDSolveValue[{StokesOp == {0, 0, 0}, bcs}, {u, v,
  24. p}, {x, y} [Element] RegionCapillary,
  25.  
  26. Method -> {"FiniteElement",
  27. "InterpolationOrder" -> {u -> 2, v -> 2, p -> 1},
  28. "MeshOptions" -> {"MaxCellMeasure" -> 10^-4}}
  29. ]];
  30.  
  31. DensityPlot[Sqrt[
  32. xVel[x, y]^2 + yVel[x, y]^2], {x, y} [Element]
  33. RegionCapillary,
  34. PlotRange -> All, PlotLabel -> "velocity magnitude",
  35. PlotPoints -> 30] // Quiet
  36.  
  37. em = First@pressure["Coordinates"];
  38. (*em["Wireframe"]*)
  39. mr = MeshRegion[em];
  40.  
  41. Pe = 10^2;
  42. advectionOp :=
  43. If[{x, y} [Element] mr,
  44. Pe {xVel[x, y], yVel[x, y]}.Inactive[Grad][c[x, y], {x, y}], 0] -
  45. Inactive[Laplacian][c[x, y], {x, y}]
  46.  
  47. bcs := {
  48. DirichletCondition[c[x, y] == 0, x == 0 && 0.8 < y < 0.9],
  49. DirichletCondition[c[x, y] == 1, x > 0]
  50. };
  51.  
  52. AbsoluteTiming[
  53. csol = NDSolveValue[{advectionOp ==
  54. NeumannValue[0, x == 0 && ((0 < y < 0.8) || (0.9 < y < 1))],
  55. bcs}, c, {x, y} [Element] RegionShell,
  56. Method -> {"FiniteElement", "InterpolationOrder" -> {c -> 2},
  57. "MeshOptions" -> {"MaxCellMeasure" -> 10^-5}}
  58. ]];
  59. DensityPlot[csol[x, y], {x, y} [Element] RegionShell,
  60. PlotRange -> All, PlotLabel -> "x velocity", PlotPoints -> 30]
  61.  
  62. advectionOp :=
  63. If[{x, y} [Element] mr,
  64. Pe {xVel[x, y], yVel[x, y]}.Inactive[Grad][c[x, y], {x, y}], 0] -
  65. Inactive[Laplacian][c[x, y], {x, y}]
Add Comment
Please, Sign In to add comment