Nektar++
Loading...
Searching...
No Matches
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,
57 const VarFactorsMap &varFactorMap = NullVarFactorsMap,
59
61 const StdRegions::MatrixType matrixType);
62
64
65 virtual ~StdMatrixKey() = default;
66
67 /// Used to lookup the create function in NekManager.
68 struct opLess
69 {
71 const StdMatrixKey &rhs) const;
72 };
73
74 /// Used for finding value given the key in NekManager.
75 STD_REGIONS_EXPORT friend bool operator<(const StdMatrixKey &lhs,
76 const StdMatrixKey &rhs);
77 STD_REGIONS_EXPORT friend bool operator==(const StdMatrixKey &lhs,
78 const StdMatrixKey &rhs);
80
82 const StdMatrixKey &lhs, const StdMatrixKey &rhs) const;
83
85 {
86 return m_matrixType;
87 }
88
90 {
91 return m_shapeType;
92 }
93
98
99 int GetNcoeffs() const
100 {
101 return m_ncoeffs;
102 }
103
105 const
106 {
107 return m_base;
108 }
109
110 std::vector<std::size_t> GetVarCoeffHashes() const
111 {
112 return m_varcoeff_hashes;
113 }
114
115 inline const LibUtilities::BasisSharedPtr GetBasis(int dir) const
116 {
117 return (m_base[dir]);
118 }
119
120 inline int GetNConstFactors() const
121 {
122 return m_factors.size();
123 }
124
125 inline NekDouble GetConstFactor(const ConstFactorType &factor) const
126 {
127 auto x = m_factors.find(factor);
128 ASSERTL1(x != m_factors.end(),
129 "Constant factor not defined: " +
130 std::string(StdRegions::ConstFactorTypeMap[factor]));
131 return x->second;
132 }
133
134 inline bool ConstFactorExists(const ConstFactorType &factor) const
135 {
136 return m_factors.find(factor) != m_factors.end();
137 }
138
139 inline const ConstFactorMap &GetConstFactors() const
140 {
141 return m_factors;
142 }
143
144 inline int GetNVarCoeff() const
145 {
146 return m_varcoeffs.size();
147 }
148
150 const StdRegions::VarCoeffType &coeff) const
151 {
152 auto x = m_varcoeffs.find(coeff);
153 ASSERTL1(x != m_varcoeffs.end(),
154 "Variable coefficient not defined: " +
155 std::string(StdRegions::VarCoeffTypeMap[coeff]));
156 return x->second.GetValue();
157 }
158
159 inline const VarCoeffMap GetVarCoeffAsMap(const VarCoeffType &coeff) const
160 {
161 VarCoeffMap m;
162 auto x = m_varcoeffs.find(coeff);
163 ASSERTL1(x != m_varcoeffs.end(),
164 "Variable coefficient not defined: " +
165 std::string(StdRegions::VarCoeffTypeMap[coeff]));
166 m[coeff] = x->second;
167 return m;
168 }
169
170 inline const VarCoeffMap &GetVarCoeffs() const
171 {
172 return m_varcoeffs;
173 }
174
175 inline bool HasVarCoeff(const StdRegions::VarCoeffType &coeff) const
176 {
177 return (m_varcoeffs.find(coeff) != m_varcoeffs.end());
178 }
179
181 const StdRegions::MatrixType &mtype) const
182 {
184 {
185 // Loop all matrix types with defined in MatrixTypeToVarCoeffsMap
186 if (x.first == mtype)
187 {
188 // If mtype defined in MatrixTypeToVarCoeffsMap,
189 // check if any varcoeffs are defined in this StdMatrixKey
190 for (auto &y : x.second)
191 {
192 if (m_varcoeffs.find(y) != m_varcoeffs.end())
193 {
194 return true;
195 }
196 }
197 return false;
198 }
199 }
200 return false;
201 }
202
203 inline int GetNVarFactors() const
204 {
205 return m_varfactors.size();
206 }
207
209 const StdRegions::ConstFactorType &type) const
210 {
211 auto x = m_varfactors.find(type);
212 ASSERTL1(x != m_varfactors.end(),
213 "Variable factors not defined: " +
214 std::string(StdRegions::ConstFactorTypeMap[type]));
215 return x->second;
216 }
217
218 std::vector<std::size_t> GetVarFactorsfHashes() const
219 {
220 return m_varfactor_hashes;
221 }
222
223 inline const VarFactorsMap &GetVarFactors() const
224 {
225 return m_varfactors;
226 }
227
228 inline bool HasVarFactors(const StdRegions::ConstFactorType &type) const
229 {
230 return (m_varfactors.find(type) != m_varfactors.end());
231 }
232
233protected:
236
237 unsigned int m_ncoeffs;
240
244
245 std::vector<std::size_t> m_varfactor_hashes;
246 std::vector<std::size_t> m_varcoeff_hashes;
247
248private:
250};
251
252STD_REGIONS_EXPORT std::ostream &operator<<(std::ostream &os,
253 const StdMatrixKey &rhs);
254
255typedef std::shared_ptr<StdMatrixKey> StdMatrixKeySharedPtr;
256
257} // namespace Nektar::StdRegions
258
259#endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define STD_REGIONS_EXPORT
The base class for all shapes.
bool HasVarCoeffForMatrixType(const StdRegions::MatrixType &mtype) const
friend bool operator<(const StdMatrixKey &lhs, const StdMatrixKey &rhs)
Used for finding value given the key in NekManager.
std::vector< std::size_t > GetVarFactorsfHashes() const
const Array< OneD, const LibUtilities::BasisSharedPtr > & GetBase() const
LibUtilities::ShapeType GetShapeType() const
LibUtilities::PointsType m_nodalPointsType
StdMatrixKey operator=(const StdMatrixKey &inKey)
const Array< OneD, const NekDouble > & GetVarFactors(const StdRegions::ConstFactorType &type) const
Array< OneD, const LibUtilities::BasisSharedPtr > m_base
const VarCoeffMap & GetVarCoeffs() const
MatrixType GetMatrixType() const
const LibUtilities::BasisSharedPtr GetBasis(int dir) const
bool HasVarCoeff(const StdRegions::VarCoeffType &coeff) const
LibUtilities::PointsType GetNodalPointsType() const
bool HasVarFactors(const StdRegions::ConstFactorType &type) const
friend bool opLess::operator()(const StdMatrixKey &lhs, const StdMatrixKey &rhs) const
const ConstFactorMap & GetConstFactors() const
friend bool operator==(const StdMatrixKey &lhs, const StdMatrixKey &rhs)
std::vector< std::size_t > m_varfactor_hashes
const Array< OneD, const NekDouble > & GetVarCoeff(const StdRegions::VarCoeffType &coeff) const
const VarFactorsMap & GetVarFactors() const
LibUtilities::ShapeType m_shapeType
std::vector< std::size_t > GetVarCoeffHashes() const
NekDouble GetConstFactor(const ConstFactorType &factor) const
std::vector< std::size_t > m_varcoeff_hashes
bool ConstFactorExists(const ConstFactorType &factor) const
const VarCoeffMap GetVarCoeffAsMap(const VarCoeffType &coeff) const
std::shared_ptr< Basis > BasisSharedPtr
constexpr std::array< std::pair< MatrixType, VarCoeffList >, 3 > MatrixTypeToVarCoeffsMap
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
static VarFactorsMap NullVarFactorsMap
const char *const VarCoeffTypeMap[]
const char *const ConstFactorTypeMap[]
std::ostream & operator<<(std::ostream &os, const StdMatrixKey &rhs)
std::map< ConstFactorType, NekDouble > ConstFactorMap
static ConstFactorMap NullConstFactorMap
static VarCoeffMap NullVarCoeffMap
std::shared_ptr< StdMatrixKey > StdMatrixKeySharedPtr
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Used to lookup the create function in NekManager.
bool operator()(const StdMatrixKey &lhs, const StdMatrixKey &rhs) const