46 namespace MultiRegions
58 string GlobalLinSysIterativeStaticCond::className
60 "IterativeStaticCond",
61 GlobalLinSysIterativeStaticCond::create,
62 "Iterative static condensation.");
64 string GlobalLinSysIterativeStaticCond::className2
66 "IterativeMultiLevelStaticCond",
67 GlobalLinSysIterativeStaticCond::create,
68 "Iterative multi-level static condensation.");
71 std::string GlobalLinSysIterativeStaticCond::storagedef =
72 LibUtilities::SessionReader::RegisterDefaultSolverInfo(
73 "LocalMatrixStorageStrategy",
75 std::string GlobalLinSysIterativeStaticCond::storagelookupIds[3] = {
76 LibUtilities::SessionReader::RegisterEnumValue(
77 "LocalMatrixStorageStrategy",
80 LibUtilities::SessionReader::RegisterEnumValue(
81 "LocalMatrixStorageStrategy",
84 LibUtilities::SessionReader::RegisterEnumValue(
85 "LocalMatrixStorageStrategy",
109 GlobalLinSysIterativeStaticCond::GlobalLinSysIterativeStaticCond(
111 const std::weak_ptr<ExpList> &pExpList,
112 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
119 "This constructor is only valid when using static "
122 == pLocToGloMap->GetGlobalSysSolnType(),
123 "The local to global map is not set up for the requested "
133 const std::weak_ptr<ExpList> &pExpList,
138 const std::shared_ptr<AssemblyMap> &pLocToGloMap,
162 int n, n_exp =
m_expList.lock()->GetNumElmts();
169 for (n = 0; n < n_exp; ++n)
178 cnt += mat->GetRows();
199 unsigned int nbdry = localMat->GetRows();
200 unsigned int nblks = 1;
201 unsigned int esize[1] = {nbdry};
205 schurComplBlock->SetBlock(0, 0, localMat);
207 return schurComplBlock;
218 boost::ignore_unused(pLocToGloMap);
243 GetSolverInfoAsEnum<LocalMatrixStorageStrategy>(
244 "LocalMatrixStorageStrategy");
246 switch(storageStrategy)
251 size_t storageSize = 0;
258 for (
int i = 0; i < nBlk; ++i)
276 for (
unsigned int n = 0; n < nBlk; ++n)
282 int loc_lda = loc_mat->GetRows();
283 int blockSize = loc_lda * loc_lda;
285 for(
int i = 0; i < loc_lda; ++i)
287 for(
int j = 0; j < loc_lda; ++j)
289 ptr[j*loc_lda+i] = (*loc_mat)(i,j);
311 std::vector<std::pair<int,int> > partitions;
312 for(
int n = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
315 loc_lda = loc_mat->GetRows();
318 boost::lexical_cast<std::string>(n) +
"-th "
319 "matrix block in Schur complement has "
322 if (blockSize == loc_lda)
324 partitions[partitions.size()-1].first++;
329 partitions.push_back(make_pair(1,loc_lda));
337 sparseStorage (partitions.size());
339 for (
int part = 0, n = 0; part < partitions.size(); ++part)
343 for(
int k = 0; k < partitions[part].first; ++k, ++n)
346 loc_lda = loc_mat->GetRows();
348 ASSERTL1(loc_lda == partitions[part].second,
349 boost::lexical_cast<std::string>(n) +
"-th"
350 " matrix block in Schur complement has "
358 loc_mat->GetRawPtr(),1,&matarray[0],1);
364 loc_lda*loc_lda, loc_mat->GetRawPtr());
370 sparseStorage[part] =
373 partitions[part].first, partitions[part].first,
374 partitions[part].second, partMat, matStorage );
385 LocalMatrixStorageStrategy takes values \
386 Contiguous, Non-contiguous and Sparse");
405 asmMap->GlobalToLocalBnd(pInput,
m_wsp);
407 asmMap->AssembleBnd(tmp, pOutput);
412 asmMap->GlobalToLocalBnd(pInput,
m_wsp);
417 const int rows =
m_rows[i];
421 0.0, tmpout.get()+cnt, 1);
423 asmMap->AssembleBnd(tmpout, pOutput);
448 int nGloBndDofs =
m_locToGloMap.lock()->GetNumGlobalBndCoeffs();
456 int nLocBndDofs =
m_locToGloMap.lock()->GetNumLocalBndCoeffs();
462 vExchange[0] +=
Blas::Ddot(nLocBndDofs, F_bnd,1,F_bnd,1);
463 m_expList.lock()->GetComm()->GetRowComm()->AllReduce(
470 NekDouble new_rhs_mag = (vExchange[0] > 1e-6)? vExchange[0] : 1.0;
494 m_precon->DoTransformBasisToLowEnergy(pInOut);
500 m_precon->DoTransformCoeffsFromLowEnergy(pInOut);
507 m_precon->DoTransformCoeffsToLowEnergy(pInput,pOutput);
512 const std::weak_ptr<ExpList> &pExpList,
517 const std::shared_ptr<AssemblyMap> &l2gMap)
521 mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap,
523 sys->Initialise(l2gMap);
#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.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
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)
PreconditionerSharedPtr m_precon
Array< OneD, int > m_map
Global to universal unique map.
NekDouble m_rhs_magnitude
dot product of rhs to normalise stopping criterion
void Set_Rhs_Magnitude(const NekVector< NekDouble > &pIn)
NekDouble m_rhs_mag_sm
cnt to how many times rhs_magnitude is called
virtual void v_InitObject()
void v_PreSolve(int scLevel, Array< OneD, NekDouble > &F_bnd)
std::vector< const double * > m_denseBlocks
Vector of pointers to local matrix data.
virtual void v_CoeffsBwdTransform(Array< OneD, NekDouble > &pInOut)
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)
virtual void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Perform a Shur-complement matrix multiply operation.
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()
virtual void v_BasisFwdTransform(Array< OneD, NekDouble > &pInOut)
Array< OneD, unsigned int > m_rows
Ranks of local matrices.
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n)
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
void v_AssembleSchurComplement(const std::shared_ptr< AssemblyMap > locToGloMap)
Assemble the Schur complement matrix.
Array< OneD, NekDouble > m_scale
Scaling factors for local matrices.
DNekSmvBsrDiagBlkMatSharedPtr m_sparseSchurCompl
Sparse representation of Schur complement matrix at this level.
virtual void v_CoeffsFwdTransform(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
virtual void v_UniqueMap()
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 = A x 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 = .
@ 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
Array< OneD, NekDouble > BCOEntryType
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
std::map< CoordType, BCOEntryType > BCOMatType
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.