1+ # Linear Verbosity
2+
3+ const linear_defaults = Dict {Symbol, Verbosity.Type} (
4+ :default_lu_fallback => Verbosity. Warn (),
5+ :no_right_preconditioning => Verbosity. Warn (),
6+ :using_iterative_solvers => Verbosity. Warn (),
7+ :using_IterativeSolvers => Verbosity. Warn (),
8+ :IterativeSolvers_iterations => Verbosity. Warn (),
9+ :KrylovKit_verbosity => Verbosity. Warn (),
10+ :KrylovJL_verbosity => Verbosity. None (),
11+ :HYPRE_verbosity => Verbosity. Level (1 ),
12+ :pardiso_verbosity => Verbosity. None ()
13+ )
14+ mutable struct LinearErrorControlVerbosity
15+ default_lu_fallback:: Verbosity.Type
16+
17+ function LinearErrorControlVerbosity (;
18+ default_lu_fallback = linear_defaults[:default_lu_fallback ])
19+ new (default_lu_fallback)
20+ end
21+
22+ function LinearErrorControlVerbosity (verbose:: Verbosity.Type )
23+ @match verbose begin
24+ Verbosity. None () => new (fill (
25+ Verbosity. None (), length (fieldnames (LinearErrorControlVerbosity)))... )
26+
27+ Verbosity. Info () => new (fill (
28+ Verbosity. Info (), length (fieldnames (LinearErrorControlVerbosity)))... )
29+
30+ Verbosity. Warn () => new (fill (
31+ Verbosity. Warn (), length (fieldnames (LinearErrorControlVerbosity)))... )
32+
33+ Verbosity. Error () => new (fill (
34+ Verbosity. Error (), length (fieldnames (LinearErrorControlVerbosity)))... )
35+
36+ Verbosity. Default () => LinearErrorControlVerbosity ()
37+
38+ Verbosity. Edge () => LinearErrorControlVerbosity ()
39+
40+ _ => @error " Not a valid choice for verbosity."
41+ end
42+ end
43+ end
44+
45+ mutable struct LinearPerformanceVerbosity
46+ no_right_preconditioning:: Verbosity.Type
47+
48+ function LinearPerformanceVerbosity (;
49+ no_right_preconditioning = linear_defaults[:no_right_preconditioning ])
50+ new (no_right_preconditioning)
51+ end
52+
53+ function LinearPerformanceVerbosity (verbose:: Verbosity.Type )
54+ @match verbose begin
55+ Verbosity. None () => new (fill (
56+ Verbosity. None (), length (fieldnames (LinearPerformanceVerbosity)))... )
57+
58+ Verbosity. Info () => new (fill (
59+ Verbosity. Info (), length (fieldnames (LinearPerformanceVerbosity)))... )
60+
61+ Verbosity. Warn () => new (fill (
62+ Verbosity. Warn (), length (fieldnames (LinearPerformanceVerbosity)))... )
63+
64+ Verbosity. Error () => new (fill (
65+ Verbosity. Error (), length (fieldnames (LinearPerformanceVerbosity)))... )
66+
67+ Verbosity. Default () => LinearPerformanceVerbosity ()
68+
69+ Verbosity. Edge () => LinearPerformanceVerbosity ()
70+
71+ _ => @error " Not a valid choice for verbosity."
72+ end
73+ end
74+ end
75+
76+ mutable struct LinearNumericalVerbosity
77+ using_IterativeSolvers:: Verbosity.Type
78+ IterativeSolvers_iterations:: Verbosity.Type
79+ KrylovKit_verbosity:: Verbosity.Type
80+ KrylovJL_verbosity:: Verbosity.Type
81+ HYPRE_verbosity:: Verbosity.Type
82+ pardiso_verbosity:: Verbosity.Type
83+
84+ function LinearNumericalVerbosity (;
85+ using_IterativeSolvers = linear_defaults[:using_IterativeSolvers ],
86+ IterativeSolvers_iterations = linear_defaults[:IterativeSolvers_iterations ],
87+ KrylovKit_verbosity = linear_defaults[:KrylovKit_verbosity ],
88+ KrylovJL_verbosity = linear_defaults[:KrylovJL_verbosity ],
89+ HYPRE_verbosity = linear_defaults[:HYPRE_verbosity ],
90+ pardiso_verbosity = linear_defaults[:pardiso_verbosity ])
91+ new (using_IterativeSolvers, IterativeSolvers_iterations,
92+ KrylovKit_verbosity, KrylovJL_verbosity, HYPRE_verbosity, pardiso_verbosity)
93+ end
94+
95+ function LinearNumericalVerbosity (verbose:: Verbosity.Type )
96+ @match verbose begin
97+ Verbosity. None () => new (fill (
98+ Verbosity. None (), length (fieldnames (LinearNumericalVerbosity)))... )
99+
100+ Verbosity. Info () => new (fill (
101+ Verbosity. Info (), length (fieldnames (LinearNumericalVerbosity)))... )
102+
103+ Verbosity. Warn () => new (fill (
104+ Verbosity. Warn (), length (fieldnames (LinearNumericalVerbosity)))... )
105+
106+ Verbosity. Error () => new (fill (
107+ Verbosity. Error (), length (fieldnames (LinearNumericalVerbosity)))... )
108+
109+ Verbosity. Default () => LinearNumericalVerbosity ()
110+
111+ Verbosity. Edge () => LinearNumericalVerbosity ()
112+
113+ _ => @error " Not a valid choice for verbosity."
114+ end
115+ end
116+ end
117+
118+ struct LinearVerbosity{T} <: AbstractVerbositySpecifier{T}
119+ error_control:: LinearErrorControlVerbosity
120+ performance:: LinearPerformanceVerbosity
121+ numerical:: LinearNumericalVerbosity
122+ end
123+
124+ function LinearVerbosity (verbose:: Verbosity.Type )
125+ @match verbose begin
126+ Verbosity. Default () => LinearVerbosity {true} (
127+ LinearErrorControlVerbosity (Verbosity. Default ()),
128+ LinearPerformanceVerbosity (Verbosity. Default ()),
129+ LinearNumericalVerbosity (Verbosity. Default ())
130+ )
131+
132+ Verbosity. None () => LinearVerbosity {false} (
133+ LinearErrorControlVerbosity (Verbosity. None ()),
134+ LinearPerformanceVerbosity (Verbosity. None ()),
135+ LinearNumericalVerbosity (Verbosity. None ()))
136+
137+ Verbosity. All () => LinearVerbosity {true} (
138+ LinearErrorControlVerbosity (Verbosity. Info ()),
139+ LinearPerformanceVerbosity (Verbosity. Info ()),
140+ LinearNumericalVerbosity (Verbosity. Info ())
141+ )
142+
143+ _ => @error " Not a valid choice for LinearVerbosity. Available choices are `Default`, `None`, and `All`."
144+ end
145+ end
146+
147+ function LinearVerbosity (;
148+ error_control = Verbosity. Default (), performance = Verbosity. Default (),
149+ numerical = Verbosity. Default (), kwargs... )
150+ if error_control isa Verbosity. Type
151+ error_control_verbosity = LinearErrorControlVerbosity (error_control)
152+ else
153+ error_control_verbosity = error_control
154+ end
155+
156+ if performance isa Verbosity. Type
157+ performance_verbosity = LinearPerformanceVerbosity (performance)
158+ else
159+ performance_verbosity = performance
160+ end
161+
162+ if numerical isa Verbosity. Type
163+ numerical_verbosity = LinearNumericalVerbosity (numerical)
164+ else
165+ numerical_verbosity = numerical
166+ end
167+
168+ if ! isempty (kwargs)
169+ for (key, value) in pairs (kwargs)
170+ if hasfield (LinearErrorControlVerbosity, key)
171+ setproperty! (error_control_verbosity, key, value)
172+ elseif hasfield (LinearPerformanceVerbosity, key)
173+ setproperty! (performance_verbosity, key, value)
174+ elseif hasfield (LinearNumericalVerbosity, key)
175+ setproperty! (numerical_verbosity, key, value)
176+ else
177+ error (" $key is not a recognized verbosity toggle." )
178+ end
179+ end
180+ end
181+
182+ LinearVerbosity {true} (error_control_verbosity,
183+ performance_verbosity, numerical_verbosity)
184+ end
0 commit comments