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
41{
42/// A global linear system.
44
46{
47public:
48 /// Support creation through MemoryManager.
50
53 const LibUtilities::CommSharedPtr &vRowComm, const int nDimen,
54 const NekSysKey &pKey)
55 {
58 pSession, vRowComm, nDimen, pKey);
59 p->InitObject();
60 return p;
61 }
62 static std::string className;
63
66 const LibUtilities::CommSharedPtr &vRowComm, const int nDimen,
67 const NekSysKey &pKey = NekSysKey());
69
71 {
73 }
74
75protected:
76 // This is maximum gmres restart iteration
78
79 // This is maximum bandwidth of Hessenburg matrix
80 // if use truncted Gmres(m)
82
85
86 bool m_DifferenceFlag0 = false;
87 bool m_DifferenceFlag1 = false;
88
89 void v_InitObject() override;
90
91 int v_SolveSystem(const int nLocal,
92 const Array<OneD, const NekDouble> &pInput,
93 Array<OneD, NekDouble> &pOutput, const int nDir,
94 const NekDouble tol, const NekDouble factor) override;
95
96private:
97 /// Actual iterative solve-GMRES
98 int DoGMRES(const int pNumRows, const Array<OneD, const NekDouble> &pInput,
99 Array<OneD, NekDouble> &pOutput);
100
101 /// Actual iterative gmres solver for one restart
102 NekDouble DoGmresRestart(const bool restarted, const bool truncted,
103 const int nLocal,
104 const Array<OneD, const NekDouble> &pInput,
105 Array<OneD, NekDouble> &pOutput);
106
107 // Arnoldi process
108 void DoArnoldi(const int starttem, const int endtem, const int nLocal,
110 // V[nd] current search direction
112 // V[nd+1] new search direction
114 // One line of Hessenburg matrix
116
117 // QR fatorization through Givens rotation
118 void DoGivensRotation(const int starttem, const int endtem,
122
123 // Backward calculation to calculate coeficients
124 // of least square problem
125 // To notice, Hessenburg's columnns and rows are reverse
126 void DoBackward(const int number, Array<OneD, Array<OneD, NekDouble>> &A,
129
130 static std::string lookupIds[];
131 static std::string def;
132
133 // Hessenburg matrix
135 // Hesseburg matrix after rotation
137 // Total search directions
139};
140} // namespace Nektar::LibUtilities
141
142#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, const NekDouble tol, const NekDouble factor) 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:46
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