Nektar++
Classes | Public Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
Nektar::StdRegions::StdMatrixKey Class Reference

#include <StdMatrixKey.h>

Inheritance diagram for Nektar::StdRegions::StdMatrixKey:
[legend]

Classes

struct  opLess
 Used to lookup the create function in NekManager. More...
 

Public Member Functions

 StdMatrixKey (const StdRegions::MatrixType matrixType, const LibUtilities::ShapeType shapeType, const StdRegions::StdExpansion &stdExpansion, const ConstFactorMap &factorMap=NullConstFactorMap, const VarCoeffMap &varCoeffMap=NullVarCoeffMap, LibUtilities::PointsType nodalType=LibUtilities::eNoPointsType)
 
 StdMatrixKey (const StdMatrixKey &rhs, const StdRegions::MatrixType matrixType)
 
 StdMatrixKey (const StdMatrixKey &rhs)
 
virtual ~StdMatrixKey ()=default
 
StdMatrixKey operator= (const StdMatrixKey &inKey)
 
MatrixType GetMatrixType () const
 
LibUtilities::ShapeType GetShapeType () const
 
LibUtilities::PointsType GetNodalPointsType () const
 
int GetNcoeffs () const
 
const Array< OneD, const LibUtilities::BasisSharedPtr > & GetBase () const
 
std::vector< std::size_t > GetVarCoeffHashes () const
 
const LibUtilities::BasisSharedPtr GetBasis (int dir) const
 
int GetNConstFactors () const
 
NekDouble GetConstFactor (const ConstFactorType &factor) const
 
bool ConstFactorExists (const ConstFactorType &factor) const
 
const ConstFactorMapGetConstFactors () const
 
int GetNVarCoeff () const
 
const Array< OneD, const NekDouble > & GetVarCoeff (const StdRegions::VarCoeffType &coeff) const
 
const VarCoeffMap GetVarCoeffAsMap (const VarCoeffType &coeff) const
 
const VarCoeffMapGetVarCoeffs () const
 
bool HasVarCoeff (const StdRegions::VarCoeffType &coeff) const
 

Protected Attributes

LibUtilities::ShapeType m_shapeType
 
Array< OneD, const LibUtilities::BasisSharedPtrm_base
 
unsigned int m_ncoeffs
 
MatrixType m_matrixType
 
LibUtilities::PointsType m_nodalPointsType
 
ConstFactorMap m_factors
 
VarCoeffMap m_varcoeffs
 
std::vector< std::size_t > m_varcoeff_hashes
 

Private Member Functions

 StdMatrixKey ()
 

Friends

bool operator< (const StdMatrixKey &lhs, const StdMatrixKey &rhs)
 Used for finding value given the key in NekManager. More...
 
bool operator== (const StdMatrixKey &lhs, const StdMatrixKey &rhs)
 
bool opLess::operator() (const StdMatrixKey &lhs, const StdMatrixKey &rhs) const
 

Detailed Description

Definition at line 48 of file StdMatrixKey.h.

Constructor & Destructor Documentation

◆ StdMatrixKey() [1/4]

Nektar::StdRegions::StdMatrixKey::StdMatrixKey ( const StdRegions::MatrixType  matrixType,
const LibUtilities::ShapeType  shapeType,
const StdRegions::StdExpansion stdExpansion,
const ConstFactorMap factorMap = NullConstFactorMap,
const VarCoeffMap varCoeffMap = NullVarCoeffMap,
LibUtilities::PointsType  nodalType = LibUtilities::eNoPointsType 
)

Definition at line 43 of file StdMatrixKey.cpp.

49 : m_shapeType(shapeType), m_base(stdExpansion.GetBase()),
50 m_ncoeffs(stdExpansion.GetNcoeffs()), m_matrixType(matrixType),
51 m_nodalPointsType(nodalType), m_factors(factorMap),
52 m_varcoeffs(varCoeffMap), m_varcoeff_hashes(varCoeffMap.size())
53{
54 // Create hash
55 int i = 0;
56 for (auto &x : varCoeffMap)
57 {
58 m_varcoeff_hashes[i] = hash_range(x.second.GetValue().begin(),
59 x.second.GetValue().begin() +
60 stdExpansion.GetTotPoints());
61 hash_combine(m_varcoeff_hashes[i], (int)x.first);
62 i++;
63 }
64}
LibUtilities::PointsType m_nodalPointsType
Definition: StdMatrixKey.h:185
Array< OneD, const LibUtilities::BasisSharedPtr > m_base
Definition: StdMatrixKey.h:181
LibUtilities::ShapeType m_shapeType
Definition: StdMatrixKey.h:180
std::vector< std::size_t > m_varcoeff_hashes
Definition: StdMatrixKey.h:190
std::size_t hash_range(Iter first, Iter last)
Definition: HashUtils.hpp:64
void hash_combine(std::size_t &seed)
Definition: HashUtils.hpp:44

