|
| 1 | +""" |
| 2 | + AbstractErrorControl |
| 3 | +
|
| 4 | +Abstract type for different error control methods. |
| 5 | +""" |
| 6 | +abstract type AbstractErrorControl end |
| 7 | + |
| 8 | +""" |
| 9 | + GlobalErrorControlMethod |
| 10 | +
|
| 11 | +Abstract type for different global error control methods, and according to the different global error estimation methods, there are |
| 12 | +
|
| 13 | + - `HOErrorControl`: Higher order global error estimation method |
| 14 | + - `REErrorControl`: Richardson extrapolation global error estimation method |
| 15 | +""" |
| 16 | +abstract type GlobalErrorControlMethod end |
| 17 | + |
| 18 | +""" |
| 19 | + DefectControl(; defect_threshold = 0.1) |
| 20 | +
|
| 21 | +Defect estimation method with defect defined as |
| 22 | +
|
| 23 | +```math |
| 24 | +defect = \\max\\frac{S'(x) - f(x,S(x))}{1 + |f(x,S(x))|} |
| 25 | +``` |
| 26 | +
|
| 27 | +Defect controller, with the maximum `defect_threshold` as 0.1, when the estimating defect is greater than the `defect_threshold`, the mesh will be refined. |
| 28 | +""" |
| 29 | +struct DefectControl{T} <: AbstractErrorControl |
| 30 | + defect_threshold::T |
| 31 | + |
| 32 | + function DefectControl(; defect_threshold = 0.1) |
| 33 | + return new{typeof(defect_threshold)}(defect_threshold) |
| 34 | + end |
| 35 | +end |
| 36 | + |
| 37 | +""" |
| 38 | + GlobalErrorControl(; method = HOErorControl()) |
| 39 | +
|
| 40 | +Global error controller, use high order global error estimation method `HOErrorControl` as default. |
| 41 | +""" |
| 42 | +struct GlobalErrorControl <: AbstractErrorControl |
| 43 | + method::GlobalErrorControlMethod |
| 44 | + |
| 45 | + function GlobalErrorControl(; method = HOErrorControl()) |
| 46 | + return new(method) |
| 47 | + end |
| 48 | +end |
| 49 | + |
| 50 | +""" |
| 51 | + SequentialErrorControl(; defect = DefectControl(), global_error = GlobalErrorControl()) |
| 52 | +
|
| 53 | +First use the defect controller, if the defect is satisfying, then use global error controller. |
| 54 | +""" |
| 55 | +struct SequentialErrorControl <: AbstractErrorControl |
| 56 | + defect::DefectControl |
| 57 | + global_error::GlobalErrorControl |
| 58 | + |
| 59 | + function SequentialErrorControl(; |
| 60 | + defect = DefectControl(), global_error = GlobalErrorControl()) |
| 61 | + return new(defect, global_error) |
| 62 | + end |
| 63 | +end |
| 64 | + |
| 65 | +""" |
| 66 | + HybridErrorControl(; DE = 1.0, GE = 1.0, defect = DefectControl(), global_error = GlobalErrorControl()) |
| 67 | +
|
| 68 | +Control both of the defect and global error, where the error norm is the linear combination of the defect and global error. |
| 69 | +""" |
| 70 | +struct HybridErrorControl{T1, T2} <: AbstractErrorControl |
| 71 | + DE::T1 |
| 72 | + GE::T2 |
| 73 | + defect::DefectControl |
| 74 | + global_error::GlobalErrorControl |
| 75 | + |
| 76 | + function HybridErrorControl(; DE = 1.0, GE = 1.0, defect = DefectControl(), |
| 77 | + global_error = GlobalErrorControl()) |
| 78 | + return new{typeof(DE), typeof(GE)}(DE, GE, defect, global_error) |
| 79 | + end |
| 80 | +end |
| 81 | + |
| 82 | +""" |
| 83 | + HOErrorControl() |
| 84 | +
|
| 85 | +Higher order global error estimation method |
| 86 | +
|
| 87 | +Uses a solution from order+2 method on the original mesh and calculate the error with |
| 88 | +
|
| 89 | +```math |
| 90 | +error = \\max\\frac{u_p - u_{p+2}}{1 + |u_p|} |
| 91 | +``` |
| 92 | +""" |
| 93 | +struct HOErrorControl <: GlobalErrorControlMethod end |
| 94 | + |
| 95 | +""" |
| 96 | + REErrorControl() |
| 97 | +
|
| 98 | +Richardson extrapolation global error estimation method |
| 99 | +
|
| 100 | +Use Richardson extrapolation to calculate the error on the doubled mesh with |
| 101 | +
|
| 102 | +```math |
| 103 | +error = \\frac{2^p}{2^p-1} * \\max\\frac{u_h - u_{h/2}}{1 + |u_h|} |
| 104 | +``` |
| 105 | +""" |
| 106 | +struct REErrorControl <: GlobalErrorControlMethod end |
| 107 | + |
| 108 | +# Some utils for error control adaptivity |
| 109 | +# If error control use both defect and global error or not |
| 110 | +@inline __use_both_error_control(::HybridErrorControl) = true |
| 111 | +@inline __use_both_error_control(_) = false |
0 commit comments