Skip to content

Commit 5eab3b5

Browse files
authored
clean up the MG docs (#234)
1 parent a143519 commit 5eab3b5

File tree

2 files changed

+54
-42
lines changed

2 files changed

+54
-42
lines changed

docs/source/multigrid.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,47 @@
11
Multigrid Solvers
22
=================
33

4+
pyro solves elliptic problems (like Laplace's equation or Poisson's
5+
equation) through multigrid. This accelerates the convergence of
6+
qsimple relaxation by moving the solution down and up through a series
7+
of grids. Chapter 9 of the `pdf notes <http://open-astrophysics-bookshelf.github.io/numerical_exercises/CompHydroTutorial.pdf>`_ gives an introduction to solving elliptic equations, including multigrid.
8+
9+
There are three solvers:
10+
11+
* The core solver, provided in the class :func:`MG.CellCenterMG2d <pyro.multigrid.MG.CellCenterMG2d>` solves constant-coefficient Helmholtz problems of the form
12+
13+
$$(\alpha - \beta \nabla^2) \phi = f$$
14+
15+
* The class :func:`variable_coeff_MG.VarCoeffCCMG2d <pyro.multigrid.variable_coeff_MG.VarCoeffCCMG2d>` solves variable coefficient Poisson problems of the form
16+
17+
$$\nabla \cdot (\eta \nabla \phi ) = f`$$
18+
19+
This class inherits the core functionality from ``MG.CellCenterMG2d``.
20+
21+
* The class :func:`general_MG.GeneralMG2d <pyro.multigrid.general_MG.GeneralMG2d>` solves a general elliptic
22+
equation of the form
23+
24+
$$`\alpha \phi + \nabla \cdot ( \beta \nabla \phi) + \gamma \cdot \nabla \phi = f`$$
25+
26+
This class inherits
27+
the core functionality from :func:`MG.CellCenterMG2d <pyro.multigrid.MG.CellCenterMG2d>`.
28+
29+
This solver is the only one to support inhomogeneous boundary
30+
conditions.
31+
32+
We simply use V-cycles in our implementation, and restrict ourselves
33+
to square grids with zoning a power of 2.
34+
35+
.. note::
36+
37+
The multigrid solver is not controlled through ``pyro_sim.py``
38+
since there is no time-dependence in pure elliptic problems. Instead,
39+
there are a few scripts in the multigrid/ subdirectory that
40+
demonstrate its use.
41+
42+
443
.. toctree::
44+
:hidden:
545

646
multigrid_basics
747
multigrid-constant-coefficients

docs/source/multigrid_basics.rst

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,9 @@
1-
Multigrid Class Overview
2-
========================
1+
Simple Multigrid Examples
2+
=========================
33

4-
pyro solves elliptic problems (like Laplace's equation or Poisson's
5-
equation) through multigrid. This accelerates the convergence of
6-
simple relaxation by moving the solution down and up through a series
7-
of grids. Chapter 9 of the `pdf notes <http://open-astrophysics-bookshelf.github.io/numerical_exercises/CompHydroTutorial.pdf>`_ gives an introduction to solving elliptic equations, including multigrid.
84

9-
There are three solvers:
10-
11-
* The core solver, provided in the class :func:`MG.CellCenterMG2d <pyro.multigrid.MG.CellCenterMG2d>` solves constant-coefficient Helmholtz problems of the form
12-
:math:`(\alpha - \beta \nabla^2) \phi = f`
13-
14-
* The class :func:`variable_coeff_MG.VarCoeffCCMG2d <pyro.multigrid.variable_coeff_MG.VarCoeffCCMG2d>` solves variable coefficient Poisson problems of the form
15-
:math:`\nabla \cdot (\eta \nabla \phi ) = f`. This class inherits the core functionality from ``MG.CellCenterMG2d``.
16-
17-
* The class :func:`general_MG.GeneralMG2d <pyro.multigrid.general_MG.GeneralMG2d>` solves a general elliptic
18-
equation of the form :math:`\alpha \phi + \nabla \cdot ( \beta
19-
\nabla \phi) + \gamma \cdot \nabla \phi = f`. This class inherits
20-
the core functionality from :func:`MG.CellCenterMG2d <pyro.multigrid.MG.CellCenterMG2d>`.
21-
22-
This solver is the only one to support inhomogeneous boundary
23-
conditions.
24-
25-
We simply use V-cycles in our implementation, and restrict ourselves
26-
to square grids with zoning a power of 2.
27-
28-
The multigrid solver is not controlled through ``pyro_sim.py`` since
29-
there is no time-dependence in pure elliptic problems. Instead, there
30-
are a few scripts in the multigrid/ subdirectory that demonstrate its
31-
use.
32-
33-
Simple Examples
34-
---------------
35-
36-
multigrid test
37-
^^^^^^^^^^^^^^
5+
Known Solution
6+
--------------
387

398
A basic multigrid test is run as (using a path relative to the root of the
409
``pyro2`` repository):
@@ -43,7 +12,7 @@ A basic multigrid test is run as (using a path relative to the root of the
4312

4413
./pyro/multigrid/examples/mg_test_simple.py
4514

46-
The ``mg_test_simple.py`` script solves a Poisson equation with a
15+
The `mg_test_simple.py <https://github.com/python-hydro/pyro2/blob/main/pyro/multigrid/examples/mg_test_simple.py>`_ script solves a Poisson equation with a
4716
known analytic solution. This particular example comes from the text
4817
`A Multigrid Tutorial, 2nd Ed.`, by Briggs. The example is:
4918

@@ -88,23 +57,25 @@ You can run this example locally by running the ``mg_vis.py`` script:
8857

8958
./pyro/multigrid/examples/mg_vis.py
9059

91-
projection
92-
^^^^^^^^^^
60+
Projection
61+
----------
9362

9463
Another example uses multigrid to extract the divergence free part of a velocity
95-
field. This is run as:
64+
field. The script to run this is `project_periodic.py <https://github.com/python-hydro/pyro2/blob/main/pyro/multigrid/examples/project_periodic.py>`_. This is run as:
9665

9766
.. prompt:: bash
9867

9968
./pyro/multigrid/examples/project_periodic.py
10069

101-
Given a vector field, :math:`U`, we can decompose it into a divergence free part, :math:`U_d`, and the gradient of a scalar, :math:`\phi`:
70+
Given a vector field, :math:`U`, we can decompose it into a divergence
71+
free part, :math:`U_d`, and the gradient of a scalar, :math:`\phi`:
10272

10373
.. math::
10474
10575
U = U_d + \nabla \phi
10676
107-
We can project out the divergence free part by taking the divergence, leading to an elliptic equation:
77+
We can project out the divergence free part by taking the divergence,
78+
leading to an elliptic equation:
10879

10980
.. math::
11081
@@ -120,6 +91,7 @@ results are shown below:
12091
:align: center
12192

12293

123-
Left is the original u velocity, middle is the modified field after adding the gradient of the scalar, and right is the recovered field.
94+
Left is the original u velocity, middle is the modified field after
95+
adding the gradient of the scalar, and right is the recovered field.
12496

12597

0 commit comments

Comments
 (0)