48 namespace MultiRegions
60 string GlobalLinSysIterativeStaticCond::className
62 "IterativeStaticCond",
63 GlobalLinSysIterativeStaticCond::create,
64 "Iterative static condensation.");
66 string GlobalLinSysIterativeStaticCond::className2
68 "IterativeMultiLevelStaticCond",
69 GlobalLinSysIterativeStaticCond::create,
70 "Iterative multi-level static condensation.");
73 std::string GlobalLinSysIterativeStaticCond::storagedef =
74 LibUtilities::SessionReader::RegisterDefaultSolverInfo(
75 "LocalMatrixStorageStrategy",
77 std::string GlobalLinSysIterativeStaticCond::storagelookupIds[3] = {
78 LibUtilities::SessionReader::RegisterEnumValue(
79 "LocalMatrixStorageStrategy",
82 LibUtilities::SessionReader::RegisterEnumValue(
83 "LocalMatrixStorageStrategy",
86 LibUtilities::SessionReader::RegisterEnumValue(
87 "LocalMatrixStorageStrategy",
111 GlobalLinSysIterativeStaticCond::GlobalLinSysIterativeStaticCond(
113 const boost::weak_ptr<ExpList> &pExpList,
114 const boost::shared_ptr<AssemblyMap> &pLocToGloMap)
121 "This constructor is only valid when using static "
124 == pLocToGloMap->GetGlobalSysSolnType(),
125 "The local to global map is not set up for the requested "
135 const boost::weak_ptr<ExpList> &pExpList,
140 const boost::shared_ptr<AssemblyMap> &pLocToGloMap,
163 int n, n_exp =
m_expList.lock()->GetNumElmts();
173 for (n = 0; n < n_exp; ++n)
183 for (n = 0; n < n_exp; ++n)
190 m_expList.lock()->GetOffset_Elmt_Id(n), mat);
214 unsigned int nbdry = localMat->GetRows();
215 unsigned int nblks = 1;
216 unsigned int esize[1] = {nbdry};
220 schurComplBlock->SetBlock(0, 0, localMat);
222 return schurComplBlock;
233 int i,j,n,cnt,gid1,gid2;
236 bool doGlobalOp =
m_expList.lock()->GetGlobalOptParam()->
257 int nBndDofs = pLocToGloMap->GetNumGlobalBndCoeffs();
258 int NumDirBCs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
259 unsigned int rows = nBndDofs - NumDirBCs;
260 unsigned int cols = nBndDofs - NumDirBCs;
272 for(n = cnt = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
275 loc_lda = loc_mat->GetRows();
278 for(i = 0; i < loc_lda; ++i)
280 gid1 = pLocToGloMap->GetLocalToGlobalBndMap (cnt + i)
282 sign1 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + i);
286 for(j = 0; j < loc_lda; ++j)
288 gid2 = pLocToGloMap->GetLocalToGlobalBndMap(cnt+j)
290 sign2 = pLocToGloMap->GetLocalToGlobalBndSign(cnt+j);
294 gmat_coo[std::make_pair(gid1,gid2)] +=
295 sign1*sign2*(*loc_mat)(i,j);
327 GetSolverInfoAsEnum<LocalMatrixStorageStrategy>(
328 "LocalMatrixStorageStrategy");
330 switch(storageStrategy)
335 size_t storageSize = 0;
342 for (
int i = 0; i < nBlk; ++i)
360 for (
unsigned int n = 0; n < nBlk; ++n)
366 int loc_lda = loc_mat->GetRows();
367 int blockSize = loc_lda * loc_lda;
369 for(
int i = 0; i < loc_lda; ++i)
371 for(
int j = 0; j < loc_lda; ++j)
373 ptr[j*loc_lda+i] = (*loc_mat)(i,j);
396 std::vector<std::pair<int,int> > partitions;
397 for(
int n = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
400 loc_lda = loc_mat->GetRows();
403 boost::lexical_cast<std::string>(n) +
"-th "
404 "matrix block in Schur complement has "
407 if (blockSize == loc_lda)
409 partitions[partitions.size()-1].first++;
414 partitions.push_back(make_pair(1,loc_lda));
422 sparseStorage (partitions.size());
424 for (
int part = 0, n = 0; part < partitions.size(); ++part)
428 for(
int k = 0; k < partitions[part].first; ++k, ++n)
431 loc_lda = loc_mat->GetRows();
433 ASSERTL1(loc_lda == partitions[part].second,
434 boost::lexical_cast<std::string>(n) +
"-th"
435 " matrix block in Schur complement has "
443 loc_mat->GetRawPtr(),1,&matarray[0],1);
449 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 bool doGlobalOp =
m_expList.lock()->GetGlobalOptParam()->
514 const int rows =
m_rows[i];
515 Blas::Dgemv(
'N', rows, rows,
518 0.0, tmpout.get()+cnt, 1);
561 m_precon->DoTransformToLowEnergy(pInOut, offset);
567 m_precon->DoTransformFromLowEnergy(pInOut);
572 const boost::weak_ptr<ExpList> &pExpList,
577 const boost::shared_ptr<AssemblyMap> &l2gMap)
581 mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap,
583 sys->Initialise(l2gMap);
Array< OneD, NekDouble > m_wsp
Workspace array for matrix multiplication.
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
virtual DNekScalBlkMatSharedPtr v_PreSolve(int scLevel, NekVector< NekDouble > &F_GlobBnd)
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
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...
void v_AssembleSchurComplement(const boost::shared_ptr< AssemblyMap > locToGloMap)
Assemble the Schur complement matrix.
std::vector< double > m_storage
Dense storage for block Schur complement matrix.
DNekScalBlkMatSharedPtr m_C
Block matrix.
virtual void v_InitObject()
virtual void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Perform a Shur-complement matrix multiply operation.
boost::shared_ptr< Preconditioner > PreconditionerSharedPtr
virtual ~GlobalLinSysIterativeStaticCond()
void Initialise(const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
DNekScalBlkMatSharedPtr m_invD
Block matrix.
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
Array< OneD, NekDouble > BCOEntryType
GlobalLinSysIterativeStaticCond(const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.
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.
boost::shared_ptr< GlobalLinSysIterativeStaticCond > GlobalLinSysIterativeStaticCondSharedPtr
virtual GlobalLinSysStaticCondSharedPtr v_Recurse(const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const DNekScalBlkMatSharedPtr pSchurCompl, const DNekScalBlkMatSharedPtr pBinvD, const DNekScalBlkMatSharedPtr pC, const DNekScalBlkMatSharedPtr pInvD, const boost::shared_ptr< AssemblyMap > &locToGloMap)
Array< OneD, NekDouble > m_scale
Scaling factors for local matrices.
virtual void v_BasisInvTransform(Array< OneD, NekDouble > &pInOut)
std::map< CoordType, BCOEntryType > BCOMatType
virtual void v_UniqueMap()
Array< OneD, int > m_map
Global to universal unique map.
boost::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Array< OneD, unsigned int > m_rows
Ranks of local matrices.
std::vector< const double * > m_denseBlocks
Vector of pointers to local matrix data.
void PrepareLocalSchurComplement()
Prepares local representation of Schur complement stored as a sparse block-diagonal matrix...
void SetupTopLevel(const boost::shared_ptr< AssemblyMap > &locToGloMap)
Set up the storage for the Schur complement or the top level of the multi-level Schur complement...
static const NekDouble kNekUnsetDouble
Describe a linear system.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
virtual void v_BasisTransform(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 void v_DropStaticCondBlock(unsigned int n)
Releases the static condensation block matrices from NekManager of n-th expansion using the matrix ke...
void convertCooToBco(const unsigned int blkRows, const unsigned int blkColumns, const unsigned int blkDim, const COOMatType &cooMat, BCOMatType &bcoMat)
boost::shared_ptr< AssemblyMap > m_locToGloMap
Local to global map.
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...
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
boost::shared_ptr< GlobalLinSysStaticCond > GlobalLinSysStaticCondSharedPtr
const boost::weak_ptr< ExpList > m_expList
Local Matrix System.