46 namespace MultiRegions
60 "IterativeStaticCond",
62 "Iterative static condensation.");
66 "IterativeMultiLevelStaticCond",
68 "Iterative multi-level static condensation.");
73 "LocalMatrixStorageStrategy",
77 "LocalMatrixStorageStrategy",
81 "LocalMatrixStorageStrategy",
85 "LocalMatrixStorageStrategy",
111 const boost::weak_ptr<ExpList> &pExpList,
112 const boost::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 boost::weak_ptr<ExpList> &pExpList,
138 const boost::shared_ptr<AssemblyMap> &pLocToGloMap,
161 int n, n_exp =
m_expList.lock()->GetNumElmts();
171 for (n = 0; n < n_exp; ++n)
181 for (n = 0; n < n_exp; ++n)
188 m_expList.lock()->GetOffset_Elmt_Id(n), mat);
212 unsigned int nbdry = localMat->GetRows();
213 unsigned int nblks = 1;
214 unsigned int esize[1] = {nbdry};
218 schurComplBlock->SetBlock(0, 0, localMat);
220 return schurComplBlock;
231 int i,j,n,cnt,gid1,gid2;
234 bool doGlobalOp =
m_expList.lock()->GetGlobalOptParam()->
255 int nBndDofs = pLocToGloMap->GetNumGlobalBndCoeffs();
256 int NumDirBCs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
257 unsigned int rows = nBndDofs - NumDirBCs;
258 unsigned int cols = nBndDofs - NumDirBCs;
270 for(n = cnt = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
273 loc_lda = loc_mat->GetRows();
276 for(i = 0; i < loc_lda; ++i)
278 gid1 = pLocToGloMap->GetLocalToGlobalBndMap (cnt + i)
280 sign1 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + i);
284 for(j = 0; j < loc_lda; ++j)
286 gid2 = pLocToGloMap->GetLocalToGlobalBndMap(cnt+j)
288 sign2 = pLocToGloMap->GetLocalToGlobalBndSign(cnt+j);
292 gmat_coo[std::make_pair(gid1,gid2)] +=
293 sign1*sign2*(*loc_mat)(i,j);
325 GetSolverInfoAsEnum<LocalMatrixStorageStrategy>(
326 "LocalMatrixStorageStrategy");
328 switch(storageStrategy)
333 size_t storageSize = 0;
340 for (
int i = 0; i < nBlk; ++i)
358 for (
unsigned int n = 0; n < nBlk; ++n)
364 int loc_lda = loc_mat->GetRows();
365 int blockSize = loc_lda * loc_lda;
367 for(
int i = 0; i < loc_lda; ++i)
369 for(
int j = 0; j < loc_lda; ++j)
371 ptr[j*loc_lda+i] = (*loc_mat)(i,j);
394 std::vector<std::pair<int,int> > partitions;
395 for(
int n = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
398 loc_lda = loc_mat->GetRows();
401 boost::lexical_cast<std::string>(n) +
"-th "
402 "matrix block in Schur complement has "
405 if (blockSize == loc_lda)
407 partitions[partitions.size()-1].first++;
412 partitions.push_back(make_pair(1,loc_lda));
420 sparseStorage (partitions.size());
422 for (
int part = 0, n = 0; part < partitions.size(); ++part)
426 for(
int k = 0; k < partitions[part].first; ++k, ++n)
429 loc_lda = loc_mat->GetRows();
431 ASSERTL1(loc_lda == partitions[part].second,
432 boost::lexical_cast<std::string>(n) +
"-th"
433 " matrix block in Schur complement has "
441 loc_mat->GetRawPtr(),1,&matarray[0],1);
447 loc_lda*loc_lda, loc_mat->GetRawPtr());
454 sparseStorage[part] =
457 partitions[part].first, partitions[part].first,
458 partitions[part].second, partMat, matStorage );
469 LocalMatrixStorageStrategy takes values \
470 Contiguous, Non-contiguous and Sparse");
483 bool doGlobalOp =
m_expList.lock()->GetGlobalOptParam()->
512 const int rows =
m_rows[i];
513 Blas::Dgemv(
'N', rows, rows,
516 0.0, tmpout.get()+cnt, 1);
559 m_precon->DoTransformToLowEnergy(pInOut, offset);
565 m_precon->DoTransformFromLowEnergy(pInOut);
570 const boost::weak_ptr<ExpList> &pExpList,
575 const boost::shared_ptr<AssemblyMap> &l2gMap)
579 mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap,
581 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 std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.
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.
static std::string className
Name of class.
static std::string className2
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
static std::string storagelookupIds[]
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.
static GlobalLinSysSharedPtr create(const GlobalLinSysKey &pLinSysKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
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...
static std::string RegisterDefaultSolverInfo(const std::string &pName, const std::string &pValue)
Registers the default string value of a solver info property.
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.
static std::string storagedef
Utility strings.
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.