Skip to content

Commit 4252335

Browse files
committed
merging
2 parents 2159b99 + 619bf1d commit 4252335

File tree

4 files changed

+61
-51
lines changed

4 files changed

+61
-51
lines changed

demos/patch/hcurl_riesz_star.py.rst

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Using patch relaxation for H(div)
2-
=================================
1+
Using patch relaxation for H(curl)
2+
==================================
33

44
Contributed by `Robert Kirby <https://sites.baylor.edu/robert_kirby/>`_
55
and `Pablo Brubeck <https://www.maths.ox.ac.uk/people/pablo.brubeckmartinez/>`_.
@@ -13,7 +13,7 @@ Here, we demonstrate how to do this in the latter case.::
1313
mh = MeshHierarchy(mesh, 3)
1414
mesh = mh[-1]
1515

16-
We consider the Riesz map on H(div), discretized with lowest order
16+
We consider the Riesz map on H(curl), discretized with lowest order
1717
Nedelec elements. We force the system with a random right-hand side and
1818
impose homogeneous Dirichlet boundary conditions::
1919

@@ -45,13 +45,13 @@ patches yield a robust method.::
4545
"ksp_type": "cg",
4646
"pc_type": "mg",
4747
"mg_levels": {
48-
"ksp_type": "chebyshev",
49-
"ksp_max_it": 1,
50-
**relax
48+
"ksp_type": "chebyshev",
49+
"ksp_max_it": 1,
50+
**relax
5151
},
5252
"mg_coarse": {
5353
"ksp_type": "preonly",
54-
"pc_type": "cholesky"
54+
"pc_type": "cholesky"
5555
}
5656
}
5757

@@ -65,27 +65,30 @@ patches yield a robust method.::
6565
}
6666

6767
Hiptmair proposed a finer space decomposition for Nedelec elements using edge
68-
patches and vertex patches on the gradient of a Lagrange space. The python type
69-
preconditioner :class:`~.HiptmairPC` automatically sets up a two-level method
70-
using the auxiliary Lagrange space in a multigrid hierarchy. ::
68+
patches on the original Nedelec space and vertex patches on the gradient of a Lagrange space. The python type
69+
preconditioner :class:`~.HiptmairPC` automatically sets up an additive two-level method
70+
using the auxiliary Lagrange space in a multigrid hierarchy. Therefore, the overall multigrid relaxation composes the edge patches with the auxiliary space relaxation. For the latter, the residual on each level is restricted from the dual of H(curl) into the dual of H1 via the adjoint of the gradient, where a vertex patch relaxation is applied to obtain a correction that is prolonged from H1 into H(curl) via the gradient. ::
7171

7272

7373
def hiptmair_params():
7474
return {
75-
"pc_type": "python",
76-
"pc_python_type": "firedrake.HiptmairPC",
77-
"hiptmair_mg_levels": asm_params(1),
78-
"hiptmair_mg_coarse": asm_params(0),
75+
"pc_type": "python",
76+
"pc_python_type": "firedrake.HiptmairPC",
77+
"hiptmair_mg_coarse": asm_params(0),
78+
"hiptmair_mg_levels": asm_params(1),
79+
"hiptmair_mg_levels_ksp_type": "richardson",
80+
"hiptmair_mg_levels_ksp_max_it": 1,
81+
"hiptmair_mg_coarse_ksp_type": "preonly",
7982
}
8083

8184

8285
Now, for each parameter choice, we report the iteration count for the Riesz map
83-
over a range of meshes. We see that the auxiliary space approach gives lower
84-
iteration counts than vertex patches, while being cheaper to invert.::
86+
over a range of meshes. We see that vertex patches approach give lower
87+
iteration counts than the Hiptmair approach, but they are more expensive.::
8588

8689
names = {
87-
"Vertex Star": mg_params(asm_params(0)),
88-
"Hiptmair": mg_params(hiptmair_params()),
90+
"Vertex Star": mg_params(asm_params(0)),
91+
"Hiptmair": mg_params(hiptmair_params()),
8992
}
9093

9194
for name, parameters in names.items():
@@ -105,16 +108,16 @@ For vertex patches, we expect output like,
105108
3 16
106109
======== ============
107110

