Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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:
Inheritance graph
[legend]
Collaboration diagram for Nektar::MultiRegions::GlobalLinSysDirectFull:
Collaboration graph
[legend]

Public Member Functions

 GlobalLinSysDirectFull (const GlobalLinSysKey &pLinSysKey, const boost::weak_ptr< ExpList > &pExpList, const boost::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 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...
 

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

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 boost::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 boost::weak_ptr< ExpListm_expList
 Local Matrix System. More...
 
const std::map< int,
RobinBCInfoSharedPtr
m_robinBCInfo
 Robin boundary info. More...
 
bool m_verbose
 

Detailed Description

A global linear system.

Definition at line 51 of file GlobalLinSysDirectFull.h.

Constructor & Destructor Documentation

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

Constructor for full direct matrix solve.

Definition at line 81 of file GlobalLinSysDirectFull.cpp.

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

86  : GlobalLinSys(pLinSysKey, pExp, pLocToGloMap),
87  GlobalLinSysDirect(pLinSysKey, pExp, pLocToGloMap)
88  {
89 
91  "This routine should only be used when using a Full Direct"
92  " matrix solve");
93  ASSERTL1(pExp.lock()->GetComm()->GetSize() == 1,
94  "Direct full matrix solve can only be used in serial.");
95 
96  AssembleFullMatrix(pLocToGloMap);
97  }
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
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.
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
Definition: GlobalLinSys.h:127
void AssembleFullMatrix(const boost::shared_ptr< AssemblyMap > &locToGloMap)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:218
Nektar::MultiRegions::GlobalLinSysDirectFull::~GlobalLinSysDirectFull ( )
virtual

Definition at line 100 of file GlobalLinSysDirectFull.cpp.

101  {
102 
103  }

Member Function Documentation

void Nektar::MultiRegions::GlobalLinSysDirectFull::AssembleFullMatrix ( const boost::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 159 of file GlobalLinSysDirectFull.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), 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().

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

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

60  {
61  return MemoryManager<GlobalLinSysDirectFull>::AllocateSharedPtr(pLinSysKey, pExpList, pLocToGloMap);
62  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
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 109 of file GlobalLinSysDirectFull.cpp.

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

114  {
115  bool dirForcCalculated = (bool) pDirForcing.num_elements();
116  int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
117  int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
118  Array<OneD, NekDouble> tmp(nGlobDofs);
119 
120  if(nDirDofs)
121  {
122  // calculate the dirichlet forcing
123  if(dirForcCalculated)
124  {
125  Vmath::Vsub(nGlobDofs,
126  pInput.get(), 1,
127  pDirForcing.get(), 1,
128  tmp.get(), 1);
129  }
130  else
131  {
132  // Calculate Dirichlet forcing and subtract it from the rhs
133  m_expList.lock()->GeneralMatrixOp(
134  m_linSysKey, pOutput, tmp, eGlobal);
135 
136  Vmath::Vsub(nGlobDofs,
137  pInput.get(), 1,
138  tmp.get(), 1,
139  tmp.get(), 1);
140  }
141 
142  Array<OneD, NekDouble> out(nGlobDofs,0.0);
143  SolveLinearSystem(nGlobDofs, tmp, out, pLocToGloMap, nDirDofs);
144  Vmath::Vadd(nGlobDofs-nDirDofs, &out [nDirDofs], 1,
145  &pOutput[nDirDofs], 1, &pOutput[nDirDofs], 1);
146  }
147  else
148  {
149  SolveLinearSystem(nGlobDofs, pInput, pOutput, pLocToGloMap, nDirDofs);
150  }
151  }
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
Global coefficients.
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
Definition: GlobalLinSys.h:127
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:329
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:285
const boost::weak_ptr< ExpList > m_expList
Local Matrix System.
Definition: GlobalLinSys.h:129

Member Data Documentation

string Nektar::MultiRegions::GlobalLinSysDirectFull::className
static
Initial value:

Name of class.

Registers the class with the Factory.

Definition at line 65 of file GlobalLinSysDirectFull.h.