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 261 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 275 of file StdRegions.hpp.

275  : m_coeffs(input)
276  {
277  ComputeHash();
278  }
Array< OneD, NekDouble > m_coeffs
Storage for the variable coefficient entries.
Definition: StdRegions.hpp:340
void ComputeHash()
Computes the hash of this entry using hash_range.
Definition: StdRegions.hpp:325

References ComputeHash().

Member Function Documentation

◆ ComputeHash()

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

Computes the hash of this entry using hash_range.

Definition at line 325 of file StdRegions.hpp.

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

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 316 of file StdRegions.hpp.

317  {
318  return m_hash;
319  }

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 308 of file StdRegions.hpp.

309  {
310  return m_coeffs;
311  }

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 299 of file StdRegions.hpp.

300  {
301  m_coeffs = rhs;
302  ComputeHash();
303  }

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 285 of file StdRegions.hpp.

286  {
287  return m_coeffs[idx];
288  }

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 340 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 337 of file StdRegions.hpp.

Referenced by ComputeHash(), and GetHash().