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
44{
45namespace StdRegions
46{
47
48class StdExpansion;
49
51{
52public:
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
85 const StdMatrixKey &lhs, const StdMatrixKey &rhs) const;
86
88 {
89 return m_matrixType;
90 }
91
93 {
94 return m_shapeType;
95 }
96
98 {
99 return m_nodalPointsType;
100 }
101
102 int GetNcoeffs() const
103 {
104 return m_ncoeffs;
105 }
106
108 const
109 {
110 return m_base;
111 }
112
113 std::vector<std::size_t> GetVarCoeffHashes() const
114 {
115 return m_varcoeff_hashes;
116 }
117
118 inline const LibUtilities::BasisSharedPtr GetBasis(int dir) const
119 {
120 return (m_base[dir]);
121 }
122
123 inline int GetNConstFactors() const
124 {
125 return m_factors.size();
126 }
127
128 inline NekDouble GetConstFactor(const ConstFactorType &factor) const
129 {
130 auto x = m_factors.find(factor);
131 ASSERTL1(x != m_factors.end(),
132 "Constant factor not defined: " +
133 std::string(StdRegions::ConstFactorTypeMap[factor]));
134 return x->second;
135 }
136
137 inline bool ConstFactorExists(const ConstFactorType &factor) const
138 {
139 return m_factors.find(factor) != m_factors.end();
140 }
141
142 inline const ConstFactorMap &GetConstFactors() const
143 {
144 return m_factors;
145 }
146
147 inline int GetNVarCoeff() const
148 {
149 return m_varcoeffs.size();
150 }
151
153 const StdRegions::VarCoeffType &coeff) const
154 {
155 auto x = m_varcoeffs.find(coeff);
156 ASSERTL1(x != m_varcoeffs.end(),
157 "Variable coefficient not defined: " +
158 std::string(StdRegions::VarCoeffTypeMap[coeff]));
159 return x->second.GetValue();
160 }
161
162 inline const VarCoeffMap GetVarCoeffAsMap(const VarCoeffType &coeff) const
163 {
164 VarCoeffMap m;
165 auto x = m_varcoeffs.find(coeff);
166 ASSERTL1(x != m_varcoeffs.end(),
167 "Variable coefficient not defined: " +
168 std::string(StdRegions::VarCoeffTypeMap[coeff]));
169 m[coeff] = x->second;
170 return m;
171 }
172
173 inline const VarCoeffMap &GetVarCoeffs() const
174 {
175 return m_varcoeffs;
176 }
177
178 inline bool HasVarCoeff(const StdRegions::VarCoeffType &coeff) const
179 {
180 return (m_varcoeffs.find(coeff) != m_varcoeffs.end());
181 }
182
183protected:
186
187 unsigned int m_ncoeffs;
190
193
194 std::vector<std::size_t> m_varcoeff_hashes;
195
196private:
198};
199
200STD_REGIONS_EXPORT std::ostream &operator<<(std::ostream &os,
201 const StdMatrixKey &rhs);
202
203typedef std::shared_ptr<StdMatrixKey> StdMatrixKeySharedPtr;
204
205} // namespace StdRegions
206} // namespace Nektar
207
208#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
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:107
LibUtilities::ShapeType GetShapeType() const
Definition: StdMatrixKey.h:92
LibUtilities::PointsType m_nodalPointsType
Definition: StdMatrixKey.h:189
StdMatrixKey operator=(const StdMatrixKey &inKey)
Array< OneD, const LibUtilities::BasisSharedPtr > m_base
Definition: StdMatrixKey.h:185
const VarCoeffMap & GetVarCoeffs() const
Definition: StdMatrixKey.h:173
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:87
const LibUtilities::BasisSharedPtr GetBasis(int dir) const
Definition: StdMatrixKey.h:118
bool HasVarCoeff(const StdRegions::VarCoeffType &coeff) const
Definition: StdMatrixKey.h:178
LibUtilities::PointsType GetNodalPointsType() const
Definition: StdMatrixKey.h:97
const ConstFactorMap & GetConstFactors() const
Definition: StdMatrixKey.h:142
friend bool operator==(const StdMatrixKey &lhs, const StdMatrixKey &rhs)
const Array< OneD, const NekDouble > & GetVarCoeff(const StdRegions::VarCoeffType &coeff) const
Definition: StdMatrixKey.h:152
LibUtilities::ShapeType m_shapeType
Definition: StdMatrixKey.h:184
std::vector< std::size_t > GetVarCoeffHashes() const
Definition: StdMatrixKey.h:113
NekDouble GetConstFactor(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:128
std::vector< std::size_t > m_varcoeff_hashes
Definition: StdMatrixKey.h:194
bool ConstFactorExists(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:137
const VarCoeffMap GetVarCoeffAsMap(const VarCoeffType &coeff) const
Definition: StdMatrixKey.h:162
std::shared_ptr< Basis > BasisSharedPtr
const char *const VarCoeffTypeMap[]
Definition: StdRegions.hpp:240
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:391
std::ostream & operator<<(std::ostream &os, const StdMatrixKey &rhs)
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:408
static ConstFactorMap NullConstFactorMap
Definition: StdRegions.hpp:409
static VarCoeffMap NullVarCoeffMap
Definition: StdRegions.hpp:353
std::shared_ptr< StdMatrixKey > StdMatrixKeySharedPtr
Definition: StdMatrixKey.h:203
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:352
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