Nektar++
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::StdRegions::VarCoeffEntry Struct Reference

Representation of a variable coefficient. More...

#include <StdRegions.hpp>

Public Member Functions

 VarCoeffEntry ()=default
 Default constructor. More...
 
 VarCoeffEntry (const Array< OneD, const NekDouble > &input)
 Copy an array of values into this entry. More...
 
const NekDoubleoperator[] (std::size_t idx) const
 Access an entry idx within m_coeffs. More...
 
void operator= (const Array< OneD, const NekDouble > &rhs)
 Assignment operator given an array rhs. More...
 
const Array< OneD, const NekDouble > & GetValue () const
 Returns a const reference to the coefficients. More...
 
std::size_t GetHash () const
 Returns the hash of this entry. More...
 

Protected Member Functions

void ComputeHash ()
 Computes the hash of this entry using hash_range. More...
 

Protected Attributes

std::size_t m_hash = 0
 Hash of the entries inside m_coeffs. More...
 
Array< OneD, NekDoublem_coeffs
 Storage for the variable coefficient entries. More...
 

Detailed Description

Representation of a variable coefficient.

Variable coefficients are entries stored inside a VarCoeffMap which are defined at each quadrature/solution point within an element. This class wraps that concept, storing the values in m_coeffs, but also stores alongside this a hash of the data in m_hash. This is then used within MultiRegions::GlobalMatrixKey to efficiently distinguish between matrix keys that have variable coefficients defined, but whose entries are different.

For that reason the entries here are deliberately protected by const references; i.e. the entries inside of m_coeffs should not be modified in-place, but a new array copied in so that the hash can be recalculated.

Definition at line 264 of file StdRegions.hpp.

Constructor & Destructor Documentation

◆ VarCoeffEntry() [1/2]

Nektar::StdRegions::VarCoeffEntry::VarCoeffEntry ( )
default

Default constructor.

◆ VarCoeffEntry() [2/2]

Nektar::StdRegions::VarCoeffEntry::VarCoeffEntry ( const Array< OneD, const NekDouble > &  input)
inline

Copy an array of values into this entry.

Upon copy into m_coeffs, compute the hash of this entry using ComputeHash.

Parameters
inputVariable coefficients to be defined at each solution point.

Definition at line 278 of file StdRegions.hpp.

278 : m_coeffs(input)
279 {
280 ComputeHash();
281 }
Array< OneD, NekDouble > m_coeffs
Storage for the variable coefficient entries.
Definition: StdRegions.hpp:343
void ComputeHash()
Computes the hash of this entry using hash_range.
Definition: StdRegions.hpp:328

References ComputeHash().

Member Function Documentation

◆ ComputeHash()

void Nektar::StdRegions::VarCoeffEntry::ComputeHash ( )
inlineprotected

Computes the hash of this entry using hash_range.

Definition at line 328 of file StdRegions.hpp.

329 {
330 if (m_coeffs.size() == 0)
331 {
332 m_hash = 0;
333 return;
334 }
335
336 m_hash = hash_range(m_coeffs.begin(), m_coeffs.end());
337 }
std::size_t hash_range(Iter first, Iter last)
Definition: HashUtils.hpp:64
std::size_t m_hash
Hash of the entries inside m_coeffs.
Definition: StdRegions.hpp:340

References Nektar::hash_range(), m_coeffs, and m_hash.

Referenced by operator=(), and VarCoeffEntry().

◆ GetHash()

std::size_t Nektar::StdRegions::VarCoeffEntry::GetHash ( ) const
inline

Returns the hash of this entry.

Definition at line 319 of file StdRegions.hpp.

320 {
321 return m_hash;
322 }

References m_hash.

◆ GetValue()

const Array< OneD, const NekDouble > & Nektar::StdRegions::VarCoeffEntry::GetValue ( ) const
inline

Returns a const reference to the coefficients.

Definition at line 311 of file StdRegions.hpp.

312 {
313 return m_coeffs;
314 }

References m_coeffs.

Referenced by VarCoeffEntryToPython::convert().

◆ operator=()

void Nektar::StdRegions::VarCoeffEntry::operator= ( const Array< OneD, const NekDouble > &  rhs)
inline

Assignment operator given an array rhs.

Upon copy into m_coeffs, compute the hash of this entry using ComputeHash.

Parameters
rhsVariable coefficients to be defined at each solution point.

Definition at line 302 of file StdRegions.hpp.

303 {
304 m_coeffs = rhs;
305 ComputeHash();
306 }

References ComputeHash(), and m_coeffs.

◆ operator[]()

const NekDouble & Nektar::StdRegions::VarCoeffEntry::operator[] ( std::size_t  idx) const
inline

Access an entry idx within m_coeffs.

Parameters
idxIndex of the entry to access.

Definition at line 288 of file StdRegions.hpp.

289 {
290 return m_coeffs[idx];
291 }

References m_coeffs.

Member Data Documentation

◆ m_coeffs

Array<OneD, NekDouble> Nektar::StdRegions::VarCoeffEntry::m_coeffs
protected

Storage for the variable coefficient entries.

Definition at line 343 of file StdRegions.hpp.

Referenced by ComputeHash(), GetValue(), operator=(), and operator[]().

◆ m_hash

std::size_t Nektar::StdRegions::VarCoeffEntry::m_hash = 0
protected

Hash of the entries inside m_coeffs.

Definition at line 340 of file StdRegions.hpp.

Referenced by ComputeHash(), and GetHash().