Nektar++
GlobalLinSysIterativeStaticCond.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: GlobalLinSysIterativeStaticCond.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: GlobalLinSysIterativeStaticCond header
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 #ifndef NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYSITERATIVESTATICCOND_H
35 #define NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYSITERATIVESTATICCOND_H
36 
41 
42 
43 namespace Nektar
44 {
45  namespace MultiRegions
46  {
47  // Forward declarations
48  class ExpList;
49  class GlobalLinSysIterativeStaticCond;
50 
51  typedef std::shared_ptr<GlobalLinSysIterativeStaticCond>
53 
55  {
59  eSparse
60  };
61 
62  const char* const LocalMatrixStorageStrategyMap[] =
63  {
64  "Contiguous",
65  "Non-contiguous",
66  "Sparse"
67  };
68 
69 
70  /// A global linear system.
72  virtual public GlobalLinSysStaticCond
73  {
74  public:
77  typedef std::shared_ptr<DNekSmvBsrDiagBlkMat>
79 
80  /// Creates an instance of this class
82  const GlobalLinSysKey &pLinSysKey,
83  const std::weak_ptr<ExpList> &pExpList,
84  const std::shared_ptr<AssemblyMap> &pLocToGloMap)
85  {
88  AllocateSharedPtr(pLinSysKey, pExpList, pLocToGloMap);
89  p->InitObject();
90  return p;
91  }
92 
93  /// Name of class
94  static std::string className;
95  static std::string className2;
96 
97  /// Constructor for full direct matrix solve.
99  const GlobalLinSysKey &mkey,
100  const std::weak_ptr<ExpList> &pExpList,
101  const std::shared_ptr<AssemblyMap> &locToGloMap);
102 
103  /// Constructor for full direct matrix solve.
105  const GlobalLinSysKey &mkey,
106  const std::weak_ptr<ExpList> &pExpList,
107  const DNekScalBlkMatSharedPtr pSchurCompl,
108  const DNekScalBlkMatSharedPtr pBinvD,
109  const DNekScalBlkMatSharedPtr pC,
110  const DNekScalBlkMatSharedPtr pInvD,
111  const std::shared_ptr<AssemblyMap> &locToGloMap,
112  const PreconditionerSharedPtr pPrecon);
113 
115 
116  protected:
117  virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n);
119  const GlobalLinSysKey &mkey,
120  const std::weak_ptr<ExpList> &pExpList,
121  const DNekScalBlkMatSharedPtr pSchurCompl,
122  const DNekScalBlkMatSharedPtr pBinvD,
123  const DNekScalBlkMatSharedPtr pC,
124  const DNekScalBlkMatSharedPtr pInvD,
125  const std::shared_ptr<AssemblyMap> &locToGloMap);
126 
127  void v_PreSolve(int scLevel,
128  Array<OneD, NekDouble> &F_bnd);
129  virtual void v_BasisFwdTransform(
130  Array<OneD, NekDouble>& pInOut);
131  virtual void v_CoeffsBwdTransform(
132  Array<OneD, NekDouble>& pInOut);
133  virtual void v_CoeffsFwdTransform(
134  const Array<OneD, NekDouble>& pInput,
135  Array<OneD, NekDouble>& pOutput);
136 
137  private:
138  /// Dense storage for block Schur complement matrix
139  std::vector<double> m_storage;
140  /// Vector of pointers to local matrix data
141  std::vector<const double*> m_denseBlocks;
142  /// Ranks of local matrices
144  /// Scaling factors for local matrices
146  /// Sparse representation of Schur complement matrix at this level
148  /// Utility strings
149  static std::string storagedef;
150  static std::string storagelookupIds[];
151 
152  virtual void v_InitObject();
153 
154  /// Assemble the Schur complement matrix.
156  const std::shared_ptr<AssemblyMap> locToGloMap);
157 
158  /// Prepares local representation of Schur complement
159  /// stored as a sparse block-diagonal matrix.
161 
162  /// Perform a Shur-complement matrix multiply operation.
163  virtual void v_DoMatrixMultiply(
164  const Array<OneD, NekDouble>& pInput,
165  Array<OneD, NekDouble>& pOutput);
166 
167  virtual void v_UniqueMap();
168  };
169  }
170 }
171 
172 #endif
#define MULTI_REGIONS_EXPORT
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static GlobalLinSysSharedPtr create(const GlobalLinSysKey &pLinSysKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
void v_PreSolve(int scLevel, Array< OneD, NekDouble > &F_bnd)
std::vector< const double * > m_denseBlocks
Vector of pointers to local matrix data.
virtual void v_CoeffsBwdTransform(Array< OneD, NekDouble > &pInOut)
virtual GlobalLinSysStaticCondSharedPtr v_Recurse(const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const DNekScalBlkMatSharedPtr pSchurCompl, const DNekScalBlkMatSharedPtr pBinvD, const DNekScalBlkMatSharedPtr pC, const DNekScalBlkMatSharedPtr pInvD, const std::shared_ptr< AssemblyMap > &locToGloMap)
virtual void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Perform a Shur-complement matrix multiply operation.
std::vector< double > m_storage
Dense storage for block Schur complement matrix.
GlobalLinSysIterativeStaticCond(const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.
void PrepareLocalSchurComplement()
Prepares local representation of Schur complement stored as a sparse block-diagonal matrix.
virtual void v_BasisFwdTransform(Array< OneD, NekDouble > &pInOut)
Array< OneD, unsigned int > m_rows
Ranks of local matrices.
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n)
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
void v_AssembleSchurComplement(const std::shared_ptr< AssemblyMap > locToGloMap)
Assemble the Schur complement matrix.
Array< OneD, NekDouble > m_scale
Scaling factors for local matrices.
DNekSmvBsrDiagBlkMatSharedPtr m_sparseSchurCompl
Sparse representation of Schur complement matrix at this level.
virtual void v_CoeffsFwdTransform(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
std::shared_ptr< DNekSmvBsrDiagBlkMat > DNekSmvBsrDiagBlkMatSharedPtr
NekSparseDiagBlkMatrix< StorageSmvBsr< NekDouble > > DNekSmvBsrDiagBlkMat
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:50
const char *const LocalMatrixStorageStrategyMap[]
std::shared_ptr< GlobalLinSysStaticCond > GlobalLinSysStaticCondSharedPtr
std::shared_ptr< GlobalLinSysIterativeStaticCond > GlobalLinSysIterativeStaticCondSharedPtr
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:60
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:73