@@ -5,6 +5,10 @@ This is the reference for combining pySDC with finite elements. It shows SDC, ML
55three FEniCS problems, using the **mass-matrix formulation throughout ** -- the mass matrix is never
66inverted, anywhere.
77
8+ Each problem comes with continuous (``CG ``) and discontinuous (``DG ``) elements, and each hierarchy
9+ can be coarsened in either direction: a coarser mesh at fixed element order (**h **), or a lower
10+ element order on the same mesh (**p **).
11+
812What is here
913------------
1014
@@ -15,8 +19,16 @@ What is here
1519 - ``burgers `` -- viscous Burgers in 1D, fully implicit with a node-local Newton.
1620 - ``grayscott `` -- Gray-Scott reaction-diffusion in 1D, fully implicit with a node-local Newton.
1721
22+ ``get_description(example, nlevels, family, coarsening) `` builds any of the twelve combinations.
23+
24+ ``problem_classes/DG_1D_FEniCS.py ``
25+ The DG counterparts of all three: interior penalty for diffusion, Nitsche for Dirichlet data,
26+ a Lax-Friedrichs flux for the Burgers advection. Each is its CG parent with the weak form
27+ replaced -- the Newton loop, the mass matrix and the solver interface are inherited unchanged.
28+
1829``run_examples.py ``
19- Runs each example with SDC, MLSDC on 2 and 3 levels, and PFASST on up to 8 parallel steps.
30+ Runs every example, family and coarsening direction with SDC, MLSDC on 2 and 3 levels, and
31+ PFASST on up to 8 parallel steps. Takes about four minutes.
2032
2133``tests/ ``
2234 Asserts the claims below, so they stay true.
@@ -41,18 +53,22 @@ and a problem class whose ``eval_f`` returns the assembled weak form rather than
4153:math: `M^{-1 }F`, whose ``solve_system `` takes a right-hand side that is already in the dual space,
4254and which implements ``apply_mass_matrix ``.
4355
44- Coarsen by **mesh refinement ** and keep the collocation nodes on every level.
56+ Then: **high order, coarsened in h. ** CG or DG, they perform identically. The rest of this file is
57+ why, and what it took to make the DG half true.
58+
59+ Use high-order elements
60+ -----------------------
4561
46- ** Use high-order elements. ** This is not a detail: it is what makes the multilevel hierarchy pay at
47- all. At * identical * fine-level dof counts, with only the element order changed:
62+ This is not a detail: it is what makes the multilevel hierarchy pay at all. At * identical *
63+ fine-level dof counts, with only the element order changed:
4864
49- ============= ============== ============== = =============
50- example CG1 CG2 CG4
51- ============= ============== ============== = =============
52- ``heat `` 0.92x / 1.05x 1.22x / 1.05x 1.22x / 1.57x
53- ``burgers `` 0.89x / 0.76x 0.94x / 0.81x 1.26x / 1.94x
54- ``grayscott `` 0.87x / 0.74x 0.87x / 0.74x 1.24x / 1.24x
55- ============= ============== ============== = =============
65+ ============= ============= ============= =============
66+ example CG1 CG2 CG4
67+ ============= ============= ============= =============
68+ ``heat `` 0.92x / 1.05x 1.22x / 1.05x 1.22x / 1.57x
69+ ``burgers `` 0.89x / 0.76x 0.94x / 0.81x 1.26x / 1.94x
70+ ``grayscott `` 0.87x / 0.74x 0.87x / 0.74x 1.24x / 1.24x
71+ ============= ============= ============= =============
5672
5773(speed-up at 2 / 3 levels; below 1.00x means MLSDC costs more than SDC)
5874
@@ -66,10 +82,109 @@ The natural prolongation between nested finite element spaces **is** the inclusi
6682approximation order is the element order. So "use CG4" here and "use ``iorder=6 ``" there are the same
6783statement about the same operator.
6884
85+ Coarsen in h, not in p
86+ ----------------------
87+
88+ The same statement, pointed at the coarsening direction. Both ladders are nested, and with CG both
89+ halve the dof count per level -- ``CG4 `` on meshes of 512/256/128 cells against ``CG4/CG2/CG1 `` on
90+ 512 cells give the identical 2049/1025/513 -- so for CG the two cost exactly the same per iteration
91+ and only the quality of the coarse space differs. (With DG the p ladder cannot halve: order 4/2/1
92+ means 5/3/2 dofs per cell, so p-coarsening is charged more there as well.)
93+
94+ ============== ========== ============== ==============
95+ config SDC (work) MLSDC 2 levels MLSDC 3 levels
96+ ============== ========== ============== ==============
97+ heat CG h 5.75 4.50 (1.28x) 3.50 (1.64x)
98+ heat DG h 5.75 4.50 (1.28x) 3.50 (1.64x)
99+ heat CG p 5.75 4.50 (1.28x) 5.25 (1.09x)
100+ heat DG p 5.75 4.80 (1.20x) 6.00 (0.96x)
101+ burgers CG h 4.12 3.19 (1.29x) 1.97 (2.09x)
102+ burgers DG h 4.12 3.19 (1.29x) 1.97 (2.10x)
103+ burgers CG p 4.12 4.50 (0.92x) 5.25 (0.79x)
104+ burgers DG p 4.12 4.80 (0.86x) 6.00 (0.69x)
105+ grayscott CG h 6.50 5.44 (1.20x) 5.47 (1.19x)
106+ grayscott DG h 6.50 5.44 (1.20x) 5.47 (1.19x)
107+ grayscott CG p 6.50 7.50 (0.87x) 8.76 (0.74x)
108+ grayscott DG p 6.50 8.00 (0.81x) 10.00 (0.65x)
109+ ============== ========== ============== ==============
110+
111+ (work = iterations x summed dof ratio, so every level is charged for what it costs)
112+
113+ h-coarsening wins in every one of the six cases. The reason is the one above: dropping from ``CG4 ``
114+ to ``CG2 `` to ``CG1 `` on a fixed mesh leaves a coarse space with :math: `O(h^2 )` approximation error,
115+ while keeping ``CG4 `` and doubling the cell size gives :math: `O((2 h)^5 )`. The coarse level is there
116+ to resolve the smooth part of the error, and a low order resolves it badly however fine the mesh.
117+
118+ Note also that p-coarsening never gets past the second level: two levels are close to h-coarsening,
119+ three are worse than two. ``CG2 `` still approximates the smooth error; ``CG1 `` does not.
120+
121+ CG or DG
122+ --------
123+
124+ Identical, once the DG hierarchy is built correctly. Same iteration counts, same speed-ups, same
125+ PFASST growth, on all three examples -- read the table above in pairs.
126+
127+ That took two fixes, both of which CG gets for free and neither of which shows up in a
128+ discretisation test. Both are in the defect list below, items 5 and 6. Before them, DG looked like a
129+ dead end:
130+
131+ ========================= ================ ================== ================
132+ DG, h-coarsening broken hierarchy Galerkin hierarchy CG for reference
133+ ========================= ================ ================== ================
134+ heat, 3 levels 1.10x 1.64x 1.64x
135+ burgers, 3 levels 0.79x 2.10x 2.09x
136+ grayscott, 3 levels 0.65x 1.19x 1.19x
137+ heat, PFASST 8 steps 12.88 iters 4.62 iters 4.62 iters
138+ burgers, PFASST 8 steps 13.50 iters 4.12 iters 4.12 iters
139+ grayscott, PFASST 8 steps did not converge 6.75 iters 6.00 iters
140+ ========================= ================ ================== ================
141+
142+ The one honest difference that remains: at the same mesh and order DG carries 25% more dofs (5 per
143+ cell against 4) for the same accuracy, because these solutions are smooth. Same iterations, more
144+ work per iteration. DG earns those dofs on discontinuities and on advection-dominated transport,
145+ which none of these examples have -- so use it here only if you want it for other reasons, and know
146+ that the multilevel machinery will not hold you back.
147+
148+ The penalty constant :math: `\sigma ` is not a tuning knob. Sweeping it over 1, 2, 5, 10, 40 changes
149+ nothing above the coercivity threshold; only :math: `\sigma = 1 ` sits below it and wrecks the coarse
150+ correction. Set it just clear of the threshold and stop thinking about it. What matters is not how
151+ big it is but that it is *the same on every level *, which is item 6.
152+
153+ What it demonstrates
154+ --------------------
155+
156+ **Savings ** -- see the table above. A third level pays clearly on the smooth problems and is neutral
157+ on Gray-Scott. Expect less from a multilevel hierarchy the more nonlinear the problem is.
158+
159+ **Stability ** -- PFASST iteration counts as parallel steps are added, every run agreeing with serial
160+ to the tolerance of the example:
161+
162+ ============== ====== ==== ==== =====
163+ config 1 step 2 4 8
164+ ============== ====== ==== ==== =====
165+ heat CG h 3.00 3.38 3.88 4.62
166+ heat DG h 3.00 3.38 3.88 4.62
167+ heat CG p 3.00 3.50 4.00 4.75
168+ heat DG p 3.00 3.50 4.00 4.75
169+ burgers CG h 2.12 2.62 3.25 4.12
170+ burgers DG h 2.12 2.62 3.25 4.12
171+ burgers CG p 3.00 3.00 3.38 4.12
172+ burgers DG p 3.00 3.00 3.38 4.12
173+ grayscott CG h 3.62 3.88 4.50 6.00
174+ grayscott DG h 3.62 4.00 4.75 6.75
175+ grayscott CG p 5.00 5.62 6.88 9.25
176+ grayscott DG p 5.00 6.00 8.12 12.12
177+ ============== ====== ==== ==== =====
178+
179+ Growth out to 8 parallel steps is 1.4-2.4x, which is what PFASST is supposed to do.
180+
69181Why earlier attempts did not pay off
70182------------------------------------
71183
72- Four separate defects, each of which quietly capped or broke the multilevel gain:
184+ Six separate defects, each of which quietly capped or broke the multilevel gain. Note what they have
185+ in common: every one of them leaves a method that still converges, still to the right answer, with a
186+ coarse level that corrects far less than it should. None of them is visible in a discretisation
187+ test, and none of them raises anything.
73188
741891. **The FAS ** :math: `\tau ` **was restricted by interpolation. ** :math: `\tau ` is a load vector, not a
75190 nodal function, so it has to be restricted with :math: `P^T`. Interpolating it is wrong by roughly
@@ -82,38 +197,27 @@ Four separate defects, each of which quietly capped or broke the multilevel gain
82197 asymptotically inert -- it can neither help nor hurt, and it masks a broken transfer. Combined
83198 with ``Problem.apply_mass_matrix `` silently defaulting to the identity, a wrong mass matrix
84199 produced a stalled iteration many sweeps later rather than an error.
200+ 5. **The prolongation was not the inclusion, for DG. ** ``mesh_to_mesh_fenics `` built :math: `P` with
201+ ``df.interpolate ``. Across meshes that is point evaluation, and a fine dof sitting *on * a coarse
202+ facet has two coarse values there -- dolfin returns whichever cell the bounding-box tree finds
203+ first. The prolonged function is therefore continuous at every coarse facet: the jumps, which are
204+ the whole point of a DG space, are deleted. The error is :math: `O(1 )` in the jump and exactly
205+ zero for smooth data, which is why it survived a convergence test at
206+ :math: `O(h^{p+1 })`. :math: `P` is now assembled cell by cell, evaluating the coarse basis in the
207+ coarse cell that *contains * each fine cell. For continuous spaces this reproduces the old
208+ construction to machine precision.
209+ 6. **The interior penalty was rediscretised on every level. ** The CG bilinear form does not know
210+ which mesh it lives on, so rediscretising it on a coarse level gives exactly the Galerkin
211+ operator :math: `P^T A_F P`. The SIPG form does know: its penalty scales as
212+ :math: `\sigma p^2 / h`, so a coarser mesh halves it and a lower order divides it by
213+ :math: `(p_f/p_c)^2 `. That is not a small perturbation -- the penalty outweighs the volume term by
214+ :math: `\sigma p^2 `, so the coarse operator was wrong in its *dominant * term and corrected almost
215+ nothing. ``setups.py `` now pins :math: `\alpha _l = \sigma p_0 ^2 \, h_l / h_0 ` so that
216+ :math: `\alpha _l / h_l` is the same on every level. With that and item 5,
217+ :math: `A_G = P^T A_F P` holds to machine precision, for both coarsening directions.
85218
86219Nodes are kept on every level here for a further reason: partial node coarsening (5 -> 4, 5 -> 3) is
87220worse than no coarse level at all, because it destroys the stiff-limit annihilation that the ``LU ``
88221preconditioner provides.
89222
90- What it demonstrates
91- --------------------
92-
93- **Savings ** (work = iterations x summed dof ratio, so a coarse level is charged for what it costs):
94-
95- ============= ========== ========== ==========
96- example SDC MLSDC (2) MLSDC (3)
97- ============= ========== ========== ==========
98- ``heat `` 5.75 3.00 2.00
99- speed-up 1.00x 1.28x **1.64x **
100- ``burgers `` 4.12 2.12 1.12
101- speed-up 1.00x 1.29x **2.09x **
102- ``grayscott `` 6.50 3.62 3.12
103- speed-up 1.00x 1.20x 1.19x
104- ============= ========== ========== ==========
105-
106- A third level pays clearly on the smooth problems and is neutral on Gray-Scott. Expect less from a
107- multilevel hierarchy the more nonlinear the problem is.
108-
109- **Stability ** -- PFASST iteration counts as parallel steps are added, every run agreeing with serial:
110-
111- ============= ====== ====== ====== ======
112- example 1 step 2 4 8
113- ============= ====== ====== ====== ======
114- ``heat `` 3.00 3.38 3.88 4.62
115- ``burgers `` 2.12 2.62 3.25 4.12
116- ``grayscott `` 3.62 3.88 4.50 6.00
117- ============= ====== ====== ====== ======
118-
119223Settings are sized for CI runtime, not for a production run. Reproduce with ``run_examples.py ``.
0 commit comments