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,
163 int n, n_exp =
m_expList.lock()->GetNumElmts();
167 = asmMap->GetNumLocalBndCoeffsPerPatch();
173 for (n = 0; n < n_exp; ++n)
184 for (n = 0; n < n_exp; ++n)
193 cnt += mat->GetRows();
216 unsigned int nbdry = localMat->GetRows();
217 unsigned int nblks = 1;
218 unsigned int esize[1] = {nbdry};
222 schurComplBlock->SetBlock(0, 0, localMat);
224 return schurComplBlock;
235 int i,j,n,cnt,gid1,gid2;
238 bool doGlobalOp =
m_expList.lock()->GetGlobalOptParam()->
259 int nBndDofs = pLocToGloMap->GetNumGlobalBndCoeffs();
260 int NumDirBCs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
261 unsigned int rows = nBndDofs - NumDirBCs;
262 unsigned int cols = nBndDofs - NumDirBCs;
274 for(n = cnt = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
277 loc_lda = loc_mat->GetRows();
280 for(i = 0; i < loc_lda; ++i)
282 gid1 = pLocToGloMap->GetLocalToGlobalBndMap (cnt + i)
284 sign1 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + i);
288 for(j = 0; j < loc_lda; ++j)
290 gid2 = pLocToGloMap->GetLocalToGlobalBndMap(cnt+j)
292 sign2 = pLocToGloMap->GetLocalToGlobalBndSign(cnt+j);
296 gmat_coo[std::make_pair(gid1,gid2)] +=
297 sign1*sign2*(*loc_mat)(i,j);
329 GetSolverInfoAsEnum<LocalMatrixStorageStrategy>(
330 "LocalMatrixStorageStrategy");
332 switch(storageStrategy)
337 size_t storageSize = 0;
344 for (
int i = 0; i < nBlk; ++i)
362 for (
unsigned int n = 0; n < nBlk; ++n)
368 int loc_lda = loc_mat->GetRows();
369 int blockSize = loc_lda * loc_lda;
371 for(
int i = 0; i < loc_lda; ++i)
373 for(
int j = 0; j < loc_lda; ++j)
375 ptr[j*loc_lda+i] = (*loc_mat)(i,j);
397 std::vector<std::pair<int,int> > partitions;
398 for(
int n = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
401 loc_lda = loc_mat->GetRows();
404 boost::lexical_cast<std::string>(n) +
"-th " 405 "matrix block in Schur complement has " 408 if (blockSize == loc_lda)
410 partitions[partitions.size()-1].first++;
415 partitions.push_back(make_pair(1,loc_lda));
423 sparseStorage (partitions.size());
425 for (
int part = 0, n = 0; part < partitions.size(); ++part)
429 for(
int k = 0; k < partitions[part].first; ++k, ++n)
432 loc_lda = loc_mat->GetRows();
434 ASSERTL1(loc_lda == partitions[part].second,
435 boost::lexical_cast<std::string>(n) +
"-th" 436 " matrix block in Schur complement has " 444 loc_mat->GetRawPtr(),1,&matarray[0],1);
450 loc_lda*loc_lda, loc_mat->GetRawPtr());
456 sparseStorage[part] =
459 partitions[part].first, partitions[part].first,
460 partitions[part].second, partMat, matStorage );
471 LocalMatrixStorageStrategy takes values \ 472 Contiguous, Non-contiguous and Sparse");
485 int nLocal = asmMap->GetNumLocalBndCoeffs();
486 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
487 bool doGlobalOp =
m_expList.lock()->GetGlobalOptParam()->
497 asmMap->UniversalAssembleBnd(pOutput, nDir);
504 asmMap->GlobalToLocalBnd(pInput,
m_wsp);
506 asmMap->AssembleBnd(tmp, pOutput);
511 asmMap->GlobalToLocalBnd(pInput,
m_wsp);
516 const int rows =
m_rows[i];
520 0.0, tmpout.get()+cnt, 1);
522 asmMap->AssembleBnd(tmpout, pOutput);
563 m_precon->DoTransformToLowEnergy(pInOut, offset);
569 m_precon->DoTransformFromLowEnergy(pInOut);
574 const std::weak_ptr<ExpList> &pExpList,
579 const std::shared_ptr<AssemblyMap> &l2gMap)
583 mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap,
585 sys->Initialise(l2gMap);
std::shared_ptr< GlobalLinSysStaticCond > GlobalLinSysStaticCondSharedPtr
Array< OneD, NekDouble > m_wsp
Workspace array for matrix multiplication.
virtual DNekScalBlkMatSharedPtr v_PreSolve(int scLevel, NekVector< NekDouble > &F_GlobBnd)
std::weak_ptr< AssemblyMap > m_locToGloMap
Local to global map.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
std::map< CoordType, NekDouble > COOMatType
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
void Set_Rhs_Magnitude(const NekVector< NekDouble > &pIn)
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
std::vector< double > m_storage
Dense storage for block Schur complement matrix.
DNekScalBlkMatSharedPtr m_C
Block matrix.
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...
virtual void v_InitObject()
virtual void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Perform a Shur-complement matrix multiply operation.
virtual void v_BasisBwdTransform(Array< OneD, NekDouble > &pInOut)
virtual ~GlobalLinSysIterativeStaticCond()
DNekScalBlkMatSharedPtr m_invD
Block matrix.
std::shared_ptr< GlobalLinSysIterativeStaticCond > GlobalLinSysIterativeStaticCondSharedPtr
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Array< OneD, NekDouble > BCOEntryType
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.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
Array< OneD, NekDouble > m_scale
Scaling factors for local matrices.
std::map< CoordType, BCOEntryType > BCOMatType
virtual void v_UniqueMap()
Array< OneD, int > m_map
Global to universal unique map.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Array< OneD, unsigned int > m_rows
Ranks of local matrices.
std::vector< const double * > m_denseBlocks
Vector of pointers to local matrix data.
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].
void PrepareLocalSchurComplement()
Prepares local representation of Schur complement stored as a sparse block-diagonal matrix...
static const NekDouble kNekUnsetDouble
Describe a linear system.
virtual void v_BasisFwdTransform(Array< OneD, NekDouble > &pInOut, int offset)
LocalMatrixStorageStrategy
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
NekDouble m_rhs_magnitude
dot product of rhs to normalise stopping criterion
DNekSmvBsrDiagBlkMatSharedPtr m_sparseSchurCompl
Sparse representation of Schur complement matrix at this level.
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)
void convertCooToBco(const unsigned int blkDim, const COOMatType &cooMat, BCOMatType &bcoMat)
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
virtual void v_DropStaticCondBlock(unsigned int n)
Releases the static condensation block matrices from NekManager of n-th expansion using the matrix ke...
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
void v_AssembleSchurComplement(const std::shared_ptr< AssemblyMap > locToGloMap)
Assemble the 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 Initialise(const std::shared_ptr< AssemblyMap > &pLocToGloMap)
GlobalLinSysFactory & GetGlobalLinSysFactory()
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
DNekScalBlkMatSharedPtr m_S1Blk
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n)
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
DNekScalBlkMatSharedPtr m_BinvD
Block matrix.
PreconditionerSharedPtr CreatePrecon(AssemblyMapSharedPtr asmMap)
Create a preconditioner object from the parameters defined in the supplied assembly map...