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:
Inheritance graph
[legend]
Collaboration diagram for Nektar::MultiRegions::GlobalLinSysPETScStaticCond:
Collaboration graph
[legend]

Public Member Functions

 GlobalLinSysPETScStaticCond (const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Constructor for full direct matrix solve. More...
 
 GlobalLinSysPETScStaticCond (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)
 Constructor for full direct matrix solve. More...
 
virtual ~GlobalLinSysPETScStaticCond ()
 
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSysPETSc
 GlobalLinSysPETSc (const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExp, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve. More...
 
virtual ~GlobalLinSysPETSc ()
 
virtual void v_SolveLinearSystem (const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)
 Solve linear system using PETSc. More...
 
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSys
 GlobalLinSys (const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExpList, const boost::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 boost::weak_ptr< ExpList > & GetLocMat (void) const
 
void InitObject ()
 
void Initialise (const boost::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...
 
boost::shared_ptr< GlobalLinSysGetSharedThisPtr ()
 Returns a shared pointer to the current object. More...
 
int GetNumBlocks ()
 
DNekScalMatSharedPtr GetBlock (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 boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Constructor for full direct matrix solve. More...
 
virtual ~GlobalLinSysStaticCond ()
 

Static Public Member Functions

static GlobalLinSysSharedPtr create (const GlobalLinSysKey &pLinSysKey, const boost::weak_ptr< ExpList > &pExpList, const boost::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

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)
 
virtual void v_AssembleSchurComplement (boost::shared_ptr< AssemblyMap > locToGloMap)
 Assemble the Schur complement matrix. More...
 
- 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 ()
 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...
 
- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSys
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 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...
 
- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSysStaticCond
virtual DNekScalBlkMatSharedPtr v_PreSolve (int scLevel, NekVector< NekDouble > &F_GlobBnd)
 
virtual void v_BasisTransform (Array< OneD, NekDouble > &pInOut, int offset)
 
virtual void v_BasisInvTransform (Array< OneD, NekDouble > &pInOut)
 
virtual int v_GetNumBlocks ()
 Get the number of blocks in this system. More...
 
virtual void v_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...
 
virtual void v_InitObject ()
 
virtual void v_Initialise (const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Initialise this object. More...
 
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. More...
 
void ConstructNextLevelCondensedSystem (const boost::shared_ptr< AssemblyMap > &locToGloMap)
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSysPETSc
Mat m_matrix
 
Vec m_x
 
Vec m_b
 
Vec m_locVec
 
KSP m_ksp
 
vector< int > m_reorderedMap
 
VecScatter m_ctx
 
int m_nLocal
 
- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSys
const GlobalLinSysKey m_linSysKey
 Key associated with this linear system. More...
 
const boost::weak_ptr< ExpListm_expList
 Local Matrix System. More...
 
const map< int, RobinBCInfoSharedPtrm_robinBCInfo
 Robin boundary info. More...
 
- 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...
 
boost::shared_ptr< AssemblyMapm_locToGloMap
 Local to global map. More...
 
Array< OneD, NekDoublem_wsp
 Workspace array for matrix multiplication. More...
 

Detailed Description

A global linear system.

Definition at line 55 of file GlobalLinSysPETScStaticCond.h.

Constructor & Destructor Documentation

Nektar::MultiRegions::GlobalLinSysPETScStaticCond::GlobalLinSysPETScStaticCond ( const GlobalLinSysKey pKey,
const boost::weak_ptr< ExpList > &  pExpList,
const boost::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 87 of file GlobalLinSysPETScStaticCond.cpp.

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

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

Constructor for full direct matrix solve.

Definition at line 109 of file GlobalLinSysPETScStaticCond.cpp.

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

118  : GlobalLinSys (pKey, pExpList, pLocToGloMap),
119  GlobalLinSysPETSc (pKey, pExpList, pLocToGloMap),
120  GlobalLinSysStaticCond(pKey, pExpList, pLocToGloMap)
121  {
122  m_schurCompl = pSchurCompl;
123  m_BinvD = pBinvD;
124  m_C = pC;
125  m_invD = pInvD;
126  }
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
DNekScalBlkMatSharedPtr m_C
Block matrix.
DNekScalBlkMatSharedPtr m_invD
Block matrix.
GlobalLinSysPETSc(const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExp, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
GlobalLinSys(const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
GlobalLinSysStaticCond(const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.
DNekScalBlkMatSharedPtr m_BinvD
Block matrix.
Nektar::MultiRegions::GlobalLinSysPETScStaticCond::~GlobalLinSysPETScStaticCond ( )
virtual

Definition at line 131 of file GlobalLinSysPETScStaticCond.cpp.

132  {
133 
134  }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 60 of file GlobalLinSysPETScStaticCond.h.

65  {
67  GlobalLinSysPETScStaticCond>::AllocateSharedPtr(
68  pLinSysKey, pExpList, pLocToGloMap);
69  p->InitObject();
70  return p;
71  }
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
GlobalLinSysPETScStaticCond(const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.
boost::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:51
void Nektar::MultiRegions::GlobalLinSysPETScStaticCond::v_AssembleSchurComplement ( boost::shared_ptr< AssemblyMap locToGloMap)
protectedvirtual

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 141 of file GlobalLinSysPETScStaticCond.cpp.

References Nektar::MultiRegions::GlobalLinSysPETSc::CalculateReordering(), Nektar::MultiRegions::GlobalLinSysStaticCond::m_BinvD, Nektar::MultiRegions::GlobalLinSysStaticCond::m_C, Nektar::MultiRegions::GlobalLinSysStaticCond::m_invD, Nektar::MultiRegions::GlobalLinSysPETSc::m_matrix, Nektar::MultiRegions::GlobalLinSysPETSc::m_reorderedMap, Nektar::MultiRegions::GlobalLinSysStaticCond::m_schurCompl, Nektar::MultiRegions::GlobalLinSysPETSc::SetUpMatVec(), Nektar::MultiRegions::GlobalLinSysPETSc::SetUpScatter(), and Nektar::MultiRegions::GlobalLinSysPETSc::SetUpSolver().

143  {
144  int i, j, n, cnt, gid1, gid2, loc_lda;
145  NekDouble sign1, sign2, value;
146 
147  const int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
148 
153  DNekScalMatSharedPtr loc_mat;
154 
155  // CALCULATE REORDERING MAPPING
156  CalculateReordering(pLocToGloMap->GetGlobalToUniversalBndMap(),
157  pLocToGloMap->GetGlobalToUniversalBndMapUnique(),
158  pLocToGloMap);
159 
160  // SET UP VECTORS AND MATRIX
161  SetUpMatVec();
162 
163  for(n = cnt = 0; n < m_schurCompl->GetNumberOfBlockRows(); ++n)
164  {
165  loc_mat = m_schurCompl->GetBlock(n,n);
166  loc_lda = loc_mat->GetRows();
167 
168  for(i = 0; i < loc_lda; ++i)
169  {
170  gid1 = pLocToGloMap->GetLocalToGlobalBndMap(cnt + i)-nDirDofs;
171  sign1 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + i);
172  if(gid1 >= 0)
173  {
174  int gid1ro = m_reorderedMap[gid1];
175  for(j = 0; j < loc_lda; ++j)
176  {
177  gid2 = pLocToGloMap->GetLocalToGlobalBndMap(cnt + j)
178  - nDirDofs;
179  sign2 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + j);
180  if(gid2 >= 0)
181  {
182  int gid2ro = m_reorderedMap[gid2];
183  value = sign1*sign2*(*loc_mat)(i,j);
184  MatSetValue(
185  m_matrix, gid1ro, gid2ro, value, ADD_VALUES);
186  }
187  }
188  }
189  }
190  cnt += loc_lda;
191  }
192 
193  // ASSEMBLE MATRIX
194  MatAssemblyBegin(m_matrix, MAT_FINAL_ASSEMBLY);
195  MatAssemblyEnd (m_matrix, MAT_FINAL_ASSEMBLY);
196 
197  // SET UP SCATTER OBJECTS
198  SetUpScatter();
199 
200  // CONSTRUCT KSP OBJECT
201  SetUpSolver(pLocToGloMap->GetIterativeTolerance());
202  }
void SetUpMatVec()
Construct PETSc matrix and vector handles.
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
DNekScalBlkMatSharedPtr m_C
Block matrix.
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.
void SetUpSolver(NekDouble tolerance)
Set up KSP solver object.
DNekScalBlkMatSharedPtr m_invD
Block matrix.
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
boost::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:74
double NekDouble
void SetUpScatter()
Set up PETSc local (equivalent to Nektar++ global) and global (equivalent to universal) scatter maps...
DNekScalBlkMatSharedPtr m_BinvD
Block matrix.
GlobalLinSysStaticCondSharedPtr Nektar::MultiRegions::GlobalLinSysPETScStaticCond::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 
)
protectedvirtual

Implements Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 204 of file GlobalLinSysPETScStaticCond.cpp.

212  {
214  GlobalLinSysPETScStaticCond>::AllocateSharedPtr(
215  mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap);
216  sys->Initialise(l2gMap);
217  return sys;
218  }
boost::shared_ptr< GlobalLinSysPETScStaticCond > GlobalLinSysPETScStaticCondSharedPtr
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
GlobalLinSysPETScStaticCond(const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.

Member Data Documentation

string Nektar::MultiRegions::GlobalLinSysPETScStaticCond::className
static
Initial value:
"PETScStaticCond",
"PETSc static condensation.")

Name of class.

Registers the class with the Factory.

Definition at line 74 of file GlobalLinSysPETScStaticCond.h.

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

Definition at line 75 of file GlobalLinSysPETScStaticCond.h.