References Nektar::StdRegions::StdExpansion::GetTotPoints(), Nektar::hash_combine(), Nektar::hash_range(), and m_varcoeff_hashes.

◆ StdMatrixKey() [2/4]

Nektar::StdRegions::StdMatrixKey::StdMatrixKey ( const StdMatrixKey rhs,
const StdRegions::MatrixType  matrixType 
)

Definition at line 66 of file StdMatrixKey.cpp.

68 : m_shapeType(rhs.m_shapeType), m_base(rhs.m_base),
69 m_ncoeffs(rhs.m_ncoeffs), m_matrixType(matrixType),
70 m_nodalPointsType(rhs.m_nodalPointsType), m_factors(rhs.m_factors),
71 m_varcoeffs(rhs.m_varcoeffs), m_varcoeff_hashes(rhs.m_varcoeff_hashes)
72{
73}

◆ StdMatrixKey() [3/4]

Nektar::StdRegions::StdMatrixKey::StdMatrixKey ( const StdMatrixKey rhs)

Definition at line 75 of file StdMatrixKey.cpp.

76 : m_shapeType(rhs.m_shapeType), m_base(rhs.m_base),
77 m_ncoeffs(rhs.m_ncoeffs), m_matrixType(rhs.m_matrixType),
78 m_nodalPointsType(rhs.m_nodalPointsType), m_factors(rhs.m_factors),
79 m_varcoeffs(rhs.m_varcoeffs), m_varcoeff_hashes(rhs.m_varcoeff_hashes)
80{
81}

◆ ~StdMatrixKey()

virtual Nektar::StdRegions::StdMatrixKey::~StdMatrixKey ( )
virtualdefault

◆ StdMatrixKey() [4/4]

Nektar::StdRegions::StdMatrixKey::StdMatrixKey ( )
private

Referenced by operator=().

Member Function Documentation

◆ ConstFactorExists()

bool Nektar::StdRegions::StdMatrixKey::ConstFactorExists ( const ConstFactorType factor) const
inline

◆ GetBase()

const Array< OneD, const LibUtilities::BasisSharedPtr > & Nektar::StdRegions::StdMatrixKey::GetBase ( ) const
inline

Definition at line 103 of file StdMatrixKey.h.

105 {
106 return m_base;
107 }

References m_base.

Referenced by Nektar::StdRegions::operator<<().

◆ GetBasis()

const LibUtilities::BasisSharedPtr Nektar::StdRegions::StdMatrixKey::GetBasis ( int  dir) const
inline

Definition at line 114 of file StdMatrixKey.h.

115 {
116 return (m_base[dir]);
117 }

References m_base.

◆ GetConstFactor()

NekDouble Nektar::StdRegions::StdMatrixKey::GetConstFactor ( const ConstFactorType factor) const
inline

Definition at line 124 of file StdMatrixKey.h.

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 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:385

References ASSERTL1, Nektar::StdRegions::ConstFactorTypeMap, and m_factors.

Referenced by Nektar::LocalRegions::Expansion2D::CreateMatrix(), Nektar::LocalRegions::Expansion3D::CreateMatrix(), Nektar::LocalRegions::SegExp::CreateMatrix(), Nektar::StdRegions::StdExpansion::HelmholtzMatrixOp_MatFree_GenericImpl(), Nektar::StdRegions::StdExpansion::LaplacianMatrixOp_MatFree(), Nektar::StdRegions::StdExpansion::LinearAdvectionDiffusionReactionMatrixOp_MatFree(), Nektar::StdRegions::StdHexExp::v_GenMatrix(), Nektar::StdRegions::StdPrismExp::v_GenMatrix(), Nektar::StdRegions::StdQuadExp::v_GenMatrix(), Nektar::StdRegions::StdSegExp::v_GenMatrix(), Nektar::StdRegions::StdTetExp::v_GenMatrix(), Nektar::StdRegions::StdTriExp::v_GenMatrix(), Nektar::LocalRegions::Expansion1D::v_GenMatrix(), Nektar::LocalRegions::Expansion2D::v_GenMatrix(), Nektar::LocalRegions::Expansion3D::v_GenMatrix(), Nektar::StdRegions::StdSegExp::v_HelmholtzMatrixOp(), Nektar::LocalRegions::SegExp::v_HelmholtzMatrixOp(), Nektar::StdRegions::StdExpansion2D::v_HelmholtzMatrixOp_MatFree(), Nektar::StdRegions::StdExpansion3D::v_HelmholtzMatrixOp_MatFree(), Nektar::StdRegions::StdHexExp::v_SVVLaplacianFilter(), Nektar::StdRegions::StdPrismExp::v_SVVLaplacianFilter(), Nektar::StdRegions::StdPyrExp::v_SVVLaplacianFilter(), Nektar::StdRegions::StdQuadExp::v_SVVLaplacianFilter(), Nektar::StdRegions::StdSegExp::v_SVVLaplacianFilter(), Nektar::StdRegions::StdTetExp::v_SVVLaplacianFilter(), and Nektar::StdRegions::StdTriExp::v_SVVLaplacianFilter().

