43 namespace LibUtilities
50 string NekLinSysIterCG::className =
52 "ConjugateGradient", NekLinSysIterCG::create,
53 "NekLinSysIterCG solver.");
55 NekLinSysIterCG::NekLinSysIterCG(
81 boost::ignore_unused(tol);
109 int nNonDir = nGlobal - nDir;
205 "Exceeded maximum number of iterations");
209 Vmath::Svtvp(nNonDir, beta, &p_A[0], 1, &w_A[nDir], 1, &p_A[0], 1);
210 Vmath::Svtvp(nNonDir, beta, &q_A[0], 1, &s_A[nDir], 1, &q_A[0], 1);
213 Vmath::Svtvp(nNonDir, alpha, &p_A[0], 1, &pOutput[nDir], 1,
217 Vmath::Svtvp(nNonDir, -alpha, &q_A[0], 1, &r_A[0], 1, &r_A[0], 1);
237 rho_new = vExchange[0];
255 min_resid = min(min_resid, eps);
258 beta = rho_new / rho;
259 alpha = rho_new / (mu - rho_new * beta / alpha);
#define ROOTONLY_NEKERROR(type, msg)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
void DoConjugateGradient(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int pNumDir)
Actual iterative solve.
virtual void v_InitObject()
virtual int v_SolveSystem(const int nGlobal, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int nDir, const NekDouble tol, const NekDouble factor)
NekDouble m_rhs_magnitude
Dot product of rhs to normalise stopping criterion.
void Set_Rhs_Magnitude(const NekVector< NekDouble > &pIn)
virtual void v_InitObject()
Array< OneD, int > m_map
Global to universal unique map.
bool m_root
Root if parallel.
NekDouble m_tolerance
Tolerance of iterative solver.
NekSysOperators m_operator
Operators.
LibUtilities::CommSharedPtr m_Comm
Communicate.
int m_maxiter
Maximum iterations.
void DoNekSysPrecon(InArrayType &inarray, OutArrayType &outarray, const bool &flag=false) const
void DoNekSysLhsEval(InArrayType &inarray, OutArrayType &outarray, const bool &flag=false) const
std::shared_ptr< SessionReader > SessionReaderSharedPtr
NekLinSysIterFactory & GetNekLinSysIterFactory()
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
static const NekDouble kNekUnsetDouble
The above copyright notice and this permission notice shall be included.
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 Dot2(int n, const T *w, const T *x, const int *y)
vvtvp (vector times vector times vector): z = w*x*y
void Zero(int n, T *x, const int incx)
Zero vector.
scalarT< T > sqrt(scalarT< T > in)