108-
and with Hiptmair (edge patches + vertex patches on gradients of H1)
111+
and with Hiptmair (edge patches + vertex patches on gradients of Lagrange)
109112

110113
======== ============
111114
Level Iterations
112115
======== ============
113-
1 10
114-
2 12
115-
3 13
116+
1 18
117+
2 20
118+
3 21
116119
======== ============
117120

118121
and additional mesh refinement will lead to these numbers leveling off.
119122

120-
A runnable python version of this demo can be found :demo:`here<hdiv_riesz_star.py>`.
123+
A runnable python version of this demo can be found :demo:`here<hcurl_riesz_star.py>`.

demos/patch/hdiv_riesz_star.py.rst

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,28 @@ Having done both :class:`~.ASMStarPC` and :class:`~.PatchPC` in other demos, her
3939
Arnold, Falk, and Winther show that either vertex (`construct_dim=0`) or edge patches (`construct_dim=1`) will be acceptable in three dimensions.::
4040

4141

42-
def asm_params(construct_dim):
42+
def mg_params(relax):
4343
return {
4444
"ksp_type": "cg",
45-
"pc_type": "mg",
46-
"mg_levels": {
47-
"ksp_type": "chebyshev",
48-
"ksp_max_it": 1,
49-
"pc_type": "python",
50-
"pc_python_type": "firedrake.ASMStarPC",
51-
"pc_star_construct_dim": construct_dim,
52-
"pc_star_backend_type": "tinyasm"
53-
},
54-
"mg_coarse": {
55-
"ksp_type": "preonly",
56-
"pc_type": "cholesky",
57-
}
45+
"pc_type": "mg",
46+
"mg_levels": {
47+
"ksp_type": "chebyshev",
48+
"ksp_max_it": 1,
49+
**relax
50+
},
51+
"mg_coarse": {
52+
"ksp_type": "preonly",
53+
"pc_type": "cholesky"
54+
}
55+
}
56+
57+
58+
def asm_params(construct_dim):
59+
return {
60+
"pc_type": "python",
61+
"pc_python_type": "firedrake.ASMStarPC",
62+
"pc_star_construct_dim": construct_dim,
63+
"pc_star_backend_type": "tinyasm"
5864
}
5965

6066
Now, for each parameter choice, we report the iteration count for the Riesz map
@@ -63,10 +69,11 @@ edge patches, but they are more expensive.::
6369

6470

6571
for cdim in (0, 1):
72+
params = mg_params(asm_params(cdim))
6673
print(f"Relaxation with patches of dimension {cdim}")
6774
print("Level | Iterations")
6875
for lvl, msh in enumerate(mh[1:], start=1):
69-
its = run_solve(msh, asm_params(cdim))
76+
its = run_solve(msh, params)
7077
print(f"{lvl} | {its}")
7178

7279
For vertex patches, we expect output like,

demos/patch/poisson_mg_patches.py.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ based on local patch-based decompositions through two different paths.
1111
This demonstration illustrates basic usage of these methods for the Poisson
1212
problem. Here, multigrid with point Jacobi relaxation works, but the iteration
1313
count degrades with polynomial degree, while vertex star patches give
14-
degree-indendent iteration counts. Here, all the degrees of freedom in the cells
14+
degree-independent iteration counts. Here, all the degrees of freedom in the cells
1515
(but not on the boundary) around each vertex are included in a patch
1616

1717
.. figure:: star.svg
@@ -63,7 +63,7 @@ on the coarsest level of the multigrid hierarchy.::
6363
}
6464

6565
When we use a matrix-free method, there will not be an assembled matrix to factor
66-
This forces the matrix to be assembled.::
66+
on the coarse level. This forces the matrix to be assembled.::
6767

6868
assembled_lu = {
6969
"ksp_type": "preonly",
@@ -103,8 +103,8 @@ degree increases.::
103103

104104
jacobi_relax = mg_params({"pc_type": "jacobi"}, mat_type="matfree")
105105

106-
These options specify an additive Schwarz relaxation through PatchPC.
107-
PatchPC builds the patch operators by assembling the bilineary form over
106+
These options specify an additive Schwarz relaxation through :class:`~.PatchPC`.
107+
:class:`~.PatchPC` builds the patch operators by assembling the bilineary form over
108108
each subdomain. Hence, it does not require the global stiffness
109109
matrix to be assembled.
110110
These options tell the patch mechanism to use vertex star patches, storing
@@ -128,7 +128,7 @@ in dense format.::
128128
"sub_pc_type": "lu"}},
129129
mat_type="matfree")
130130

