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...
 
VarCoeffEntry restrict (size_t offset, size_t size) const
 

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:372
void ComputeHash()
Computes the hash of this entry using hash_range.
Definition: StdRegions.hpp:357

References ComputeHash().

Member Function Documentation

◆ ComputeHash()

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

Computes the hash of this entry using hash_range.

Definition at line 357 of file StdRegions.hpp.

358 {
359 if (m_coeffs.size() == 0)
360 {
361 m_hash = 0;
362 return;
363 }
364
365 m_hash = hash_range(m_coeffs.begin(), m_coeffs.end());
366 }
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:369

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.

◆ restrict()

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

Definition at line 334 of file StdRegions.hpp.

335 {
336 VarCoeffEntry tmp;
337
338 // This avoids copy of Array
339 tmp.m_coeffs = Array<OneD, NekDouble>(size, m_coeffs + offset);
340
341 // The logic is that since we are using a 'window' into the original
342 // data we should preserve the original hash of that data.
343 // Giving just m_hash will result in the same hash for all collections.
344 // This is sufficient, because if we only need to update once every time
345 // step. For possible future changes, we could combine it with the
346 // offset and size to make it different enough to the original hash, if
347 // necessary.
348 tmp.m_hash = m_hash;
349
350 return tmp;
351 }
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 372 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 369 of file StdRegions.hpp.

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