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> &>
64 
66 {
67 public:
69  const std::shared_ptr<GlobalLinSys> &plinsys,
70  const AssemblyMapSharedPtr &pLocToGloMap);
71 
73  virtual ~Preconditioner()
74  {
75  }
76 
77  inline void DoPreconditioner(const Array<OneD, NekDouble> &pInput,
78  Array<OneD, NekDouble> &pOutput);
79 
81  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
82  const Array<OneD, NekDouble> &pNonVertOutput,
84 
86 
88 
89  inline void DoTransformCoeffsToLowEnergy(
90  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
91 
93  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
94 
95  inline void BuildPreconditioner();
96 
97  inline void InitObject();
98 
100 
102 
104 
106 
108 
110 
112  const;
113 
115  int offset, int bndoffset, const std::shared_ptr<DNekScalMat> &loc_mat);
116 
117 protected:
118  const std::weak_ptr<GlobalLinSys> m_linsys;
121  std::weak_ptr<AssemblyMap> m_locToGloMap;
123 
125  int offset, int bndoffset, const std::shared_ptr<DNekScalMat> &loc_mat);
126 
127  virtual void v_InitObject();
128 
129  virtual void v_DoPreconditioner(const Array<OneD, NekDouble> &pInput,
130  Array<OneD, NekDouble> &pOutput);
131 
133  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
134  const Array<OneD, NekDouble> &pNonVertOutput,
135  Array<OneD, NekDouble> &pVertForce);
136 
138 
140  Array<OneD, NekDouble> &pInOut);
141 
142  virtual void v_DoTransformCoeffsToLowEnergy(
143  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
144 
145  virtual void v_DoTransformBasisFromLowEnergy(
146  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
147 
148  virtual void v_BuildPreconditioner();
149 
150 private:
151  void NullPreconditioner(void);
152 
153  static std::string lookupIds[];
154  static std::string def;
155 };
156 typedef std::shared_ptr<Preconditioner> PreconditionerSharedPtr;
157 
158 /**
159  *
160  */
162 {
163  v_InitObject();
164 }
165 
166 /**
167  *
168  */
170  int offset, int bndoffset, const std::shared_ptr<DNekScalMat> &loc_mat)
171 {
172  return v_TransformedSchurCompl(offset, bndoffset, loc_mat);
173 }
174 
175 /**
176  *
177  */
179  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput)
180 {
181  v_DoPreconditioner(pInput, pOutput);
182 }
183 
184 /**
185  *
186  */
188  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
189  const Array<OneD, NekDouble> &pNonVertOutput,
190  Array<OneD, NekDouble> &pVertForce)
191 {
192  v_DoPreconditionerWithNonVertOutput(pInput, pOutput, pNonVertOutput,
193  pVertForce);
194 }
195 
196 /**
197  *
198  */
200  Array<OneD, NekDouble> &pInOut)
201 {
203 }
204 
205 /**
206  *
207  */
209  Array<OneD, NekDouble> &pInput)
210 {
212 }
213 
214 /**
215  *
216  */
218  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput)
219 {
220  v_DoTransformCoeffsToLowEnergy(pInput, pOutput);
221 }
222 
223 /**
224  *
225  */
227  const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput)
228 {
229  v_DoTransformBasisFromLowEnergy(pInput, pOutput);
230 }
231 
232 /**
233  *
234  */
236 {
238 }
239 } // namespace MultiRegions
240 } // namespace Nektar
241 
242 #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
LibUtilities::NekFactory< std::string, Preconditioner, const std::shared_ptr< GlobalLinSys > &, const std::shared_ptr< AssemblyMap > & > PreconFactory
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:60
PreconFactory & GetPreconFactory()
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:51
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:79
static Array< OneD, NekDouble > NullNekDouble1DArray
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75