Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
57  typedef boost::shared_ptr<Preconditioner> PreconditionerSharedPtr;
58 
60 
61  typedef LibUtilities::NekFactory< std::string, Preconditioner,
62  const boost::shared_ptr<GlobalLinSys>&,
63  const boost::shared_ptr<AssemblyMap>& > PreconFactory;
65 
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,
84  Array<OneD, NekDouble>& pVertForce = NullNekDouble1DArray);
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 
110  Array<OneD, NekDouble> AssembleStaticCondGlobalDiagonals();
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