chombo-discharge
Loading...
Searching...
No Matches
CD_KrylovBiCGStab.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_KRYLOVBICGSTAB_H
14#define CD_KRYLOVBICGSTAB_H
15
16// Chombo includes
17#include <LevelData.H>
18#include <Vector.H>
19
20// Our includes
22#include <CD_NamespaceHeader.H>
23
34template <class T>
36{
37public:
41 Real m_eps = 1.E-10;
42
46 int m_maxIter = 50;
47
52
56 int m_verbosity = -1;
57
61 int m_exitStatus = -1;
62
66 Real m_residualNorm = -1.0;
67
71 int m_iterations = 0;
72
78 Real m_residualScale = 1.0;
79
83 KrylovBiCGStab() noexcept = default;
84
88 ~KrylovBiCGStab() noexcept;
89
95 void
96 define(AMRMultigridKrylovOp<T>* a_op, const Vector<LevelData<T>*>& a_template) noexcept;
97
101 void
102 undefine() noexcept;
103
108 bool
109 isDefined() const noexcept;
110
117 bool
118 solve(Vector<LevelData<T>*>& a_phi, const Vector<LevelData<T>*>& a_rhs) noexcept;
119
120protected:
125
129 bool m_isDefined = false;
130
134 Vector<LevelData<T>*> m_r;
135
139 Vector<LevelData<T>*> m_rTilde;
140
144 Vector<LevelData<T>*> m_e;
145
149 Vector<LevelData<T>*> m_p;
150
154 Vector<LevelData<T>*> m_pTilde;
155
159 Vector<LevelData<T>*> m_sTilde;
160
164 Vector<LevelData<T>*> m_t;
165
169 Vector<LevelData<T>*> m_v;
170};
171
172#include <CD_NamespaceFooter.H>
173
175
176#endif
Linear-operator adapter that exposes an AMR-multigrid cycle as a Krylov preconditioner.
Implementation of CD_KrylovBiCGStab.H.
Adapter presenting an already-defined AMRMultiGrid as a LinearOp over the AMR hierarchy.
Definition CD_AMRMultigridKrylovOp.H:78
Preconditioned BiCGStab solver acting on an AMR hierarchy through AMRMultigridKrylovOp.
Definition CD_KrylovBiCGStab.H:36
KrylovBiCGStab() noexcept=default
Default constructor. Call define() before use.
Vector< LevelData< T > * > m_p
Search direction.
Definition CD_KrylovBiCGStab.H:149
int m_exitStatus
Exit status after solve(): 1 = converged, 2 = breakdown, 3 = max iterations, -1 = not run.
Definition CD_KrylovBiCGStab.H:61
Vector< LevelData< T > * > m_pTilde
Preconditioned search direction.
Definition CD_KrylovBiCGStab.H:154
bool isDefined() const noexcept
Whether define() has been called and the work vectors are allocated.
Definition CD_KrylovBiCGStabImplem.H:73
Vector< LevelData< T > * > m_e
Accumulated correction (added to a_phi at the end).
Definition CD_KrylovBiCGStab.H:144
Real m_residualNorm
Final residual norm after solve() (in the adapter inner-product norm).
Definition CD_KrylovBiCGStab.H:66
bool solve(Vector< LevelData< T > * > &a_phi, const Vector< LevelData< T > * > &a_rhs) noexcept
Solve a_op(a_phi) = a_rhs (homogeneous operator) with preconditioned BiCGStab.
Definition CD_KrylovBiCGStabImplem.H:80
int m_maxIter
Maximum number of iterations.
Definition CD_KrylovBiCGStab.H:46
Vector< LevelData< T > * > m_t
A*s_tilde.
Definition CD_KrylovBiCGStab.H:164
int m_numRestarts
Maximum number of restarts on breakdown.
Definition CD_KrylovBiCGStab.H:51
void undefine() noexcept
Free the persistent work vectors.
Definition CD_KrylovBiCGStabImplem.H:55
Vector< LevelData< T > * > m_rTilde
Shadow residual.
Definition CD_KrylovBiCGStab.H:139
Real m_residualScale
Display normalization for printed residuals (set to the zero-residual by the driver; 1 = print absolu...
Definition CD_KrylovBiCGStab.H:78
Vector< LevelData< T > * > m_r
Residual / s.
Definition CD_KrylovBiCGStab.H:134
int m_verbosity
Verbosity; at >= 4 a terse one-line-per-iteration residual/rate history is printed.
Definition CD_KrylovBiCGStab.H:56
Real m_eps
Relative residual tolerance (against the initial residual norm).
Definition CD_KrylovBiCGStab.H:41
Vector< LevelData< T > * > m_sTilde
Preconditioned s.
Definition CD_KrylovBiCGStab.H:159
Vector< LevelData< T > * > m_v
A*p_tilde.
Definition CD_KrylovBiCGStab.H:169
int m_iterations
Number of iterations performed by the last solve().
Definition CD_KrylovBiCGStab.H:71
void define(AMRMultigridKrylovOp< T > *a_op, const Vector< LevelData< T > * > &a_template) noexcept
Allocate the persistent work vectors. Call once per regrid.
Definition CD_KrylovBiCGStabImplem.H:32
AMRMultigridKrylovOp< T > * m_op
Operator/adapter (not owned).
Definition CD_KrylovBiCGStab.H:124
bool m_isDefined
Whether the work vectors are allocated.
Definition CD_KrylovBiCGStab.H:129