◆ GetConstFactors()

const ConstFactorMap & Nektar::StdRegions::StdMatrixKey::GetConstFactors ( ) const
inline

◆ GetMatrixType()

MatrixType Nektar::StdRegions::StdMatrixKey::GetMatrixType ( ) const
inline

Definition at line 83 of file StdMatrixKey.h.

84 {
85 return m_matrixType;
86 }

References m_matrixType.

Referenced by Nektar::StdRegions::StdExpansion::CreateGeneralMatrix(), Nektar::LocalRegions::Expansion2D::CreateMatrix(), Nektar::LocalRegions::Expansion3D::CreateMatrix(), Nektar::LocalRegions::SegExp::CreateMatrix(), Nektar::LocalRegions::Expansion::CreateStaticCondMatrix(), Nektar::StdRegions::StdExpansion::GeneralMatrixOp(), Nektar::StdRegions::StdExpansion::GeneralMatrixOp_MatFree(), Nektar::LocalRegions::MatrixKey::opLess::operator()(), Nektar::StdRegions::operator<<(), Nektar::StdRegions::StdHexExp::v_GenMatrix(), Nektar::StdRegions::StdNodalPrismExp::v_GenMatrix(), Nektar::StdRegions::StdNodalTetExp::v_GenMatrix(), Nektar::StdRegions::StdNodalTriExp::v_GenMatrix(), Nektar::StdRegions::StdPointExp::v_GenMatrix(), Nektar::StdRegions::StdPrismExp::v_GenMatrix(), Nektar::StdRegions::StdQuadExp::v_GenMatrix(), Nektar::StdRegions::StdSegExp::v_GenMatrix(), Nektar::StdRegions::StdTetExp::v_GenMatrix(), Nektar::StdRegions::StdTriExp::v_GenMatrix(), Nektar::LocalRegions::Expansion1D::v_GenMatrix(), Nektar::LocalRegions::Expansion2D::v_GenMatrix(), Nektar::LocalRegions::Expansion3D::v_GenMatrix(), Nektar::LocalRegions::HexExp::v_GenMatrix(), Nektar::LocalRegions::NodalTriExp::v_GenMatrix(), Nektar::LocalRegions::PrismExp::v_GenMatrix(), Nektar::LocalRegions::PyrExp::v_GenMatrix(), Nektar::LocalRegions::QuadExp::v_GenMatrix(), Nektar::LocalRegions::SegExp::v_GenMatrix(), Nektar::LocalRegions::TetExp::v_GenMatrix(), and Nektar::LocalRegions::TriExp::v_GenMatrix().

◆ GetNcoeffs()

int Nektar::StdRegions::StdMatrixKey::GetNcoeffs ( void  ) const
inline

Definition at line 98 of file StdMatrixKey.h.

99 {
100 return m_ncoeffs;
101 }

References m_ncoeffs.

Referenced by Nektar::StdRegions::operator<<().

◆ GetNConstFactors()

int Nektar::StdRegions::StdMatrixKey::GetNConstFactors ( ) const
inline

Definition at line 119 of file StdMatrixKey.h.

120 {
121 return m_factors.size();
122 }

References m_factors.

◆ GetNodalPointsType()

LibUtilities::PointsType Nektar::StdRegions::StdMatrixKey::GetNodalPointsType ( ) const
inline

◆ GetNVarCoeff()

int Nektar::StdRegions::StdMatrixKey::GetNVarCoeff ( ) const
inline

