Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // 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: GlobalLinSysIterative header
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 #ifndef NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYSITERATIVE_H
36 #define NEKTAR_LIB_MULTIREGIONS_GLOBALLINSYSITERATIVE_H
37 
41 
42 #include <boost/circular_buffer.hpp>
43 
44 namespace Nektar
45 {
46  namespace MultiRegions
47  {
48  // Forward declarations
49  class ExpList;
50 
51  /// A global linear system.
52  class GlobalLinSysIterative : virtual public GlobalLinSys
53  {
54  public:
55  /// Constructor for full direct matrix solve.
57  const GlobalLinSysKey &pKey,
58  const boost::weak_ptr<ExpList> &pExpList,
59  const boost::shared_ptr<AssemblyMap> &pLocToGloMap);
60 
62 
63  protected:
64  /// Global to universal unique map
65  Array<OneD, int> m_map;
66 
67  /// Tolerance of iterative solver.
69 
70  /// dot product of rhs to normalise stopping criterion
72 
74 
76 
78 
79  /// Whether to apply projection technique
81 
82  /// Provide verbose output and root if parallel.
83  bool m_root;
84  bool m_verbose;
85 
86  /// Storage for solutions to previous linear problems
87  boost::circular_buffer<Array<OneD, NekDouble> > m_prevLinSol;
88 
89  /// Total counter of previous solutions
91 
92  /// A-conjugate projection technique
94  const int pNumRows,
95  const Array<OneD,const NekDouble> &pInput,
96  Array<OneD, NekDouble> &pOutput,
97  const AssemblyMapSharedPtr &locToGloMap,
98  const int pNumDir);
99 
100  /// Actual iterative solve
101  void DoConjugateGradient(
102  const int pNumRows,
103  const Array<OneD,const NekDouble> &pInput,
104  Array<OneD, NekDouble> &pOutput,
105  const AssemblyMapSharedPtr &locToGloMap,
106  const int pNumDir);
107 
108 
109  void Set_Rhs_Magnitude(const NekVector<NekDouble> &pIn);
110 
111  virtual void v_UniqueMap() = 0;
112 
113  private:
115  const int pGlobalBndDofs,
116  const Array<OneD,const NekDouble> &pSolution,
117  const int pNumDirBndDofs);
118 
120  const int nGlobal,
121  const Array<OneD,const NekDouble> &in,
122  const int nDir);
123 
124 
125  /// Solve the matrix system
126  virtual void v_SolveLinearSystem(
127  const int pNumRows,
128  const Array<OneD,const NekDouble> &pInput,
129  Array<OneD, NekDouble> &pOutput,
130  const AssemblyMapSharedPtr &locToGloMap,
131  const int pNumDir);
132 
133  virtual void v_DoMatrixMultiply(
134  const Array<OneD, NekDouble>& pInput,
135  Array<OneD, NekDouble>& pOutput) = 0;
136  };
137  }
138 }
139 
140 #endif