52 "NekLinSysIterGMRES local storage solver.");
102 int niterations =
DoGMRES(nLocal, pInput, pOutput);
135 bool restarted =
false;
136 bool truncted =
false;
143 for (
int nrestart = 0; nrestart <
m_maxrestart; ++nrestart)
145 eps =
DoGmresRestart(restarted, truncted, nLocal, pInput, pOutput);
177 cout << std::scientific << std::setw(nwidthcolm)
178 << std::setprecision(nwidthcolm - 8)
184 cout <<
" WITH (GMRES eps = " << eps <<
" REAL eps= " << eps1
189 cout <<
" CONVERGED" << endl;
193 cout <<
" WARNING: Exceeded maxIt" << endl;
206 const bool restarted,
const bool truncted,
const int nLocal,
275 ASSERTL0(
false,
"Need to set up/debugging");
299 if (truncted && (starttem) > 0)
301 id_start[nd] = starttem;
310 alpha = 1.0 / eta[0];
348 starttem = id_start[idtem];
349 endtem = id_end[idtem];
351 DoArnoldi(starttem, endtem, nLocal,
w, wk, V1, V2, h1);
355 starttem = starttem - 1;
362 eps = eta[nd + 1] * eta[nd + 1];
388 for (
int i = 0; i < nswp; ++i)
400 Vmath::Vadd(nLocal, solution, 1, pOutput, 1, pOutput, 1);
429 for (
int i = starttem; i < endtem; ++i)
440 beta = -1.0 * vExchange;
450 h[endtem] =
sqrt(vExchange);
452 alpha = 1.0 / h[endtem];
467 int idtem = endtem - 1;
473 for (
int i = starttem; i < idtem; ++i)
475 temp_dbl = c[i] * h[i] - s[i] * h[i + 1];
476 h[i + 1] = s[i] * h[i] + c[i] * h[i + 1];
486 else if (
abs(hh) >
abs(dd))
489 s[idtem] = 1.0 /
sqrt(1.0 + temp_dbl * temp_dbl);
490 c[idtem] = temp_dbl * s[idtem];
495 c[idtem] = 1.0 /
sqrt(1.0 + temp_dbl * temp_dbl);
496 s[idtem] = temp_dbl * c[idtem];
499 h[idtem] = c[idtem] * h[idtem] - s[idtem] * h[endtem];
502 temp_dbl = c[idtem] * eta[idtem] - s[idtem] * eta[endtem];
503 eta[endtem] = s[idtem] * eta[idtem] + c[idtem] * eta[endtem];
504 eta[idtem] = temp_dbl;
518 int maxid = number - 1;
520 y[maxid] = b[maxid] /
A[maxid][maxid];
521 for (
int i = maxid - 1; i > -1; --i)
524 for (
int j = i + 1; j < number; ++j)
527 sum -= y[j] *
A[j][i];
529 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) 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
bool m_GMRESCentralDifference
Array< OneD, Array< OneD, NekDouble > > m_Upper
void v_InitObject() override
int m_NekLinSysMaxIterations
void Set_Rhs_Magnitude(const Array< OneD, NekDouble > &pIn)
NekDouble m_NekLinSysTolerance
LibUtilities::CommSharedPtr m_rowComm
NekSysOperators m_operator
NekDouble m_rhs_magnitude
bool m_NekLinSysLeftPrecon
bool m_GMRESCentralDifference
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)
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
scalarT< T > abs(scalarT< T > in)
scalarT< T > sqrt(scalarT< T > in)