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

A global linear system. More...

#include <GlobalLinSysDirectFull.h>

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

Public Member Functions

 GlobalLinSysDirectFull (const GlobalLinSysKey &pLinSysKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve. More...
 
virtual ~GlobalLinSysDirectFull ()
 
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSysDirect
 GlobalLinSysDirect (const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExp, const std::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 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)
 
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...
 

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...
 

Private 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)
 Solve the linear system for given input and output vectors using a specified local to global map. More...
 
void AssembleFullMatrix (const std::shared_ptr< AssemblyMap > &locToGloMap)
 

Additional Inherited Members

- 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)
 Solve the linear system for given input and output vectors. More...
 
- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSys
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 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 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 std::weak_ptr< ExpListm_expList
 Local Matrix System. More...
 
const std::map< int, RobinBCInfoSharedPtrm_robinBCInfo
 Robin boundary info. More...
 
bool m_verbose
 

Detailed Description

A global linear system.

Definition at line 50 of file GlobalLinSysDirectFull.h.

Constructor & Destructor Documentation

◆ GlobalLinSysDirectFull()

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

Constructor for full direct matrix solve.

Definition at line 80 of file GlobalLinSysDirectFull.cpp.

84  : GlobalLinSys(pLinSysKey, pExp, pLocToGloMap),
85  GlobalLinSysDirect(pLinSysKey, pExp, pLocToGloMap)
86  {
87 
89  "This routine should only be used when using a Full Direct"
90  " matrix solve");
91  ASSERTL1(pExp.lock()->GetComm()->GetSize() == 1,
92  "Direct full matrix solve can only be used in serial.");
93 
94  AssembleFullMatrix(pLocToGloMap);
95  }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250
void AssembleFullMatrix(const std::shared_ptr< AssemblyMap > &locToGloMap)
GlobalLinSysDirect(const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExp, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
GlobalLinSys(const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
Definition: GlobalLinSys.h:125
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.

References AssembleFullMatrix(), ASSERTL1, Nektar::MultiRegions::eDirectFullMatrix, Nektar::MultiRegions::GlobalLinSysKey::GetGlobalSysSolnType(), and Nektar::MultiRegions::GlobalLinSys::m_linSysKey.

◆ ~GlobalLinSysDirectFull()

Nektar::MultiRegions::GlobalLinSysDirectFull::~GlobalLinSysDirectFull ( )
virtual

Definition at line 98 of file GlobalLinSysDirectFull.cpp.

99  {
100 
101  }

Member Function Documentation

◆ AssembleFullMatrix()

void Nektar::MultiRegions::GlobalLinSysDirectFull::AssembleFullMatrix ( const std::shared_ptr< AssemblyMap > &  locToGloMap)
private

Assemble a full matrix from the block matrix stored in #m_blkMatrices and the given local to global mapping information.

Parameters
locToGloMapLocal to global mapping information.

Definition at line 158 of file GlobalLinSysDirectFull.cpp.

160  {
161  int i,j,n,cnt,gid1,gid2;
162  NekDouble sign1,sign2,value;
163  int totDofs = pLocToGloMap->GetNumGlobalCoeffs();
164  int NumDirBCs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
165 
166  unsigned int rows = totDofs - NumDirBCs;
167  unsigned int cols = totDofs - NumDirBCs;
168  NekDouble zero = 0.0;
169 
170  DNekMatSharedPtr Gmat;
171  int bwidth = pLocToGloMap->GetFullSystemBandWidth();
172  MatrixStorage matStorage = eFULL;
173 
174  switch(m_linSysKey.GetMatrixType())
175  {
176  // case for all symmetric matices
177  case StdRegions::eMass:
181  {
182  if( (2*(bwidth+1)) < rows)
183  {
186  ::AllocateSharedPtr(rows, cols, zero,
187  matStorage,
188  bwidth, bwidth);
189  }
190  else
191  {
192  matStorage = ePOSITIVE_DEFINITE_SYMMETRIC;
194  ::AllocateSharedPtr(rows, cols, zero,
195  matStorage);
196  }
197  break;
198  }
201  {
202  matStorage = eFULL;
204  ::AllocateSharedPtr(rows, cols, zero,
205  matStorage);
206  break;
207  }
208  default:
209  {
210  NEKERROR(ErrorUtil::efatal, "Add MatrixType to switch "
211  "statement");
212  }
213  }
214 
215  // fill global matrix
216  DNekScalMatSharedPtr loc_mat;
217 
218  int loc_lda;
219  for(n = cnt = 0; n < m_expList.lock()->GetNumElmts(); ++n)
220  {
221  loc_mat = GetBlock(n);
222  loc_lda = loc_mat->GetRows();
223 
224  for(i = 0; i < loc_lda; ++i)
225  {
226  gid1 = pLocToGloMap->GetLocalToGlobalMap(cnt + i)-NumDirBCs;
227  sign1 = pLocToGloMap->GetLocalToGlobalSign(cnt + i);
228  if(gid1 >= 0)
229  {
230  for(j = 0; j < loc_lda; ++j)
231  {
232  gid2 = pLocToGloMap->GetLocalToGlobalMap(cnt + j)
233  - NumDirBCs;
234  sign2 = pLocToGloMap->GetLocalToGlobalSign(cnt + j);
235  if(gid2 >= 0)
236  {
237  // When global matrix is symmetric,
238  // only add the value for the upper
239  // triangular part in order to avoid
240  // entries to be entered twice
241  if((matStorage == eFULL)||(gid2 >= gid1))
242  {
243  value = Gmat->GetValue(gid1,gid2)
244  + sign1*sign2*(*loc_mat)(i,j);
245  Gmat->SetValue(gid1,gid2,value);
246  }
247  }
248  }
249  }
250  }
251  cnt += loc_lda;
252  }
253 
254  if(rows)
255  {
258  }
259  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
DNekLinSysSharedPtr m_linSys
Basic linear system object.
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
Definition: GlobalLinSys.h:127
DNekScalMatSharedPtr GetBlock(unsigned int n)
Definition: GlobalLinSys.h:222
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
@ ePOSITIVE_DEFINITE_SYMMETRIC_BANDED
@ ePOSITIVE_DEFINITE_SYMMETRIC
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:69
double NekDouble
PointerWrapper
Specifies if the pointer passed to a NekMatrix or NekVector is copied into an internal representation...

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::ErrorUtil::efatal, 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::eWrapper, Nektar::MultiRegions::GlobalLinSys::GetBlock(), Nektar::MultiRegions::GlobalMatrixKey::GetMatrixType(), Nektar::MultiRegions::GlobalLinSys::m_expList, Nektar::MultiRegions::GlobalLinSysDirect::m_linSys, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, and NEKERROR.

Referenced by GlobalLinSysDirectFull().

◆ create()

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

59  {
60  return MemoryManager<GlobalLinSysDirectFull>::AllocateSharedPtr(pLinSysKey, pExpList, pLocToGloMap);
61  }

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

◆ v_Solve()

void Nektar::MultiRegions::GlobalLinSysDirectFull::v_Solve ( const Array< OneD, const NekDouble > &  pInput,
Array< OneD, NekDouble > &  pOutput,
const AssemblyMapSharedPtr pLocToGloMap,
const Array< OneD, const NekDouble > &  pDirForcing = NullNekDouble1DArray 
)
privatevirtual

Solve the linear system for given input and output vectors using a specified local to global map.

Solve the linear system using a full global matrix system.

Implements Nektar::MultiRegions::GlobalLinSys.

Definition at line 107 of file GlobalLinSysDirectFull.cpp.

112  {
113  bool dirForcCalculated = (bool) pDirForcing.num_elements();
114  int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
115  int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
116  Array<OneD, NekDouble> tmp(nGlobDofs);
117 
118  if(nDirDofs)
119  {
120  // calculate the dirichlet forcing
121  if(dirForcCalculated)
122  {
123  Vmath::Vsub(nGlobDofs,
124  pInput.get(), 1,
125  pDirForcing.get(), 1,
126  tmp.get(), 1);
127  }
128  else
129  {
130  Vmath::Zero(nGlobDofs-nDirDofs, &pOutput[nDirDofs], 1);
131  // Calculate Dirichlet forcing and subtract it from the rhs
132  m_expList.lock()->GeneralMatrixOp(
133  m_linSysKey, pOutput, tmp, eGlobal);
134 
135  Vmath::Vsub(nGlobDofs,
136  pInput.get(), 1,
137  tmp.get(), 1,
138  tmp.get(), 1);
139  }
140 
141  Array<OneD, NekDouble> out(nGlobDofs,0.0);
142  SolveLinearSystem(nGlobDofs, tmp, out, pLocToGloMap, nDirDofs);
143  Vmath::Vadd(nGlobDofs-nDirDofs, &out [nDirDofs], 1,
144  &pOutput[nDirDofs], 1, &pOutput[nDirDofs], 1);
145  }
146  else
147  {
148  SolveLinearSystem(nGlobDofs, pInput, pOutput, pLocToGloMap, nDirDofs);
149  }
150  }
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.
Definition: GlobalLinSys.h:201
@ eGlobal
Global coefficients.
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:302
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:376
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:346

References Nektar::MultiRegions::eGlobal, Nektar::MultiRegions::GlobalLinSys::m_expList, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, Nektar::MultiRegions::GlobalLinSys::SolveLinearSystem(), Vmath::Vadd(), Vmath::Vsub(), and Vmath::Zero().

Member Data Documentation

◆ className

string Nektar::MultiRegions::GlobalLinSysDirectFull::className
static
Initial value:
"DirectFull",
"Direct Full.")
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
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 64 of file GlobalLinSysDirectFull.h.