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::GlobalLinSysXxtFull Class Reference

A global linear system. More...

#include <GlobalLinSysXxtFull.h>

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

Public Member Functions

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

Additional Inherited Members

- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSysXxt
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...
 
void GlobalToLocalNoSign (const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &local)
 
void LocalToGlobalNoSign (const Array< OneD, const NekDouble > &local, Array< OneD, NekDouble > &global)
 
- 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::GlobalLinSysXxt
struct Xxt::crs_datam_crsData
 
Array< OneD, unsigned int > m_Ai
 
Array< OneD, unsigned int > m_Aj
 
Array< OneD, double > m_Ar
 
Array< OneD, NekDoublem_locToGloSignMult
 
Array< OneD, int > m_map
 
- 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 GlobalLinSysXxtFull.h.

Constructor & Destructor Documentation

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

Constructor for full direct matrix solve.

Definition at line 59 of file GlobalLinSysXxtFull.cpp.

References AssembleMatrixArrays(), ASSERTL1, CreateMap(), Nektar::MultiRegions::eXxtFullMatrix, Nektar::MultiRegions::GlobalLinSysKey::GetGlobalSysSolnType(), and Nektar::MultiRegions::GlobalLinSys::m_linSysKey.

64  : GlobalLinSys (pLinSysKey, pExp, pLocToGloMap),
65  GlobalLinSysXxt(pLinSysKey, pExp, pLocToGloMap)
66  {
67 
69  "This routine should only be used when using a Full XXT"
70  " matrix solve");
71 
72  CreateMap(pLocToGloMap);
73  AssembleMatrixArrays(pLocToGloMap);
74  }
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
void CreateMap(const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
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 AssembleMatrixArrays(const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
GlobalLinSysXxt(const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExp, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
Nektar::MultiRegions::GlobalLinSysXxtFull::~GlobalLinSysXxtFull ( )
virtual

Definition at line 77 of file GlobalLinSysXxtFull.cpp.

78  {
79 
80  }

Member Function Documentation

void Nektar::MultiRegions::GlobalLinSysXxtFull::AssembleMatrixArrays ( const boost::shared_ptr< AssemblyMap > &  pLocToGloMap)
private

Construct the local matrix row index, column index and value index arrays and initialize the XXT data structure with this information.

Parameters
locToGloMapLocal to global mapping information.

Definition at line 186 of file GlobalLinSysXxtFull.cpp.

References Nektar::StdRegions::ePreconLinearSpace, Nektar::StdRegions::ePreconLinearSpaceMass, Nektar::MultiRegions::GlobalLinSys::GetBlock(), Nektar::MultiRegions::GlobalMatrixKey::GetMatrixType(), Xxt::Init(), Nektar::MultiRegions::GlobalLinSysXxt::m_Ai, Nektar::MultiRegions::GlobalLinSysXxt::m_Aj, Nektar::MultiRegions::GlobalLinSysXxt::m_Ar, Nektar::MultiRegions::GlobalLinSysXxt::m_crsData, Nektar::MultiRegions::GlobalLinSys::m_expList, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, and Xxt::nektar_crs_stats().

Referenced by GlobalLinSysXxtFull().

188  {
189  ExpListSharedPtr vExp = m_expList.lock();
190  unsigned int nElmt = vExp->GetNumElmts();
191  DNekScalMatSharedPtr loc_mat;
192  unsigned int iCount = 0;
193  unsigned int rCount = 0;
194  unsigned int nRows = 0;
195  unsigned int nEntries = 0;
196  unsigned int numDirBnd = pLocToGloMap->GetNumGlobalDirBndCoeffs();
197  unsigned int nLocal = pLocToGloMap->GetNumLocalCoeffs();
198  const Array<OneD, NekDouble> &vMapSign
199  = pLocToGloMap->GetLocalToGlobalSign();
200  bool doSign = pLocToGloMap->GetSignChange();
201  unsigned int i = 0, j = 0, k = 0, n = 0;
202  int gid1;
203  Array<OneD, unsigned int> vSizes(nElmt);
204 
205  // First construct a map of the number of local DOFs in each block
206  // and the number of matrix entries for each block
207 
208  // Dimension of matrix is just the linear vertex space
211  {
212  for (n = 0; n < nElmt; ++n)
213  {
214  i = vExp->GetOffset_Elmt_Id(n);
215  vSizes[n] = vExp->GetExp(i)->GetNverts();
216  nEntries += vSizes[n]*vSizes[n];
217  }
218  }
219  else
220  {
221  for (n = 0; n < nElmt; ++n)
222  {
223  i = vExp->GetOffset_Elmt_Id(n);
224  vSizes[n] = vExp->GetExp(i)->GetNcoeffs();
225  nEntries += vSizes[n]*vSizes[n];
226  }
227  }
228 
229  // Set up i-index, j-index and value arrays
230  m_Ai = Array<OneD, unsigned int>(nEntries);
231  m_Aj = Array<OneD, unsigned int>(nEntries);
232  m_Ar = Array<OneD, double>(nEntries, 0.0);
233 
234  // Set up the universal ID array for XXT
235  Array<OneD, unsigned long> vId(nLocal);
236 
237  // Loop over each elemental block, extract matrix indices and value
238  // and set the universal ID array
239  for(n = iCount = 0; n < nElmt; ++n)
240  {
241  loc_mat = GetBlock(vExp->GetOffset_Elmt_Id(n));
242  nRows = loc_mat->GetRows();
243 
244  for(i = 0; i < nRows; ++i)
245  {
246  gid1 = pLocToGloMap->GetLocalToGlobalMap(iCount + i);
247  for(j = 0; j < nRows; ++j)
248  {
249  k = rCount + i*vSizes[n] + j;
250  m_Ai[k] = iCount + i;
251  m_Aj[k] = iCount + j;
252  m_Ar[k] = (*loc_mat)(i,j);
253  if (doSign)
254  {
255  m_Ar[k] *= vMapSign[iCount+i]*vMapSign[iCount+j];
256  }
257  }
258 
259  // Dirichlet DOFs are not included in the solve, so we set
260  // these to the special XXT id=0.
261  if (gid1 < numDirBnd)
262  {
263  vId[iCount + i] = 0;
264  }
265  else
266  {
267  vId[iCount + i]
268  = pLocToGloMap->GetGlobalToUniversalMap(gid1);
269  }
270  }
271  iCount += vSizes[n];
272  rCount += vSizes[n]*vSizes[n];
273  }
274 
275  // Set up XXT and output some stats
276  LibUtilities::CommSharedPtr vComm = pLocToGloMap->GetComm();
277  m_crsData = Xxt::Init(nLocal, vId, m_Ai, m_Aj, m_Ar, vComm);
279  }
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
DNekScalMatSharedPtr GetBlock(unsigned int n)
Definition: GlobalLinSys.h:220
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static struct crs_data * Init(unsigned int pRank, const Nektar::Array< OneD, unsigned long > pId, const Nektar::Array< OneD, unsigned int > pAi, const Nektar::Array< OneD, unsigned int > pAj, const Nektar::Array< OneD, NekDouble > pAr, const LibUtilities::CommSharedPtr &pComm)
Initialise the matrix-solve.
Definition: Xxt.hpp:157
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
Definition: GlobalLinSys.h:127
Array< OneD, unsigned int > m_Aj
Array< OneD, unsigned int > m_Ai
void nektar_crs_stats(struct crs_data *data)
const boost::weak_ptr< ExpList > m_expList
Local Matrix System.
Definition: GlobalLinSys.h:129
static GlobalLinSysSharedPtr Nektar::MultiRegions::GlobalLinSysXxtFull::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 GlobalLinSysXxtFull.h.

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

60  {
61  return MemoryManager<GlobalLinSysXxtFull>::AllocateSharedPtr(pLinSysKey, pExpList, pLocToGloMap);
62  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::MultiRegions::GlobalLinSysXxtFull::CreateMap ( const boost::shared_ptr< AssemblyMap > &  pLocToGloMap)
private

Create the inverse multiplicity map.

Parameters
locToGloMapLocal to global mapping information.

Definition at line 151 of file GlobalLinSysXxtFull.cpp.

References Nektar::MultiRegions::GlobalLinSysXxt::m_locToGloSignMult, and Nektar::MultiRegions::GlobalLinSysXxt::m_map.

Referenced by GlobalLinSysXxtFull().

153  {
154  const Array<OneD, const int> &vMap
155  = pLocToGloMap->GetLocalToGlobalMap();
156  unsigned int nGlo = pLocToGloMap->GetNumGlobalCoeffs();
157  unsigned int nEntries = pLocToGloMap->GetNumLocalCoeffs();
158  unsigned int i;
159 
160  // Count the multiplicity of each global DOF on this process
161  Array<OneD, NekDouble> vCounts(nGlo, 0.0);
162  for (i = 0; i < nEntries; ++i)
163  {
164  vCounts[vMap[i]] += 1.0;
165  }
166 
167  // Get universal multiplicity by globally assembling counts
168  pLocToGloMap->UniversalAssemble(vCounts);
169 
170  // Construct a map of 1/multiplicity for use in XXT solve
172  for (i = 0; i < nEntries; ++i)
173  {
174  m_locToGloSignMult[i] = 1.0/vCounts[vMap[i]];
175  }
176 
177  m_map = pLocToGloMap->GetLocalToGlobalMap();
178  }
Array< OneD, NekDouble > m_locToGloSignMult
void Nektar::MultiRegions::GlobalLinSysXxtFull::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 86 of file GlobalLinSysXxtFull.cpp.

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

91  {
92  bool dirForcCalculated = (bool) pDirForcing.num_elements();
93  int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
94  int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
95 
96  Array<OneD, NekDouble> tmp (nGlobDofs);
97  Array<OneD, NekDouble> tmp2(nGlobDofs);
98  Array<OneD, NekDouble> tmp3 = pOutput + nDirDofs;
99 
100  if(nDirDofs)
101  {
102  // calculate the dirichlet forcing
103  if(dirForcCalculated)
104  {
105  Vmath::Vsub(nGlobDofs, pInput.get(), 1,
106  pDirForcing.get(), 1,
107  tmp.get(), 1);
108  }
109  else
110  {
111  // Calculate the dirichlet forcing and substract it
112  // from the rhs
113  //int nLocDofs = pLocToGloMap->GetNumLocalCoeffs();
114 
115  m_expList.lock()->GeneralMatrixOp(
116  m_linSysKey,
117  pOutput, tmp, eGlobal);
118 
119  Vmath::Vsub( nGlobDofs, pInput.get(),1,
120  tmp.get(), 1,
121  tmp.get(), 1);
122  }
123 
124  SolveLinearSystem(pLocToGloMap->GetNumLocalCoeffs(),
125  tmp, tmp2, pLocToGloMap);
126 
127  // Enforce the Dirichlet boundary conditions on the solution
128  // array as XXT discards them.
129  Vmath::Vcopy(nDirDofs, pOutput, 1,
130  tmp2, 1);
131  }
132  else
133  {
134  Vmath::Vcopy(nGlobDofs, pInput, 1, tmp, 1);
135  SolveLinearSystem(pLocToGloMap->GetNumLocalCoeffs(),
136  tmp,tmp2, pLocToGloMap);
137  }
138 
139  // Perturb the output array (previous solution) by the result of
140  // this solve to get full solution.
141  Vmath::Vadd(nGlobDofs - nDirDofs,
142  tmp2 + nDirDofs, 1, tmp3, 1, tmp3, 1);
143 
144  }
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 Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
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::GlobalLinSysXxtFull::className
static
Initial value:

Name of class.

Registers the class with the Factory.

Definition at line 65 of file GlobalLinSysXxtFull.h.