59 "Iterative static condensation.");
63 "IterativeMultiLevelStaticCond",
65 "Iterative multi-level static condensation.");
69 "LocalMatrixStorageStrategy",
"Sparse");
74 "LocalMatrixStorageStrategy",
"Non-contiguous",
101 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
109 "This constructor is only valid when using static "
112 pLocToGloMap->GetGlobalSysSolnType(),
113 "The local to global map is not set up for the requested "
125 const std::shared_ptr<AssemblyMap> &pLocToGloMap,
148 int n, n_exp =
m_expList.lock()->GetNumElmts();
155 for (n = 0; n < n_exp; ++n)
161 m_precon->TransformedSchurCompl(n, cnt, mat);
163 cnt += mat->GetRows();
183 unsigned int nbdry = localMat->GetRows();
184 unsigned int nblks = 1;
185 unsigned int esize[1] = {nbdry};
188 nblks, nblks, esize, esize);
189 schurComplBlock->SetBlock(0, 0, localMat);
191 return schurComplBlock;
226 "LocalMatrixStorageStrategy");
228 switch (storageStrategy)
233 size_t storageSize = 0;
240 for (
int i = 0; i < nBlk; ++i)
250 double *ptr =
nullptr;
258 for (
unsigned int n = 0; n < nBlk; ++n)
264 int loc_lda = loc_mat->GetRows();
265 int blockSize = loc_lda * loc_lda;
267 for (
int i = 0; i < loc_lda; ++i)
269 for (
int j = 0; j < loc_lda; ++j)
271 ptr[j * loc_lda + i] = (*loc_mat)(i, j);
293 std::vector<std::pair<int, int>> partitions;
294 for (
int n = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
297 loc_lda = loc_mat->GetRows();
302 "matrix block in Schur complement has "
305 if (blockSize == loc_lda)
307 partitions[partitions.size() - 1].first++;
312 partitions.push_back(make_pair(1, loc_lda));
322 for (
int part = 0, n = 0; part < partitions.size(); ++part)
326 for (
int k = 0; k < partitions[part].first; ++k, ++n)
329 loc_lda = loc_mat->GetRows();
331 ASSERTL1(loc_lda == partitions[part].second,
334 " matrix block in Schur complement has "
342 loc_mat->GetRawPtr(), 1, &matarray[0], 1);
348 loc_lda * loc_lda, loc_mat->GetRawPtr());
354 sparseStorage[part] =
357 partitions[part].first, partitions[part].first,
358 partitions[part].second, partMat, matStorage);
370 LocalMatrixStorageStrategy takes values \
371 Contiguous, Non-contiguous and Sparse");
393 const int rows =
m_rows[i];
395 pInput.get() + cnt, 1, 0.0, pOutput.get() + cnt, 1);
409 asmMap->GlobalToLocalBnd(pInput,
m_wsp);
411 asmMap->AssembleBnd(tmp, pOutput);
416 asmMap->GlobalToLocalBnd(pInput,
m_wsp);
421 const int rows =
m_rows[i];
423 m_wsp.get() + cnt, 1, 0.0, tmpout.get() + cnt, 1);
425 asmMap->AssembleBnd(tmpout, pOutput);
454 int nGloBndDofs =
m_locToGloMap.lock()->GetNumGlobalBndCoeffs();
460 if (
m_map.size() > 0)
463 &F_GloBnd[0], &
m_map[0]);
466 m_expList.lock()->GetComm()->GetRowComm()->AllReduce(
473 NekDouble new_rhs_mag = (vExchange > 1e-6) ? vExchange : 1.0;
496 m_precon->DoTransformBasisToLowEnergy(pInOut);
502 m_precon->DoTransformCoeffsFromLowEnergy(pInOut);
508 m_precon->DoTransformCoeffsToLowEnergy(pInput, pOutput);
516 const std::shared_ptr<AssemblyMap> &l2gMap)
520 mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap,
m_precon);
521 sys->Initialise(l2gMap);
537 m_expList.lock()->GetComm()->GetRowComm();
545 "' is not defined.\n");
549 string variable = plocToGloMap->GetVariable();
553 if (pSession->DefinesGlobalSysSolnInfo(variable,
554 "IterativeSolverTolerance"))
556 sysKey.m_NekLinSysTolerance = boost::lexical_cast<double>(
558 ->GetGlobalSysSolnInfo(variable,
"IterativeSolverTolerance")
563 pSession->LoadParameter(
"IterativeSolverTolerance",
564 sysKey.m_NekLinSysTolerance,
568 if (pSession->DefinesGlobalSysSolnInfo(variable,
569 "NekLinSysMaxIterations"))
571 sysKey.m_NekLinSysMaxIterations = boost::lexical_cast<int>(
573 ->GetGlobalSysSolnInfo(variable,
"NekLinSysMaxIterations")
578 pSession->LoadParameter(
"NekLinSysMaxIterations",
579 sysKey.m_NekLinSysMaxIterations, 5000);
582 if (pSession->DefinesGlobalSysSolnInfo(variable,
"LinSysMaxStorage"))
584 sysKey.m_LinSysMaxStorage = boost::lexical_cast<int>(
585 pSession->GetGlobalSysSolnInfo(variable,
"LinSysMaxStorage")
590 pSession->LoadParameter(
"LinSysMaxStorage",
591 sysKey.m_LinSysMaxStorage, 100);
594 if (pSession->DefinesGlobalSysSolnInfo(variable,
"GMRESMaxHessMatBand"))
596 sysKey.m_KrylovMaxHessMatBand = boost::lexical_cast<int>(
597 pSession->GetGlobalSysSolnInfo(variable,
"GMRESMaxHessMatBand")
602 pSession->LoadParameter(
"GMRESMaxHessMatBand",
603 sysKey.m_KrylovMaxHessMatBand,
604 sysKey.m_LinSysMaxStorage + 1);
609 pSession->MatchSolverInfo(
"GMRESLeftPrecon",
"True",
610 sysKey.m_NekLinSysLeftPrecon,
false);
611 pSession->MatchSolverInfo(
"GMRESRightPrecon",
"True",
612 sysKey.m_NekLinSysRightPrecon,
true);
634 plocToGloMap->AssembleBnd(pInput, gloIn);
636 plocToGloMap->GlobalToLocalBnd(gloOut, pOutput);
642 int nLocDofs = plocToGloMap->GetNumLocalBndCoeffs();
644 m_linsol->SolveSystem(nLocDofs, pInput, pOutput, nDir);
650 plocToGloMap->AssembleBnd(pInput, gloIn);
651 m_linsol->SolveSystem(nGlobal, gloIn, gloOut, nDir);
652 plocToGloMap->GlobalToLocalBnd(gloOut, pOutput);
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Nektar::ErrorUtil::NekError NekError
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
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.
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
PreconditionerSharedPtr CreatePrecon(AssemblyMapSharedPtr asmMap)
Create a preconditioner object from the parameters defined in the supplied assembly map.
virtual void v_DropStaticCondBlock(unsigned int n)
Releases the static condensation block matrices from NekManager of n-th expansion using the matrix ke...
void Initialise(const std::shared_ptr< AssemblyMap > &pLocToGloMap)
LibUtilities::NekLinSysIterSharedPtr m_linsol
bool m_isAbsoluteTolerance
PreconditionerSharedPtr m_precon
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
LibUtilities::NekSysOperators m_NekSysOp
std::string m_linSysIterSolver
Iterative solver: Conjugate Gradient, GMRES.
NekDouble m_rhs_mag_sm
cnt to how many times rhs_magnitude is called
std::vector< const double * > m_denseBlocks
Vector of pointers to local matrix data.
static GlobalLinSysSharedPtr create(const GlobalLinSysKey &pLinSysKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n) override
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
~GlobalLinSysIterativeStaticCond() override
void v_CoeffsBwdTransform(Array< OneD, NekDouble > &pInOut) override
std::vector< double > m_storage
Dense storage for block Schur complement matrix.
GlobalLinSysIterativeStaticCond(const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.
void PrepareLocalSchurComplement()
Prepares local representation of Schur complement stored as a sparse block-diagonal matrix.
Array< OneD, unsigned int > m_rows
Ranks of local matrices.
void v_InitObject() override
GlobalLinSysStaticCondSharedPtr v_Recurse(const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const DNekScalBlkMatSharedPtr pSchurCompl, const DNekScalBlkMatSharedPtr pBinvD, const DNekScalBlkMatSharedPtr pC, const DNekScalBlkMatSharedPtr pInvD, const std::shared_ptr< AssemblyMap > &locToGloMap) override
void v_BasisFwdTransform(Array< OneD, NekDouble > &pInOut) override
void v_AssembleSchurComplement(const std::shared_ptr< AssemblyMap > locToGloMap) override
Assemble the Schur complement matrix.
void v_SolveLinearSystem(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir) override
Solve the matrix system.
Array< OneD, NekDouble > m_scale
Scaling factors for local matrices.
DNekSmvBsrDiagBlkMatSharedPtr m_sparseSchurCompl
Sparse representation of Schur complement matrix at this level.
static std::string className
Name of class.
static std::string storagelookupIds[]
static std::string className2
void v_UniqueMap() override
void v_PreSolve(int scLevel, Array< OneD, NekDouble > &F_bnd) override
void v_CoeffsFwdTransform(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
static std::string storagedef
Utility strings.
void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
Perform a Shur-complement matrix multiply operation.
Describe a linear system.
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
std::weak_ptr< AssemblyMap > m_locToGloMap
Local to global map.
void SetupTopLevel(const std::shared_ptr< AssemblyMap > &locToGloMap)
Set up the storage for the Schur complement or the top level of the multi-level Schur complement.
Array< OneD, NekDouble > m_wsp
Workspace array for matrix multiplication.
DNekScalBlkMatSharedPtr m_BinvD
Block matrix.
DNekScalBlkMatSharedPtr m_C
Block matrix.
DNekScalBlkMatSharedPtr m_invD
Block matrix.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
unsigned int GetDimension() const
Returns the number of dimensions for the point.
static void Dgemv(const char &trans, const int &m, const int &n, const double &alpha, const double *a, const int &lda, const double *x, const int &incx, const double &beta, double *y, const int &incy)
BLAS level 2: Matrix vector multiply y = alpha A x plus beta y where A[m x n].
std::shared_ptr< SessionReader > SessionReaderSharedPtr
NekLinSysIterFactory & GetNekLinSysIterFactory()
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
@ eIterativeMultiLevelStaticCond
LocalMatrixStorageStrategy
std::shared_ptr< GlobalLinSysStaticCond > GlobalLinSysStaticCondSharedPtr
GlobalLinSysFactory & GetGlobalLinSysFactory()
std::shared_ptr< GlobalLinSysIterativeStaticCond > GlobalLinSysIterativeStaticCondSharedPtr
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
static const NekDouble kNekIterativeTol
static const NekDouble kNekUnsetDouble
static const NekDouble kNekZeroTol
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
std::map< CoordType, BCOEntryType > BCOMatType
Array< OneD, NekDouble > BCOEntryType
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
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.