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 ()
 
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 50 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 45 of file StdMatrixKey.cpp.

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

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 68 of file StdMatrixKey.cpp.

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

◆ StdMatrixKey() [3/4]

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

Definition at line 77 of file StdMatrixKey.cpp.

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

◆ ~StdMatrixKey()

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

Definition at line 66 of file StdMatrixKey.h.

67 {
68 }

◆ 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 107 of file StdMatrixKey.h.

109 {
110 return m_base;
111 }

References m_base.

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

◆ GetBasis()

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

Definition at line 118 of file StdMatrixKey.h.

119 {
120 return (m_base[dir]);
121 }

References m_base.

◆ GetConstFactor()

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

Definition at line 128 of file StdMatrixKey.h.

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

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 87 of file StdMatrixKey.h.

88 {
89 return m_matrixType;
90 }

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 102 of file StdMatrixKey.h.

103 {
104 return m_ncoeffs;
105 }

References m_ncoeffs.

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

◆ GetNConstFactors()

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

Definition at line 123 of file StdMatrixKey.h.

124 {
125 return m_factors.size();
126 }

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 162 of file StdMatrixKey.h.

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

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 113 of file StdMatrixKey.h.

114 {
115 return m_varcoeff_hashes;
116 }

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 91 of file StdMatrixKey.cpp.

92{
93 return StdMatrixKey(inKey);
94}

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 96 of file StdMatrixKey.cpp.

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

◆ operator==

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

Definition at line 204 of file StdMatrixKey.cpp.

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

◆ 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 185 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 187 of file StdMatrixKey.h.

Referenced by GetNcoeffs().

◆ m_nodalPointsType

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

Definition at line 189 of file StdMatrixKey.h.

Referenced by GetNodalPointsType().

◆ m_shapeType

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

Definition at line 184 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 194 of file StdMatrixKey.h.

Referenced by GetVarCoeffHashes(), and StdMatrixKey().

◆ m_varcoeffs

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