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 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 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 61 of file GlobalLinSysXxtFull.cpp.

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

66  : GlobalLinSys (pLinSysKey, pExp, pLocToGloMap),
67  GlobalLinSysXxt(pLinSysKey, pExp, pLocToGloMap)
68  {
69 
71  "This routine should only be used when using a Full XXT"
72  " matrix solve");
73 
74  CreateMap(pLocToGloMap);
75  AssembleMatrixArrays(pLocToGloMap);
76  }
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:218
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 79 of file GlobalLinSysXxtFull.cpp.

80  {
81 
82  }

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 188 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, Nektar::MultiRegions::GlobalLinSys::m_verbose, and Xxt::nektar_crs_stats().

Referenced by GlobalLinSysXxtFull().

190  {
191  ExpListSharedPtr vExp = m_expList.lock();
192  unsigned int nElmt = vExp->GetNumElmts();
193  DNekScalMatSharedPtr loc_mat;
194  unsigned int iCount = 0;
195  unsigned int rCount = 0;
196  unsigned int nRows = 0;
197  unsigned int nEntries = 0;
198  unsigned int numDirBnd = pLocToGloMap->GetNumGlobalDirBndCoeffs();
199  unsigned int nLocal = pLocToGloMap->GetNumLocalCoeffs();
200  const Array<OneD, NekDouble> &vMapSign
201  = pLocToGloMap->GetLocalToGlobalSign();
202  bool doSign = pLocToGloMap->GetSignChange();
203  unsigned int i = 0, j = 0, k = 0, n = 0;
204  int gid1;
205  Array<OneD, unsigned int> vSizes(nElmt);
206 
207  // First construct a map of the number of local DOFs in each block
208  // and the number of matrix entries for each block
209 
210  // Dimension of matrix is just the linear vertex space
213  {
214  for (n = 0; n < nElmt; ++n)
215  {
216  i = vExp->GetOffset_Elmt_Id(n);
217  vSizes[n] = vExp->GetExp(i)->GetNverts();
218  nEntries += vSizes[n]*vSizes[n];
219  }
220  }
221  else
222  {
223  for (n = 0; n < nElmt; ++n)
224  {
225  i = vExp->GetOffset_Elmt_Id(n);
226  vSizes[n] = vExp->GetExp(i)->GetNcoeffs();
227  nEntries += vSizes[n]*vSizes[n];
228  }
229  }
230 
231  // Set up i-index, j-index and value arrays
232  m_Ai = Array<OneD, unsigned int>(nEntries);
233  m_Aj = Array<OneD, unsigned int>(nEntries);
234  m_Ar = Array<OneD, double>(nEntries, 0.0);
235 
236  // Set up the universal ID array for XXT
237  Array<OneD, unsigned long> vId(nLocal);
238 
239  // Loop over each elemental block, extract matrix indices and value
240  // and set the universal ID array
241  for(n = iCount = 0; n < nElmt; ++n)
242  {
243  loc_mat = GetBlock(vExp->GetOffset_Elmt_Id(n));
244  nRows = loc_mat->GetRows();
245 
246  for(i = 0; i < nRows; ++i)
247  {
248  gid1 = pLocToGloMap->GetLocalToGlobalMap(iCount + i);
249  for(j = 0; j < nRows; ++j)
250  {
251  k = rCount + i*vSizes[n] + j;
252  m_Ai[k] = iCount + i;
253  m_Aj[k] = iCount + j;
254  m_Ar[k] = (*loc_mat)(i,j);
255  if (doSign)
256  {
257  m_Ar[k] *= vMapSign[iCount+i]*vMapSign[iCount+j];
258  }
259  }
260 
261  // Dirichlet DOFs are not included in the solve, so we set
262  // these to the special XXT id=0.
263  if (gid1 < numDirBnd)
264  {
265  vId[iCount + i] = 0;
266  }
267  else
268  {
269  vId[iCount + i]
270  = pLocToGloMap->GetGlobalToUniversalMap(gid1);
271  }
272  }
273  iCount += vSizes[n];
274  rCount += vSizes[n]*vSizes[n];
275  }
276 
277  // Set up XXT and output some stats
278  LibUtilities::CommSharedPtr vComm = pLocToGloMap->GetComm();
279  m_crsData = Xxt::Init(nLocal, vId, m_Ai, m_Aj, m_Ar, vComm);
280  if (m_verbose)
281  {
283  }
284  }
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
DNekScalMatSharedPtr GetBlock(unsigned int n)
Definition: GlobalLinSys.h:222
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:158
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 153 of file GlobalLinSysXxtFull.cpp.

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

Referenced by GlobalLinSysXxtFull().

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

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