◆ GetShapeType()

LibUtilities::ShapeType Nektar::StdRegions::StdMatrixKey::GetShapeType ( ) const
inline

◆ GetVarCoeff()

const Array< OneD, const NekDouble > & Nektar::StdRegions::StdMatrixKey::GetVarCoeff ( const StdRegions::VarCoeffType coeff) const
inline

◆ GetVarCoeffAsMap()

const VarCoeffMap Nektar::StdRegions::StdMatrixKey::GetVarCoeffAsMap ( const VarCoeffType coeff) const
inline

Definition at line 158 of file StdMatrixKey.h.

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 }
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:346

References ASSERTL1, m_varcoeffs, and Nektar::StdRegions::VarCoeffTypeMap.

Referenced by Nektar::LocalRegions::Expansion2D::v_GenMatrix().

◆ GetVarCoeffHashes()

std::vector< std::size_t > Nektar::StdRegions::StdMatrixKey::GetVarCoeffHashes ( ) const
inline

Definition at line 109 of file StdMatrixKey.h.

110 {
111 return m_varcoeff_hashes;
112 }

References m_varcoeff_hashes.

Referenced by Nektar::StdRegions::operator<<().

◆ GetVarCoeffs()

const VarCoeffMap & Nektar::StdRegions::StdMatrixKey::GetVarCoeffs ( ) const
inline

◆ HasVarCoeff()

bool Nektar::StdRegions::StdMatrixKey::HasVarCoeff ( const StdRegions::VarCoeffType coeff) const
inline

◆ operator=()

StdMatrixKey Nektar::StdRegions::StdMatrixKey::operator= ( const StdMatrixKey inKey)

Definition at line 89 of file StdMatrixKey.cpp.

90{
91 return StdMatrixKey(inKey);
92}

References StdMatrixKey().

Friends And Related Function Documentation

◆ operator<

bool operator< ( const StdMatrixKey lhs,
const StdMatrixKey rhs 
)
friend

Used for finding value given the key in NekManager.

Definition at line 94 of file StdMatrixKey.cpp.

95{
96 if (lhs.m_matrixType < rhs.m_matrixType)
97 {
98 return true;
99 }
100
101 if (lhs.m_matrixType > rhs.m_matrixType)
102 {
103 return false;
104 }
105
106 if (lhs.m_ncoeffs < rhs.m_ncoeffs) // probably do not need this check since
107 // checking the m_base below?
108 {
109 return true;
110 }
111
112 if (lhs.m_ncoeffs > rhs.m_ncoeffs)
113 {
114 return false;
115 }
116
117 if (LibUtilities::ShapeTypeDimMap[lhs.m_shapeType] <
118 LibUtilities::ShapeTypeDimMap[rhs.m_shapeType])
119 {
120 return true;
121 }
122
123 if (LibUtilities::ShapeTypeDimMap[lhs.m_shapeType] >
124 LibUtilities::ShapeTypeDimMap[rhs.m_shapeType])
125 {
126 return false;
127 }
128
129 for (unsigned int i = 0; i < LibUtilities::ShapeTypeDimMap[lhs.m_shapeType];
130 ++i)
131 {
132 if (lhs.m_base[i].get() < rhs.m_base[i].get())
133 {
134 return true;
135 }
136
137 if (lhs.m_base[i].get() > rhs.m_base[i].get())
138 {
139 return false;
140 }
141 }
142
143 if (lhs.m_factors.size() < rhs.m_factors.size())
144 {
145 return true;
146 }
147 else if (lhs.m_factors.size() > rhs.m_factors.size())
148 {
149 return false;
150 }
151 else
152 {
153 for (auto x = lhs.m_factors.begin(), y = rhs.m_factors.begin();
154 x != lhs.m_factors.end(); ++x, ++y)
155 {
156 if (x->second < y->second)
157 {
158 return true;
159 }
160 if (x->second > y->second)
161 {
162 return false;
163 }
164 }
165 }
166
167 if (lhs.m_varcoeffs.size() < rhs.m_varcoeffs.size())
168 {
169 return true;
170 }
171
172 if (lhs.m_varcoeffs.size() > rhs.m_varcoeffs.size())
173 {
174 return false;
175 }
176
177 for (unsigned int i = 0; i < lhs.m_varcoeff_hashes.size(); ++i)
178 {
179 if (lhs.m_varcoeff_hashes[i] < rhs.m_varcoeff_hashes[i])
180 {
181 return true;
182 }
183 if (lhs.m_varcoeff_hashes[i] > rhs.m_varcoeff_hashes[i])
184 {
185 return false;
186 }
187 }
188
189 if (lhs.m_nodalPointsType < rhs.m_nodalPointsType)
190 {
191 return true;
192 }
193
194 if (lhs.m_nodalPointsType > rhs.m_nodalPointsType)
195 {
196 return false;
197 }
198
199 return false;
200}
constexpr unsigned int ShapeTypeDimMap[SIZE_ShapeType]
Definition: ShapeType.hpp:81

