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
42namespace Nektar
43{
44namespace MultiRegions
45{
46// Forward declarations
47class ExpList;
48class GlobalLinSysIterativeStaticCond;
49
50typedef std::shared_ptr<GlobalLinSysIterativeStaticCond>
52
54{
59};
60
61const char *const LocalMatrixStorageStrategyMap[] = {
62 "Contiguous", "Non-contiguous", "Sparse"};
63
64/// A global linear system.
66 virtual public GlobalLinSysStaticCond
67{
68public:
71 typedef std::shared_ptr<DNekSmvBsrDiagBlkMat> DNekSmvBsrDiagBlkMatSharedPtr;
72
73 /// Creates an instance of this class
75 const GlobalLinSysKey &pLinSysKey,
76 const std::weak_ptr<ExpList> &pExpList,
77 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
78 {
81 pLinSysKey, pExpList, pLocToGloMap);
82 p->InitObject();
83 return p;
84 }
85
86 /// Name of class
87 static std::string className;
88 static std::string className2;
89
90 /// Constructor for full direct matrix solve.
92 const GlobalLinSysKey &mkey, const std::weak_ptr<ExpList> &pExpList,
93 const std::shared_ptr<AssemblyMap> &locToGloMap);
94
95 /// Constructor for full direct matrix solve.
97 const GlobalLinSysKey &mkey, const std::weak_ptr<ExpList> &pExpList,
98 const DNekScalBlkMatSharedPtr pSchurCompl,
100 const DNekScalBlkMatSharedPtr pInvD,
101 const std::shared_ptr<AssemblyMap> &locToGloMap,
102 const PreconditionerSharedPtr pPrecon);
103
105
106protected:
107 virtual void v_InitObject() override;
108
109 /// Assemble the Schur complement matrix.
110 virtual void v_AssembleSchurComplement(
111 const std::shared_ptr<AssemblyMap> locToGloMap) override;
112
113 /// Perform a Shur-complement matrix multiply operation.
114 virtual void v_DoMatrixMultiply(const Array<OneD, NekDouble> &pInput,
115 Array<OneD, NekDouble> &pOutput) override;
116
117 virtual void v_UniqueMap() override;
118
120 unsigned int n) override;
122 const GlobalLinSysKey &mkey, const std::weak_ptr<ExpList> &pExpList,
123 const DNekScalBlkMatSharedPtr pSchurCompl,
125 const DNekScalBlkMatSharedPtr pInvD,
126 const std::shared_ptr<AssemblyMap> &locToGloMap) override;
127
128 virtual void v_PreSolve(int scLevel,
129 Array<OneD, NekDouble> &F_bnd) override;
130 virtual void v_BasisFwdTransform(Array<OneD, NekDouble> &pInOut) override;
131 virtual void v_CoeffsBwdTransform(Array<OneD, NekDouble> &pInOut) override;
132 virtual void v_CoeffsFwdTransform(const Array<OneD, NekDouble> &pInput,
133 Array<OneD, NekDouble> &pOutput) override;
134
135private:
136 /// Dense storage for block Schur complement matrix
137 std::vector<double> m_storage;
138 /// Vector of pointers to local matrix data
139 std::vector<const double *> m_denseBlocks;
140 /// Ranks of local matrices
142 /// Scaling factors for local matrices
144 /// Sparse representation of Schur complement matrix at this level
146 /// Utility strings
147 static std::string storagedef;
148 static std::string storagelookupIds[];
149
150 /// Prepares local representation of Schur complement
151 /// stored as a sparse block-diagonal matrix.
153
154 /// Solve the matrix system
155 virtual void v_SolveLinearSystem(const int pNumRows,
156 const Array<OneD, const NekDouble> &pInput,
157 Array<OneD, NekDouble> &pOutput,
158 const AssemblyMapSharedPtr &locToGloMap,
159 const int pNumDir) override;
160};
161} // namespace MultiRegions
162} // namespace Nektar
163
164#endif
#define MULTI_REGIONS_EXPORT
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::vector< const double * > m_denseBlocks
Vector of pointers to local matrix data.
static GlobalLinSysSharedPtr create(const GlobalLinSysKey &pLinSysKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n) override
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
virtual void v_CoeffsBwdTransform(Array< OneD, NekDouble > &pInOut) override
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.
Array< OneD, unsigned int > m_rows
Ranks of local matrices.
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) override
virtual void v_BasisFwdTransform(Array< OneD, NekDouble > &pInOut) override
virtual void v_AssembleSchurComplement(const std::shared_ptr< AssemblyMap > locToGloMap) override
Assemble the Schur complement matrix.
virtual void v_SolveLinearSystem(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir) override
Solve the matrix system.
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_PreSolve(int scLevel, Array< OneD, NekDouble > &F_bnd) override
virtual void v_CoeffsFwdTransform(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
std::shared_ptr< DNekSmvBsrDiagBlkMat > DNekSmvBsrDiagBlkMatSharedPtr
virtual void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
Perform a Shur-complement matrix multiply operation.
NekSparseDiagBlkMatrix< StorageSmvBsr< NekDouble > > DNekSmvBsrDiagBlkMat
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:53
const char *const LocalMatrixStorageStrategyMap[]
std::shared_ptr< GlobalLinSysStaticCond > GlobalLinSysStaticCondSharedPtr
std::shared_ptr< GlobalLinSysIterativeStaticCond > GlobalLinSysIterativeStaticCondSharedPtr
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:60
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:52
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:79