Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Nektar::MultiRegions::GlobalLinSysPETScStaticCond Class Reference

A global linear system. More...

#include <GlobalLinSysPETScStaticCond.h>

Inheritance diagram for Nektar::MultiRegions::GlobalLinSysPETScStaticCond:
[legend]

Public Member Functions

 GlobalLinSysPETScStaticCond (const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &locToGloMap)
 Constructor for full direct matrix solve. More...
 
 GlobalLinSysPETScStaticCond (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, const PreconditionerSharedPtr pPrecon=PreconditionerSharedPtr())
 Constructor for full direct matrix solve. More...
 
 ~GlobalLinSysPETScStaticCond () override
 
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSysPETSc
 GlobalLinSysPETSc (const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExp, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve. More...
 
 ~GlobalLinSysPETSc () override
 Clean up PETSc objects. More...
 
- Public Member Functions inherited from 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. More...
 
virtual ~GlobalLinSys ()
 
const GlobalLinSysKeyGetKey (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< GlobalLinSysGetSharedThisPtr ()
 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...
 
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSysStaticCond
 GlobalLinSysStaticCond (const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &locToGloMap)
 Constructor for full direct matrix solve. More...
 
 ~GlobalLinSysStaticCond () override
 

Static Public Member Functions

static GlobalLinSysSharedPtr create (const GlobalLinSysKey &pLinSysKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
 Creates an instance of this class. More...
 

Static Public Attributes

static std::string className
 Name of class. More...
 
static std::string className2
 

Protected Member Functions

void v_InitObject () override
 
void v_AssembleSchurComplement (std::shared_ptr< AssemblyMap > locToGloMap) override
 Assemble the Schur complement matrix. More...
 
void v_DoMatrixMultiply (const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output) override
 Apply matrix-vector multiplication using local approach and the assembly map. More...
 
DNekScalBlkMatSharedPtr v_GetStaticCondBlock (unsigned int n) override
 Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided by the m_linSysKey. More...
 
void v_PreSolve (int scLevel, Array< OneD, NekDouble > &F_bBnd) override
 
void v_SolveLinearSystem (const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir) override
 Solve linear system using PETSc. More...
 
void v_BasisFwdTransform (Array< OneD, NekDouble > &pInOut) override
 
void v_CoeffsBwdTransform (Array< OneD, NekDouble > &pInOut) override
 
void v_CoeffsFwdTransform (const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
 
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) override
 
- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSysPETSc
void SetUpScatter ()
 Set up PETSc local (equivalent to Nektar++ global) and global (equivalent to universal) scatter maps. More...
 
void SetUpMatVec (int nGlobal, int nDir)
 Construct PETSc matrix and vector handles. More...
 
void SetUpSolver (NekDouble tolerance)
 Set up KSP solver object. More...
 
void CalculateReordering (const Array< OneD, const int > &glo2uniMap, const Array< OneD, const int > &glo2unique, const AssemblyMapSharedPtr &pLocToGloMap)
 Calculate a reordering of universal IDs for PETSc. More...
 
void v_SolveLinearSystem (const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir) override
 Solve linear system using PETSc. More...
 
virtual void v_DoMatrixMultiply (const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)=0
 
- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSys
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 Member Functions inherited from Nektar::MultiRegions::GlobalLinSysStaticCond
virtual void v_PreSolve (int scLevel, Array< OneD, NekDouble > &F_bnd)
 
virtual void v_BasisFwdTransform (Array< OneD, NekDouble > &pInOut)
 
virtual void v_CoeffsBwdTransform (Array< OneD, NekDouble > &pInOut)
 
virtual void v_CoeffsFwdTransform (const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
 
virtual void v_AssembleSchurComplement (std::shared_ptr< AssemblyMap > pLoctoGloMap)
 
int v_GetNumBlocks () override
 Get the number of blocks in this system. More...
 
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)=0
 
void v_Solve (const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray) override
 Solve the linear system for given input and output vectors using a specified local to global map. More...
 
void v_InitObject () override
 
void v_Initialise (const std::shared_ptr< AssemblyMap > &locToGloMap) override
 Initialise this object. More...
 
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. More...
 
void ConstructNextLevelCondensedSystem (const std::shared_ptr< AssemblyMap > &locToGloMap)
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSysPETSc
Mat m_matrix
 PETSc matrix object. More...
 
Vec m_x
 PETSc vector objects used for local storage. More...
 
Vec m_b
 
Vec m_locVec
 
KSP m_ksp
 KSP object that represents solver system. More...
 
PC m_pc
 PCShell for preconditioner. More...
 
PETScMatMult m_matMult
 Enumerator to select matrix multiplication type. More...
 
std::vector< int > m_reorderedMap
 Reordering that takes universal IDs to a unique row in the PETSc matrix. More...
 
VecScatter m_ctx
 PETSc scatter context that takes us between Nektar++ global ordering and PETSc vector ordering. More...
 
int m_nLocal
 Number of unique degrees of freedom on this process. More...
 
PreconditionerSharedPtr m_precon
 
- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSys
const GlobalLinSysKey m_linSysKey
 Key associated with this linear system. More...
 
const std::weak_ptr< ExpListm_expList
 Local Matrix System. More...
 
const std::map< int, RobinBCInfoSharedPtrm_robinBCInfo
 Robin boundary info. More...
 
bool m_verbose
 
- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSysStaticCond
GlobalLinSysStaticCondSharedPtr m_recursiveSchurCompl
 Schur complement for Direct Static Condensation. More...
 
DNekScalBlkMatSharedPtr m_schurCompl
 Block Schur complement matrix. More...
 
DNekScalBlkMatSharedPtr m_BinvD
 Block \( BD^{-1} \) matrix. More...
 
DNekScalBlkMatSharedPtr m_C
 Block \( C \) matrix. More...
 
DNekScalBlkMatSharedPtr m_invD
 Block \( D^{-1} \) matrix. More...
 
std::weak_ptr< AssemblyMapm_locToGloMap
 Local to global map. More...
 
Array< OneD, NekDoublem_wsp
 Workspace array for matrix multiplication. More...
 
Array< OneD, const NekDoublem_sign
 

Detailed Description

A global linear system.

Definition at line 52 of file GlobalLinSysPETScStaticCond.h.

Constructor & Destructor Documentation

◆ GlobalLinSysPETScStaticCond() [1/2]

Nektar::MultiRegions::GlobalLinSysPETScStaticCond::GlobalLinSysPETScStaticCond ( const GlobalLinSysKey pKey,
const std::weak_ptr< ExpList > &  pExpList,
const std::shared_ptr< AssemblyMap > &  pLocToGloMap 
)

Constructor for full direct matrix solve.

For a matrix system of the form

\[ \left[ \begin{array}{cc} \boldsymbol{A} & \boldsymbol{B}\\ \boldsymbol{C} & \boldsymbol{D} \end{array} \right] \left[ \begin{array}{c} \boldsymbol{x_1}\\ \boldsymbol{x_2} \end{array}\right] = \left[ \begin{array}{c} \boldsymbol{y_1}\\ \boldsymbol{y_2} \end{array}\right], \]

where \(\boldsymbol{D}\) and \((\boldsymbol{A-BD^{-1}C})\) are invertible, store and assemble a static condensation system, according to a given local to global mapping. #m_linSys is constructed by AssembleSchurComplement().

Parameters
mKeyAssociated matrix key.
pLocMatSysLocalMatrixSystem
locToGloMapLocal to global mapping.

Definition at line 84 of file GlobalLinSysPETScStaticCond.cpp.

87 : GlobalLinSys(pKey, pExpList, pLocToGloMap),
88 GlobalLinSysPETSc(pKey, pExpList, pLocToGloMap),
89 GlobalLinSysStaticCond(pKey, pExpList, pLocToGloMap)
90{
91 ASSERTL1((pKey.GetGlobalSysSolnType() == ePETScStaticCond) ||
92 (pKey.GetGlobalSysSolnType() == ePETScMultiLevelStaticCond),
93 "This constructor is only valid when using static "
94 "condensation");
95 ASSERTL1(pKey.GetGlobalSysSolnType() ==
96 pLocToGloMap->GetGlobalSysSolnType(),
97 "The local to global map is not set up for the requested "
98 "solution type");
99}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
GlobalLinSys(const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
GlobalLinSysPETSc(const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExp, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
GlobalLinSysStaticCond(const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.

References ASSERTL1, Nektar::MultiRegions::ePETScMultiLevelStaticCond, Nektar::MultiRegions::ePETScStaticCond, and Nektar::MultiRegions::GlobalLinSysKey::GetGlobalSysSolnType().

◆ GlobalLinSysPETScStaticCond() [2/2]

Nektar::MultiRegions::GlobalLinSysPETScStaticCond::GlobalLinSysPETScStaticCond ( 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,
const PreconditionerSharedPtr  pPrecon = PreconditionerSharedPtr() 
)

Constructor for full direct matrix solve.

Definition at line 104 of file GlobalLinSysPETScStaticCond.cpp.

111 : GlobalLinSys(pKey, pExpList, pLocToGloMap),
112 GlobalLinSysPETSc(pKey, pExpList, pLocToGloMap),
113 GlobalLinSysStaticCond(pKey, pExpList, pLocToGloMap)
114{
115 m_schurCompl = pSchurCompl;
116 m_BinvD = pBinvD;
117 m_C = pC;
118 m_invD = pInvD;
119 m_precon = pPrecon;
120}
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
DNekScalBlkMatSharedPtr m_BinvD
Block matrix.
DNekScalBlkMatSharedPtr m_C
Block matrix.
DNekScalBlkMatSharedPtr m_invD
Block matrix.

References Nektar::MultiRegions::GlobalLinSysStaticCond::m_BinvD, Nektar::MultiRegions::GlobalLinSysStaticCond::m_C, Nektar::MultiRegions::GlobalLinSysStaticCond::m_invD, Nektar::MultiRegions::GlobalLinSysPETSc::m_precon, and Nektar::MultiRegions::GlobalLinSysStaticCond::m_schurCompl.

◆ ~GlobalLinSysPETScStaticCond()

Nektar::MultiRegions::GlobalLinSysPETScStaticCond::~GlobalLinSysPETScStaticCond ( )
override

Definition at line 125 of file GlobalLinSysPETScStaticCond.cpp.

126{
127}

Member Function Documentation

◆ create()

static GlobalLinSysSharedPtr Nektar::MultiRegions::GlobalLinSysPETScStaticCond::create ( const GlobalLinSysKey pLinSysKey,
const std::weak_ptr< ExpList > &  pExpList,
const std::shared_ptr< AssemblyMap > &  pLocToGloMap 
)
inlinestatic

Creates an instance of this class.

Definition at line 57 of file GlobalLinSysPETScStaticCond.h.

61 {
64 pLinSysKey, pExpList, pLocToGloMap);
65 p->InitObject();
66 return p;
67 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:51

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and CellMLToNektar.cellml_metadata::p.

◆ v_AssembleSchurComplement()

void Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_AssembleSchurComplement ( std::shared_ptr< AssemblyMap locToGloMap)
overrideprotectedvirtual

Assemble the Schur complement matrix.

Assemble the schur complement matrix from the block matrices stored in #m_blkMatrices and the given local to global mapping information.

Parameters
locToGloMapLocal to global mapping information.

Reimplemented from Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 167 of file GlobalLinSysPETScStaticCond.cpp.

169{
170 int i, j, n, cnt, gid1, gid2, loc_lda;
171 NekDouble sign1, sign2, value;
172
173 const int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
174
179 DNekScalMatSharedPtr loc_mat;
180
181 // Build precon again if we in multi-level static condensation (a
182 // bit of a hack)
184 {
186 m_precon->BuildPreconditioner();
187 }
188
189 // CALCULATE REORDERING MAPPING
190 CalculateReordering(pLocToGloMap->GetGlobalToUniversalBndMap(),
191 pLocToGloMap->GetGlobalToUniversalBndMapUnique(),
192 pLocToGloMap);
193
194 // SET UP VECTORS AND MATRIX
195 SetUpMatVec(pLocToGloMap->GetNumGlobalBndCoeffs(), nDirDofs);
196
197 // SET UP SCATTER OBJECTS
198 SetUpScatter();
199
200 // CONSTRUCT KSP OBJECT
201 SetUpSolver(pLocToGloMap->GetIterativeTolerance());
202
203 // If we are using the matrix multiplication shell don't try to
204 // populate the matrix.
206 {
207 return;
208 }
209
210 // POPULATE MATRIX
211 for (n = cnt = 0; n < m_schurCompl->GetNumberOfBlockRows(); ++n)
212 {
213 loc_mat = m_schurCompl->GetBlock(n, n);
214 loc_lda = loc_mat->GetRows();
215
216 for (i = 0; i < loc_lda; ++i)
217 {
218 gid1 = pLocToGloMap->GetLocalToGlobalBndMap(cnt + i) - nDirDofs;
219 sign1 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + i);
220 if (gid1 >= 0)
221 {
222 int gid1ro = m_reorderedMap[gid1];
223 for (j = 0; j < loc_lda; ++j)
224 {
225 gid2 = pLocToGloMap->GetLocalToGlobalBndMap(cnt + j) -
226 nDirDofs;
227 sign2 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + j);
228 if (gid2 >= 0)
229 {
230 int gid2ro = m_reorderedMap[gid2];
231 value = sign1 * sign2 * (*loc_mat)(i, j);
232 MatSetValue(m_matrix, gid1ro, gid2ro, value,
233 ADD_VALUES);
234 }
235 }
236 }
237 }
238 cnt += loc_lda;
239 }
240
241 // ASSEMBLE MATRIX
242 MatAssemblyBegin(m_matrix, MAT_FINAL_ASSEMBLY);
243 MatAssemblyEnd(m_matrix, MAT_FINAL_ASSEMBLY);
244}
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
Definition: GlobalLinSys.h:120
PreconditionerSharedPtr CreatePrecon(AssemblyMapSharedPtr asmMap)
Create a preconditioner object from the parameters defined in the supplied assembly map.
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
PETScMatMult m_matMult
Enumerator to select matrix multiplication type.
std::vector< int > m_reorderedMap
Reordering that takes universal IDs to a unique row in the PETSc matrix.
void SetUpScatter()
Set up PETSc local (equivalent to Nektar++ global) and global (equivalent to universal) scatter maps.
void SetUpSolver(NekDouble tolerance)
Set up KSP solver object.
void SetUpMatVec(int nGlobal, int nDir)
Construct PETSc matrix and vector handles.
void CalculateReordering(const Array< OneD, const int > &glo2uniMap, const Array< OneD, const int > &glo2unique, const AssemblyMapSharedPtr &pLocToGloMap)
Calculate a reordering of universal IDs for PETSc.
std::weak_ptr< AssemblyMap > m_locToGloMap
Local to global map.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:79
double NekDouble

References Nektar::MultiRegions::GlobalLinSysPETSc::CalculateReordering(), Nektar::MultiRegions::GlobalLinSys::CreatePrecon(), Nektar::MultiRegions::ePETScMatMultShell, Nektar::MultiRegions::ePETScMultiLevelStaticCond, Nektar::MultiRegions::GlobalLinSysKey::GetGlobalSysSolnType(), Nektar::MultiRegions::GlobalLinSysStaticCond::m_BinvD, Nektar::MultiRegions::GlobalLinSysStaticCond::m_C, Nektar::MultiRegions::GlobalLinSysStaticCond::m_invD, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, Nektar::MultiRegions::GlobalLinSysStaticCond::m_locToGloMap, Nektar::MultiRegions::GlobalLinSysPETSc::m_matMult, Nektar::MultiRegions::GlobalLinSysPETSc::m_matrix, Nektar::MultiRegions::GlobalLinSysPETSc::m_precon, Nektar::MultiRegions::GlobalLinSysPETSc::m_reorderedMap, Nektar::MultiRegions::GlobalLinSysStaticCond::m_schurCompl, Nektar::MultiRegions::GlobalLinSysPETSc::SetUpMatVec(), Nektar::MultiRegions::GlobalLinSysPETSc::SetUpScatter(), and Nektar::MultiRegions::GlobalLinSysPETSc::SetUpSolver().

◆ v_BasisFwdTransform()

void Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_BasisFwdTransform ( Array< OneD, NekDouble > &  pInOut)
overrideprotectedvirtual

Reimplemented from Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 332 of file GlobalLinSysPETScStaticCond.cpp.

334{
335 m_precon->DoTransformBasisToLowEnergy(pInOut);
336}

References Nektar::MultiRegions::GlobalLinSysPETSc::m_precon.

◆ v_CoeffsBwdTransform()

void Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_CoeffsBwdTransform ( Array< OneD, NekDouble > &  pInOut)
overrideprotectedvirtual

Reimplemented from Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 338 of file GlobalLinSysPETScStaticCond.cpp.

340{
341 m_precon->DoTransformCoeffsFromLowEnergy(pInOut);
342}

References Nektar::MultiRegions::GlobalLinSysPETSc::m_precon.

◆ v_CoeffsFwdTransform()

void Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_CoeffsFwdTransform ( const Array< OneD, NekDouble > &  pInput,
Array< OneD, NekDouble > &  pOutput 
)
overrideprotectedvirtual

Reimplemented from Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 344 of file GlobalLinSysPETScStaticCond.cpp.

346{
347 m_precon->DoTransformCoeffsToLowEnergy(pInput, pOutput);
348}

References Nektar::MultiRegions::GlobalLinSysPETSc::m_precon.

◆ v_DoMatrixMultiply()

void Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_DoMatrixMultiply ( const Array< OneD, const NekDouble > &  input,
Array< OneD, NekDouble > &  output 
)
overrideprotectedvirtual

Apply matrix-vector multiplication using local approach and the assembly map.

Parameters
inputVector input.
outputResult of multiplication.
Todo:
This can possibly be made faster by using the sparse block-matrix multiplication code from the iterative elastic systems.

Implements Nektar::MultiRegions::GlobalLinSysPETSc.

Definition at line 361 of file GlobalLinSysPETScStaticCond.cpp.

363{
364 auto asmMap = m_locToGloMap.lock();
365
366 int nLocBndDofs = asmMap->GetNumLocalBndCoeffs();
367 int nDirDofs = asmMap->GetNumGlobalDirBndCoeffs();
368
369 NekVector<NekDouble> in(nLocBndDofs), out(nLocBndDofs);
370 asmMap->GlobalToLocalBnd(input, in.GetPtr(), nDirDofs);
371 out = (*m_schurCompl) * in;
372 asmMap->AssembleBnd(out.GetPtr(), output, nDirDofs);
373}

References Nektar::NekVector< DataType >::GetPtr(), and Nektar::MultiRegions::GlobalLinSysStaticCond::m_locToGloMap.

◆ v_GetStaticCondBlock()

DNekScalBlkMatSharedPtr Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_GetStaticCondBlock ( unsigned int  n)
overrideprotectedvirtual

Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided by the m_linSysKey.

Parameters
nNumber of the expansion
Returns
2x2 Block matrix holding the static condensation matrices for the n-th expansion.

Reimplemented from Nektar::MultiRegions::GlobalLinSys.

Definition at line 246 of file GlobalLinSysPETScStaticCond.cpp.

248{
249 DNekScalBlkMatSharedPtr schurComplBlock;
250 DNekScalMatSharedPtr localMat = m_schurCompl->GetBlock(n, n);
251 unsigned int nbdry = localMat->GetRows();
252 unsigned int nblks = 1;
253 unsigned int esize[1] = {nbdry};
254
256 nblks, nblks, esize, esize);
257 schurComplBlock->SetBlock(0, 0, localMat);
258
259 return schurComplBlock;
260}

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and Nektar::MultiRegions::GlobalLinSysStaticCond::m_schurCompl.

◆ v_InitObject()

void Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_InitObject ( )
overrideprotectedvirtual

Reimplemented from Nektar::MultiRegions::GlobalLinSys.

Definition at line 129 of file GlobalLinSysPETScStaticCond.cpp.

130{
131 auto asmMap = m_locToGloMap.lock();
132
133 m_precon = CreatePrecon(asmMap);
134
135 // Allocate memory for top-level structure
136 SetupTopLevel(asmMap);
137
138 // Setup Block Matrix systems
139 int n, n_exp = m_expList.lock()->GetNumElmts();
140
141 // Build preconditioner
142 m_precon->BuildPreconditioner();
143
144 // Do transform of Schur complement matrix
145 int cnt = 0;
146 for (n = 0; n < n_exp; ++n)
147 {
149 {
150 DNekScalMatSharedPtr mat = m_schurCompl->GetBlock(n, n);
152 m_precon->TransformedSchurCompl(n, cnt, mat);
153 m_schurCompl->SetBlock(n, n, t);
154 cnt += mat->GetRows();
155 }
156 }
157
158 // Construct this level
159 Initialise(asmMap);
160}
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
Definition: GlobalLinSys.h:122
void Initialise(const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Definition: GlobalLinSys.h:203
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.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.

References Nektar::MultiRegions::GlobalLinSys::CreatePrecon(), Nektar::StdRegions::eHybridDGHelmBndLam, Nektar::MultiRegions::GlobalMatrixKey::GetMatrixType(), Nektar::MultiRegions::GlobalLinSys::Initialise(), Nektar::MultiRegions::GlobalLinSys::m_expList, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, Nektar::MultiRegions::GlobalLinSysStaticCond::m_locToGloMap, Nektar::MultiRegions::GlobalLinSysPETSc::m_precon, Nektar::MultiRegions::GlobalLinSysStaticCond::m_schurCompl, and Nektar::MultiRegions::GlobalLinSysStaticCond::SetupTopLevel().

◆ v_PreSolve()

void Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_PreSolve ( int  scLevel,
Array< OneD, NekDouble > &  F_bBnd 
)
overrideprotectedvirtual

Reimplemented from Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 262 of file GlobalLinSysPETScStaticCond.cpp.

264{
265 if (scLevel == 0)
266 {
267 // When matrices are supplied to the constructor at the top
268 // level, the preconditioner is never set up.
269 if (!m_precon)
270 {
272 m_precon->BuildPreconditioner();
273 }
274 }
275}

References Nektar::MultiRegions::GlobalLinSys::CreatePrecon(), Nektar::MultiRegions::GlobalLinSysStaticCond::m_locToGloMap, and Nektar::MultiRegions::GlobalLinSysPETSc::m_precon.

◆ v_Recurse()

GlobalLinSysStaticCondSharedPtr Nektar::MultiRegions::GlobalLinSysPETScStaticCond::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 
)
overrideprotectedvirtual

Implements Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 375 of file GlobalLinSysPETScStaticCond.cpp.

381{
384 mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap, m_precon);
385 sys->Initialise(l2gMap);
386 return sys;
387}
std::shared_ptr< GlobalLinSysPETScStaticCond > GlobalLinSysPETScStaticCondSharedPtr

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and Nektar::MultiRegions::GlobalLinSysPETSc::m_precon.

◆ v_SolveLinearSystem()

void Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_SolveLinearSystem ( const int  pNumRows,
const Array< OneD, const NekDouble > &  pInput,
Array< OneD, NekDouble > &  pOutput,
const AssemblyMapSharedPtr locToGloMap,
const int  pNumDir 
)
overrideprotectedvirtual

Solve linear system using PETSc.

The general strategy being a PETSc solve is to:

  • Copy values into the PETSc vector m_b
  • Solve the system m_ksp and place result into m_x.
  • Scatter results back into m_locVec using m_ctx scatter object.
  • Copy from m_locVec to output array #pOutput.

Reimplemented from Nektar::MultiRegions::GlobalLinSysPETSc.

Definition at line 287 of file GlobalLinSysPETScStaticCond.cpp.

291{
292 const int nHomDofs = pNumRows - pNumDir;
293
295 {
296 m_precon = CreatePrecon(locToGloMap);
297 m_precon->BuildPreconditioner();
298 }
299
300 Array<OneD, NekDouble> Glo(pNumRows);
301 locToGloMap->AssembleBnd(pInput, Glo);
302
303 // Populate RHS vector from input
304 VecSetValues(m_b, nHomDofs, &m_reorderedMap[0], &Glo[pNumDir],
305 INSERT_VALUES);
306
307 // Assemble RHS vector
308 VecAssemblyBegin(m_b);
309 VecAssemblyEnd(m_b);
310
311 // Do system solve
312 KSPSolve(m_ksp, m_b, m_x);
313
314 KSPConvergedReason reason;
315 KSPGetConvergedReason(m_ksp, &reason);
316 ASSERTL0(reason > 0, "PETSc solver diverged, reason is: " +
317 std::string(KSPConvergedReasons[reason]));
318
319 // Scatter results to local vector
320 VecScatterBegin(m_ctx, m_x, m_locVec, INSERT_VALUES, SCATTER_FORWARD);
321 VecScatterEnd(m_ctx, m_x, m_locVec, INSERT_VALUES, SCATTER_FORWARD);
322
323 // Copy results into output vector
324 PetscScalar *tmp;
325 VecGetArray(m_locVec, &tmp);
326 Vmath::Vcopy(nHomDofs, tmp, 1, &Glo[pNumDir], 1);
327 Vmath::Zero(pNumDir, Glo, 1);
328 locToGloMap->GlobalToLocalBnd(Glo, pOutput);
329 VecRestoreArray(m_locVec, &tmp);
330}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
Vec m_x
PETSc vector objects used for local storage.
VecScatter m_ctx
PETSc scatter context that takes us between Nektar++ global ordering and PETSc vector ordering.
KSP m_ksp
KSP object that represents solver system.
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.hpp:273
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

References ASSERTL0, Nektar::MultiRegions::GlobalLinSys::CreatePrecon(), Nektar::MultiRegions::ePETScMatMultShell, Nektar::MultiRegions::GlobalLinSysPETSc::m_b, Nektar::MultiRegions::GlobalLinSysPETSc::m_ctx, Nektar::MultiRegions::GlobalLinSysPETSc::m_ksp, Nektar::MultiRegions::GlobalLinSysPETSc::m_locVec, Nektar::MultiRegions::GlobalLinSysPETSc::m_matMult, Nektar::MultiRegions::GlobalLinSysPETSc::m_precon, Nektar::MultiRegions::GlobalLinSysPETSc::m_reorderedMap, Nektar::MultiRegions::GlobalLinSysPETSc::m_x, Vmath::Vcopy(), and Vmath::Zero().

Member Data Documentation

◆ className

string Nektar::MultiRegions::GlobalLinSysPETScStaticCond::className
static
Initial value:
=
"PETSc static condensation.")
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
static GlobalLinSysSharedPtr create(const GlobalLinSysKey &pLinSysKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
GlobalLinSysFactory & GetGlobalLinSysFactory()

Name of class.

Registers the class with the Factory.

Definition at line 70 of file GlobalLinSysPETScStaticCond.h.

◆ className2

string Nektar::MultiRegions::GlobalLinSysPETScStaticCond::className2
static
Initial value:
=
"PETScMultiLevelStaticCond", GlobalLinSysPETScStaticCond::create,
"PETSc multi-level static condensation.")

Definition at line 71 of file GlobalLinSysPETScStaticCond.h.