◆ operator==

bool operator== ( const StdMatrixKey lhs,
const StdMatrixKey rhs 
)
friend

Definition at line 202 of file StdMatrixKey.cpp.

203{
204 if (lhs.m_matrixType != rhs.m_matrixType)
205 {
206 return false;
207 }
208
209 if (lhs.m_ncoeffs != rhs.m_ncoeffs)
210 {
211 return false;
212 }
213
214 for (unsigned int i = 0; i < LibUtilities::ShapeTypeDimMap[lhs.m_shapeType];
215 ++i)
216 {
217 if (lhs.m_base[i].get() != rhs.m_base[i].get())
218 {
219 return false;
220 }
221 }
222
223 if (lhs.m_factors.size() != rhs.m_factors.size())
224 {
225 return false;
226 }
227 else
228 {
229 return lhs.m_factors.size() == rhs.m_factors.size() &&
230 std::equal(lhs.m_factors.begin(), lhs.m_factors.end(),
231 rhs.m_factors.begin());
232 }
233
234 if (lhs.m_nodalPointsType != rhs.m_nodalPointsType)
235 {
236 return false;
237 }
238
239 if (lhs.m_varcoeffs.size() != rhs.m_varcoeffs.size())
240 {
241 return false;
242 }
243
244 for (unsigned int i = 0; i < lhs.m_varcoeff_hashes.size(); ++i)
245 {
246 if (lhs.m_varcoeff_hashes[i] != rhs.m_varcoeff_hashes[i])
247 {
248 return false;
249 }
250 }
251
252 for (auto &x : lhs.m_varcoeffs)
253 {
254 auto y = rhs.m_varcoeffs.find(x.first);
255 // Check var coeff is found
256 if (y == rhs.m_varcoeffs.end())
257 {
258 return false;
259 }
260
261 if (x.second.GetValue() != y->second.GetValue())
262 {
263 return false;
264 }
265 }
266 for (unsigned int i = 0; i < lhs.m_varcoeffs.size(); ++i)
267 {
268 if (lhs.m_varcoeff_hashes[i] != rhs.m_varcoeff_hashes[i])
269 {
270 return false;
271 }
272 }
273
274 return true;
275}

◆ opLess::operator()

bool opLess::operator() ( const StdMatrixKey lhs,
const StdMatrixKey rhs 
) const
friend

Member Data Documentation

◆ m_base

Array<OneD, const LibUtilities::BasisSharedPtr> Nektar::StdRegions::StdMatrixKey::m_base
protected

Definition at line 181 of file StdMatrixKey.h.

Referenced by GetBase(), and GetBasis().

◆ m_factors

ConstFactorMap Nektar::StdRegions::StdMatrixKey::m_factors
protected

◆ m_matrixType

MatrixType Nektar::StdRegions::StdMatrixKey::m_matrixType
protected

◆ m_ncoeffs

unsigned int Nektar::StdRegions::StdMatrixKey::m_ncoeffs
protected

Definition at line 183 of file StdMatrixKey.h.

Referenced by GetNcoeffs().

◆ m_nodalPointsType

LibUtilities::PointsType Nektar::StdRegions::StdMatrixKey::m_nodalPointsType
protected

Definition at line 185 of file StdMatrixKey.h.

Referenced by GetNodalPointsType().

◆ m_shapeType

LibUtilities::ShapeType Nektar::StdRegions::StdMatrixKey::m_shapeType
protected

Definition at line 180 of file StdMatrixKey.h.

Referenced by GetShapeType().

◆ m_varcoeff_hashes

std::vector<std::size_t> Nektar::StdRegions::StdMatrixKey::m_varcoeff_hashes
protected

Definition at line 190 of file StdMatrixKey.h.

Referenced by GetVarCoeffHashes(), and StdMatrixKey().

◆ m_varcoeffs

VarCoeffMap Nektar::StdRegions::StdMatrixKey::m_varcoeffs
protected