Nektar++
Loading...
Searching...
No Matches
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.
 
 VarCoeffEntry (const Array< OneD, const NekDouble > &input)
 Copy an array of values into this entry.
 
const NekDoubleoperator[] (std::size_t idx) const
 Access an entry idx within m_coeffs.
 
void operator= (const Array< OneD, const NekDouble > &rhs)
 Assignment operator given an array rhs.
 
const Array< OneD, const NekDouble > & GetValue () const
 Returns a const reference to the coefficients.
 
std::size_t GetHash () const
 Returns the hash of this entry.
 
VarCoeffEntry restrict (size_t offset, size_t size) const
 

Protected Member Functions

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

Protected Attributes

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

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

335 : m_coeffs(input)
336 {
337 ComputeHash();
338 }
Array< OneD, NekDouble > m_coeffs
Storage for the variable coefficient entries.
void ComputeHash()
Computes the hash of this entry using hash_range.

References ComputeHash().

Member Function Documentation

◆ ComputeHash()

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

Computes the hash of this entry using hash_range.

Definition at line 414 of file StdRegions.hpp.

415 {
416 if (m_coeffs.size() == 0)
417 {
418 m_hash = 0;
419 return;
420 }
421
422 m_hash = hash_range(m_coeffs.begin(), m_coeffs.end());
423 }
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.

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

377 {
378 return m_hash;
379 }

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

369 {
370 return m_coeffs;
371 }

References m_coeffs.

Referenced by pybind11::detail::type_caster< VarCoeffEntry >::cast().

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

360 {
361 m_coeffs = rhs;
362 ComputeHash();
363 }

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

346 {
347 return m_coeffs[idx];
348 }

References m_coeffs.

◆ restrict()

VarCoeffEntry Nektar::StdRegions::VarCoeffEntry::restrict ( size_t  offset,
size_t  size 
) const
inline

Definition at line 391 of file StdRegions.hpp.

392 {
393 VarCoeffEntry tmp;
394
395 // This avoids copy of Array
396 tmp.m_coeffs = Array<OneD, NekDouble>(size, m_coeffs + offset);
397
398 // The logic is that since we are using a 'window' into the original
399 // data we should preserve the original hash of that data.
400 // Giving just m_hash will result in the same hash for all collections.
401 // This is sufficient, because if we only need to update once every time
402 // step. For possible future changes, we could combine it with the
403 // offset and size to make it different enough to the original hash, if
404 // necessary.
405 tmp.m_hash = m_hash;
406
407 return tmp;
408 }
VarCoeffEntry()=default
Default constructor.

References m_coeffs, and m_hash.

Member Data Documentation

◆ m_coeffs

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

Storage for the variable coefficient entries.

Definition at line 429 of file StdRegions.hpp.

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

◆ m_hash

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

Hash of the entries inside m_coeffs.

Definition at line 426 of file StdRegions.hpp.

Referenced by ComputeHash(), GetHash(), and restrict().