Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // 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: Preconditioner header
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_MULTIREGIONS_PRECONDITIONER_H
37 #define NEKTAR_LIB_MULTIREGIONS_PRECONDITIONER_H
38 
46 
47 #include <boost/shared_ptr.hpp>
48 
49 namespace Nektar
50 {
51  namespace MultiRegions
52  {
53  class AssemblyMap;
54  typedef boost::shared_ptr<AssemblyMap> AssemblyMapSharedPtr;
55 
56  class Preconditioner;
57  typedef boost::shared_ptr<Preconditioner> PreconditionerSharedPtr;
58 
59  static PreconditionerSharedPtr NullPreconditionerSharedPtr;
60 
61  typedef LibUtilities::NekFactory< std::string, Preconditioner,
62  const boost::shared_ptr<GlobalLinSys>&,
63  const boost::shared_ptr<AssemblyMap>& > PreconFactory;
64  PreconFactory& GetPreconFactory();
65 
66  class Preconditioner
67  {
68  public:
70  const boost::shared_ptr<GlobalLinSys> &plinsys,
71  const AssemblyMapSharedPtr &pLocToGloMap);
72 
74  virtual ~Preconditioner() {}
75 
76  inline void DoPreconditioner(
77  const Array<OneD, NekDouble>& pInput,
78  Array<OneD, NekDouble>& pOutput);
79 
81  const Array<OneD, NekDouble>& pInput,
82  Array<OneD, NekDouble>& pOutput,
83  const Array<OneD, NekDouble>& pNonVertOutput,
85 
86 
87  inline void DoTransformToLowEnergy(
88  Array<OneD, NekDouble>& pInOut,
89  int offset);
90 
91  inline void DoTransformToLowEnergy(
92  const Array<OneD, NekDouble>& pInput,
93  Array<OneD, NekDouble>& pOutput);
94 
95  inline void DoTransformFromLowEnergy(
96  Array<OneD, NekDouble>& pInOut);
97 
99  const Array<OneD, NekDouble>& pInput,
100  Array<OneD, NekDouble>& pOutput);
101 
103  const Array<OneD, NekDouble>& pInput,
104  Array<OneD, NekDouble>& pOutput);
105 
106  inline void BuildPreconditioner();
107 
108  inline void InitObject();
109 
111 
112  inline const DNekScalBlkMatSharedPtr&
114 
115  inline const DNekScalBlkMatSharedPtr&
116  GetBlockCMatrix() const;
117 
118  inline const DNekScalBlkMatSharedPtr&
119  GetBlockInvDMatrix() const;
120 
121  inline const DNekScalBlkMatSharedPtr&
122  GetBlockSchurCompl() const;
123 
124  inline const DNekScalBlkMatSharedPtr&
126 
127  inline const DNekScalBlkMatSharedPtr&
129 
131  int offset, const boost::shared_ptr<DNekScalMat > &loc_mat);
132 
133  protected:
134  const boost::weak_ptr<GlobalLinSys> m_linsys;
137  boost::shared_ptr<AssemblyMap> m_locToGloMap;
139 
141  int offset, const boost::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 boost::shared_ptr<Preconditioner> PreconditionerSharedPtr;
186 
187  /**
188  *
189  */
191  {
192  v_InitObject();
193  }
194 
195  /**
196  *
197  */
199  int offset, const boost::shared_ptr<DNekScalMat > &loc_mat)
200  {
201  return v_TransformedSchurCompl(offset,loc_mat);
202  }
203 
204  /**
205  *
206  */
208  const Array<OneD, NekDouble> &pInput,
209  Array<OneD, NekDouble> &pOutput)
210  {
211  v_DoPreconditioner(pInput,pOutput);
212  }
213 
214 
215  /**
216  *
217  */
219  const Array<OneD, NekDouble>& pInput,
220  Array<OneD, NekDouble>& pOutput,
221  const Array<OneD, NekDouble>& pNonVertOutput,
222  Array<OneD, NekDouble>& pVertForce)
223  {
224  v_DoPreconditionerWithNonVertOutput(pInput,pOutput,pNonVertOutput,
225  pVertForce);
226  }
227 
228  /**
229  *
230  */
232  Array<OneD, NekDouble>& pInOut, int offset)
233  {
234  v_DoTransformToLowEnergy(pInOut,offset);
235  }
236 
237  /**
238  *
239  */
241  const Array<OneD, NekDouble>& pInput,
242  Array<OneD, NekDouble>& pOutput)
243  {
244  v_DoTransformToLowEnergy(pInput,pOutput);
245  }
246 
247  /**
248  *
249  */
251  Array<OneD, NekDouble>& pInput)
252  {
254  }
255 
256  /**
257  *
258  */
260  const Array<OneD, NekDouble>& pInput,
261  Array<OneD, NekDouble>& pOutput)
262  {
264  }
265 
266  /**
267  *
268  */
269  inline void Preconditioner::
271  const Array<OneD, NekDouble>& pInput,
272  Array<OneD, NekDouble>& pOutput)
273  {
275  }
276 
277  /**
278  *
279  */
281  {
283  }
284  }
285 }
286 
287 #endif
LibUtilities::CommSharedPtr m_comm
boost::shared_ptr< AssemblyMap > m_locToGloMap
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
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:53
void DoMultiplybyInverseTransformationMatrix(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
const DNekScalBlkMatSharedPtr & GetBlockTransformationMatrix() const
const DNekScalBlkMatSharedPtr & GetBlockCMatrix() const
Preconditioner(const boost::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
virtual void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Apply a preconditioner to the conjugate gradient method.
LibUtilities::NekFactory< std::string, Preconditioner, const boost::shared_ptr< GlobalLinSys > &, const boost::shared_ptr< AssemblyMap > & > PreconFactory
#define MULTI_REGIONS_EXPORT
const DNekScalBlkMatSharedPtr & GetBlockSchurCompl() const
PreconFactory & GetPreconFactory()
boost::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:62
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...
boost::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:70
virtual void v_DoMultiplybyInverseTransformationMatrix(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Multiply by the block inverse transformation matrix.
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
const boost::weak_ptr< GlobalLinSys > m_linsys
void DoMultiplybyInverseTransposedTransformationMatrix(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
void DoTransformFromLowEnergy(Array< OneD, NekDouble > &pInOut)
static PreconditionerSharedPtr NullPreconditionerSharedPtr
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)
boost::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:74
virtual DNekScalMatSharedPtr v_TransformedSchurCompl(int offset, const boost::shared_ptr< DNekScalMat > &loc_mat)
Get block elemental transposed transformation matrix .
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)
const DNekScalBlkMatSharedPtr & GetBlockInvDMatrix() const
DNekScalMatSharedPtr TransformedSchurCompl(int offset, const boost::shared_ptr< DNekScalMat > &loc_mat)
const DNekScalBlkMatSharedPtr & GetBlockTransformedSchurCompl() const
const DNekScalBlkMatSharedPtr & GetBlockTransposedTransformationMatrix() const
Provides a generic Factory class.
Definition: NekFactory.hpp:116