43 "LinSysIterSolver",
"ConjugateGradient",
46 "LinSysIterSolver",
"ConjugateGradientLoc",
67 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
71 m_useProjection(false), m_numPrevSols(0)
77 m_expList.lock()->GetComm()->GetRowComm();
78 m_root = (vComm->GetRank()) ?
false :
true;
88 m_matrixType.find(
"AdvectionDiffusionReaction") != string::npos;
96 "Detected ConjugateGradient solver and a "
97 "Advection-Diffusion-Reaction matrix. "
98 "Switchted to a GMRES solver for this non-symmetric matrix type. "
99 "Change LinSysIterSolver to GMRES in the session file to suppress "
106 WARNINGL0(
false,
"To use A-conjugate projection, the matrix "
107 "should be symmetric positive definite.");
132 int numIterations = 0;
136 numIterations =
m_linsol->SolveSystem(nGlobal, pInput, pOutput, nDir);
142 m_expList.lock()->GetComm()->GetRowComm();
145 int nNonDir = nGlobal - nDir;
161 cout <<
"No iterations made"
162 <<
" using tolerance of " << tol
198 alpha.get(), n, info);
203 alpha[0] = alphaback[latest];
212 Vmath::Vcopy(nNonDir, pInput.get() + nDir, 1, pb_s.get() + nDir, 1);
223 <<
"-bases projection reduces L2-norm of RHS from "
236 numIterations =
m_linsol->SolveSystem(nGlobal, pb_s, tmpx_s, nDir);
271 const bool isAconjugate)
274 int nNonDir = nGlobal - nDir;
280 m_expList.lock()->GetComm()->GetRowComm();
292 newBasis = newX + nDir;
296 newBasis = tmpAx_s + nDir;
311 tmp = tmpAx_s + nDir, 1);
315 if (i == insertLocation)
319 int skip = i > insertLocation;
333 if (i == insertLocation)
337 int iskip = i > insertLocation;
340 if (j == insertLocation)
344 int jskip = j > insertLocation;
345 tilCoeffMatrix->SetValue(i - iskip, j - jskip,
355 1, tilCoeffMatrix->GetPtr(), 1);
358 int n, info1 = 0, info2 = 0, info3 = 0;
361 n = tilCoeffMatrix->GetRows();
363 tilCoeffMatrix->GetStorageSize());
364 Vmath::Vcopy(tilCoeffMatrix->GetStorageSize(), tilCoeffMatrix->GetPtr(),
365 1, tilCoeffMatrixFactor, 1);
366 Lapack::Dsptrf(
'U', n, tilCoeffMatrixFactor.get(), ipivot.get(), info1);
370 Lapack::Dsptrs(
'U', n, 1, tilCoeffMatrixFactor.get(), ipivot.get(),
371 invMy_s.get(), n, info2);
377 y_s[0] = y_s[latest - (latest > insertLocation)];
384 for (
int i = 0; i <
m_prevBasis.size() - fullbuffer; i++)
386 residual -= y_s[i] * invMy_s[i];
390 cout <<
"SuccessiveRHS: residual " << residual;
392 if (residual < epsilon)
396 cout <<
" < " << epsilon <<
", reject" << endl;
408 1, newCoeffMatrix->GetPtr(), 1);
409 newCoeffMatrix->SetValue(insertLocation, insertLocation, 1.);
412 if (i == insertLocation)
416 int iskip = i > insertLocation;
417 newCoeffMatrix->SetValue(insertLocation, i, y_s[i - iskip]);
424 newCoeffMatrix->SetValue(insertLocation, insertLocation, 1.);
427 newCoeffMatrix->SetValue(insertLocation, i, y_s[i]);
430 newCoeffMatrix->SetValue(i, j,
m_coeffMatrix->GetValue(i, j));
434 n = newCoeffMatrix->GetRows();
436 Vmath::Vcopy(newCoeffMatrix->GetStorageSize(), newCoeffMatrix->GetPtr(), 1,
437 coeffMatrixFactor, 1);
438 Lapack::Dsptrf(
'U', n, coeffMatrixFactor.get(), ipivot.get(), info3);
443 cout <<
" >= " << epsilon <<
", reject (Dsptrf fails)" << endl;
449 cout <<
" >= " << epsilon <<
", accept" << endl;
#define WARNINGL0(condition, msg)
void DefineAssembleLoc(FuncPointerT func, ObjectPointerT obj)
void DefineNekSysLhsEval(FuncPointerT func, ObjectPointerT obj)
void DefineNekSysPrecon(FuncPointerT func, ObjectPointerT obj)
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.
static std::string RegisterDefaultSolverInfo(const std::string &pName, const std::string &pValue)
Registers the default string value of a solver info property.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
GlobalLinSysIterative(const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
static std::string IteratSolverdef
Array< OneD, int > m_ipivot
std::vector< Array< OneD, NekDouble > > m_prevBasis
LibUtilities::NekLinSysIterSharedPtr m_linsol
bool m_isAbsoluteTolerance
void UpdateKnownSolutions(const int pGlobalBndDofs, const Array< OneD, const NekDouble > &pSolution, const int pNumDirBndDofs, const bool isAconjugate)
Array< OneD, NekDouble > m_coeffMatrixFactor
void DoAssembleLocFlag(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &ZeroDir)
int ResetKnownSolutionsToLatestOne()
bool m_isNonSymmetricLinSys
void DoPreconditionerFlag(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &isLocal=false)
std::vector< Array< OneD, NekDouble > > m_prevLinSol
Storage for solutions to previous linear problems.
void DoMatrixMultiplyFlag(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &controlFlag)
static std::string IteratSolverlookupIds[]
void DoProjection(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int pNumDir, const bool isAconjugate)
projection technique
bool m_useProjection
Whether to apply projection technique.
Array< OneD, int > m_map
Global to universal unique map.
NekDouble m_rhs_magnitude
dot product of rhs to normalise stopping criterion
DNekMatSharedPtr m_coeffMatrix
LibUtilities::NekSysOperators m_NekSysOp
std::string m_linSysIterSolver
Iterative solver: Conjugate Gradient, GMRES.
~GlobalLinSysIterative() override
bool m_root
Root if parallel.
Describe a linear system.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
static void Dsptrs(const char &uplo, const int &n, const int &nrhs, const double *ap, const int *ipiv, double *b, const int &ldb, int &info)
Solve a real packed-symmetric matrix problem using Bunch-Kaufman pivoting.
static void Dsptrf(const char &uplo, const int &n, double *ap, int *ipiv, int &info)
factor a real packed-symmetric matrix using Bunch-Kaufman pivoting.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
static PreconditionerSharedPtr NullPreconditionerSharedPtr
@ eGMRESLoc
GMRES in Local storage.
@ eConjugateGradient
Conjugate Gradient.
static const NekDouble kNekUnsetDouble
static const NekDouble kNekSparseNonZeroTol
static const NekDouble kNekZeroTol
const char *const MatrixTypeMap[]
std::shared_ptr< DNekMat > DNekMatSharedPtr
T Dot2(int n, const T *w, const T *x, const int *y)
dot product
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)