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
48{
49class AssemblyMap;
50typedef std::shared_ptr<AssemblyMap> AssemblyMapSharedPtr;
51
52class Preconditioner;
53typedef std::shared_ptr<Preconditioner> PreconditionerSharedPtr;
54
56
57typedef LibUtilities::NekFactory<std::string, Preconditioner,
58 const std::shared_ptr<GlobalLinSys> &,
59 const std::shared_ptr<AssemblyMap> &>
62
64{
65public:
67 const std::shared_ptr<GlobalLinSys> &plinsys,
68 const AssemblyMapSharedPtr &pLocToGloMap);
69
72 {
73 }
74
75 inline void DoPreconditioner(const Array<OneD, NekDouble> &pInput,
77 const bool &IsLocal = false);
78
79 void DoAssembleLoc(const Array<OneD, NekDouble> &pInput,
80 Array<OneD, NekDouble> &pOutput, const bool &ZeroDir);
81
83 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
84 const Array<OneD, NekDouble> &pNonVertOutput,
86
88
90
92 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
93
95 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
96
97 inline void BuildPreconditioner();
98
99 inline void InitObject();
100
102
104
106
108
110
112
114 const;
115
117 int offset, int bndoffset, const std::shared_ptr<DNekScalMat> &loc_mat);
118
119protected:
120 const std::weak_ptr<GlobalLinSys> m_linsys;
121 std::string m_preconType;
123 std::weak_ptr<AssemblyMap> m_locToGloMap;
124
126 int offset, int bndoffset, const std::shared_ptr<DNekScalMat> &loc_mat);
127
128 virtual void v_InitObject();
129
130 virtual void v_DoPreconditioner(const Array<OneD, NekDouble> &pInput,
131 Array<OneD, NekDouble> &pOutput,
132 const bool &isLocal = false);
133
135 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
136 const Array<OneD, NekDouble> &pNonVertOutput,
137 Array<OneD, NekDouble> &pVertForce);
138
140
142 Array<OneD, NekDouble> &pInOut);
143
145 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
146
148 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
149
150 virtual void v_BuildPreconditioner();
151
152private:
154
155 static std::string lookupIds[];
156 static std::string def;
157};
158typedef std::shared_ptr<Preconditioner> PreconditionerSharedPtr;
159
160/**
161 *
162 */
164{
165 v_InitObject();
166}
167
168/**
169 *
170 */
172 int offset, int bndoffset, const std::shared_ptr<DNekScalMat> &loc_mat)
173{
174 return v_TransformedSchurCompl(offset, bndoffset, loc_mat);
175}
176
177/**
178 *
179 */
181 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
182 const bool &ZeroDir)
183{
184 v_DoPreconditioner(pInput, pOutput, ZeroDir);
185}
186
187/**
188 *
189 */
191 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
192 const Array<OneD, NekDouble> &pNonVertOutput,
193 Array<OneD, NekDouble> &pVertForce)
194{
195 v_DoPreconditionerWithNonVertOutput(pInput, pOutput, pNonVertOutput,
196 pVertForce);
197}
198
199/**
200 *
201 */
204{
206}
207
208/**
209 *
210 */
213{
215}
216
217/**
218 *
219 */
221 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput)
222{
223 v_DoTransformCoeffsToLowEnergy(pInput, pOutput);
224}
225
226/**
227 *
228 */
230 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput)
231{
232 v_DoTransformBasisFromLowEnergy(pInput, pOutput);
233}
234
235/**
236 *
237 */
239{
241}
242} // namespace Nektar::MultiRegions
243
244#endif
#define MULTI_REGIONS_EXPORT
Provides a generic Factory class.
const DNekScalBlkMatSharedPtr & GetBlockTransformationMatrix() const
virtual void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &isLocal=false)
Apply a preconditioner to the conjugate gradient method.
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.
const std::weak_ptr< GlobalLinSys > m_linsys
const DNekScalBlkMatSharedPtr & GetBlockTransformedSchurCompl() const
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 & GetBlockTransposedTransformationMatrix() const
Array< OneD, NekDouble > AssembleStaticCondGlobalDiagonals()
Performs global assembly of diagonal entries to global Schur complement matrix.
void DoAssembleLoc(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &ZeroDir)
Apply an assembly and scatter back to lcoal array.
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)
const DNekScalBlkMatSharedPtr & GetBlockCMatrix() const
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)
void DoTransformBasisFromLowEnergy(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
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 .
void DoTransformCoeffsFromLowEnergy(Array< OneD, NekDouble > &pInOut)
const DNekScalBlkMatSharedPtr & GetBlockSchurCompl() const
const DNekScalBlkMatSharedPtr & GetBlockInvDMatrix() const
void DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &IsLocal=false)
virtual void v_DoTransformCoeffsToLowEnergy(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Multiply by the block inverse transformation matrix.
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:58
PreconFactory & GetPreconFactory()
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:50
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