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 
57  static PreconditionerSharedPtr NullPreconditionerSharedPtr;
58 
59  typedef LibUtilities::NekFactory< std::string, Preconditioner,
60  const std::shared_ptr<GlobalLinSys>&,
61  const std::shared_ptr<AssemblyMap>& > PreconFactory;
62  PreconFactory& GetPreconFactory();
63 
64  class Preconditioner
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 DoTransformToLowEnergy(
86  Array<OneD, NekDouble>& pInOut,
87  int offset);
88 
89  inline void DoTransformToLowEnergy(
90  const Array<OneD, NekDouble>& pInput,
91  Array<OneD, NekDouble>& pOutput);
92 
93  inline void DoTransformFromLowEnergy(
94  Array<OneD, NekDouble>& pInOut);
95 
97  const Array<OneD, NekDouble>& pInput,
98  Array<OneD, NekDouble>& pOutput);
99 
101  const Array<OneD, NekDouble>& pInput,
102  Array<OneD, NekDouble>& pOutput);
103 
104  inline void BuildPreconditioner();
105 
106  inline void InitObject();
107 
109 
110  inline const DNekScalBlkMatSharedPtr&
112 
113  inline const DNekScalBlkMatSharedPtr&
114  GetBlockCMatrix() const;
115 
116  inline const DNekScalBlkMatSharedPtr&
117  GetBlockInvDMatrix() const;
118 
119  inline const DNekScalBlkMatSharedPtr&
120  GetBlockSchurCompl() const;
121 
122  inline const DNekScalBlkMatSharedPtr&
124 
125  inline const DNekScalBlkMatSharedPtr&
127 
129  int offset, int bndoffset,
130  const std::shared_ptr<DNekScalMat > &loc_mat);
131 
132  protected:
133  const std::weak_ptr<GlobalLinSys> m_linsys;
136  std::weak_ptr<AssemblyMap> m_locToGloMap;
138 
140  int offset, int bndoffset,
141  const std::shared_ptr<DNekScalMat > &loc_mat);
142 
143 
144  private:
145 
146  void NullPreconditioner(void);
147 
148  virtual void v_InitObject();
149 
150  virtual void v_DoPreconditioner(
151  const Array<OneD, NekDouble>& pInput,
152  Array<OneD, NekDouble>& pOutput);
153 
155  const Array<OneD, NekDouble>& pInput,
156  Array<OneD, NekDouble>& pOutput,
157  const Array<OneD, NekDouble>& pNonVertOutput,
158  Array<OneD, NekDouble>& pVertForce);
159 
160 
161  virtual void v_DoTransformToLowEnergy(
162  Array<OneD, NekDouble>& pInOut,
163  int offset);
164 
165  virtual void v_DoTransformToLowEnergy(
166  const Array<OneD, NekDouble>& pInput,
167  Array<OneD, NekDouble>& pOutput);
168 
169  virtual void v_DoTransformFromLowEnergy(
170  Array<OneD, NekDouble>& pInput);
171 
173  const Array<OneD, NekDouble>& pInput,
174  Array<OneD, NekDouble>& pOutput);
175 
177  const Array<OneD, NekDouble>& pInput,
178  Array<OneD, NekDouble>& pOutput);
179 
180  virtual void v_BuildPreconditioner();
181 
182  static std::string lookupIds[];
183  static std::string def;
184  };
185  typedef std::shared_ptr<Preconditioner> PreconditionerSharedPtr;
186 
187  /**
188  *
189  */
191  {
192  v_InitObject();
193  }
194 
195  /**
196  *
197  */
199  int offset, int bndoffset,
200  const std::shared_ptr<DNekScalMat > &loc_mat)
201  {
202  return v_TransformedSchurCompl(offset,bndoffset,loc_mat);
203  }
204 
205  /**
206  *
207  */
209  const Array<OneD, NekDouble> &pInput,
210  Array<OneD, NekDouble> &pOutput)
211  {
212  v_DoPreconditioner(pInput,pOutput);
213  }
214 
215 
216  /**
217  *
218  */
220  const Array<OneD, NekDouble>& pInput,
221  Array<OneD, NekDouble>& pOutput,
222  const Array<OneD, NekDouble>& pNonVertOutput,
223  Array<OneD, NekDouble>& pVertForce)
224  {
225  v_DoPreconditionerWithNonVertOutput(pInput,pOutput,pNonVertOutput,
226  pVertForce);
227  }
228 
229  /**
230  *
231  */
233  Array<OneD, NekDouble>& pInOut, int offset)
234  {
235  v_DoTransformToLowEnergy(pInOut,offset);
236  }
237 
238  /**
239  *
240  */
242  const Array<OneD, NekDouble>& pInput,
243  Array<OneD, NekDouble>& pOutput)
244  {
245  v_DoTransformToLowEnergy(pInput,pOutput);
246  }
247 
248  /**
249  *
250  */
252  Array<OneD, NekDouble>& pInput)
253  {
255  }
256 
257  /**
258  *
259  */
261  const Array<OneD, NekDouble>& pInput,
262  Array<OneD, NekDouble>& pOutput)
263  {
265  }
266 
267  /**
268  *
269  */
270  inline void Preconditioner::
272  const Array<OneD, NekDouble>& pInput,
273  Array<OneD, NekDouble>& pOutput)
274  {
276  }
277 
278  /**
279  *
280  */
282  {
284  }
285  }
286 }
287 
288 #endif
const DNekScalBlkMatSharedPtr & GetBlockCMatrix() const
Preconditioner(const std::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
LibUtilities::CommSharedPtr m_comm
virtual DNekScalMatSharedPtr v_TransformedSchurCompl(int offset, int bndoffset, const std::shared_ptr< DNekScalMat > &loc_mat)
Get block elemental transposed transformation matrix .
virtual void v_DoMultiplybyInverseTransposedTransformationMatrix(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Multiply by the block transposed inverse transformation matrix.
static Array< OneD, NekDouble > NullNekDouble1DArray
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
const DNekScalBlkMatSharedPtr & GetBlockTransformationMatrix() const
void DoMultiplybyInverseTransformationMatrix(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:73
const std::weak_ptr< GlobalLinSys > m_linsys
const DNekScalBlkMatSharedPtr & GetBlockSchurCompl() const
virtual void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Apply a preconditioner to the conjugate gradient method.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
#define MULTI_REGIONS_EXPORT
PreconFactory & GetPreconFactory()
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...
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:69
virtual void v_DoMultiplybyInverseTransformationMatrix(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Multiply by the block inverse transformation matrix.
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
void DoMultiplybyInverseTransposedTransformationMatrix(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
const DNekScalBlkMatSharedPtr & GetBlockTransformedSchurCompl() const
void DoTransformFromLowEnergy(Array< OneD, NekDouble > &pInOut)
static PreconditionerSharedPtr NullPreconditionerSharedPtr
const DNekScalBlkMatSharedPtr & GetBlockTransposedTransformationMatrix() const
virtual void v_DoTransformFromLowEnergy(Array< OneD, NekDouble > &pInput)
Transform from low energy basis to orignal basis.
Array< OneD, NekDouble > AssembleStaticCondGlobalDiagonals()
Performs global assembly of diagonal entries to global Schur complement matrix.
void DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
virtual void v_DoTransformToLowEnergy(Array< OneD, NekDouble > &pInOut, int offset)
Transform from original basis to low energy basis.
void DoPreconditionerWithNonVertOutput(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const Array< OneD, NekDouble > &pNonVertOutput, Array< OneD, NekDouble > &pVertForce=NullNekDouble1DArray)
void DoTransformToLowEnergy(Array< OneD, NekDouble > &pInOut, int offset)
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:60
const DNekScalBlkMatSharedPtr & GetBlockInvDMatrix() const
std::weak_ptr< AssemblyMap > m_locToGloMap
DNekScalMatSharedPtr TransformedSchurCompl(int offset, int bndoffset, const std::shared_ptr< DNekScalMat > &loc_mat)
Provides a generic Factory class.
Definition: NekFactory.hpp:103