Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | List of all members
Nektar::MultiRegions::GlobalLinSysDirectStaticCond Class Reference

A global linear system. More...

#include <GlobalLinSysDirectStaticCond.h>

Inheritance diagram for Nektar::MultiRegions::GlobalLinSysDirectStaticCond:
Inheritance graph
[legend]
Collaboration diagram for Nektar::MultiRegions::GlobalLinSysDirectStaticCond:
Collaboration graph
[legend]

Public Member Functions

 GlobalLinSysDirectStaticCond (const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Constructor for full direct matrix solve. More...
 
 GlobalLinSysDirectStaticCond (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 ~GlobalLinSysDirectStaticCond ()
 
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSysDirect
 GlobalLinSysDirect (const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExp, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve. More...
 
virtual ~GlobalLinSysDirect ()
 
- 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 void v_AssembleSchurComplement (boost::shared_ptr< AssemblyMap > pLocToGloMap)
 
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 > &l2gMap)
 
- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSysDirect
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 the linear system for given input and output vectors. 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...
 
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 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)
 

Private Member Functions

MatrixStorage DetermineMatrixStorage (const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Matrix Storage type for known matrices. More...
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSysDirect
DNekLinSysSharedPtr m_linSys
 Basic linear system object. More...
 
- 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,
RobinBCInfoSharedPtr
m_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 54 of file GlobalLinSysDirectStaticCond.h.

Constructor & Destructor Documentation

Nektar::MultiRegions::GlobalLinSysDirectStaticCond::GlobalLinSysDirectStaticCond ( 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 83 of file GlobalLinSysDirectStaticCond.cpp.

References ASSERTL1, Nektar::MultiRegions::eDirectMultiLevelStaticCond, Nektar::MultiRegions::eDirectStaticCond, and Nektar::MultiRegions::GlobalLinSysKey::GetGlobalSysSolnType().

88  : GlobalLinSys (pKey, pExpList, pLocToGloMap),
89  GlobalLinSysDirect (pKey, pExpList, pLocToGloMap),
90  GlobalLinSysStaticCond(pKey, pExpList, pLocToGloMap)
91  {
92  ASSERTL1((pKey.GetGlobalSysSolnType()==eDirectStaticCond)||
93  (pKey.GetGlobalSysSolnType()==eDirectMultiLevelStaticCond),
94  "This constructor is only valid when using static "
95  "condensation");
96  ASSERTL1(pKey.GetGlobalSysSolnType()
97  == pLocToGloMap->GetGlobalSysSolnType(),
98  "The local to global map is not set up for the requested "
99  "solution type");
100  }
GlobalLinSysDirect(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::GlobalLinSysDirectStaticCond::GlobalLinSysDirectStaticCond ( 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 105 of file GlobalLinSysDirectStaticCond.cpp.

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

113  : GlobalLinSys (pKey, pExpList, pLocToGloMap),
114  GlobalLinSysDirect (pKey, pExpList, pLocToGloMap),
115  GlobalLinSysStaticCond(pKey, pExpList, pLocToGloMap)
116  {
117  m_schurCompl = pSchurCompl;
118  m_BinvD = pBinvD;
119  m_C = pC;
120  m_invD = pInvD;
121  }
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
DNekScalBlkMatSharedPtr m_C
Block matrix.
DNekScalBlkMatSharedPtr m_invD
Block matrix.
GlobalLinSysDirect(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::GlobalLinSysDirectStaticCond::~GlobalLinSysDirectStaticCond ( )
virtual

Definition at line 127 of file GlobalLinSysDirectStaticCond.cpp.

128  {
129 
130  }

Member Function Documentation

static GlobalLinSysSharedPtr Nektar::MultiRegions::GlobalLinSysDirectStaticCond::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 59 of file GlobalLinSysDirectStaticCond.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

63  {
66  ::AllocateSharedPtr(pLinSysKey, pExpList, pLocToGloMap);
67  ret->InitObject();
68  return ret;
69  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< GlobalLinSysDirectStaticCond > GlobalLinSysDirectStaticCondSharedPtr
MatrixStorage Nektar::MultiRegions::GlobalLinSysDirectStaticCond::DetermineMatrixStorage ( const boost::shared_ptr< AssemblyMap > &  locToGloMap)
private

Matrix Storage type for known matrices.

Definition at line 133 of file GlobalLinSysDirectStaticCond.cpp.

References Nektar::eFULL, Nektar::StdRegions::eHelmholtz, Nektar::StdRegions::eHybridDGHelmBndLam, Nektar::StdRegions::eLaplacian, Nektar::StdRegions::eLinearAdvectionDiffusionReaction, Nektar::StdRegions::eLinearAdvectionReaction, Nektar::StdRegions::eMass, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC_BANDED, Nektar::MultiRegions::GlobalMatrixKey::GetMatrixType(), and Nektar::MultiRegions::GlobalLinSys::m_linSysKey.

Referenced by v_AssembleSchurComplement().

135  {
136  int nBndDofs = pLocToGloMap->GetNumGlobalBndCoeffs();
137  int NumDirBCs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
138  unsigned int rows = nBndDofs - NumDirBCs;
139  int bwidth = pLocToGloMap->GetBndSystemBandWidth();
140 
141  MatrixStorage matStorage;
142 
143  switch(m_linSysKey.GetMatrixType())
144  {
145  // case for all symmetric matices
146  case StdRegions::eMass:
150  {
151  if( (2*(bwidth+1)) < rows)
152  {
154  }
155  else
156  {
157  matStorage = ePOSITIVE_DEFINITE_SYMMETRIC;
158  }
159  }
160  break;
163  default:
164  {
165  // Current inversion techniques do not seem to
166  // allow banded matrices to be used as a linear
167  // system
168  matStorage = eFULL;
169  }
170  break;
171  }
172 
173  return matStorage;
174  }
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
Definition: GlobalLinSys.h:127
void Nektar::MultiRegions::GlobalLinSysDirectStaticCond::v_AssembleSchurComplement ( boost::shared_ptr< AssemblyMap pLocToGloMap)
protectedvirtual

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 181 of file GlobalLinSysDirectStaticCond.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), DetermineMatrixStorage(), ErrorUtil::efatal, Nektar::eFULL, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC_BANDED, Nektar::eWrapper, Nektar::MultiRegions::GlobalLinSysStaticCond::m_BinvD, Nektar::MultiRegions::GlobalLinSysStaticCond::m_C, Nektar::MultiRegions::GlobalLinSysStaticCond::m_invD, Nektar::MultiRegions::GlobalLinSysDirect::m_linSys, Nektar::MultiRegions::GlobalLinSysStaticCond::m_schurCompl, and NEKERROR.

183  {
184  int i, j, n, cnt, gid1, gid2;
185  NekDouble sign1, sign2, value;
186 
187  int nBndDofs = pLocToGloMap->GetNumGlobalBndCoeffs();
188  int NumDirBCs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
189 
194 
195  unsigned int rows = nBndDofs - NumDirBCs;
196  unsigned int cols = nBndDofs - NumDirBCs;
197 
198  DNekMatSharedPtr Gmat;
199  int bwidth = pLocToGloMap->GetBndSystemBandWidth();
200 
201  MatrixStorage matStorage = DetermineMatrixStorage(pLocToGloMap);
202 
203  switch(matStorage)
204  {
206  {
207  try {
209  ::AllocateSharedPtr(rows, cols, 0.0,
210  matStorage,
211  bwidth, bwidth);
212  }
213  catch (...) {
215  "Insufficient memory for GlobalLinSys.");
216  }
217  break;
218  }
219 
221  case eFULL:
222  {
224  ::AllocateSharedPtr(rows, cols, 0.0, matStorage);
225  break;
226  }
227 
228  default:
229  {
231  "Unknown matrix storage type of type not set up");
232  }
233  }
234 
235  // fill global matrix
236  DNekScalMatSharedPtr loc_mat;
237  int loc_lda;
238  for(n = cnt = 0; n < SchurCompl->GetNumberOfBlockRows(); ++n)
239  {
240  loc_mat = SchurCompl->GetBlock(n,n);
241  loc_lda = loc_mat->GetRows();
242 
243  // Set up Matrix;
244  for(i = 0; i < loc_lda; ++i)
245  {
246  gid1 = pLocToGloMap->GetLocalToGlobalBndMap (cnt + i)
247  - NumDirBCs;
248  sign1 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + i);
249 
250  if(gid1 >= 0)
251  {
252  for(j = 0; j < loc_lda; ++j)
253  {
254  gid2 = pLocToGloMap->GetLocalToGlobalBndMap(cnt+j)
255  - NumDirBCs;
256  sign2 = pLocToGloMap->GetLocalToGlobalBndSign(cnt+j);
257 
258  if(gid2 >= 0)
259  {
260  // As the global matrix should be symmetric,
261  // only add the value for the upper triangular
262  // part in order to avoid entries to be entered
263  // twice
264  if((matStorage == eFULL)||(gid2 >= gid1))
265  {
266  value = Gmat->GetValue(gid1,gid2)
267  + sign1*sign2*(*loc_mat)(i,j);
268  Gmat->SetValue(gid1,gid2,value);
269  }
270  }
271  }
272  }
273  }
274  cnt += loc_lda;
275  }
276 
277  if(rows)
278  {
281  }
282  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
MatrixStorage DetermineMatrixStorage(const boost::shared_ptr< AssemblyMap > &locToGloMap)
Matrix Storage type for known matrices.
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
DNekLinSysSharedPtr m_linSys
Basic linear system object.
DNekScalBlkMatSharedPtr m_C
Block matrix.
DNekScalBlkMatSharedPtr m_invD
Block matrix.
boost::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:70
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
boost::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:74
double NekDouble
PointerWrapper
Specifies if the pointer passed to a NekMatrix or NekVector is copied into an internal representation...
DNekScalBlkMatSharedPtr m_BinvD
Block matrix.
GlobalLinSysStaticCondSharedPtr Nektar::MultiRegions::GlobalLinSysDirectStaticCond::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 > &  l2gMap 
)
protectedvirtual

Implements Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 284 of file GlobalLinSysDirectStaticCond.cpp.

292  {
294  GlobalLinSysDirectStaticCond>::AllocateSharedPtr(
295  mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap);
296  sys->Initialise(l2gMap);
297  return sys;
298  }
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
boost::shared_ptr< GlobalLinSysDirectStaticCond > GlobalLinSysDirectStaticCondSharedPtr
GlobalLinSysDirectStaticCond(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::GlobalLinSysDirectStaticCond::className
static
Initial value:
"DirectStaticCond",
"Direct static condensation.")

Name of class.

Registers the class with the Factory.

Definition at line 72 of file GlobalLinSysDirectStaticCond.h.

string Nektar::MultiRegions::GlobalLinSysDirectStaticCond::className2
static
Initial value:
"DirectMultiLevelStaticCond",
"Direct multi-level static condensation.")

Definition at line 73 of file GlobalLinSysDirectStaticCond.h.