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
43{
44// Forward declarations
45class ExpList;
46class GlobalLinSysIterativeStaticCond;
47
48typedef std::shared_ptr<GlobalLinSysIterativeStaticCond>
50
52{
57};
58
59const char *const LocalMatrixStorageStrategyMap[] = {
60 "Contiguous", "Non-contiguous", "Sparse"};
61
62/// A global linear system.
64 virtual public GlobalLinSysStaticCond
65{
66public:
69 typedef std::shared_ptr<DNekSmvBsrDiagBlkMat> DNekSmvBsrDiagBlkMatSharedPtr;
70
71 /// Creates an instance of this class
73 const GlobalLinSysKey &pLinSysKey,
74 const std::weak_ptr<ExpList> &pExpList,
75 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
76 {
79 pLinSysKey, pExpList, pLocToGloMap);
80 p->InitObject();
81 return p;
82 }
83
84 /// Name of class
85 static std::string className;
86 static std::string className2;
87
88 /// Constructor for full direct matrix solve.
90 const GlobalLinSysKey &mkey, const std::weak_ptr<ExpList> &pExpList,
91 const std::shared_ptr<AssemblyMap> &locToGloMap);
92
93 /// Constructor for full direct matrix solve.
95 const GlobalLinSysKey &mkey, const std::weak_ptr<ExpList> &pExpList,
96 const DNekScalBlkMatSharedPtr pSchurCompl,
98 const DNekScalBlkMatSharedPtr pInvD,
99 const std::shared_ptr<AssemblyMap> &locToGloMap,
100 const PreconditionerSharedPtr pPrecon);
101
103
104protected:
105 void v_InitObject() override;
106
107 /// Assemble the Schur complement matrix.
109 const std::shared_ptr<AssemblyMap> locToGloMap) override;
110
111 /// Perform a Shur-complement matrix multiply operation.
113 Array<OneD, NekDouble> &pOutput) override;
114
115 void v_UniqueMap() override;
116
117 DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n) override;
119 const GlobalLinSysKey &mkey, const std::weak_ptr<ExpList> &pExpList,
120 const DNekScalBlkMatSharedPtr pSchurCompl,
122 const DNekScalBlkMatSharedPtr pInvD,
123 const std::shared_ptr<AssemblyMap> &locToGloMap) override;
124
125 void v_PreSolve(int scLevel, Array<OneD, NekDouble> &F_bnd) override;
126 void v_BasisFwdTransform(Array<OneD, NekDouble> &pInOut) override;
127 void v_CoeffsBwdTransform(Array<OneD, NekDouble> &pInOut) override;
129 Array<OneD, NekDouble> &pOutput) override;
130
131private:
132 /// Dense storage for block Schur complement matrix
133 std::vector<double> m_storage;
134 /// Vector of pointers to local matrix data
135 std::vector<const double *> m_denseBlocks;
136 /// Ranks of local matrices
138 /// Scaling factors for local matrices
140 /// Sparse representation of Schur complement matrix at this level
142 /// Utility strings
143 static std::string storagedef;
144 static std::string storagelookupIds[];
145
146 /// Prepares local representation of Schur complement
147 /// stored as a sparse block-diagonal matrix.
149
150 /// Solve the matrix system
151 void v_SolveLinearSystem(const int pNumRows,
152 const Array<OneD, const NekDouble> &pInput,
153 Array<OneD, NekDouble> &pOutput,
154 const AssemblyMapSharedPtr &locToGloMap,
155 const int pNumDir) override;
156};
157} // namespace Nektar::MultiRegions
158
159#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.
DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n) override
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
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.
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
void v_BasisFwdTransform(Array< OneD, NekDouble > &pInOut) override
void v_AssembleSchurComplement(const std::shared_ptr< AssemblyMap > locToGloMap) override
Assemble the Schur complement matrix.
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.
void v_PreSolve(int scLevel, Array< OneD, NekDouble > &F_bnd) override
void v_CoeffsFwdTransform(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
std::shared_ptr< DNekSmvBsrDiagBlkMat > DNekSmvBsrDiagBlkMatSharedPtr
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:51
const char *const LocalMatrixStorageStrategyMap[]
std::shared_ptr< GlobalLinSysStaticCond > GlobalLinSysStaticCondSharedPtr
std::shared_ptr< GlobalLinSysIterativeStaticCond > GlobalLinSysIterativeStaticCondSharedPtr
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:58
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:50
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:79