Skip to content

Commit 774aedf

Browse files
committed
Cleanup
1 parent e1daada commit 774aedf

File tree

3 files changed

+185
-238
lines changed

3 files changed

+185
-238
lines changed

demos/goal_based_adaptivity_bvp/goal_based_adaptivity_bvp.py.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ We now specify options for how the goal-based adaptivity should proceed. We choo
6868
where the adjoint solution is approximated in a higher-degree function space, and where both the adjoint and primal residuals
6969
are employed for the error estimate. This requires four solves on every grid (primal and adjoint solutions with degree :math:`p`
7070
and :math:`p+1`), and gives a provably efficient and reliable error estimator under a saturation assumption up to a term that is cubic in the error :cite:`Endtmayer2024`.
71-
It is possible to employ cheaper and more practical approximations by setting the parameters for the :code:`GoalAdaptiveNonlinearVariationalSolver`
71+
It is possible to employ cheaper and more practical approximations by setting the options for the :code:`GoalAdaptiveNonlinearVariationalSolver`
7272
appropriately, as discussed below. ::
7373

74-
dwr_parameters = {
74+
goal_adaptive_options = {
7575
"max_iterations": 100,
7676
"use_adjoint_residual": True,
7777
"dual_low_method": "solve",
7878
"primal_low_method": "solve",
7979
"dorfler_alpha": 0.5,
8080
"dual_extra_degree": 1,
8181
"run_name": "p-laplace",
82-
"output_dir": "output/p-laplace",
82+
"output_dir": "./output",
8383
}
8484

8585
We then solve the problem, passing the goal functional :math:`J` and our specified tolerance. We also pass the exact solution, so that
@@ -88,9 +88,10 @@ the DWR automation can compute effectivity indices, but this is not generally re
8888
tolerance = 1e-4
8989
problem = NonlinearVariationalProblem(F, u, bcs)
9090

91-
adaptive_solver = GoalAdaptiveNonlinearVariationalSolver(problem, J, tolerance, dwr_parameters,
92-
exact_solution=u_exact,
93-
primal_solver_parameters=solver_parameters)
91+
adaptive_solver = GoalAdaptiveNonlinearVariationalSolver(problem, J, tolerance,
92+
goal_adaptive_options=goal_adaptive_options,
93+
primal_solver_parameters=solver_parameters,
94+
exact_solution=u_exact)
9495
adaptive_solver.solve()
9596

9697
The initial error in the goal functional is :math:`-3.5 \times 10^{-2}`. The solver terminates with the goal functional computed to :math:`10^{-4}` after 4 refinements. Each nonlinear solve only required one Newton iteration. The error estimates :math:`\eta` are very accurate: their effectivity indices
@@ -123,7 +124,7 @@ Changing the tolerance to :math:`10^{-8}` takes 40 refinements. The resulting me
123124
:align: center
124125
:width: 60%
125126

126-
We now discuss more practical variants. The configuration above solves four PDEs per adaptive step (primal and adjoint, degree :math:`p` and :math:`p+1`). Changing the DWR parameters to `{"use_adjoint_residual": False, "dual_low_method": "interpolate"}` instead only solves two PDEs per adaptive step (primal at degree :math:`p`, and adjoint at degree :math:`p+1`), and is thus much faster. For this problem with tolerance :math:`10^{-4}` this barely makes a difference to the effectivity indices: most are around 1, with only one step where :math:`I \approx 1.25`. We therefore recommend this as the default settings for production use.
127+
We now discuss more practical variants. The configuration above solves four PDEs per adaptive step (primal and adjoint, degree :math:`p` and :math:`p+1`). Changing `goal_adaptive_options` to `{"use_adjoint_residual": False, "dual_low_method": "interpolate"}` instead only solves two PDEs per adaptive step (primal at degree :math:`p`, and adjoint at degree :math:`p+1`), and is thus much faster. For this problem with tolerance :math:`10^{-4}` this barely makes a difference to the effectivity indices: most are around 1, with only one step where :math:`I \approx 1.25`. We therefore recommend this as the default settings for production use.
127128

128129
:demo:`A Python script version of this demo can be found here
129130
<goal_based_adaptivity_bvp.py>`.

0 commit comments

Comments
 (0)