41 namespace MultiRegions
50 GlobalLinSysIterative::GlobalLinSysIterative(
52 const std::weak_ptr<ExpList> &pExpList,
53 const std::shared_ptr<AssemblyMap>
60 m_useProjection(false),
63 m_tolerance = pLocToGloMap->GetIterativeTolerance();
64 m_maxiter = pLocToGloMap->GetMaxIterations();
67 m_root = (vComm->GetRank())?
false :
true;
71 if((successiveRHS = pLocToGloMap->GetSuccessiveRHS()))
124 =
m_expList.lock()->GetComm()->GetRowComm();
127 int nNonDir = nGlobal - nDir;
199 pInput.get() + nDir, 1,
200 pb_s.get() + nDir, 1);
231 =
m_expList.lock()->GetComm()->GetRowComm();
234 int nNonDir = nGlobal - nDir;
246 return std::sqrt(anorm_sq);
259 int nNonDir = nGlobal - nDir;
263 =
m_expList.lock()->GetComm()->GetRowComm();
291 tmp1 = newX + nDir, 1,
292 tmp2 = px_s + nDir, 1);
332 Vmath::Smul(nNonDir, 1.0/anorm, px_s.get() + nDir, 1, px_s.get() + nDir, 1);
370 =
m_expList.lock()->GetComm()->GetRowComm();
373 int nNonDir = nGlobal - nDir;
393 NekDouble alpha, beta, rho, rho_new, mu, eps, min_resid;
429 <<
" (error = " << sqrt(eps/m_rhs_magnitude)
430 <<
", rhs_mag = " << sqrt(m_rhs_magnitude) <<
")" 436 m_precon->DoPreconditioner(r_A, tmp = w_A + nDir);
470 <<
" (error = " << sqrt(eps/m_rhs_magnitude)
471 <<
", rhs_mag = " << sqrt(m_rhs_magnitude) <<
")" 475 "Exceeded maximum number of iterations");
479 Vmath::Svtvp(nNonDir, beta, &p_A[0], 1, &w_A[nDir], 1, &p_A[0], 1);
480 Vmath::Svtvp(nNonDir, beta, &q_A[0], 1, &s_A[nDir], 1, &q_A[0], 1);
483 Vmath::Svtvp(nNonDir, alpha, &p_A[0], 1, &pOutput[nDir], 1, &pOutput[nDir], 1);
486 Vmath::Svtvp(nNonDir, -alpha, &q_A[0], 1, &r_A[0], 1, &r_A[0], 1);
489 m_precon->DoPreconditioner(r_A, tmp = w_A + nDir);
514 rho_new = vExchange[0];
527 <<
" (error = " << sqrt(eps/m_rhs_magnitude)
528 <<
", rhs_mag = " << sqrt(m_rhs_magnitude) <<
")" 533 min_resid = min(min_resid, eps);
537 alpha = rho_new/(mu - rho_new*beta/alpha);
547 if (
m_map.num_elements() > 0)
550 &pIn[0],&pIn[0],&
m_map[0]);
553 m_expList.lock()->GetComm()->GetRowComm()->AllReduce(
560 NekDouble new_rhs_mag = (vExchange[0] > 1e-6)? vExchange[0] : 1.0;
NekDouble m_rhs_mag_sm
cnt to how many times rhs_magnitude is called
void Set_Rhs_Magnitude(const NekVector< NekDouble > &pIn)
void UpdateKnownSolutions(const int pGlobalBndDofs, const Array< OneD, const NekDouble > &pSolution, const int pNumDirBndDofs)
bool m_root
Root if parallel.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
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
bool m_useProjection
Whether to apply projection technique.
boost::circular_buffer< Array< OneD, NekDouble > > m_prevLinSol
Storage for solutions to previous linear problems.
virtual void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)=0
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
NekDouble CalculateAnorm(const int nGlobal, const Array< OneD, const NekDouble > &in, const int nDir)
PreconditionerSharedPtr m_precon
static const NekDouble kNekZeroTol
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
static PreconditionerSharedPtr NullPreconditionerSharedPtr
NekDouble m_tolerance
Tolerance of iterative solver.
int m_numPrevSols
Total counter of previous solutions.
Array< OneD, int > m_map
Global to universal unique map.
static const NekDouble kNekUnsetDouble
Describe a linear system.
void DoAconjugateProjection(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)
A-conjugate projection technique.
NekDouble m_rhs_magnitude
dot product of rhs to normalise stopping criterion
int m_maxiter
maximum iterations
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
T Dot2(int n, const T *w, const T *x, const int *y)
vvtvp (vector times vector times vector): z = w*x*y
#define ROOTONLY_NEKERROR(type, msg)
unsigned int GetDimension() const
Returns the number of dimensions for the point.
virtual void v_SolveLinearSystem(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)
Solve the matrix system.
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 DoConjugateGradient(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)
Actual iterative solve.
PreconditionerSharedPtr CreatePrecon(AssemblyMapSharedPtr asmMap)
Create a preconditioner object from the parameters defined in the supplied assembly map...
virtual ~GlobalLinSysIterative()
virtual void v_UniqueMap()=0