Nektar++
StdMatrixKey.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: StdMatrixKey.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: Headers for StdMatrixKey
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef STDMATRIXKEY_H
36 #define STDMATRIXKEY_H
37 
39 #include <LibUtilities/Foundations/Foundations.hpp> // for PointsType, etc
42 
43 namespace Nektar
44 {
45 namespace StdRegions
46 {
47 
48 class StdExpansion;
49 
51 {
52 public:
54  const StdRegions::MatrixType matrixType,
55  const LibUtilities::ShapeType shapeType,
56  const StdRegions::StdExpansion &stdExpansion,
57  const ConstFactorMap &factorMap = NullConstFactorMap,
58  const VarCoeffMap &varCoeffMap = NullVarCoeffMap,
60 
62  const StdRegions::MatrixType matrixType);
63 
65 
66  virtual ~StdMatrixKey()
67  {
68  }
69 
70  /// Used to lookup the create function in NekManager.
71  struct opLess
72  {
74  const StdMatrixKey &rhs) const;
75  };
76 
77  /// Used for finding value given the key in NekManager.
78  STD_REGIONS_EXPORT friend bool operator<(const StdMatrixKey &lhs,
79  const StdMatrixKey &rhs);
80  STD_REGIONS_EXPORT friend bool operator==(const StdMatrixKey &lhs,
81  const StdMatrixKey &rhs);
83  const StdMatrixKey &lhs, const StdMatrixKey &rhs) const;
84 
86  {
87  return m_matrixType;
88  }
89 
91  {
92  return m_shapeType;
93  }
94 
96  {
97  return m_nodalPointsType;
98  }
99 
100  int GetNcoeffs() const
101  {
102  return m_ncoeffs;
103  }
104 
106  const
107  {
108  return m_base;
109  }
110 
111  std::vector<std::size_t> GetVarCoeffHashes() const
112  {
113  return m_varcoeff_hashes;
114  }
115 
116  inline const LibUtilities::BasisSharedPtr GetBasis(int dir) const
117  {
118  return (m_base[dir]);
119  }
120 
121  inline int GetNConstFactors() const
122  {
123  return m_factors.size();
124  }
125 
126  inline NekDouble GetConstFactor(const ConstFactorType &factor) const
127  {
128  auto x = m_factors.find(factor);
129  ASSERTL1(x != m_factors.end(),
130  "Constant factor not defined: " +
131  std::string(StdRegions::ConstFactorTypeMap[factor]));
132  return x->second;
133  }
134 
135  inline bool ConstFactorExists(const ConstFactorType &factor) const
136  {
137  return m_factors.find(factor) != m_factors.end();
138  }
139 
140  inline const ConstFactorMap &GetConstFactors() const
141  {
142  return m_factors;
143  }
144 
145  inline int GetNVarCoeff() const
146  {
147  return m_varcoeffs.size();
148  }
149 
151  const StdRegions::VarCoeffType &coeff) const
152  {
153  auto x = m_varcoeffs.find(coeff);
154  ASSERTL1(x != m_varcoeffs.end(),
155  "Variable coefficient not defined: " +
156  std::string(StdRegions::VarCoeffTypeMap[coeff]));
157  return x->second.GetValue();
158  }
159 
160  inline const VarCoeffMap GetVarCoeffAsMap(const VarCoeffType &coeff) const
161  {
162  VarCoeffMap m;
163  auto x = m_varcoeffs.find(coeff);
164  ASSERTL1(x != m_varcoeffs.end(),
165  "Variable coefficient not defined: " +
166  std::string(StdRegions::VarCoeffTypeMap[coeff]));
167  m[coeff] = x->second;
168  return m;
169  }
170 
171  inline const VarCoeffMap &GetVarCoeffs() const
172  {
173  return m_varcoeffs;
174  }
175 
176  inline bool HasVarCoeff(const StdRegions::VarCoeffType &coeff) const
177  {
178  return (m_varcoeffs.find(coeff) != m_varcoeffs.end());
179  }
180 
181 protected:
184 
185  unsigned int m_ncoeffs;
188 
191 
192  std::vector<std::size_t> m_varcoeff_hashes;
193 
194 private:
196 };
197 
198 STD_REGIONS_EXPORT std::ostream &operator<<(std::ostream &os,
199  const StdMatrixKey &rhs);
200 
201 typedef std::shared_ptr<StdMatrixKey> StdMatrixKeySharedPtr;
202 
203 } // namespace StdRegions
204 } // namespace Nektar
205 
206 #endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
#define STD_REGIONS_EXPORT
The base class for all shapes.
Definition: StdExpansion.h:71
const ConstFactorMap & GetConstFactors() const
Definition: StdMatrixKey.h:140
friend bool operator<(const StdMatrixKey &lhs, const StdMatrixKey &rhs)
Used for finding value given the key in NekManager.
const Array< OneD, const LibUtilities::BasisSharedPtr > & GetBase() const
Definition: StdMatrixKey.h:105
std::vector< std::size_t > GetVarCoeffHashes() const
Definition: StdMatrixKey.h:111
LibUtilities::ShapeType GetShapeType() const
Definition: StdMatrixKey.h:90
LibUtilities::PointsType m_nodalPointsType
Definition: StdMatrixKey.h:187
const VarCoeffMap & GetVarCoeffs() const
Definition: StdMatrixKey.h:171
Array< OneD, const LibUtilities::BasisSharedPtr > m_base
Definition: StdMatrixKey.h:183
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:85
const Array< OneD, const NekDouble > & GetVarCoeff(const StdRegions::VarCoeffType &coeff) const
Definition: StdMatrixKey.h:150
const LibUtilities::BasisSharedPtr GetBasis(int dir) const
Definition: StdMatrixKey.h:116
bool HasVarCoeff(const StdRegions::VarCoeffType &coeff) const
Definition: StdMatrixKey.h:176
LibUtilities::PointsType GetNodalPointsType() const
Definition: StdMatrixKey.h:95
friend bool operator==(const StdMatrixKey &lhs, const StdMatrixKey &rhs)
LibUtilities::ShapeType m_shapeType
Definition: StdMatrixKey.h:182
NekDouble GetConstFactor(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:126
std::vector< std::size_t > m_varcoeff_hashes
Definition: StdMatrixKey.h:192
bool ConstFactorExists(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:135
const VarCoeffMap GetVarCoeffAsMap(const VarCoeffType &coeff) const
Definition: StdMatrixKey.h:160
std::shared_ptr< Basis > BasisSharedPtr
const char *const VarCoeffTypeMap[]
Definition: StdRegions.hpp:232
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:382
std::ostream & operator<<(std::ostream &os, const StdMatrixKey &rhs)
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:399
static ConstFactorMap NullConstFactorMap
Definition: StdRegions.hpp:400
static VarCoeffMap NullVarCoeffMap
Definition: StdRegions.hpp:344
std::shared_ptr< StdMatrixKey > StdMatrixKeySharedPtr
Definition: StdMatrixKey.h:201
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:343
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble
Used to lookup the create function in NekManager.
Definition: StdMatrixKey.h:72
bool operator()(const StdMatrixKey &lhs, const StdMatrixKey &rhs) const