Nektar++
GlobalLinSys.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: GlobalLinSys.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: GlobalLinSys header
32//
33///////////////////////////////////////////////////////////////////////////////
34#ifndef NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYS_H
35#define NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYS_H
36
42
44{
45// Forward declarations
46class ExpList;
47class GlobalLinSys;
48class Preconditioner;
49
50/// Pointer to a GlobalLinSys object.
51typedef std::shared_ptr<GlobalLinSys> GlobalLinSysSharedPtr;
52/// Mapping between GlobalLinSys objects and their associated keys.
53typedef std::map<GlobalLinSysKey, GlobalLinSysSharedPtr> GlobalLinSysMap;
54/// Pointer to a GlobalLinSys/key map.
55typedef std::shared_ptr<GlobalLinSysMap> GlobalLinSysMapShPtr;
56
57// Forward declaration
58typedef std::shared_ptr<Preconditioner> PreconditionerSharedPtr;
59
60/// Datatype of the NekFactory used to instantiate classes derived from
61/// the EquationSystem class.
63 std::string, GlobalLinSys, const GlobalLinSysKey &,
64 const std::weak_ptr<ExpList> &, const std::shared_ptr<AssemblyMap> &>
67
68/// A global linear system.
69class GlobalLinSys : public std::enable_shared_from_this<GlobalLinSys>
70{
71public:
72 /// Constructor for full direct matrix solve.
74 const GlobalLinSysKey &pKey, const std::weak_ptr<ExpList> &pExpList,
75 const std::shared_ptr<AssemblyMap> &pLocToGloMap);
76
78 virtual ~GlobalLinSys()
79 {
80 }
81
82 /// Returns the key associated with the system.
83 const inline GlobalLinSysKey &GetKey(void) const;
84
85 // Returns the local matrix associated with the system
86 const inline std::weak_ptr<ExpList> &GetLocMat(void) const;
87
88 inline void InitObject();
89 inline void Initialise(const std::shared_ptr<AssemblyMap> &pLocToGloMap);
90
91 /// Solve the linear system for given input and output vectors
92 /// using a specified local to global map.
94 inline void Solve(
96 const AssemblyMapSharedPtr &locToGloMap,
98
99 /// Returns a shared pointer to the current object.
100 std::shared_ptr<GlobalLinSys> GetSharedThisPtr()
101 {
102 return shared_from_this();
103 }
104
105 inline int GetNumBlocks();
106 inline DNekScalMatSharedPtr GetBlock(unsigned int n);
107 inline void DropBlock(unsigned int n);
108 inline DNekScalBlkMatSharedPtr GetStaticCondBlock(unsigned int n);
109 inline void DropStaticCondBlock(unsigned int n);
110
111 /// Solve the linear system for given input and output vectors.
112 inline void SolveLinearSystem(const int pNumRows,
113 const Array<OneD, const NekDouble> &pInput,
114 Array<OneD, NekDouble> &pOutput,
115 const AssemblyMapSharedPtr &locToGloMap,
116 const int pNumDir = 0);
117
118protected:
119 /// Key associated with this linear system.
121 /// Local Matrix System
122 const std::weak_ptr<ExpList> m_expList;
123 /// Robin boundary info
124 const std::map<int, RobinBCInfoSharedPtr> m_robinBCInfo;
125 // Provide verbose output
127
128 /// Solve a linear system based on mapping.
129 virtual void v_Solve(const Array<OneD, const NekDouble> &in,
131 const AssemblyMapSharedPtr &locToGloMap,
132 const Array<OneD, const NekDouble> &dirForcing =
134
135 /// Solve a basic matrix system.
136 virtual void v_SolveLinearSystem(const int pNumRows,
137 const Array<OneD, const NekDouble> &pInput,
138 Array<OneD, NekDouble> &pOutput,
139 const AssemblyMapSharedPtr &locToGloMap,
140 const int pNumDir) = 0;
141
142 virtual void v_InitObject();
143 virtual void v_Initialise(const std::shared_ptr<AssemblyMap> &pLocToGloMap);
144
145 virtual int v_GetNumBlocks();
146 virtual DNekScalMatSharedPtr v_GetBlock(unsigned int n);
147 virtual void v_DropBlock(unsigned int n);
148 virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n);
149 virtual void v_DropStaticCondBlock(unsigned int n);
150
152
153private:
155
156 static std::string lookupIds[];
157 static std::string def;
158};
159
160/**
161 *
162 */
163const inline GlobalLinSysKey &GlobalLinSys::GetKey(void) const
164{
165 return m_linSysKey;
166}
167
168/**
169 *
170 */
171const inline std::weak_ptr<ExpList> &GlobalLinSys::GetLocMat(void) const
172{
173 return m_expList;
174}
175
176/**
177 *
178 */
181 const AssemblyMapSharedPtr &locToGloMap,
182 const Array<OneD, const NekDouble> &dirForcing)
183{
184 v_Solve(in, out, locToGloMap, dirForcing);
185}
186
187/**
188 *
189 */
191 const int pNumRows, const Array<OneD, const NekDouble> &pInput,
192 Array<OneD, NekDouble> &pOutput, const AssemblyMapSharedPtr &locToGloMap,
193 const int pNumDir)
194{
195 v_SolveLinearSystem(pNumRows, pInput, pOutput, locToGloMap, pNumDir);
196}
197
199{
200 v_InitObject();
201}
202
204 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
205{
206 v_Initialise(pLocToGloMap);
207}
208
210{
211 return v_GetBlock(n);
212}
213
214inline void GlobalLinSys::DropBlock(unsigned int n)
215{
216 return v_DropBlock(n);
217}
218
220{
221 return v_GetStaticCondBlock(n);
222}
223
224inline void GlobalLinSys::DropStaticCondBlock(unsigned int n)
225{
226 return v_DropStaticCondBlock(n);
227}
228
230{
231 return v_GetNumBlocks();
232}
233} // namespace Nektar::MultiRegions
234
235#endif
#define MULTI_REGIONS_EXPORT
Provides a generic Factory class.
Definition: NekFactory.hpp:104
A global linear system.
Definition: GlobalLinSys.h:70
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 a basic matrix system.
virtual int v_GetNumBlocks()
Get the number of blocks in this system.
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
Definition: GlobalLinSys.h:122
void DropStaticCondBlock(unsigned int n)
Definition: GlobalLinSys.h:224
static std::string lookupIds[]
Definition: GlobalLinSys.h:156
LocalRegions::MatrixKey GetBlockMatrixKey(unsigned int n)
std::shared_ptr< GlobalLinSys > GetSharedThisPtr()
Returns a shared pointer to the current object.
Definition: GlobalLinSys.h:100
const GlobalLinSysKey & GetKey(void) const
Returns the key associated with the system.
Definition: GlobalLinSys.h:163
const std::map< int, RobinBCInfoSharedPtr > m_robinBCInfo
Robin boundary info.
Definition: GlobalLinSys.h:124
virtual void v_Solve(const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)=0
Solve a linear system based on mapping.
GlobalLinSys(const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
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.
Definition: GlobalLinSys.h:179
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:190
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
Definition: GlobalLinSys.h:120
virtual DNekScalMatSharedPtr v_GetBlock(unsigned int n)
Retrieves the block matrix from n-th expansion using the matrix key provided by the m_linSysKey.
DNekScalMatSharedPtr GetBlock(unsigned int n)
Definition: GlobalLinSys.h:209
virtual void v_DropBlock(unsigned int n)
Releases the local block matrix from NekManager of n-th expansion using the matrix key provided by th...
const std::weak_ptr< ExpList > & GetLocMat(void) const
Definition: GlobalLinSys.h:171
PreconditionerSharedPtr CreatePrecon(AssemblyMapSharedPtr asmMap)
Create a preconditioner object from the parameters defined in the supplied assembly map.
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n)
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
virtual void v_Initialise(const std::shared_ptr< AssemblyMap > &pLocToGloMap)
virtual void v_DropStaticCondBlock(unsigned int n)
Releases the static condensation block matrices from NekManager of n-th expansion using the matrix ke...
void Initialise(const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Definition: GlobalLinSys.h:203
DNekScalBlkMatSharedPtr GetStaticCondBlock(unsigned int n)
Definition: GlobalLinSys.h:219
void DropBlock(unsigned int n)
Definition: GlobalLinSys.h:214
LibUtilities::NekFactory< std::string, GlobalLinSys, const GlobalLinSysKey &, const std::weak_ptr< ExpList > &, const std::shared_ptr< AssemblyMap > & > GlobalLinSysFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class.
Definition: GlobalLinSys.h:65
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:51
std::map< GlobalLinSysKey, GlobalLinSysSharedPtr > GlobalLinSysMap
Mapping between GlobalLinSys objects and their associated keys.
Definition: GlobalLinSys.h:53
GlobalLinSysFactory & GetGlobalLinSysFactory()
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:58
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:50
std::shared_ptr< GlobalLinSysMap > GlobalLinSysMapShPtr
Pointer to a GlobalLinSys/key map.
Definition: GlobalLinSys.h:55
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:79
static Array< OneD, NekDouble > NullNekDouble1DArray