Nektar++
NekLinSysIterGMRESLoc.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: NekLinSysIterGMRESLoc.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// License for the specific language governing rights and limitations under
14// Permission is hereby granted, free of charge, to any person obtaining a
15// copy of this software and associated documentation files (the "Software"),
16// to deal in the Software without restriction, including without limitation
17// the rights to use, copy, modify, merge, publish, distribute, sublicense,
18// and/or sell copies of the Software, and to permit persons to whom the
19// Software is furnished to do so, subject to the following conditions:
20//
21// The above copyright notice and this permission notice shall be included
22// in all copies or substantial portions of the Software.
23//
24// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30// DEALINGS IN THE SOFTWARE.
31//
32// Description: NekLinSysIterGMRESLoc header
33//
34///////////////////////////////////////////////////////////////////////////////
35
36#ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_NEK_LINSYS_ITERAT_GMRESLoc_H
37#define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_NEK_LINSYS_ITERAT_GMRESLoc_H
38
40
42{
43/// A global linear system.
45
47{
48public:
49 /// Support creation through MemoryManager.
51
54 const LibUtilities::CommSharedPtr &vRowComm, const int nDimen,
55 const NekSysKey &pKey)
56 {
59 pSession, vRowComm, nDimen, pKey);
60 p->InitObject();
61 return p;
62 }
63
64 static std::string className;
65
68 const LibUtilities::CommSharedPtr &vRowComm, const int nDimen,
69 const NekSysKey &pKey = NekSysKey());
71
73 {
75 }
76
77protected:
78 // This is maximum gmres restart iteration
80
81 // This is maximum bandwidth of Hessenburg matrix
82 // if use truncted Gmres(m)
84
85 // This is the maximum number of solution vectors that can be stored
86 // For example, in gmres, it is the max number of Krylov space
87 // search directions can be stored
88 // It determines the max storage usage
90
92
96
97 void v_InitObject() override;
98
99 int v_SolveSystem(const int nLocal,
100 const Array<OneD, const NekDouble> &pInput,
101 Array<OneD, NekDouble> &pOutput, const int nDir) override;
102
103private:
104 /// Actual iterative solve-GMRES
105 int DoGMRES(const int pNumRows, const Array<OneD, const NekDouble> &pInput,
106 Array<OneD, NekDouble> &pOutput);
107
108 /// Actual iterative gmres solver for one restart
109 NekDouble DoGmresRestart(const bool restarted, const bool truncted,
110 const int nLocal,
111 const Array<OneD, const NekDouble> &pInput,
112 Array<OneD, NekDouble> &pOutput);
113
114 // Arnoldi process
115 void DoArnoldi(const int starttem, const int endtem, const int nLocal,
117 // V[nd] current search direction
119 // V[nd+1] new search direction
121 // One line of Hessenburg matrix
123
124 // QR fatorization through Givens rotation
125 void DoGivensRotation(const int starttem, const int endtem,
129
130 // Backward calculation to calculate coeficients
131 // of least square problem
132 // To notice, Hessenburg's columnns and rows are reverse
133 void DoBackward(const int number, Array<OneD, Array<OneD, NekDouble>> &A,
136
137 static std::string lookupIds[];
138 static std::string def;
139
140 // Hessenburg matrix
142 // Hesseburg matrix after rotation
144 // Total search directions
146};
147} // namespace Nektar::LibUtilities
148
149#endif
#define LIB_UTILITIES_EXPORT
static NekLinSysIterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vRowComm, const int nDimen, const NekSysKey &pKey)
Array< OneD, Array< OneD, NekDouble > > m_V_total
NekDouble DoGmresRestart(const bool restarted, const bool truncted, const int nLocal, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Actual iterative gmres solver for one restart.
void DoArnoldi(const int starttem, const int endtem, const int nLocal, Array< OneD, NekDouble > &w, Array< OneD, NekDouble > &wk, Array< OneD, NekDouble > &V1, Array< OneD, NekDouble > &V2, Array< OneD, NekDouble > &h)
void DoBackward(const int number, Array< OneD, Array< OneD, NekDouble > > &A, const Array< OneD, const NekDouble > &b, Array< OneD, NekDouble > &y)
void DoGivensRotation(const int starttem, const int endtem, Array< OneD, NekDouble > &c, Array< OneD, NekDouble > &s, Array< OneD, NekDouble > &h, Array< OneD, NekDouble > &eta)
int v_SolveSystem(const int nLocal, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int nDir) override
NekLinSysIterGMRESLoc(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vRowComm, const int nDimen, const NekSysKey &pKey=NekSysKey())
Array< OneD, Array< OneD, NekDouble > > m_hes
int DoGMRES(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Actual iterative solve-GMRES.
Array< OneD, Array< OneD, NekDouble > > m_Upper
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< NekLinSysIter > NekLinSysIterSharedPtr
Definition: NekLinSysIter.h:47
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
std::vector< double > w(NPUPPER)
double NekDouble