Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Nektar::EnergyOp< TData > Class Template Referenceabstract

Integrate the squared velocity and vorticity magnitudes and the domain volume. More...

#include <EnergyOp.hpp>

Inheritance diagram for Nektar::EnergyOp< TData >:
[legend]

Public Member Functions

void Configure (const std::vector< unsigned int > &velocityComponents)
 velocityComponents are the indices of the velocity components in the velocity field, which may hold further components.
 
void Apply (LibUtilities::Field< TData, FieldState::Phys > &velocity, LibUtilities::Field< TData, FieldState::Phys > &velocityGradient)
 Collective: every rank must call it.
 
void operator() (LibUtilities::Field< TData, FieldState::Phys > &velocity, LibUtilities::Field< TData, FieldState::Phys > &velocityGradient)
 Collective: as Apply().
 
void SetRootOnly (const bool rootOnly)
 Reduce the results of the next Apply() to rank zero alone if rootOnly, else to every rank.
 
TData GetKineticEnergy ()
 Integral of the squared velocity magnitude from the last Apply().
 
TData GetEnstrophy ()
 Integral of the squared vorticity magnitude from the last Apply().
 
TData GetVolume ()
 Domain volume from the last Apply().
 
- Public Member Functions inherited from Nektar::MultiRegions::Operator< TData >
virtual ~Operator ()=default
 
 Operator (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > components)
 Construct the interface part of a concrete operator; called by the factory-registered creator functions.
 

Static Public Member Functions

static std::shared_ptr< EnergyOp< TData > > Create (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="")
 
- Static Public Member Functions inherited from Nektar::MultiRegions::Operator< TData >
template<template< typename > typename TOperator>
static std::shared_ptr< TOperator< TData > > Create (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > components, const std::string &execStr)
 Create a concrete operator instance through the operator factory.
 
static std::string GetOpExecSpace (std::shared_ptr< LibUtilities::SessionReader > session, const bool warn=true)
 Return the execution space name ("opExecSpace") for an operator.
 
static const DefaultOpImplRule * GetDefaultOpImplRule (const StdRegions::StdExpansionSharedPtr &exp, const std::string &execSpace)
 Return the row of the default implementation table (DefaultOpImplTable.hpp) that a block of elements takes, or null if none does.
 
static std::string GetDefaultOpImpl (const StdRegions::StdExpansionSharedPtr &exp, const std::string &execSpace)
 Return the implementation a block of elements takes when neither the command line nor the session names one for its operator.
 
static std::vector< unsigned int > GetDefaultInterleaveWidths (const MultiRegions::ExpListSharedPtr &expansionList)
 Return the default interleave widths, one per block of expansionList, that persistent Fields (e.g. solution storage, time-integration and linear-solver workspace) built on it should be constructed with.
 
static bool IsDiscontinuousProjection (std::shared_ptr< LibUtilities::SessionReader > session)
 Return true if the session uses a Discontinuous (DG) projection.
 

Static Public Attributes

static const std::string name = "Energy"
 

