Nektar++
GlobalLinSysIterative.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: GlobalLinSysIterative.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: GlobalLinSysIterative header
32//
33///////////////////////////////////////////////////////////////////////////////
34#ifndef NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYSITERATIVE_H
35#define NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYSITERATIVE_H
36
41
43{
44// Forward declarations
45class ExpList;
46
47/// A global linear system.
48class GlobalLinSysIterative : virtual public GlobalLinSys
49{
50public:
51 /// Constructor for full direct matrix solve.
53 const GlobalLinSysKey &pKey, const std::weak_ptr<ExpList> &pExpList,
54 const std::shared_ptr<AssemblyMap> &pLocToGloMap);
55
57
60 {
61 v_DoMatrixMultiply(pInput, pOutput);
62 }
63
64protected:
65 /// Global to universal unique map
67
68 /// dot product of rhs to normalise stopping criterion
70
71 /// cnt to how many times rhs_magnitude is called
73
75
76 std::string m_precontype;
77
79
80 /// Whether to apply projection technique
82
83 /// Root if parallel
84 bool m_root;
85
86 /// Iterative solver: Conjugate Gradient, GMRES
87 std::string m_linSysIterSolver;
88
89 /// Storage for solutions to previous linear problems
90 std::vector<Array<OneD, NekDouble>> m_prevLinSol;
91 std::vector<Array<OneD, NekDouble>> m_prevBasis;
97 std::string m_matrixType;
101
103
105
106 static std::string IteratSolverlookupIds[];
107 static std::string IteratSolverdef;
108
109 /// projection technique
110 void DoProjection(const int pNumRows,
111 const Array<OneD, const NekDouble> &pInput,
112 Array<OneD, NekDouble> &pOutput, const int pNumDir,
113 const bool isAconjugate);
114
115 virtual void v_UniqueMap() = 0;
116
117 virtual void v_DoMatrixMultiply(const Array<OneD, NekDouble> &pInput,
118 Array<OneD, NekDouble> &pOutput) = 0;
119
120private:
121 void UpdateKnownSolutions(const int pGlobalBndDofs,
122 const Array<OneD, const NekDouble> &pSolution,
123 const int pNumDirBndDofs,
124 const bool isAconjugate);
125
127
129 Array<OneD, NekDouble> &pOutput,
130 const bool &isLocal = false)
131 {
132 m_precon->DoPreconditioner(pInput, pOutput, isLocal);
133 }
134
136 Array<OneD, NekDouble> &pOutput,
137 [[maybe_unused]] const bool &controlFlag)
138 {
139 v_DoMatrixMultiply(pInput, pOutput);
140 }
141
143 Array<OneD, NekDouble> &pOutput, const bool &ZeroDir)
144 {
145 m_precon->DoAssembleLoc(pInput, pOutput, ZeroDir);
146 }
147};
148} // namespace Nektar::MultiRegions
149
150#endif
#define MULTI_REGIONS_EXPORT
A global linear system.
Definition: GlobalLinSys.h:70
GlobalLinSysIterative(const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
std::vector< Array< OneD, NekDouble > > m_prevBasis
LibUtilities::NekLinSysIterSharedPtr m_linsol
void DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
void UpdateKnownSolutions(const int pGlobalBndDofs, const Array< OneD, const NekDouble > &pSolution, const int pNumDirBndDofs, const bool isAconjugate)
void DoAssembleLocFlag(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &ZeroDir)
void DoPreconditionerFlag(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &isLocal=false)
std::vector< Array< OneD, NekDouble > > m_prevLinSol
Storage for solutions to previous linear problems.
void DoMatrixMultiplyFlag(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &controlFlag)
void DoProjection(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int pNumDir, const bool isAconjugate)
projection technique
virtual void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)=0
bool m_useProjection
Whether to apply projection technique.
Array< OneD, int > m_map
Global to universal unique map.
NekDouble m_rhs_magnitude
dot product of rhs to normalise stopping criterion
std::string m_linSysIterSolver
Iterative solver: Conjugate Gradient, GMRES.
NekDouble m_rhs_mag_sm
cnt to how many times rhs_magnitude is called
std::shared_ptr< NekLinSysIter > NekLinSysIterSharedPtr
Definition: NekLinSysIter.h:47
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:58
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75
double NekDouble