61 "Iterative static condensation.");
65 "IterativeMultiLevelStaticCond",
67 "Iterative multi-level static condensation.");
71 "LocalMatrixStorageStrategy",
"Sparse");
76 "LocalMatrixStorageStrategy",
"Non-contiguous",
103 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
111 "This constructor is only valid when using static "
114 pLocToGloMap->GetGlobalSysSolnType(),
115 "The local to global map is not set up for the requested "
127 const std::shared_ptr<AssemblyMap> &pLocToGloMap,
150 int n, n_exp =
m_expList.lock()->GetNumElmts();
157 for (n = 0; n < n_exp; ++n)
163 m_precon->TransformedSchurCompl(n, cnt, mat);
165 cnt += mat->GetRows();
185 unsigned int nbdry = localMat->GetRows();
186 unsigned int nblks = 1;
187 unsigned int esize[1] = {nbdry};
190 nblks, nblks, esize, esize);
191 schurComplBlock->SetBlock(0, 0, localMat);
193 return schurComplBlock;
204 boost::ignore_unused(pLocToGloMap);
229 "LocalMatrixStorageStrategy");
231 switch (storageStrategy)
236 size_t storageSize = 0;
243 for (
int i = 0; i < nBlk; ++i)
261 for (
unsigned int n = 0; n < nBlk; ++n)
267 int loc_lda = loc_mat->GetRows();
268 int blockSize = loc_lda * loc_lda;
270 for (
int i = 0; i < loc_lda; ++i)
272 for (
int j = 0; j < loc_lda; ++j)
274 ptr[j * loc_lda + i] = (*loc_mat)(i, j);
296 std::vector<std::pair<int, int>> partitions;
297 for (
int n = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
300 loc_lda = loc_mat->GetRows();
303 boost::lexical_cast<std::string>(n) +
305 "matrix block in Schur complement has "
308 if (blockSize == loc_lda)
310 partitions[partitions.size() - 1].first++;
315 partitions.push_back(make_pair(1, loc_lda));
325 for (
int part = 0, n = 0; part < partitions.size(); ++part)
329 for (
int k = 0; k < partitions[part].first; ++k, ++n)
332 loc_lda = loc_mat->GetRows();
334 ASSERTL1(loc_lda == partitions[part].second,
335 boost::lexical_cast<std::string>(n) +
337 " matrix block in Schur complement has "
345 loc_mat->GetRawPtr(), 1, &matarray[0], 1);
351 loc_lda * loc_lda, loc_mat->GetRawPtr());
357 sparseStorage[part] =
360 partitions[part].first, partitions[part].first,
361 partitions[part].second, partMat, matStorage);
373 LocalMatrixStorageStrategy takes values \
374 Contiguous, Non-contiguous and Sparse");
396 const int rows =
m_rows[i];
398 pInput.get() + cnt, 1, 0.0, pOutput.get() + cnt, 1);
412 asmMap->GlobalToLocalBnd(pInput,
m_wsp);
414 asmMap->AssembleBnd(tmp, pOutput);
419 asmMap->GlobalToLocalBnd(pInput,
m_wsp);
424 const int rows =
m_rows[i];
426 m_wsp.get() + cnt, 1, 0.0, tmpout.get() + cnt, 1);
428 asmMap->AssembleBnd(tmpout, pOutput);
453 int nGloBndDofs =
m_locToGloMap.lock()->GetNumGlobalBndCoeffs();
461 int nLocBndDofs =
m_locToGloMap.lock()->GetNumLocalBndCoeffs();
467 vExchange[0] +=
Blas::Ddot(nLocBndDofs, F_bnd, 1, F_bnd, 1);
468 m_expList.lock()->GetComm()->GetRowComm()->AllReduce(
475 NekDouble new_rhs_mag = (vExchange[0] > 1e-6) ? vExchange[0] : 1.0;
499 m_precon->DoTransformBasisToLowEnergy(pInOut);
505 m_precon->DoTransformCoeffsFromLowEnergy(pInOut);
511 m_precon->DoTransformCoeffsToLowEnergy(pInput, pOutput);
519 const std::shared_ptr<AssemblyMap> &l2gMap)
523 mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap,
m_precon);
524 sys->Initialise(l2gMap);
539 m_expList.lock()->GetComm()->GetRowComm();
547 "' is not defined.\n");
569 plocToGloMap->AssembleBnd(pInput, gloIn);
571 plocToGloMap->GlobalToLocalBnd(gloOut, pOutput);
577 int nLocDofs = plocToGloMap->GetNumLocalBndCoeffs();
585 plocToGloMap->AssembleBnd(pInput, gloIn);
587 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
PreconditionerSharedPtr m_precon
void DoProjection(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int pNumDir, const NekDouble tol, const bool isAconjugate)
projection technique
bool m_useProjection
Whether to apply projection technique.
NekDouble m_tolerance
Tolerance of iterative solver.
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.
void Set_Rhs_Magnitude(const NekVector< NekDouble > &pIn)
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.
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n) override
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
virtual 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.
virtual ~GlobalLinSysIterativeStaticCond()
Array< OneD, unsigned int > m_rows
Ranks of local matrices.
virtual void v_InitObject() override
virtual 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
virtual void v_BasisFwdTransform(Array< OneD, NekDouble > &pInOut) override
virtual void v_AssembleSchurComplement(const std::shared_ptr< AssemblyMap > locToGloMap) override
Assemble the Schur complement matrix.
virtual 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
virtual void v_UniqueMap() override
virtual void v_PreSolve(int scLevel, Array< OneD, NekDouble > &F_bnd) override
virtual void v_CoeffsFwdTransform(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
static std::string storagedef
Utility strings.
virtual 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.
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].
static double Ddot(const int &n, const double *x, const int &incx, const double *y, const int &incy)
BLAS level 1: output = .
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 kNekUnsetDouble
static const NekDouble kNekZeroTol
The above copyright notice and this permission notice shall be included.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
std::map< CoordType, BCOEntryType > BCOMatType
Array< OneD, NekDouble > BCOEntryType
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
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.