Nektar++
Preconditioner.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File Preconditioner.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: Preconditioner header
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIB_MULTIREGIONS_PRECONDITIONER_H
36 #define NEKTAR_LIB_MULTIREGIONS_PRECONDITIONER_H
37 
44 
45 #include <memory>
46 
47 namespace Nektar
48 {
49  namespace MultiRegions
50  {
51  class AssemblyMap;
52  typedef std::shared_ptr<AssemblyMap> AssemblyMapSharedPtr;
53 
54  class Preconditioner;
55  typedef std::shared_ptr<Preconditioner> PreconditionerSharedPtr;
56 
58 
59  typedef LibUtilities::NekFactory< std::string, Preconditioner,
60  const std::shared_ptr<GlobalLinSys>&,
61  const std::shared_ptr<AssemblyMap>& > PreconFactory;
63 
65  {
66  public:
68  const std::shared_ptr<GlobalLinSys> &plinsys,
69  const AssemblyMapSharedPtr &pLocToGloMap);
70 
72  virtual ~Preconditioner() {}
73 
74  inline void DoPreconditioner(
75  const Array<OneD, NekDouble>& pInput,
76  Array<OneD, NekDouble>& pOutput);
77 
79  const Array<OneD, NekDouble>& pInput,
80  Array<OneD, NekDouble>& pOutput,
81  const Array<OneD, NekDouble>& pNonVertOutput,
83 
84 
85  inline void DoTransformBasisToLowEnergy(
86  Array<OneD, NekDouble>& pInOut);
87 
89  Array<OneD, NekDouble>& pInOut);
90 
91  inline void DoTransformCoeffsToLowEnergy(
92  const Array<OneD, NekDouble>& pInput,
93  Array<OneD, NekDouble>& pOutput);
94 
96  const Array<OneD, NekDouble>& pInput,
97  Array<OneD, NekDouble>& pOutput);
98 
99  inline void BuildPreconditioner();
100 
101  inline void InitObject();
102 
104 
105  inline const DNekScalBlkMatSharedPtr&
107 
108  inline const DNekScalBlkMatSharedPtr&
110 
111  inline const DNekScalBlkMatSharedPtr&
113 
114  inline const DNekScalBlkMatSharedPtr&
116 
117  inline const DNekScalBlkMatSharedPtr&
119 
120  inline const DNekScalBlkMatSharedPtr&
122 
124  int offset, int bndoffset,
125  const std::shared_ptr<DNekScalMat > &loc_mat);
126 
127  protected:
128  const std::weak_ptr<GlobalLinSys> m_linsys;
131  std::weak_ptr<AssemblyMap> m_locToGloMap;
133 
135  int offset, int bndoffset,
136  const std::shared_ptr<DNekScalMat > &loc_mat);
137 
138 
139  private:
140 
141  void NullPreconditioner(void);
142 
143  virtual void v_InitObject();
144 
145  virtual void v_DoPreconditioner(
146  const Array<OneD, NekDouble>& pInput,
147  Array<OneD, NekDouble>& pOutput);
148 
150  const Array<OneD, NekDouble>& pInput,
151  Array<OneD, NekDouble>& pOutput,
152  const Array<OneD, NekDouble>& pNonVertOutput,
153  Array<OneD, NekDouble>& pVertForce);
154 
155 
156  virtual void v_DoTransformBasisToLowEnergy(
157  Array<OneD, NekDouble>& pInOut);
158 
160  Array<OneD, NekDouble>& pInOut);
161 
162  virtual void v_DoTransformCoeffsToLowEnergy(
163  const Array<OneD, NekDouble>& pInput,
164  Array<OneD, NekDouble>& pOutput);
165 
166  virtual void v_DoTransformBasisFromLowEnergy(
167  const Array<OneD, NekDouble>& pInput,
168  Array<OneD, NekDouble>& pOutput);
169 
170  virtual void v_BuildPreconditioner();
171 
172  static std::string lookupIds[];
173  static std::string def;
174  };
175  typedef std::shared_ptr<Preconditioner> PreconditionerSharedPtr;
176 
177  /**
178  *
179  */
181  {
182  v_InitObject();
183  }
184 
185  /**
186  *
187  */
189  int offset, int bndoffset,
190  const std::shared_ptr<DNekScalMat > &loc_mat)
191  {
192  return v_TransformedSchurCompl(offset,bndoffset,loc_mat);
193  }
194 
195  /**
196  *
197  */
199  const Array<OneD, NekDouble> &pInput,
200  Array<OneD, NekDouble> &pOutput)
201  {
202  v_DoPreconditioner(pInput,pOutput);
203  }
204 
205 
206  /**
207  *
208  */
210  const Array<OneD, NekDouble>& pInput,
211  Array<OneD, NekDouble>& pOutput,
212  const Array<OneD, NekDouble>& pNonVertOutput,
213  Array<OneD, NekDouble>& pVertForce)
214  {
215  v_DoPreconditionerWithNonVertOutput(pInput,pOutput,pNonVertOutput,
216  pVertForce);
217  }
218 
219  /**
220  *
221  */
223  Array<OneD, NekDouble>& pInOut)
224  {
226  }
227 
228  /**
229  *
230  */
232  Array<OneD, NekDouble>& pInput)
233  {
235  }
236 
237  /**
238  *
239  */
241  const Array<OneD, NekDouble>& pInput,
242  Array<OneD, NekDouble>& pOutput)
243  {
244  v_DoTransformCoeffsToLowEnergy(pInput,pOutput);
245  }
246 
247  /**
248  *
249  */
251  const Array<OneD, NekDouble>& pInput,
252  Array<OneD, NekDouble>& pOutput)
253  {
254  v_DoTransformBasisFromLowEnergy(pInput,pOutput);
255  }
256 
257  /**
258  *
259  */
261  {
263  }
264  }
265 }
266 
267 #endif
#define MULTI_REGIONS_EXPORT
Provides a generic Factory class.
Definition: NekFactory.hpp:105
void DoTransformCoeffsToLowEnergy(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
virtual void v_DoTransformBasisToLowEnergy(Array< OneD, NekDouble > &pInOut)
Transform from original basis to low energy basis.
LibUtilities::CommSharedPtr m_comm
const std::weak_ptr< GlobalLinSys > m_linsys
virtual void v_DoPreconditionerWithNonVertOutput(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const Array< OneD, NekDouble > &pNonVertOutput, Array< OneD, NekDouble > &pVertForce)
Apply a preconditioner to the conjugate gradient method with an output for non-vertex degrees of free...
const DNekScalBlkMatSharedPtr & GetBlockInvDMatrix() const
const DNekScalBlkMatSharedPtr & GetBlockTransformationMatrix() const
void DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Array< OneD, NekDouble > AssembleStaticCondGlobalDiagonals()
Performs global assembly of diagonal entries to global Schur complement matrix.
virtual void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Apply a preconditioner to the conjugate gradient method.
std::weak_ptr< AssemblyMap > m_locToGloMap
virtual void v_DoTransformBasisFromLowEnergy(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Multiply by the block transposed inverse transformation matrix.
void DoTransformBasisToLowEnergy(Array< OneD, NekDouble > &pInOut)
void DoPreconditionerWithNonVertOutput(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const Array< OneD, NekDouble > &pNonVertOutput, Array< OneD, NekDouble > &pVertForce=NullNekDouble1DArray)
DNekScalMatSharedPtr TransformedSchurCompl(int offset, int bndoffset, const std::shared_ptr< DNekScalMat > &loc_mat)
Preconditioner(const std::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
const DNekScalBlkMatSharedPtr & GetBlockTransformedSchurCompl() const
void DoTransformBasisFromLowEnergy(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
const DNekScalBlkMatSharedPtr & GetBlockSchurCompl() const
virtual void v_DoTransformCoeffsFromLowEnergy(Array< OneD, NekDouble > &pInOut)
Transform from low energy coeffs to orignal basis.
virtual DNekScalMatSharedPtr v_TransformedSchurCompl(int offset, int bndoffset, const std::shared_ptr< DNekScalMat > &loc_mat)
Get block elemental transposed transformation matrix .
const DNekScalBlkMatSharedPtr & GetBlockTransposedTransformationMatrix() const
const DNekScalBlkMatSharedPtr & GetBlockCMatrix() const
void DoTransformCoeffsFromLowEnergy(Array< OneD, NekDouble > &pInOut)
virtual void v_DoTransformCoeffsToLowEnergy(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Multiply by the block inverse transformation matrix.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:54
static PreconditionerSharedPtr NullPreconditionerSharedPtr
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:60
PreconFactory & GetPreconFactory()
LibUtilities::NekFactory< std::string, Preconditioner, const std::shared_ptr< GlobalLinSys > &, const std::shared_ptr< AssemblyMap > & > PreconFactory
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< DNekScalMat > DNekScalMatSharedPtr
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:73
static Array< OneD, NekDouble > NullNekDouble1DArray
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:69