Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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  /// Root if parallel
89  bool m_root;
90 
91  /// Storage for solutions to previous linear problems
92  boost::circular_buffer<Array<OneD, NekDouble> > m_prevLinSol;
93 
94  /// Total counter of previous solutions
96 
97  /// A-conjugate projection technique
99  const int pNumRows,
100  const Array<OneD,const NekDouble> &pInput,
101  Array<OneD, NekDouble> &pOutput,
102  const AssemblyMapSharedPtr &locToGloMap,
103  const int pNumDir);
104 
105  /// Actual iterative solve
106  void DoConjugateGradient(
107  const int pNumRows,
108  const Array<OneD,const NekDouble> &pInput,
109  Array<OneD, NekDouble> &pOutput,
110  const AssemblyMapSharedPtr &locToGloMap,
111  const int pNumDir);
112 
113 
114  void Set_Rhs_Magnitude(const NekVector<NekDouble> &pIn);
115 
116  virtual void v_UniqueMap() = 0;
117 
118  private:
120  const int pGlobalBndDofs,
121  const Array<OneD,const NekDouble> &pSolution,
122  const int pNumDirBndDofs);
123 
125  const int nGlobal,
126  const Array<OneD,const NekDouble> &in,
127  const int nDir);
128 
129 
130  /// Solve the matrix system
131  virtual void v_SolveLinearSystem(
132  const int pNumRows,
133  const Array<OneD,const NekDouble> &pInput,
134  Array<OneD, NekDouble> &pOutput,
135  const AssemblyMapSharedPtr &locToGloMap,
136  const int pNumDir);
137 
138  virtual void v_DoMatrixMultiply(
139  const Array<OneD, NekDouble>& pInput,
140  Array<OneD, NekDouble>& pOutput) = 0;
141  };
142  }
143 }
144 
145 #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_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.