Skip to content

Commit 36e19a2

Browse files
committed
update project Stokes MAC
1 parent 0e2ea35 commit 36e19a2

File tree

2 files changed

+44
-35
lines changed

2 files changed

+44
-35
lines changed

docs/_projects/projectStokesMAC.md

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,69 @@ sidebar:
66
---
77

88

9-
The purpose of this project is to implement the simple and popular MAC scheme for solving Stokes equations in two dimensions.
9+
The purpose of this project is to implement the MAC scheme for solving Stokes equations in two dimensions.
1010

1111
Reference
12-
* [Progamming of MAC for Stokes equations](http://math.uci.edu/~chenlong/226/MACcode.pdf)
12+
* [Progamming of MAC for Stokes Equations](http://math.uci.edu/~chenlong/226/MACcode.pdf)
13+
* [Progamming of Finite Difference Methods](http://math.uci.edu/~chenlong/226/FDMcode.pdf)
1314

14-
## Test Examples
1515

16-
* Analytic solution. We use a simple model of colliding flow with
17-
analytic solutions to test the code. The domain is $[-1,1]^2$ Compute the data `f` and Dirichlet boundary condition `g_D` for the analytic solution:
1816

19-
$$u = 20xy^3; \quad v = 5x^4 - 5y^4; \quad p = 60x^2y - 20y^3 + {\rm constant}.$$
17+
## Step 1: Distributive Gauss-Seidel Smoothing (DGS)
2018

21-
* Driven cavity problem. The domain is [-1,1]^2. Stokes equation with zero Dirichlet boundary condition except on the top:
22-
23-
$$ \{ y=1; -1 <= x <= 1 | u = 1, v = 0 \}.$$
24-
25-
## Step 1: Gauss-Seidel smoothing of velocity
19+
1. Gauss-Seidel smoothing of velocity to update `u`;
20+
2. form the residual for the continuity equation `rp = g-Bu`;
21+
3. solve the Poisson equation for pressure `Ap*ep = rp` by G-S;
22+
4. distribute the correction to velocity by `u = u + B'*ep`;
23+
5. update the pressure by `p = p - Ap*ep`.
2624

27-
Given a pressure approximation, relax the momentum equation to update velocity. See [Project: Multigrid Methods](projectMG.md) on the matrix free implemenation of G-S relaxation.
25+
Every step can be implemented in a matrix-free version.
2826

29-
Note that the boundary or near boundary dof should be updated diffeently. The stencil should be changed according to different boundary conditions.
27+
Then use DGS as an iterative method to solve the Stokes equation for a fixed level. As the level increases, the iteration steps will increase to achieve the same tolerance, e.g. the relative residual norm is less than $10^{-3}$​.
3028

31-
# Step 2: Distributive Gauss-Seidel Smoothing (DGS)
29+
To debug your code, let the exact solution be zero. Start from a random initial guess. The DGS iteration will push all unknowns to zero.
3230

33-
1. Gauss-Seidel smoothing of velocity to update `u`;
34-
* form the residual for the continuity equation `rp = g-Bu`;
35-
* solve the Poisson equation for pressure `Ap*ep = rp` by G-S;
36-
* distribute the correction to velocity by `u = u + B'*ep`;
37-
* update the pressure by `p = p - Ap*ep`.
3831

39-
Every step can be implemented in a matrix-free version; see [Progamming of MAC for Stokes equations](http://math.uci.edu/~chenlong/226/MACcode.pdf).
4032

41-
Use DGS as an iterative method to solve the Stokes equation. The iteration steps could be very large but will converges.
42-
43-
# Step 3: Two level method
33+
## Step 2: Two Level Method
4434

4535
The two level method is
4636

47-
1. presmoothing by DGS
48-
* form residuals for momentum and continunity equations
49-
* restrict the residual to the coarse grid
50-
* iterate DGS in the coarse grid till converge
51-
* prolongate the correction to the fine grid
52-
* postsmoothing by DGS
37+
1. Presmoothing by DGS
38+
2. Form residuals for momentum and continunity equations
39+
3. Restrict the residual to the coarse grid
40+
4. Use DGS in the coarse grid till converge (Step 1)
41+
5. Prolongate the correction to the fine grid
42+
6. Postsmoothing by DGS
5343

54-
Note: the index map between coarse and fine grids are slightly different for `u,v,p`; see [Progamming of MAC for Stokes equations](http://math.uci.edu/~chenlong/226/MACcode.pdf).
44+
Note: the index map between coarse and fine grids are slightly different for `u,v,p`.
5545

5646
Test your two level methods for different levels. It should convergence in less than 20 steps and indepedent of the number of levels.
5747

58-
## Step 4: Vcycle multigrid method
5948

60-
Recrusively apply the two-level method to the coarse grid problem
61-
in the previous step to get a V-cycle method.
6249

63-
* Test the convergence of Vcycle method. Record the iteration steps needed to push the relative residual smaller than a tolerance.
50+
## Step 3: Vcycle Multigrid Method
51+
52+
Recrusively apply the two-level method to the coarse grid problem in the previous step to get a V-cycle method.
53+
54+
* Test the convergence of Vcycle method. Record the iteration steps needed to push the relative residual smaller than a tolerance say $10^{-3}$.
6455

6556
* Compute the error between the computed approximation to the exact solution and show the convergence rate in terms of mesh size `h`.
57+
58+
59+
60+
## Step 4: Test Examples
61+
62+
1. **Analytic solution.** We use a simple model of colliding flow with analytic solutions to test the code. The domain is $[-1,1]^2$​ Compute the data `f` and Dirichlet boundary condition `g_D` for the analytic solution:
63+
$$
64+
u = 20xy^3; \quad v = 5x^4 - 5y^4; \quad p = 60x^2y - 20y^3 + {\rm constant}.
65+
$$
66+
Choose the constant s.t. the integral of $p$ over the domain is zero.
67+
68+
2. **Driven cavity problem.** The domain is $[-1,1]^2$​ . Stokes equation with $f=0,g=0$ and zero Dirichlet boundary condition except on the top:
69+
70+
$$
71+
\{ y=1; -1 \leq x \leq 1 \mid u = 1, v = 0 \}.
72+
$$
73+
74+
##

tutorial/mgS.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
%% Options
4343
% Assign default values to unspecified parameters
44-
if ~exist('option','var'),
44+
if ~exist('option','var')
4545
option = [];
4646
end
4747
option = mgoptions(option,Ndof); % parameters

0 commit comments

Comments
 (0)