Nektar++
PreconditionerLowEnergy.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: PreconditionerLowEnergy.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: PreconditionerLowEnergy header
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 #ifndef NEKTAR_LIB_MULTIREGIONS_PRECONDITIONERLOWENERGY_H
35 #define NEKTAR_LIB_MULTIREGIONS_PRECONDITIONERLOWENERGY_H
36 #include <LocalRegions/HexExp.h>
37 #include <LocalRegions/PrismExp.h>
38 #include <LocalRegions/PyrExp.h>
39 #include <LocalRegions/TetExp.h>
44 
45 namespace Nektar
46 {
47 namespace MultiRegions
48 {
49 class PreconditionerLowEnergy;
50 typedef std::shared_ptr<PreconditionerLowEnergy>
52 
54 {
55 public:
56  /// Creates an instance of this class
58  const std::shared_ptr<GlobalLinSys> &plinsys,
59  const std::shared_ptr<AssemblyMap> &pLocToGloMap)
60  {
63  plinsys, pLocToGloMap);
64  p->InitObject();
65  return p;
66  }
67 
68  /// Name of class
69  static std::string className;
70 
72  const std::shared_ptr<GlobalLinSys> &plinsys,
73  const AssemblyMapSharedPtr &pLocToGloMap);
74 
77  {
78  }
79 
80 protected:
84 
86 
88 
89  // store how many consecutive similar blocks there
90  // are in R and Rinv
91  std::vector<std::pair<int, int>> m_sameBlock;
92 
93  virtual void v_InitObject() override;
94 
95  virtual void v_DoPreconditioner(const Array<OneD, NekDouble> &pInput,
96  Array<OneD, NekDouble> &pOutput) override;
97 
98  virtual void v_BuildPreconditioner() override;
99 
101  int n, int offset,
102  const std::shared_ptr<DNekScalMat> &loc_mat) override;
103 
104  virtual void v_DoTransformBasisToLowEnergy(
105  Array<OneD, NekDouble> &pInOut) override;
106 
108  Array<OneD, NekDouble> &pInOut) override;
109 
110  virtual void v_DoTransformBasisFromLowEnergy(
111  const Array<OneD, NekDouble> &pInput,
112  Array<OneD, NekDouble> &pOutput) override;
113 
114  virtual void v_DoTransformCoeffsToLowEnergy(
115  const Array<OneD, NekDouble> &pInput,
116  Array<OneD, NekDouble> &pOutput) override;
117 
118 private:
120 
121  typedef std::map<LibUtilities::ShapeType, DNekScalMatSharedPtr>
123  typedef std::map<LibUtilities::ShapeType,
126  typedef std::map<LibUtilities::ShapeType, Array<OneD, unsigned int>>
128  typedef std::map<LibUtilities::ShapeType,
131 
132  void SetUpReferenceElements(ShapeToDNekMap &maxRmat, ShapeToExpMap &maxElmt,
133  ShapeToIntArrayMap &vertMapMaxR,
134  ShapeToIntArrayArrayMap &edgeMapMaxR);
135 
136  void SetUpPyrMaxRMat(int nummodesmax, LocalRegions::PyrExpSharedPtr &PyrExp,
137  ShapeToDNekMap &maxRmat,
138  ShapeToIntArrayMap &vertMapMaxR,
139  ShapeToIntArrayArrayMap &edgeMapMaxR,
140  ShapeToIntArrayArrayMap &faceMapMaxR);
141 
142  void ReSetTetMaxRMat(int nummodesmax, LocalRegions::TetExpSharedPtr &TetExp,
143  ShapeToDNekMap &maxRmat,
144  ShapeToIntArrayMap &vertMapMaxR,
145  ShapeToIntArrayArrayMap &edgeMapMaxR,
146  ShapeToIntArrayArrayMap &faceMapMaxR);
147 
148  void ReSetPrismMaxRMat(int nummodesmax,
150  ShapeToDNekMap &maxRmat,
151  ShapeToIntArrayMap &vertMapMaxR,
152  ShapeToIntArrayArrayMap &edgeMapMaxR,
153  ShapeToIntArrayArrayMap &faceMapMaxR,
154  bool UseTetOnly);
155 
158  DNekScalMatSharedPtr &maxRmat,
160  Array<OneD, unsigned int> &vertMapMaxR,
161  Array<OneD, Array<OneD, unsigned int>> &edgeMapMaxR);
162 
163  void CreateVariablePMask(void);
164 
169 };
170 } // namespace MultiRegions
171 } // namespace Nektar
172 
173 #endif
#define MULTI_REGIONS_EXPORT
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
virtual void v_DoTransformCoeffsFromLowEnergy(Array< OneD, NekDouble > &pInOut) override
transform the solution coeffiicents from low energy back to the original coefficient space.
SpatialDomains::HexGeomSharedPtr CreateRefHexGeom(void)
Sets up the reference hexahedral element needed to construct a low energy basis.
void ReSetPrismMaxRMat(int nummodesmax, LocalRegions::PrismExpSharedPtr &PirsmExp, ShapeToDNekMap &maxRmat, ShapeToIntArrayMap &vertMapMaxR, ShapeToIntArrayArrayMap &edgeMapMaxR, ShapeToIntArrayArrayMap &faceMapMaxR, bool UseTetOnly)
DNekMatSharedPtr ExtractLocMat(LocalRegions::Expansion3DSharedPtr &locExp, DNekScalMatSharedPtr &maxRmat, LocalRegions::Expansion3DSharedPtr &expMax, Array< OneD, unsigned int > &vertMapMaxR, Array< OneD, Array< OneD, unsigned int >> &edgeMapMaxR)
std::vector< std::pair< int, int > > m_sameBlock
virtual void v_DoTransformCoeffsToLowEnergy(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
Multiply by the block tranposed inverse transformation matrix (R^T)^{-1} which is equivlaent to trans...
std::map< LibUtilities::ShapeType, LocalRegions::Expansion3DSharedPtr > ShapeToExpMap
virtual DNekScalMatSharedPtr v_TransformedSchurCompl(int n, int offset, const std::shared_ptr< DNekScalMat > &loc_mat) override
Set up the transformed block matrix system.
virtual void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
virtual void v_BuildPreconditioner() override
Construct the low energy preconditioner from .
void ReSetTetMaxRMat(int nummodesmax, LocalRegions::TetExpSharedPtr &TetExp, ShapeToDNekMap &maxRmat, ShapeToIntArrayMap &vertMapMaxR, ShapeToIntArrayArrayMap &edgeMapMaxR, ShapeToIntArrayArrayMap &faceMapMaxR)
std::map< LibUtilities::ShapeType, DNekScalMatSharedPtr > ShapeToDNekMap
static PreconditionerSharedPtr create(const std::shared_ptr< GlobalLinSys > &plinsys, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
PreconditionerLowEnergy(const std::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
SpatialDomains::TetGeomSharedPtr CreateRefTetGeom(void)
Sets up the reference tretrahedral element needed to construct a low energy basis.
virtual void v_DoTransformBasisFromLowEnergy(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput) override
Multiply by the block inverse transformation matrix This transforms the bassi from Low Energy to orig...
virtual void v_DoTransformBasisToLowEnergy(Array< OneD, NekDouble > &pInOut) override
Transform the basis vector to low energy space.
std::map< LibUtilities::ShapeType, Array< OneD, Array< OneD, unsigned int > > > ShapeToIntArrayArrayMap
SpatialDomains::PrismGeomSharedPtr CreateRefPrismGeom(void)
Sets up the reference prismatic element needed to construct a low energy basis.
void SetUpReferenceElements(ShapeToDNekMap &maxRmat, ShapeToExpMap &maxElmt, ShapeToIntArrayMap &vertMapMaxR, ShapeToIntArrayArrayMap &edgeMapMaxR)
Loop expansion and determine different variants of the transformation matrix.
std::map< LibUtilities::ShapeType, Array< OneD, unsigned int > > ShapeToIntArrayMap
void SetUpPyrMaxRMat(int nummodesmax, LocalRegions::PyrExpSharedPtr &PyrExp, ShapeToDNekMap &maxRmat, ShapeToIntArrayMap &vertMapMaxR, ShapeToIntArrayArrayMap &edgeMapMaxR, ShapeToIntArrayArrayMap &faceMapMaxR)
SpatialDomains::PyrGeomSharedPtr CreateRefPyrGeom(void)
Sets up the reference prismatic element needed to construct a low energy basis mapping arrays.
std::shared_ptr< PrismExp > PrismExpSharedPtr
Definition: PrismExp.h:209
std::shared_ptr< PyrExp > PyrExpSharedPtr
Definition: PyrExp.h:185
std::shared_ptr< Expansion3D > Expansion3DSharedPtr
Definition: Expansion2D.h:50
std::shared_ptr< TetExp > TetExpSharedPtr
Definition: TetExp.h:214
std::shared_ptr< PreconditionerLowEnergy > PreconditionerLowEnergySharedPtr
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
Definition: GlobalLinSys.h:60
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:51
std::shared_ptr< PrismGeom > PrismGeomSharedPtr
Definition: PrismGeom.h:85
std::shared_ptr< HexGeom > HexGeomSharedPtr
Definition: HexGeom.h:87
std::shared_ptr< PyrGeom > PyrGeomSharedPtr
Definition: PyrGeom.h:77
std::shared_ptr< TetGeom > TetGeomSharedPtr
Definition: TetGeom.h:85
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
std::shared_ptr< DNekBlkMat > DNekBlkMatSharedPtr
Definition: NekTypeDefs.hpp:77
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75