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