Nektar++
|
A global linear system. More...
#include <GlobalLinSys.h>
Public Member Functions | |
GlobalLinSys (const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap) | |
Constructor for full direct matrix solve. More... | |
virtual | ~GlobalLinSys () |
const GlobalLinSysKey & | GetKey (void) const |
Returns the key associated with the system. More... | |
const std::weak_ptr< ExpList > & | GetLocMat (void) const |
void | InitObject () |
void | Initialise (const std::shared_ptr< AssemblyMap > &pLocToGloMap) |
void | Solve (const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray) |
Solve the linear system for given input and output vectors using a specified local to global map. More... | |
std::shared_ptr< GlobalLinSys > | GetSharedThisPtr () |
Returns a shared pointer to the current object. More... | |
int | GetNumBlocks () |
DNekScalMatSharedPtr | GetBlock (unsigned int n) |
void | DropBlock (unsigned int n) |
DNekScalBlkMatSharedPtr | GetStaticCondBlock (unsigned int n) |
void | DropStaticCondBlock (unsigned int n) |
void | SolveLinearSystem (const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir=0) |
Solve the linear system for given input and output vectors. More... | |
Protected Member Functions | |
virtual void | v_Solve (const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)=0 |
Solve a linear system based on mapping. More... | |
virtual void | v_SolveLinearSystem (const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)=0 |
Solve a basic matrix system. More... | |
virtual void | v_InitObject () |
virtual void | v_Initialise (const std::shared_ptr< AssemblyMap > &pLocToGloMap) |
virtual int | v_GetNumBlocks () |
Get the number of blocks in this system. More... | |
virtual DNekScalMatSharedPtr | v_GetBlock (unsigned int n) |
Retrieves the block matrix from n-th expansion using the matrix key provided by the m_linSysKey. More... | |
virtual void | v_DropBlock (unsigned int n) |
Releases the local block matrix from NekManager of n-th expansion using the matrix key provided by the m_linSysKey. More... | |
virtual DNekScalBlkMatSharedPtr | v_GetStaticCondBlock (unsigned int n) |
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided by the m_linSysKey. More... | |
virtual void | v_DropStaticCondBlock (unsigned int n) |
Releases the static condensation block matrices from NekManager of n-th expansion using the matrix key provided by the m_linSysKey. More... | |
PreconditionerSharedPtr | CreatePrecon (AssemblyMapSharedPtr asmMap) |
Create a preconditioner object from the parameters defined in the supplied assembly map. More... | |
Protected Attributes | |
const GlobalLinSysKey | m_linSysKey |
Key associated with this linear system. More... | |
const std::weak_ptr< ExpList > | m_expList |
Local Matrix System. More... | |
const std::map< int, RobinBCInfoSharedPtr > | m_robinBCInfo |
Robin boundary info. More... | |
bool | m_verbose |
Private Member Functions | |
LocalRegions::MatrixKey | GetBlockMatrixKey (unsigned int n) |
Static Private Attributes | |
static std::string | lookupIds [] |
static std::string | def |
A global linear system.
Consider the linear system \(\boldsymbol{M\hat{u}}_g=\boldsymbol{\hat{f}}\). Distinguishing between the boundary and interior components of \(\boldsymbol{\hat{u}}_g\) and \(\boldsymbol{\hat{f}}\) using \(\boldsymbol{\hat{u}}_b\), \(\boldsymbol{\hat{u}}_i\) and \(\boldsymbol{\hat{f}}_b\), \(\boldsymbol{\hat{f}}_i\) respectively, this system can be split into its constituent parts as
\[\left[\begin{array}{cc} \boldsymbol{M}_b&\boldsymbol{M}_{c1}\\ \boldsymbol{M}_{c2}&\boldsymbol{M}_i\\ \end{array}\right] \left[\begin{array}{c} \boldsymbol{\hat{u}_b}\\ \boldsymbol{\hat{u}_i}\\ \end{array}\right]= \left[\begin{array}{c} \boldsymbol{\hat{f}_b}\\ \boldsymbol{\hat{f}_i}\\ \end{array}\right]\]
where \(\boldsymbol{M}_b\) represents the components of \(\boldsymbol{M}\) resulting from boundary-boundary mode interactions, \(\boldsymbol{M}_{c1}\) and \(\boldsymbol{M}_{c2}\) represent the components resulting from coupling between the boundary-interior modes, and \(\boldsymbol{M}_i\) represents the components of \(\boldsymbol{M}\) resulting from interior-interior mode interactions.
The solution of the linear system can now be determined in two steps:
\begin{eqnarray*} \mathrm{step 1:}&\quad&(\boldsymbol{M}_b-\boldsymbol{M}_{c1} \boldsymbol{M}_i^{-1}\boldsymbol{M}_{c2}) \boldsymbol{\hat{u}_b} = \boldsymbol{\hat{f}}_b - \boldsymbol{M}_{c1}\boldsymbol{M}_i^{-1} \boldsymbol{\hat{f}}_i,\nonumber \\ \mathrm{step 2:}&\quad&\boldsymbol{\hat{u}_i}=\boldsymbol{M}_i^{-1} \left( \boldsymbol{\hat{f}}_i - \boldsymbol{M}_{c2}\boldsymbol{\hat{u}_b} \right). \nonumber \\ \end{eqnarray*}
As the inverse of \(\boldsymbol{M}_i^{-1}\) is
\[ \boldsymbol{M}_i^{-1} = \left [\underline{\boldsymbol{M}^e_i} \right ]^{-1} = \underline{[\boldsymbol{M}^e_i]}^{-1} \]
and the following operations can be evaluated as,
\begin{eqnarray*} \boldsymbol{M}_{c1}\boldsymbol{M}_i^{-1}\boldsymbol{\hat{f}}_i & =& \boldsymbol{\mathcal{A}}_b^T \underline{\boldsymbol{M}^e_{c1}} \underline{[\boldsymbol{M}^e_i]}^{-1} \boldsymbol{\hat{f}}_i \\ \boldsymbol{M}_{c2} \boldsymbol{\hat{u}_b} &=& \underline{\boldsymbol{M}^e_{c2}} \boldsymbol{\mathcal{A}}_b \boldsymbol{\hat{u}_b}.\end{eqnarray*}
where \(\boldsymbol{\mathcal{A}}_b \) is the permutation matrix which scatters from global to local degrees of freedom, only the following four matrices should be constructed:
The first three matrices are just a concatenation of the corresponding local matrices and they can be created as such. They also allow for an elemental evaluation of the operations concerned.
The global Schur complement however should be assembled from the concatenation of the local elemental Schur complements, that is,
\[ \boldsymbol{M}_{\mathrm{Schur}}=\boldsymbol{M}_b - \boldsymbol{M}_{c1} \boldsymbol{M}_i^{-1} \boldsymbol{M}_{c2} = \boldsymbol{\mathcal{A}}_b^T \left [\underline{\boldsymbol{M}^e_b - \boldsymbol{M}^e_{c1} [\boldsymbol{M}^e_i]^{-1} (\boldsymbol{M}^e_{c2})} \right ] \boldsymbol{\mathcal{A}}_b \]
and it is the only matrix operation that need to be evaluated on a global level when using static condensation. However, due to the size and sparsity of the matrix \(\boldsymbol{\mathcal{A}}_b\), it is more efficient to assemble the global Schur matrix using the mapping array bmap \([e][i]\) contained in the input argument locToGloMap. The global Schur complement is then constructed as:
\[\boldsymbol{M}_{\mathrm{Schur}}\left[\mathrm{\a bmap}[e][i]\right] \left[\mathrm{\a bmap}[e][j]\right]=\mathrm{\a bsign}[e][i]\cdot \mathrm{\a bsign}[e][j] \cdot\boldsymbol{M}^e_{\mathrm{Schur}}[i][j]\]
All four matrices are stored in the GlobalLinSys returned by this function.
Definition at line 69 of file GlobalLinSys.h.
Nektar::MultiRegions::GlobalLinSys::GlobalLinSys | ( | const GlobalLinSysKey & | pKey, |
const std::weak_ptr< ExpList > & | pExpList, | ||
const std::shared_ptr< AssemblyMap > & | pLocToGloMap | ||
) |
Constructor for full direct matrix solve.
Given a block matrix, construct a global matrix system according to a local to global mapping. #m_linSys is constructed by AssembleFullMatrix().
pkey | Associated linear system key. |
locToGloMap | Local to global mapping. |
Definition at line 193 of file GlobalLinSys.cpp.
|
inlinevirtual |
Definition at line 78 of file GlobalLinSys.h.
|
protected |
Create a preconditioner object from the parameters defined in the supplied assembly map.
asmMap | Assembly map used to construct the global system. |
Definition at line 209 of file GlobalLinSys.cpp.
References Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::MultiRegions::GetPreconFactory(), and GetSharedThisPtr().
Referenced by Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_AssembleSchurComplement(), Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_AssembleSchurComplement(), Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_InitObject(), Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_InitObject(), Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_PreSolve(), Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_PreSolve(), Nektar::MultiRegions::GlobalLinSysIterativeFull::v_SolveLinearSystem(), Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_SolveLinearSystem(), Nektar::MultiRegions::GlobalLinSysPETSc::v_SolveLinearSystem(), and Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_SolveLinearSystem().
|
inline |
Definition at line 214 of file GlobalLinSys.h.
References v_DropBlock().
|
inline |
Definition at line 224 of file GlobalLinSys.h.
References v_DropStaticCondBlock().
|
inline |
Definition at line 209 of file GlobalLinSys.h.
References v_GetBlock().
Referenced by Nektar::MultiRegions::GlobalLinSysDirectFull::AssembleFullMatrix(), Nektar::MultiRegions::GlobalLinSysXxtFull::AssembleMatrixArrays(), and Nektar::MultiRegions::GlobalLinSysPETScFull::GlobalLinSysPETScFull().
|
private |
Assemble the matrix key for each block n
Definition at line 231 of file GlobalLinSys.cpp.
References ASSERTL1, Nektar::StdRegions::eFactorSVVCutoffRatio, Nektar::StdRegions::eFactorSVVDGKerDiffCoeff, Nektar::StdRegions::eFactorSVVDiffCoeff, Nektar::StdRegions::eFactorSVVPowerKerDiffCoeff, Nektar::MultiRegions::GlobalMatrixKey::GetConstFactors(), Nektar::MultiRegions::GlobalMatrixKey::GetMatrixType(), Nektar::MultiRegions::GlobalMatrixKey::GetNVarCoeffs(), Nektar::MultiRegions::GlobalLinSysKey::GetNVarFactors(), Nektar::MultiRegions::GlobalMatrixKey::GetVarCoeffs(), Nektar::MultiRegions::GlobalLinSysKey::GetVarFactors(), m_expList, m_linSysKey, and Nektar::StdRegions::RestrictCoeffMap().
Referenced by v_DropBlock(), v_DropStaticCondBlock(), v_GetBlock(), and v_GetStaticCondBlock().
|
inline |
Returns the key associated with the system.
Definition at line 163 of file GlobalLinSys.h.
References m_linSysKey.
|
inline |
Definition at line 171 of file GlobalLinSys.h.
References m_expList.
|
inline |
Definition at line 229 of file GlobalLinSys.h.
References v_GetNumBlocks().
|
inline |
Returns a shared pointer to the current object.
Definition at line 100 of file GlobalLinSys.h.
Referenced by CreatePrecon().
|
inline |
Definition at line 219 of file GlobalLinSys.h.
References v_GetStaticCondBlock().
|
inline |
Definition at line 203 of file GlobalLinSys.h.
References v_Initialise().
Referenced by Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_InitObject(), Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_InitObject(), and Nektar::MultiRegions::GlobalLinSysStaticCond::v_InitObject().
|
inline |
Definition at line 198 of file GlobalLinSys.h.
References v_InitObject().
|
inline |
Solve the linear system for given input and output vectors using a specified local to global map.
Definition at line 179 of file GlobalLinSys.h.
References v_Solve().
|
inline |
Solve the linear system for given input and output vectors.
Definition at line 190 of file GlobalLinSys.h.
References v_SolveLinearSystem().
Referenced by Nektar::MultiRegions::GlobalLinSysIterativeFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysPETScFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysStaticCond::v_Solve(), Nektar::MultiRegions::GlobalLinSysXxtFull::v_Solve(), and Nektar::MultiRegions::GlobalLinSysDirectFull::v_Solve().
|
protectedvirtual |
Releases the local block matrix from NekManager of n-th expansion using the matrix key provided by the m_linSysKey.
n | Number of the expansion |
Definition at line 408 of file GlobalLinSys.cpp.
References GetBlockMatrixKey(), and m_expList.
Referenced by DropBlock().
|
protectedvirtual |
Releases the static condensation block matrices from NekManager of n-th expansion using the matrix key provided by the m_linSysKey.
n | Number of the expansion |
Definition at line 396 of file GlobalLinSys.cpp.
References GetBlockMatrixKey(), and m_expList.
Referenced by DropStaticCondBlock(), and Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::PrepareLocalSchurComplement().
|
protectedvirtual |
Retrieves the block matrix from n-th expansion using the matrix key provided by the m_linSysKey.
n | Number of the expansion. |
Definition at line 300 of file GlobalLinSys.cpp.
References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Blas::Dscal(), GetBlockMatrixKey(), m_expList, and m_robinBCInfo.
Referenced by GetBlock(), and Nektar::MultiRegions::GlobalLinSysStaticCond::SetupTopLevel().
|
protectedvirtual |
Get the number of blocks in this system.
At the top level this corresponds to the number of elements in the expansion list.
Reimplemented in Nektar::MultiRegions::GlobalLinSysStaticCond.
Definition at line 222 of file GlobalLinSys.cpp.
References m_expList.
Referenced by GetNumBlocks().
|
protectedvirtual |
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided by the m_linSysKey.
n | Number of the expansion |
Reimplemented in Nektar::MultiRegions::GlobalLinSysIterativeStaticCond, and Nektar::MultiRegions::GlobalLinSysPETScStaticCond.
Definition at line 342 of file GlobalLinSys.cpp.
References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Blas::Dscal(), GetBlockMatrixKey(), m_expList, and m_robinBCInfo.
Referenced by GetStaticCondBlock(), and Nektar::MultiRegions::GlobalLinSysStaticCond::SetupTopLevel().
|
protectedvirtual |
Reimplemented in Nektar::MultiRegions::GlobalLinSysStaticCond.
Definition at line 419 of file GlobalLinSys.cpp.
References Nektar::ErrorUtil::efatal, and NEKERROR.
Referenced by Initialise().
|
protectedvirtual |
Reimplemented in Nektar::MultiRegions::GlobalLinSysIterativeStaticCond, Nektar::MultiRegions::GlobalLinSysPETScStaticCond, and Nektar::MultiRegions::GlobalLinSysStaticCond.
Definition at line 414 of file GlobalLinSys.cpp.
References Nektar::ErrorUtil::efatal, and NEKERROR.
Referenced by InitObject().
|
protectedpure virtual |
Solve a linear system based on mapping.
Implemented in Nektar::MultiRegions::GlobalLinSysIterativeFull, Nektar::MultiRegions::GlobalLinSysPETScFull, Nektar::MultiRegions::GlobalLinSysStaticCond, Nektar::MultiRegions::GlobalLinSysXxtFull, and Nektar::MultiRegions::GlobalLinSysDirectFull.
Referenced by Solve().
|
protectedpure virtual |
Solve a basic matrix system.
Implemented in Nektar::MultiRegions::GlobalLinSysDirectFull, Nektar::MultiRegions::GlobalLinSysDirectStaticCond, Nektar::MultiRegions::GlobalLinSysIterativeFull, Nektar::MultiRegions::GlobalLinSysIterativeStaticCond, Nektar::MultiRegions::GlobalLinSysPETSc, Nektar::MultiRegions::GlobalLinSysPETScStaticCond, Nektar::MultiRegions::GlobalLinSysXxtStaticCond, and Nektar::MultiRegions::GlobalLinSysXxtFull.
Referenced by SolveLinearSystem().
|
staticprivate |
Definition at line 157 of file GlobalLinSys.h.
|
staticprivate |
Definition at line 156 of file GlobalLinSys.h.
|
protected |
Local Matrix System.
Definition at line 122 of file GlobalLinSys.h.
Referenced by Nektar::MultiRegions::GlobalLinSysDirectFull::AssembleFullMatrix(), Nektar::MultiRegions::GlobalLinSysXxtFull::AssembleMatrixArrays(), Nektar::MultiRegions::GlobalLinSysPETSc::CalculateReordering(), Nektar::MultiRegions::GlobalLinSysStaticCond::ConstructNextLevelCondensedSystem(), Nektar::MultiRegions::GlobalLinSysIterative::DoProjection(), GetBlockMatrixKey(), GetLocMat(), Nektar::MultiRegions::GlobalLinSysIterative::GlobalLinSysIterative(), Nektar::MultiRegions::GlobalLinSysPETSc::GlobalLinSysPETSc(), Nektar::MultiRegions::GlobalLinSysPETScFull::GlobalLinSysPETScFull(), Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::PrepareLocalSchurComplement(), Nektar::MultiRegions::GlobalLinSysStaticCond::SetupTopLevel(), Nektar::MultiRegions::GlobalLinSysIterative::UpdateKnownSolutions(), Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_AssembleSchurComplement(), Nektar::MultiRegions::GlobalLinSysXxtStaticCond::v_AssembleSchurComplement(), Nektar::MultiRegions::GlobalLinSysPETScFull::v_DoMatrixMultiply(), Nektar::MultiRegions::GlobalLinSysIterativeFull::v_DoMatrixMultiply(), v_DropBlock(), v_DropStaticCondBlock(), v_GetBlock(), v_GetNumBlocks(), v_GetStaticCondBlock(), Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_InitObject(), Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_InitObject(), Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_PreSolve(), Nektar::MultiRegions::GlobalLinSysIterativeFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysPETScFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysXxtFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysDirectFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysIterativeFull::v_SolveLinearSystem(), and Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_SolveLinearSystem().
|
protected |
Key associated with this linear system.
Definition at line 120 of file GlobalLinSys.h.
Referenced by Nektar::MultiRegions::GlobalLinSysDirectFull::AssembleFullMatrix(), Nektar::MultiRegions::GlobalLinSysXxtFull::AssembleMatrixArrays(), Nektar::MultiRegions::GlobalLinSysStaticCond::ConstructNextLevelCondensedSystem(), Nektar::MultiRegions::GlobalLinSysDirectStaticCond::DetermineMatrixStorage(), GetBlockMatrixKey(), GetKey(), Nektar::MultiRegions::GlobalLinSysDirectFull::GlobalLinSysDirectFull(), Nektar::MultiRegions::GlobalLinSysIterativeFull::GlobalLinSysIterativeFull(), Nektar::MultiRegions::GlobalLinSysXxtFull::GlobalLinSysXxtFull(), Nektar::MultiRegions::GlobalLinSysStaticCond::SetupTopLevel(), Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_AssembleSchurComplement(), Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_AssembleSchurComplement(), Nektar::MultiRegions::GlobalLinSysPETScFull::v_DoMatrixMultiply(), Nektar::MultiRegions::GlobalLinSysIterativeFull::v_DoMatrixMultiply(), Nektar::MultiRegions::GlobalLinSysIterativeStaticCond::v_InitObject(), Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_InitObject(), Nektar::MultiRegions::GlobalLinSysIterativeFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysPETScFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysXxtFull::v_Solve(), and Nektar::MultiRegions::GlobalLinSysDirectFull::v_Solve().
|
protected |
Robin boundary info.
Definition at line 124 of file GlobalLinSys.h.
Referenced by Nektar::MultiRegions::GlobalLinSysIterativeFull::v_DoMatrixMultiply(), v_GetBlock(), v_GetStaticCondBlock(), Nektar::MultiRegions::GlobalLinSysIterativeFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysPETScFull::v_Solve(), Nektar::MultiRegions::GlobalLinSysXxtFull::v_Solve(), and Nektar::MultiRegions::GlobalLinSysDirectFull::v_Solve().
|
protected |
Definition at line 126 of file GlobalLinSys.h.
Referenced by Nektar::MultiRegions::GlobalLinSysXxtFull::AssembleMatrixArrays(), Nektar::MultiRegions::GlobalLinSysIterative::DoProjection(), Nektar::MultiRegions::GlobalLinSysIterative::UpdateKnownSolutions(), and Nektar::MultiRegions::GlobalLinSysXxtStaticCond::v_AssembleSchurComplement().