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 
42 namespace Nektar
43 {
44  namespace MultiRegions
45  {
46  // Forward declarations
47  class ExpList;
48 
49  /// A global linear system.
50  class GlobalLinSysIterative : virtual public GlobalLinSys
51  {
52  public:
53  /// Constructor for full direct matrix solve.
55  const GlobalLinSysKey &pKey,
56  const std::weak_ptr<ExpList> &pExpList,
57  const std::shared_ptr<AssemblyMap> &pLocToGloMap);
58 
60 
61  protected:
62  /// Global to universal unique map
64 
65  /// maximum iterations
66  int m_maxiter;
67 
68  /// Tolerance of iterative solver.
70 
71  /// dot product of rhs to normalise stopping criterion
73 
74  /// cnt to how many times rhs_magnitude is called
76 
78 
80 
82 
83  /// Whether to apply projection technique
85 
86  /// Root if parallel
87  bool m_root;
88 
89  /// Iterative solver: Conjugate Gradient, GMRES
90  std::string m_linSysIterSolver;
91 
92  /// Storage for solutions to previous linear problems
93  std::vector<Array<OneD, NekDouble> > m_prevLinSol;
94  std::vector<Array<OneD, NekDouble> > m_prevBasis;
101 
103 
105 
106  static std::string IteratSolverlookupIds[];
107  static std::string IteratSolverdef;
108 
109  /// projection technique
110  void DoProjection(
111  const int pNumRows,
112  const Array<OneD,const NekDouble> &pInput,
113  Array<OneD, NekDouble> &pOutput,
114  const int pNumDir,
115  const NekDouble tol,
116  const bool isAconjugate);
117 
118  void Set_Rhs_Magnitude(const NekVector<NekDouble> &pIn);
119 
120  virtual void v_UniqueMap() = 0;
121 
122  private:
124  const int pGlobalBndDofs,
125  const Array<OneD,const NekDouble> &pSolution,
126  const int pNumDirBndDofs,
127  const bool isAconjugate);
128 
130 
132  const Array<OneD, NekDouble> &pInput,
133  Array<OneD, NekDouble> &pOutput,
134  const bool &controlFlag)
135  {
136  boost::ignore_unused(controlFlag);
137 
138  v_DoMatrixMultiply(pInput,pOutput);
139  }
140 
142  const Array<OneD, NekDouble> &pInput,
143  Array<OneD, NekDouble> &pOutput,
144  const bool &controlFlag)
145  {
146  boost::ignore_unused(controlFlag);
147 
148  m_precon->DoPreconditioner(pInput, pOutput);
149  }
150 
151 
152  /// Solve the matrix system
153  virtual void v_SolveLinearSystem(
154  const int pNumRows,
155  const Array<OneD,const NekDouble> &pInput,
156  Array<OneD, NekDouble> &pOutput,
157  const AssemblyMapSharedPtr &locToGloMap,
158  const int pNumDir);
159 
160  virtual void v_DoMatrixMultiply(
161  const Array<OneD, NekDouble>& pInput,
162  Array<OneD, NekDouble>& pOutput) = 0;
163  };
164  }
165 }
166 
167 #endif
#define MULTI_REGIONS_EXPORT
A global linear system.
Definition: GlobalLinSys.h:73
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 DoProjection(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int pNumDir, const NekDouble tol, const bool isAconjugate)
projection technique
void UpdateKnownSolutions(const int pGlobalBndDofs, const Array< OneD, const NekDouble > &pSolution, const int pNumDirBndDofs, const bool isAconjugate)
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)
virtual void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)=0
bool m_useProjection
Whether to apply projection technique.
NekDouble m_tolerance
Tolerance of iterative solver.
void DoPreconditionerFlag(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &controlFlag)
Array< OneD, int > m_map
Global to universal unique map.
NekDouble m_rhs_magnitude
dot product of rhs to normalise stopping criterion
virtual void v_SolveLinearSystem(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)
Solve the matrix system.
MultiRegions::PreconditionerType m_precontype
std::string m_linSysIterSolver
Iterative solver: Conjugate Gradient, GMRES.
void Set_Rhs_Magnitude(const NekVector< NekDouble > &pIn)
NekDouble m_rhs_mag_sm
cnt to how many times rhs_magnitude is called
std::shared_ptr< NekLinSysIter > NekLinSysIterSharedPtr
Definition: NekLinSysIter.h:46
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:60
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:52
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:69
double NekDouble