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;
125
127 int offset, int bndoffset, const std::shared_ptr<DNekScalMat> &loc_mat);
128
129 virtual void v_InitObject();
130
131 virtual void v_DoPreconditioner(const Array<OneD, NekDouble> &pInput,
132 Array<OneD, NekDouble> &pOutput,
133 const bool &isLocal = false);
134
136 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
137 const Array<OneD, NekDouble> &pNonVertOutput,
138 Array<OneD, NekDouble> &pVertForce);
139
141
143 Array<OneD, NekDouble> &pInOut);
144
146 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
147
149 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput);
150
151 virtual void v_BuildPreconditioner();
152
153private:
155
156 static std::string lookupIds[];
157 static std::string def;
158};
159typedef std::shared_ptr<Preconditioner> PreconditionerSharedPtr;
160
161/**
162 *
163 */
165{
166 v_InitObject();
167}
168
169/**
170 *
171 */
173 int offset, int bndoffset, const std::shared_ptr<DNekScalMat> &loc_mat)
174{
175 return v_TransformedSchurCompl(offset, bndoffset, loc_mat);
176}
177
178/**
179 *
180 */
182 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
183 const bool &ZeroDir)
184{
185 v_DoPreconditioner(pInput, pOutput, ZeroDir);
186}
187
188/**
189 *
190 */
192 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput,
193 const Array<OneD, NekDouble> &pNonVertOutput,
194 Array<OneD, NekDouble> &pVertForce)
195{
196 v_DoPreconditionerWithNonVertOutput(pInput, pOutput, pNonVertOutput,
197 pVertForce);
198}
199
200/**
201 *
202 */
205{
207}
208
209/**
210 *
211 */
214{
216}
217
218/**
219 *
220 */
222 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput)
223{
224 v_DoTransformCoeffsToLowEnergy(pInput, pOutput);
225}
226
227/**
228 *
229 */
231 const Array<OneD, NekDouble> &pInput, Array<OneD, NekDouble> &pOutput)
232{
233 v_DoTransformBasisFromLowEnergy(pInput, pOutput);
234}
235
236/**
237 *
238 */
240{
242}
243} // namespace Nektar::MultiRegions
244
245#endif
#define MULTI_REGIONS_EXPORT
Provides a generic Factory class.
Definition: NekFactory.hpp:104
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.
LibUtilities::CommSharedPtr m_comm
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.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
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