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=0)
 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 map< int,
RobinBCInfoSharedPtr
m_robinBCInfo
 Robin boundary info. More...
 

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 79 of file GlobalLinSysDirectFull.cpp.

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

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  }
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:191
Nektar::MultiRegions::GlobalLinSysDirectFull::~GlobalLinSysDirectFull ( )
virtual

Definition at line 98 of file GlobalLinSysDirectFull.cpp.

99  {
100 
101  }

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 157 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().

159  {
160  int i,j,n,cnt,gid1,gid2;
161  NekDouble sign1,sign2,value;
162  int totDofs = pLocToGloMap->GetNumGlobalCoeffs();
163  int NumDirBCs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
164 
165  unsigned int rows = totDofs - NumDirBCs;
166  unsigned int cols = totDofs - NumDirBCs;
167  NekDouble zero = 0.0;
168 
169  DNekMatSharedPtr Gmat;
170  int bwidth = pLocToGloMap->GetFullSystemBandWidth();
171  MatrixStorage matStorage;
172 
173  switch(m_linSysKey.GetMatrixType())
174  {
175  // case for all symmetric matices
176  case StdRegions::eMass:
180  {
181  if( (2*(bwidth+1)) < rows)
182  {
185  ::AllocateSharedPtr(rows, cols, zero,
186  matStorage,
187  bwidth, bwidth);
188  }
189  else
190  {
191  matStorage = ePOSITIVE_DEFINITE_SYMMETRIC;
193  ::AllocateSharedPtr(rows, cols, zero,
194  matStorage);
195  }
196  break;
197  }
200  {
201  matStorage = eFULL;
203  ::AllocateSharedPtr(rows, cols, zero,
204  matStorage);
205  break;
206  }
207  default:
208  {
209  NEKERROR(ErrorUtil::efatal, "Add MatrixType to switch "
210  "statement");
211  }
212  }
213 
214  // fill global matrix
215  DNekScalMatSharedPtr loc_mat;
216 
217  int loc_lda;
218  for(n = cnt = 0; n < m_expList.lock()->GetNumElmts(); ++n)
219  {
220  loc_mat = GetBlock(m_expList.lock()->GetOffset_Elmt_Id(n));
221  loc_lda = loc_mat->GetRows();
222 
223  for(i = 0; i < loc_lda; ++i)
224  {
225  gid1 = pLocToGloMap->GetLocalToGlobalMap(cnt + i)-NumDirBCs;
226  sign1 = pLocToGloMap->GetLocalToGlobalSign(cnt + i);
227  if(gid1 >= 0)
228  {
229  for(j = 0; j < loc_lda; ++j)
230  {
231  gid2 = pLocToGloMap->GetLocalToGlobalMap(cnt + j)
232  - NumDirBCs;
233  sign2 = pLocToGloMap->GetLocalToGlobalSign(cnt + j);
234  if(gid2 >= 0)
235  {
236  // When global matrix is symmetric,
237  // only add the value for the upper
238  // triangular part in order to avoid
239  // entries to be entered twice
240  if((matStorage == eFULL)||(gid2 >= gid1))
241  {
242  value = Gmat->GetValue(gid1,gid2)
243  + sign1*sign2*(*loc_mat)(i,j);
244  Gmat->SetValue(gid1,gid2,value);
245  }
246  }
247  }
248  }
249  }
250  cnt += loc_lda;
251  }
252 
253  if(rows)
254  {
257  }
258  }
#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.
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:220
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 107 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().

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  // Calculate Dirichlet forcing and subtract it from the rhs
131  m_expList.lock()->GeneralMatrixOp(
132  m_linSysKey, pOutput, tmp, eGlobal);
133 
134  Vmath::Vsub(nGlobDofs,
135  pInput.get(), 1,
136  tmp.get(), 1,
137  tmp.get(), 1);
138  }
139 
140  Array<OneD, NekDouble> out(nGlobDofs,0.0);
141  SolveLinearSystem(nGlobDofs, tmp, out, pLocToGloMap, nDirDofs);
142  Vmath::Vadd(nGlobDofs-nDirDofs, &out [nDirDofs], 1,
143  &pOutput[nDirDofs], 1, &pOutput[nDirDofs], 1);
144  }
145  else
146  {
147  SolveLinearSystem(nDirDofs, pInput, pOutput, pLocToGloMap);
148  }
149  }
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:199
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.