52 "NekLinSysIterGMRES local storage solver.");
104 int niterations =
DoGMRES(nLocal, pInput, pOutput);
137 bool restarted =
false;
138 bool truncted =
false;
145 for (
int nrestart = 0; nrestart <
m_maxrestart; ++nrestart)
147 eps =
DoGmresRestart(restarted, truncted, nLocal, pInput, pOutput);
179 cout << std::scientific << std::setw(nwidthcolm)
180 << std::setprecision(nwidthcolm - 8)
186 cout <<
" WITH (GMRES eps = " << eps <<
" REAL eps= " << eps1
191 cout <<
" CONVERGED" << endl;
195 cout <<
" WARNING: Exceeded maxIt" << endl;
208 const bool restarted,
const bool truncted,
const int nLocal,
277 ASSERTL0(
false,
"Need to set up/debugging");
301 if (truncted && (starttem) > 0)
303 id_start[nd] = starttem;
312 alpha = 1.0 / eta[0];
350 starttem = id_start[idtem];
351 endtem = id_end[idtem];
353 DoArnoldi(starttem, endtem, nLocal,
w, wk, V1, V2, h1);
357 starttem = starttem - 1;
364 eps = eta[nd + 1] * eta[nd + 1];
390 for (
int i = 0; i < nswp; ++i)
402 Vmath::Vadd(nLocal, solution, 1, pOutput, 1, pOutput, 1);
431 for (
int i = starttem; i < endtem; ++i)
442 beta = -1.0 * vExchange;
452 h[endtem] =
sqrt(vExchange);
454 alpha = 1.0 / h[endtem];
469 int idtem = endtem - 1;
475 for (
int i = starttem; i < idtem; ++i)
477 temp_dbl = c[i] * h[i] - s[i] * h[i + 1];
478 h[i + 1] = s[i] * h[i] + c[i] * h[i + 1];
488 else if (
abs(hh) >
abs(dd))
491 s[idtem] = 1.0 /
sqrt(1.0 + temp_dbl * temp_dbl);
492 c[idtem] = temp_dbl * s[idtem];
497 c[idtem] = 1.0 /
sqrt(1.0 + temp_dbl * temp_dbl);
498 s[idtem] = temp_dbl * c[idtem];
501 h[idtem] = c[idtem] * h[idtem] - s[idtem] * h[endtem];
504 temp_dbl = c[idtem] * eta[idtem] - s[idtem] * eta[endtem];
505 eta[endtem] = s[idtem] * eta[idtem] + c[idtem] * eta[endtem];
506 eta[idtem] = temp_dbl;
520 int maxid = number - 1;
522 y[maxid] = b[maxid] /
A[maxid][maxid];
523 for (
int i = maxid - 1; i > -1; --i)
526 for (
int j = i + 1; j < number; ++j)
529 sum -= y[j] *
A[j][i];
531 y[i] = sum /
A[i][i];
#define WARNINGL1(condition, msg)
#define ASSERTL0(condition, msg)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static NekLinSysIterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vRowComm, const int nDimen, const NekSysKey &pKey)
int m_KrylovMaxHessMatBand
Array< OneD, Array< OneD, NekDouble > > m_V_total
NekDouble DoGmresRestart(const bool restarted, const bool truncted, const int nLocal, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Actual iterative gmres solver for one restart.
bool m_NekLinSysLeftPrecon
void DoArnoldi(const int starttem, const int endtem, const int nLocal, Array< OneD, NekDouble > &w, Array< OneD, NekDouble > &wk, Array< OneD, NekDouble > &V1, Array< OneD, NekDouble > &V2, Array< OneD, NekDouble > &h)
void DoBackward(const int number, Array< OneD, Array< OneD, NekDouble > > &A, const Array< OneD, const NekDouble > &b, Array< OneD, NekDouble > &y)
static std::string className
void DoGivensRotation(const int starttem, const int endtem, Array< OneD, NekDouble > &c, Array< OneD, NekDouble > &s, Array< OneD, NekDouble > &h, Array< OneD, NekDouble > &eta)
int v_SolveSystem(const int nLocal, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int nDir, const NekDouble tol, const NekDouble factor) override
bool m_NekLinSysRightPrecon
NekLinSysIterGMRESLoc(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vRowComm, const int nDimen, const NekSysKey &pKey=NekSysKey())
Array< OneD, Array< OneD, NekDouble > > m_hes
int DoGMRES(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Actual iterative solve-GMRES.
void v_InitObject() override
Array< OneD, Array< OneD, NekDouble > > m_Upper
void v_InitObject() override
NekDouble m_rhs_magnitude
Dot product of rhs to normalise stopping criterion.
void Set_Rhs_Magnitude(const NekVector< NekDouble > &pIn)
bool m_root
Root if parallel.
LibUtilities::CommSharedPtr m_rowComm
Communicate.
NekDouble m_tolerance
Tolerance of iterative solver.
NekSysOperators m_operator
Operators.
bool m_converged
Whether the iteration has been converged.
int m_maxiter
Maximum iterations.
bool m_NekLinSysLeftPrecon
bool m_NekLinSysRightPrecon
int m_KrylovMaxHessMatBand
void DoAssembleLoc(InArrayType &xn, OutArrayType &xn1, const bool &flag=false) const
void DoNekSysPrecon(InArrayType &inarray, OutArrayType &outarray, const bool &flag=false) const
void DoNekSysLhsEval(InArrayType &inarray, OutArrayType &outarray, const bool &flag=false) const
void AccumulateRegion(std::string, int iolevel=0)
Accumulate elapsed time for a region.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
NekLinSysIterFactory & GetNekLinSysIterFactory()
@ beta
Gauss Radau pinned at x=-1,.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
static const NekDouble kNekUnsetDouble
std::vector< double > w(NPUPPER)
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
T Dot(int n, const T *w, const T *x)
dot product
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Zero(int n, T *x, const int incx)
Zero vector.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > abs(scalarT< T > in)
scalarT< T > sqrt(scalarT< T > in)