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 
40 
41 #include <boost/circular_buffer.hpp>
42 
43 namespace Nektar
44 {
45  namespace MultiRegions
46  {
47  // Forward declarations
48  class ExpList;
49 
50  /// A global linear system.
51  class GlobalLinSysIterative : virtual public GlobalLinSys
52  {
53  public:
54  /// Constructor for full direct matrix solve.
56  const GlobalLinSysKey &pKey,
57  const std::weak_ptr<ExpList> &pExpList,
58  const std::shared_ptr<AssemblyMap> &pLocToGloMap);
59 
61 
62  protected:
63  /// Global to universal unique map
65 
66  /// maximum iterations
67  int m_maxiter;
68 
69  /// Tolerance of iterative solver.
71 
72  /// dot product of rhs to normalise stopping criterion
74 
75  /// cnt to how many times rhs_magnitude is called
77 
79 
81 
83 
84  /// Whether to apply projection technique
86 
87  /// Root if parallel
88  bool m_root;
89 
90  /// Storage for solutions to previous linear problems
91  boost::circular_buffer<Array<OneD, NekDouble> > m_prevLinSol;
92 
93  /// Total counter of previous solutions
95 
96  /// A-conjugate projection technique
98  const int pNumRows,
99  const Array<OneD,const NekDouble> &pInput,
100  Array<OneD, NekDouble> &pOutput,
101  const AssemblyMapSharedPtr &locToGloMap,
102  const int pNumDir);
103 
104  /// Actual iterative solve
105  void DoConjugateGradient(
106  const int pNumRows,
107  const Array<OneD,const NekDouble> &pInput,
108  Array<OneD, NekDouble> &pOutput,
109  const AssemblyMapSharedPtr &locToGloMap,
110  const int pNumDir);
111 
112 
113  void Set_Rhs_Magnitude(const NekVector<NekDouble> &pIn);
114 
115  virtual void v_UniqueMap() = 0;
116 
117  private:
119  const int pGlobalBndDofs,
120  const Array<OneD,const NekDouble> &pSolution,
121  const int pNumDirBndDofs);
122 
124  const int nGlobal,
125  const Array<OneD,const NekDouble> &in,
126  const int nDir);
127 
128 
129  /// Solve the matrix system
130  virtual void v_SolveLinearSystem(
131  const int pNumRows,
132  const Array<OneD,const NekDouble> &pInput,
133  Array<OneD, NekDouble> &pOutput,
134  const AssemblyMapSharedPtr &locToGloMap,
135  const int pNumDir);
136 
137  virtual void v_DoMatrixMultiply(
138  const Array<OneD, NekDouble>& pInput,
139  Array<OneD, NekDouble>& pOutput) = 0;
140  };
141  }
142 }
143 
144 #endif
NekDouble m_rhs_mag_sm
cnt to how many times rhs_magnitude is called
void Set_Rhs_Magnitude(const NekVector< NekDouble > &pIn)
void UpdateKnownSolutions(const int pGlobalBndDofs, const Array< OneD, const NekDouble > &pSolution, const int pNumDirBndDofs)
bool m_useProjection
Whether to apply projection technique.
#define MULTI_REGIONS_EXPORT
boost::circular_buffer< Array< OneD, NekDouble > > m_prevLinSol
Storage for solutions to previous linear problems.
virtual void v_DoMatrixMultiply(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)=0
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:52
NekDouble CalculateAnorm(const int nGlobal, const Array< OneD, const NekDouble > &in, const int nDir)
NekDouble m_tolerance
Tolerance of iterative solver.
int m_numPrevSols
Total counter of previous solutions.
Array< OneD, int > m_map
Global to universal unique map.
double NekDouble
Describe a linear system.
void DoAconjugateProjection(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)
A-conjugate projection technique.
NekDouble m_rhs_magnitude
dot product of rhs to normalise stopping criterion
A global linear system.
Definition: GlobalLinSys.h:72
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.
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:60
MultiRegions::PreconditionerType m_precontype
void DoConjugateGradient(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)
Actual iterative solve.
GlobalLinSysIterative(const GlobalLinSysKey &pKey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.