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