Nektar++
Loading...
Searching...
No Matches
NekNonlinSysIterNewtonHookStep.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: NekNonlinSysIterNewtonHookStep.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: NekNonlinSysIterNewtonHookStep definition
33//
34///////////////////////////////////////////////////////////////////////////////
35
36#ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_NEK_NONLINSYS_NEWTON_HOOKSTEP_H
37#define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_NEK_NONLINSYS_NEWTON_HOOKSTEP_H
38
41
43{
44
45/**
46 * Newton hook-step solver uses GMRES data to compute a trust-region
47 * constrained step. During the GMRES solution the Arnoldi process constructs
48 * a Krylov basis and an upper Hessenberg matrix such that the linear residual
49 * is represented by the reduced model:
50 *
51 * || beta e_1 - H y ||_2.
52 *
53 * The hook-step solver reuses this reduced problem to solve the constrained
54 * trust-region problem
55 *
56 * min || beta e_1 - H y ||_2, subject to ||y||_2 <= Delta,
57 *
58 * and reconstructs the full-space correction from the Krylov basis.
59 *
60 * This implementation requires GMRES and uses GMRESHookData from the recently
61 * completed GMRES solve.
62 * Left-preconditioned GMRES is not supported.
63 * The reconstruction assumes the exported GMRES basis represents
64 * the same search space used by the linear solve.
65 */
67{
68public:
70
73 const LibUtilities::CommSharedPtr &vComm, const int nDimen,
74 const NekSysKey &pKey)
75 {
78 pSession, vComm, nDimen, pKey);
79 p->InitObject();
80 return p;
81 }
82
83 static std::string className;
84
87 const LibUtilities::CommSharedPtr &vComm, const int nDimen,
88 const NekSysKey &pKey);
89
91
92protected:
93 // Initial, current and min and max trust radi
94 NekDouble m_trustRadiusInit = 1.0e-2; // can be set via parameters
96 NekDouble m_trustRadiusMin = 1.0e-8; // can be set via parameters
97 NekDouble m_trustRadiusMax = 1.0e2; // can be set via parameters
98
99 // Acceptance measure rho
100 // minimum rho to accept the trial update
102 // If rho < m_rhoShrink will result in trust radius shrink
104 // If rho > m_rhoGrow will result in trust radius growth
106
107 // If rho < m_rhoShrink, shrink by m_shrinkFactor
109 // If rho > m_rhoGrow, grow by m_growFactor
111
112 // in fallback mode, used to test if the residual grcrease is sufficient
115
116 // In fallback mode, the maximum number of shrink steps
118 // In oportunistic mode, the maximum number of growth steps
120 // Limit the residuum growth befor failing
122
123 // temporary trial vectors
127
128 // temporary exploration vecotrs
131
132 void v_InitObject() override;
133
134 bool v_ApplyNewtonUpdate(const int ntotal,
135 const NekDouble oldResNorm) override;
136
137private:
138 NekDouble CalcL2Norm(const int ntotal,
139 const Array<OneD, const NekDouble> &x) const;
140
141 std::vector<NekDouble> SolveDenseLinearSystem(
142 std::vector<std::vector<NekDouble>> A, std::vector<NekDouble> b) const;
143
146 const NekDouble Delta) const;
147
151
154 const Array<OneD, const NekDouble> &y) const;
155
156 bool HasMeaningfulDecrease(const NekDouble oldResNorm,
157 const NekDouble newResNorm) const;
158};
159
160} // namespace Nektar::LibUtilities
161
162#endif
#define LIB_UTILITIES_EXPORT
NekDouble CalcL2Norm(const int ntotal, const Array< OneD, const NekDouble > &x) const
bool HasMeaningfulDecrease(const NekDouble oldResNorm, const NekDouble newResNorm) const
bool v_ApplyNewtonUpdate(const int ntotal, const NekDouble oldResNorm) override
Array< OneD, NekDouble > SolveReducedHookStep(const NekLinSysIterGMRES::GMRESHookData &data, const NekDouble Delta) const
std::vector< NekDouble > SolveDenseLinearSystem(std::vector< std::vector< NekDouble > > A, std::vector< NekDouble > b) const
void BuildHookStepFromKrylovBasis(const NekLinSysIterGMRES::GMRESHookData &data, const Array< OneD, const NekDouble > &y, Array< OneD, NekDouble > &delta)
static NekNonlinSysIterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vComm, const int nDimen, const NekSysKey &pKey)
NekDouble ComputeReducedResidualNorm(const NekLinSysIterGMRES::GMRESHookData &data, const Array< OneD, const NekDouble > &y) const
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< NekNonlinSysIter > NekNonlinSysIterSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition Comm.h:55
Data exported from GMRES for use by the Newton hook-step solver. The data stored here correspond to t...