131-
ASMStarPC, on the other hand, does no re-discretization, but extracts the
131+
:class:`~.ASMStarPC`, on the other hand, does no re-discretization, but extracts the
132132
patch operators for each patch from the already-assembled global stiffness matrix.
133133

134134

@@ -144,7 +144,7 @@ direct or Krylov method on each one.::
144144

145145
Now, for each parameter choice, we report the iteration count for the Poisson problem
146146
over a range of polynomial degrees. We see that the Jacobi relaxation leads to growth
147-
in iteration count, while both PatchPC and ASMStarPC do not. Mathematically, the two
147+
in iteration count, while both :class:`~.PatchPC` and :class:`~.ASMStarPC` do not. Mathematically, the two
148148
latter options do the same operations, just via different code paths.::
149149

150150
names = {"Jacobi": jacobi_relax,
@@ -173,7 +173,7 @@ For Jacobi, we expect output such as
173173
7 19
174174
======== ================
175175

176-
While for either PatchPC or ASMStarPC, we expect
176+
While for either :class:`~.PatchPC` or :class:`~.ASMStarPC`, we expect
177177

178178
======== ================
179179
Degree Iterations

demos/patch/stokes_vanka_patches.py.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ of the patch but not pressures.
1414
:align: center
1515

1616
In practice, we arrive at mesh-independent multigrid convergence using these relaxation.
17-
We can construct Vanka patches either through firedrake.PatchPC, in which the bilinear form
17+
We can construct Vanka patches either through :class:`~.PatchPC`, in which the bilinear form
1818
is assembled on each vertex patch, or through firedrake.ASMVankaPC, in which the patch
1919
operators are extracted from the globally assembled stiffness matrix.::
2020

@@ -62,7 +62,7 @@ on the coarsest level of the multigrid hierarchy.::
6262
}
6363

6464
When we use a matrix-free method, there will not be an assembled matrix to factor
65-
This forces the matrix to be assembled.::
65+
on the coarse level. This forces the matrix to be assembled.::
6666

6767
assembled_ldlt = {
6868
"ksp_type": "preonly",
@@ -94,8 +94,8 @@ relaxation options and matrix assembled type.::
9494
}
9595

9696

97-
These options specify an additive Schwarz relaxation through PatchPC.
98-
PatchPC builds the patch operators by assembling the bilineary form over
97+
These options specify an additive Schwarz relaxation through :class:`~.PatchPC`.
98+
:class:`~.PatchPC` builds the patch operators by assembling the bilineary form over
9999
each subdomain. Hence, it does not require the global stiffness
100100
matrix to be assembled. These are quite similar to the options used in
101101
<poisson_mg_patches.py>::
@@ -115,7 +115,7 @@ matrix to be assembled. These are quite similar to the options used in
115115
"pc_patch_precompute_element_tensors": None}},
116116
mat_type="matfree")
117117

118-
ASMStarPC, on the other hand, does no re-discretization, but extracts the
118+
:class:`~.ASMStarPC`, on the other hand, does no re-discretization, but extracts the
119119
patch operators for each patch from the already-assembled global stiffness matrix.::
120120

121121
asm_relax = mg_params(
@@ -133,7 +133,7 @@ direct or Krylov method on each one.
133133

134134
Now, for each parameter choice, we report the iteration count for the Poisson problem
135135
over a range of polynomial degrees. We see that the Jacobi relaxation leads to growth
136-
in iteration count, while both PatchPC and ASMStarPC do not. Mathematically, the two
136+
in iteration count, while both :class:`~.PatchPC` and :class:`~.ASMStarPC` do not. Mathematically, the two
137137
latter options do the same operations, just via different code paths.::
138138

139139
names = {"ASM Vanka": asm_relax,

0 commit comments

Comments
 (0)