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
66 
67  /// maximum iterations
68  int m_maxiter;
69 
70  /// Tolerance of iterative solver.
72 
73  /// dot product of rhs to normalise stopping criterion
75 
76  /// cnt to how many times rhs_magnitude is called
78 
80 
82 
84 
85  /// Whether to apply projection technique
87 
88  /// Provide verbose output and root if parallel.
89  bool m_root;
90  bool m_verbose;
91 
92  /// Storage for solutions to previous linear problems
93  boost::circular_buffer<Array<OneD, NekDouble> > m_prevLinSol;
94 
95  /// Total counter of previous solutions
97 
98  /// A-conjugate projection technique
100  const int pNumRows,
101  const Array<OneD,const NekDouble> &pInput,
102  Array<OneD, NekDouble> &pOutput,
103  const AssemblyMapSharedPtr &locToGloMap,
104  const int pNumDir);
105 
106  /// Actual iterative solve
107  void DoConjugateGradient(
108  const int pNumRows,
109  const Array<OneD,const NekDouble> &pInput,
110  Array<OneD, NekDouble> &pOutput,
111  const AssemblyMapSharedPtr &locToGloMap,
112  const int pNumDir);
113 
114 
115  void Set_Rhs_Magnitude(const NekVector<NekDouble> &pIn);
116 
117  virtual void v_UniqueMap() = 0;
118 
119  private:
121  const int pGlobalBndDofs,
122  const Array<OneD,const NekDouble> &pSolution,
123  const int pNumDirBndDofs);
124 
126  const int nGlobal,
127  const Array<OneD,const NekDouble> &in,
128  const int nDir);
129 
130 
131  /// Solve the matrix system
132  virtual void v_SolveLinearSystem(
133  const int pNumRows,
134  const Array<OneD,const NekDouble> &pInput,
135  Array<OneD, NekDouble> &pOutput,
136  const AssemblyMapSharedPtr &locToGloMap,
137  const int pNumDir);
138 
139  virtual void v_DoMatrixMultiply(
140  const Array<OneD, NekDouble>& pInput,
141  Array<OneD, NekDouble>& pOutput) = 0;
142  };
143  }
144 }
145 
146 #endif
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:53
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_root
Provide verbose output and root if parallel.
bool m_useProjection
Whether to apply projection technique.
#define MULTI_REGIONS_EXPORT
boost::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:62
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
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
GlobalLinSysIterative(const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
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:74
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
void DoConjugateGradient(const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)
Actual iterative solve.