Protected Member Functions

 EnergyOp (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
 
 ~EnergyOp () override=default
 
virtual void v_Configure (const std::vector< unsigned int > &velocityComponents)=0
 
virtual void v_Apply (LibUtilities::Field< TData, FieldState::Phys > &velocity, LibUtilities::Field< TData, FieldState::Phys > &velocityGradient)=0
 
TData GetResult (const unsigned int index)
 Entry index of the reduced result, read on the host.
 

Protected Attributes

bool m_rootOnly = false
 Whether Apply() reduces the results to rank zero alone.
 
LibUtilities::MemoryRegion< TData > m_result
 Reduced result of Apply(), of size resultSize, allocated by the implementation's constructor.
 
- Protected Attributes inherited from Nektar::MultiRegions::Operator< TData >
MultiRegions::ExpListSharedPtr m_expansionList
 Expansion list the operator acts on.
 
std::vector< std::string > m_components
 Names of the field components the operator was built for.
 
LibUtilities::NekDataWarehouseSharedPtr m_dataWarehouse
 Data warehouse shared with the other operators on the expansion list, used to build and cache shared tables (basis matrices, mode indices, geometric factors) once.
 

Static Protected Attributes

static constexpr unsigned int kineticEnergy = 0
 Indices of the integrals in m_result.
 
static constexpr unsigned int enstrophy = 1
 
static constexpr unsigned int volume = 2
 
static constexpr unsigned int resultSize = 3
 Number of entries in m_result.
 

Detailed Description

template<typename TData>
class Nektar::EnergyOp< TData >

Integrate the squared velocity and vorticity magnitudes and the domain volume.

The quadrature and the local reduction execute in the selected operator execution space, and the three integrals are reduced across the ranks in one packed buffer. The velocity gradient is an input, so that it can be shared with other consumers.

After Apply(), the getters return:

A 3DH1 expansion is integrated as a 3D one, its planes summed with their z quadrature weights; the velocity gradient then carries the homogeneous derivative, which needs more than one plane on each rank.

The two integrals carry neither the factor one half nor the division by the volume; FilterEnergy applies both.

Apply() is collective: every rank must call it. The getters read the reduced values on the host, on every rank, or on rank zero only after SetRootOnly(true), which reduces them to rank zero alone. Internally the three values are packed in m_result, at the indices kineticEnergy, enstrophy and volume.

Definition at line 75 of file EnergyOp.hpp.

Constructor & Destructor Documentation

◆ EnergyOp()

template<typename TData >
Nektar::EnergyOp< TData >::EnergyOp ( const MultiRegions::ExpListSharedPtr &  expansionList,
const std::vector< std::string > &  components 
)
inlineprotected

Definition at line 150 of file EnergyOp.hpp.

152 : MultiRegions::Operator<TData>(expansionList, components)
153 {
154 }

◆ ~EnergyOp()

template<typename TData >
Nektar::EnergyOp< TData >::~EnergyOp ( )
overrideprotecteddefault

Member Function Documentation

◆ Apply()

template<typename TData >
void Nektar::EnergyOp< TData >::Apply ( LibUtilities::Field< TData, FieldState::Phys > &  velocity,
LibUtilities::Field< TData, FieldState::Phys > &  velocityGradient 
)
inline

Collective: every rank must call it.

Definition at line 97 of file EnergyOp.hpp.

99 {
100 v_Apply(velocity, velocityGradient);
101 }
virtual void v_Apply(LibUtilities::Field< TData, FieldState::Phys > &velocity, LibUtilities::Field< TData, FieldState::Phys > &velocityGradient)=0

References Nektar::EnergyOp< TData >::v_Apply().

◆ Configure()

template<typename TData >
void Nektar::EnergyOp< TData >::Configure ( const std::vector< unsigned int > &  velocityComponents)
inline

velocityComponents are the indices of the velocity components in the velocity field, which may hold further components.

Definition at line 91 of file EnergyOp.hpp.

92 {
93 v_Configure(velocityComponents);
94 }
virtual void v_Configure(const std::vector< unsigned int > &velocityComponents)=0

References Nektar::EnergyOp< TData >::v_Configure().

◆ Create()

template<typename TData >
static std::shared_ptr< EnergyOp< TData > > Nektar::EnergyOp< TData >::Create ( const MultiRegions::ExpListSharedPtr &  expansionList,
const std::vector< std::string > &  components,
const std::string &  execStr = "" 
)
inlinestatic

Definition at line 78 of file EnergyOp.hpp.

82 {
83 return MultiRegions::Operator<TData>::template Create<EnergyOp>(
84 expansionList, components, execStr);
85 }

Referenced by Nektar::FilterEnergy::v_Initialise().

◆ GetEnstrophy()

template<typename TData >
TData Nektar::EnergyOp< TData >::GetEnstrophy ( )
inline

Integral of the squared vorticity magnitude from the last Apply().

Definition at line 125 of file EnergyOp.hpp.

126 {
127 return GetResult(enstrophy);
128 }
TData GetResult(const unsigned int index)
Entry index of the reduced result, read on the host.
Definition EnergyOp.hpp:166
static constexpr unsigned int enstrophy
Definition EnergyOp.hpp:139

References Nektar::EnergyOp< TData >::enstrophy, and Nektar::EnergyOp< TData >::GetResult().

◆ GetKineticEnergy()

template<typename TData >
TData Nektar::EnergyOp< TData >::GetKineticEnergy ( )
inline

Integral of the squared velocity magnitude from the last Apply().

Definition at line 119 of file EnergyOp.hpp.

120 {
121 return GetResult(kineticEnergy);
122 }
static constexpr unsigned int kineticEnergy
Indices of the integrals in m_result.
Definition EnergyOp.hpp:138

References Nektar::EnergyOp< TData >::GetResult(), and Nektar::EnergyOp< TData >::kineticEnergy.

◆ GetResult()

template<typename TData >
TData Nektar::EnergyOp< TData >::GetResult ( const unsigned int  index)
inlineprotected

Entry index of the reduced result, read on the host.

Definition at line 166 of file EnergyOp.hpp.

167 {
168 ASSERTL0(!m_rootOnly || this->m_expansionList->GetComm()
169 ->GetSpaceComm()
170 ->TreatAsRankZero(),
171 "EnergyOp reduced its results to rank zero only.");
172 return m_result
173 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>()[index];
174 }
#define ASSERTL0(condition, msg)
bool m_rootOnly
Whether Apply() reduces the results to rank zero alone.
Definition EnergyOp.hpp:145
LibUtilities::MemoryRegion< TData > m_result
Reduced result of Apply(), of size resultSize, allocated by the implementation's constructor.
Definition EnergyOp.hpp:148
MultiRegions::ExpListSharedPtr m_expansionList
Expansion list the operator acts on.
Definition Operator.hpp:349

References ASSERTL0, Nektar::MultiRegions::Operator< TData >::m_expansionList, and Nektar::EnergyOp< TData >::m_rootOnly.

Referenced by Nektar::EnergyOp< TData >::GetEnstrophy(), Nektar::EnergyOp< TData >::GetKineticEnergy(), and Nektar::EnergyOp< TData >::GetVolume().

◆ GetVolume()

template<typename TData >
TData Nektar::EnergyOp< TData >::GetVolume ( )
inline

Domain volume from the last Apply().

Definition at line 131 of file EnergyOp.hpp.

132 {
133 return GetResult(volume);
134 }
static constexpr unsigned int volume
Definition EnergyOp.hpp:140

References Nektar::EnergyOp< TData >::GetResult(), and Nektar::EnergyOp< TData >::volume.

◆ operator()()

template<typename TData >
void Nektar::EnergyOp< TData >::operator() ( LibUtilities::Field< TData, FieldState::Phys > &  velocity,
LibUtilities::Field< TData, FieldState::Phys > &  velocityGradient 
)
inline

Collective: as Apply().

Definition at line 104 of file EnergyOp.hpp.

107 {
108 v_Apply(velocity, velocityGradient);
109 }

References Nektar::EnergyOp< TData >::v_Apply().

◆ SetRootOnly()

template<typename TData >
void Nektar::EnergyOp< TData >::SetRootOnly ( const bool  rootOnly)
inline

Reduce the results of the next Apply() to rank zero alone if rootOnly, else to every rank.

Definition at line 113 of file EnergyOp.hpp.

114 {
115 m_rootOnly = rootOnly;
116 }

References Nektar::EnergyOp< TData >::m_rootOnly.

◆ v_Apply()

template<typename TData >
virtual void Nektar::EnergyOp< TData >::v_Apply ( LibUtilities::Field< TData, FieldState::Phys > &  velocity,
LibUtilities::Field< TData, FieldState::Phys > &  velocityGradient 
)
protectedpure virtual

◆ v_Configure()

template<typename TData >
virtual void Nektar::EnergyOp< TData >::v_Configure ( const std::vector< unsigned int > &  velocityComponents)
protectedpure virtual

Member Data Documentation

◆ enstrophy

template<typename TData >
constexpr unsigned int Nektar::EnergyOp< TData >::enstrophy = 1
staticconstexprprotected

Definition at line 139 of file EnergyOp.hpp.

Referenced by Nektar::EnergyOp< TData >::GetEnstrophy().

◆ kineticEnergy

template<typename TData >
constexpr unsigned int Nektar::EnergyOp< TData >::kineticEnergy = 0
staticconstexprprotected

Indices of the integrals in m_result.

Definition at line 138 of file EnergyOp.hpp.

Referenced by Nektar::EnergyOp< TData >::GetKineticEnergy().

◆ m_result

template<typename TData >
LibUtilities::MemoryRegion<TData> Nektar::EnergyOp< TData >::m_result
protected

Reduced result of Apply(), of size resultSize, allocated by the implementation's constructor.

Definition at line 148 of file EnergyOp.hpp.

Referenced by Nektar::detail::EnergyOpImpl< ExecSpace, TData >::EnergyOpImpl(), and Nektar::detail::EnergyOpImpl< ExecSpace, TData >::v_Apply().

◆ m_rootOnly

template<typename TData >
bool Nektar::EnergyOp< TData >::m_rootOnly = false
protected

◆ name

template<typename TData >
const std::string Nektar::EnergyOp< TData >::name = "Energy"
inlinestatic

Definition at line 87 of file EnergyOp.hpp.

◆ resultSize

template<typename TData >
constexpr unsigned int Nektar::EnergyOp< TData >::resultSize = 3
staticconstexprprotected

Number of entries in m_result.

Definition at line 142 of file EnergyOp.hpp.

◆ volume

template<typename TData >
constexpr unsigned int Nektar::EnergyOp< TData >::volume = 2
staticconstexprprotected

Definition at line 140 of file EnergyOp.hpp.

Referenced by Nektar::EnergyOp< TData >::GetVolume().