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

Whole-field interface of the advection element operator: writes scale * (V . grad u) at every quadrature point of every component u of the input field. More...

#include <AdvectionOp.hpp>

Inheritance diagram for Nektar::MultiRegions::AdvectionOp< TData >:
[legend]

Public Member Functions

void SetScale (const TData &scale)
 Set the scalar factor applied to the advection term on every block and on the homogeneous term, so that Apply() produces scale * (V . grad u).
 
void SetAppend (const bool &append)
 Choose between overwriting and accumulating output.
 
void SetAdvVel (LibUtilities::Field< TData, FieldState::Phys > &advVel)
 Supply the advection velocity field V; must be called before the first Apply().
 
- Public Member Functions inherited from Nektar::MultiRegions::ElmtOp< FieldState::Phys, FieldState::Phys, TData >
void Apply (LibUtilities::Field< TData, TFieldIn > &in, LibUtilities::Field< TData, TFieldOut > &out)
 Apply the operator to in, writing the result to out.
 
void operator() (LibUtilities::Field< TData, TFieldIn > &in, LibUtilities::Field< TData, TFieldOut > &out)
 Call operator; equivalent to 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< AdvectionOp< TData > > Create (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
 Build a complete advection operator through the operator and block-operator factories.
 
- Static Public Member Functions inherited from Nektar::MultiRegions::ElmtOp< FieldState::Phys, FieldState::Phys, TData >
static std::shared_ptr< TOperator< TData > > Create (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
 Build a complete element operator: the whole-field interface object plus one block operator per element block.
 
static std::string GetOpImpl (const std::string &opName, const std::string &opExecSpace, LibUtilities::SessionReaderSharedPtr session, const StdRegions::StdExpansionSharedPtr &exp=nullptr, const std::string &policyName="")
 Return the implementation for an operator.
 
- 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 = "Advection"
 Operator base name; Create() appends the execution space to it to form the operator-factory key.
 

Protected Member Functions

 AdvectionOp (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.
 
 ~AdvectionOp () override=default
 
void v_Apply (LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out) override
 Apply the advection operator block by block.
 
virtual void v_SetScaleFFT (const TData &scale)=0
 Pass the scale factor on to the homogeneous term; called by SetScale().
 
virtual void v_SetAdvVelFFT (LibUtilities::Field< TData, FieldState::Phys > &advVel)=0
 Pass the advection velocity on to the homogeneous term; called by SetAdvVel().
 
virtual void v_ApplyFFT (LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out)=0
 Add the homogeneous term to out; called by v_Apply() after the block loop.
 
- Protected Member Functions inherited from Nektar::MultiRegions::ElmtOp< FieldState::Phys, FieldState::Phys, TData >
 ElmtOp (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.
 
 ~ElmtOp () override=default
 
virtual void v_Apply (LibUtilities::Field< TData, TFieldIn > &in, LibUtilities::Field< TData, TFieldOut > &out)=0
 Implementation hook for Apply().
 

Protected Attributes

bool m_isSetAdvVel = false
 Whether SetAdvVel() has been called; checked by v_Apply().
 
std::vector< std::shared_ptr< AdvectionBlockOp< TData > > > m_blockOp
 One block operator per element block, filled by Create().
 
- 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.
 

Friends

class ElmtOp< FieldState::Phys, FieldState::Phys, TData >
 

Detailed Description

template<typename TData>
class Nektar::MultiRegions::AdvectionOp< TData >

Whole-field interface of the advection element operator: writes scale * (V . grad u) at every quadrature point of every component u of the input field.

The operator maps physical space to physical space. Before the first Apply() the advection velocity V must be supplied through SetAdvVel(); Apply() then evaluates, element by element, \( s \sum_k V_k \, \partial u / \partial x_k \) at each quadrature point – overwriting the output, or accumulating onto it when SetAppend(true) is set – with s the factor given by SetScale() (default 1). The same velocity is applied to every component of the input field. On a multi-plane 3DH1 expansion the sum includes the homogeneous term w du/dz, added after the block loop through the v_SetScaleFFT(), v_SetAdvVelFFT() and v_ApplyFFT() hooks.

As with the other element-operator families, this class sets the Apply() field states at compile time and drives one AdvectionBlockOp per element block; the per-execution-space behaviour lives in the block operators and, for the homogeneous term, in the z-operator owned by detail::AdvectionOpImpl, which implements the hooks. See ElmtOp for the block decomposition and factory scheme.

Template Parameters
TDataFloating-point type of the field data.

Definition at line 97 of file AdvectionOp.hpp.

Constructor & Destructor Documentation

◆ AdvectionOp()

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

Construct the interface part of a concrete operator; called by the factory-registered creator functions.

Parameters
expansionListExpansion list the operator acts on.
componentsComponent names the operator is set up for.

Definition at line 226 of file AdvectionOp.hpp.

229 components)
230 {
231 }
friend class ElmtOp< FieldState::Phys, FieldState::Phys, TData >

◆ ~AdvectionOp()

template<typename TData >
Nektar::MultiRegions::AdvectionOp< TData >::~AdvectionOp ( )
overrideprotecteddefault

Member Function Documentation

◆ Create()

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

Build a complete advection operator through the operator and block-operator factories.

See ElmtOp::Create for the two-stage construction and the execution-space/implementation lookup rules.

Parameters
expansionListExpansion list the operator acts on.
componentsNames of the field components.
execStrExecution space ("Serial", "AVX" or "Device"); the session's setting is used if empty.
implStrImplementation ("StdMat", "SumFac" or, on Device, "SumFacTOP"); the session's setting is used if empty.
Returns
The fully assembled operator. SetAdvVel() must still be called before the first Apply().

Definition at line 121 of file AdvectionOp.hpp.

125 {
127 template Create<AdvectionOp, AdvectionBlockOp>(
128 expansionList, components, execStr, implStr);
129 }

Referenced by TestAdvection< TData >::RunTestCase().

◆ SetAdvVel()

template<typename TData >
void Nektar::MultiRegions::AdvectionOp< TData >::SetAdvVel ( LibUtilities::Field< TData, FieldState::Phys > &  advVel)
inline

Supply the advection velocity field V; must be called before the first Apply().

advVel must be built on the operator's expansion list and hold one component per coordinate dimension of the mesh, or three on a 3DH1 expansion, each a physical-space scalar field; the component count is checked with a level-1 assertion. Each block accessor is handed to the corresponding block operator, which keeps a non-owning pointer to it, and the whole field to v_SetAdvVelFFT(), so the field must outlive the operator's use. The block implementations reshape the velocity storage in place to their own interleave width the first time Apply() finds it at another width, updating the accessor's recorded width: the field's interleave width is modified as a side effect.

Parameters
advVelAdvection velocity field, one component per coordinate dimension (three on 3DH1).

Definition at line 191 of file AdvectionOp.hpp.

192 {
193 // A 3DH1 expansion carries a third velocity component along the
194 // homogeneous direction, which the planes themselves do not count.
195 ASSERTL1(advVel.GetNumComponents() ==
196 ((advVel.GetNumHomoModes() == 1)
197 ? static_cast<unsigned int>(
198 this->m_expansionList->GetCoordim(0))
199 : 3u),
200 "Advection velocity must have coordDim components, or three "
201 "on a 3DH1 expansion");
202
203 // Loop over the blocks.
204 for (unsigned int blk = 0; blk < this->m_blockOp.size(); ++blk)
205 {
206 this->m_blockOp[blk]->SetAdvVel(advVel.GetBlocks()[blk]);
207 }
208 v_SetAdvVelFFT(advVel);
209 m_isSetAdvVel = true;
210 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
virtual void v_SetAdvVelFFT(LibUtilities::Field< TData, FieldState::Phys > &advVel)=0
Pass the advection velocity on to the homogeneous term; called by SetAdvVel().
bool m_isSetAdvVel
Whether SetAdvVel() has been called; checked by v_Apply().
std::vector< std::shared_ptr< AdvectionBlockOp< TData > > > m_blockOp
One block operator per element block, filled by Create().

References ASSERTL1, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes(), Nektar::MultiRegions::AdvectionOp< TData >::m_blockOp, Nektar::MultiRegions::AdvectionOp< TData >::m_isSetAdvVel, and Nektar::MultiRegions::AdvectionOp< TData >::v_SetAdvVelFFT().

◆ SetAppend()

template<typename TData >
void Nektar::MultiRegions::AdvectionOp< TData >::SetAppend ( const bool &  append)
inline

Choose between overwriting and accumulating output.

With append set, Apply() adds scale * (V . grad u) onto the existing contents of the output field instead of overwriting it – useful when the advection term is one of several contributions to a right-hand side.

Parameters
appendTrue to accumulate, false (the initial state) to overwrite.

Definition at line 163 of file AdvectionOp.hpp.

164 {
165 // Loop over the blocks.
166 for (unsigned int blk = 0; blk < this->m_blockOp.size(); ++blk)
167 {
168 this->m_blockOp[blk]->SetAppend(append);
169 }
170 }

References Nektar::MultiRegions::AdvectionOp< TData >::m_blockOp.

◆ SetScale()

template<typename TData >
void Nektar::MultiRegions::AdvectionOp< TData >::SetScale ( const TData &  scale)
inline

Set the scalar factor applied to the advection term on every block and on the homogeneous term, so that Apply() produces scale * (V . grad u).

Parameters
scaleNew scale factor (initially 1).

Definition at line 142 of file AdvectionOp.hpp.

143 {
144 // Loop over the blocks.
145 for (unsigned int blk = 0; blk < this->m_blockOp.size(); ++blk)
146 {
147 this->m_blockOp[blk]->SetScale(scale);
148 }
149 v_SetScaleFFT(scale);
150 }
virtual void v_SetScaleFFT(const TData &scale)=0
Pass the scale factor on to the homogeneous term; called by SetScale().

References Nektar::MultiRegions::AdvectionOp< TData >::m_blockOp, and Nektar::MultiRegions::AdvectionOp< TData >::v_SetScaleFFT().

◆ v_Apply()

template<typename TData >
void Nektar::MultiRegions::AdvectionOp< TData >::v_Apply ( LibUtilities::Field< TData, FieldState::Phys > &  in,
LibUtilities::Field< TData, FieldState::Phys > &  out 
)
inlineoverrideprotected

Apply the advection operator block by block.

Checks that the fields conform (component and homogeneous-mode counts) and that the advection velocity has been set, then hands each input/output block pair to the corresponding entry of m_blockOp, and finally calls v_ApplyFFT() to add the homogeneous term.

Parameters
inPhysical-space input field.
outPhysical-space output field; overwritten, or accumulated onto when append is set.

Definition at line 248 of file AdvectionOp.hpp.

250 {
251 ASSERTL1(in.GetNumComponents() == out.GetNumComponents(),
252 "Number of input and output components differ");
253
254 ASSERTL1(in.GetNumHomoModes() == out.GetNumHomoModes(),
255 "Number of input and output homogeneous modes differ");
256
258 "Advection velocity has not been set."
259 "Set the value with SetAdvVel() before calling Apply().");
260
261 // Loop over the blocks.
262 for (unsigned int blk = 0; blk < this->m_blockOp.size(); ++blk)
263 {
264 // Block dependent.
265 auto &inblock = in.GetBlocks()[blk];
266 auto &outblock = out.GetBlocks()[blk];
267
268 this->m_blockOp[blk]->Apply(inblock, outblock);
269 }
270
271 // Apply FFT.
272 v_ApplyFFT(in, out);
273 }
virtual void v_ApplyFFT(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out)=0
Add the homogeneous term to out; called by v_Apply() after the block loop.
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT in
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT TData *NEK_RESTRICT out

References ASSERTL1, Nektar::MultiRegions::AdvectionOp< TData >::m_isSetAdvVel, and Nektar::MultiRegions::AdvectionOp< TData >::v_ApplyFFT().

◆ v_ApplyFFT()

template<typename TData >
virtual void Nektar::MultiRegions::AdvectionOp< TData >::v_ApplyFFT ( LibUtilities::Field< TData, FieldState::Phys > &  in,
LibUtilities::Field< TData, FieldState::Phys > &  out 
)
protectedpure virtual

Add the homogeneous term to out; called by v_Apply() after the block loop.

Implemented in Nektar::MultiRegions::detail::AdvectionOpImpl< ExecSpace, TData >.

Referenced by Nektar::MultiRegions::AdvectionOp< TData >::v_Apply().

◆ v_SetAdvVelFFT()

template<typename TData >
virtual void Nektar::MultiRegions::AdvectionOp< TData >::v_SetAdvVelFFT ( LibUtilities::Field< TData, FieldState::Phys > &  advVel)
protectedpure virtual

Pass the advection velocity on to the homogeneous term; called by SetAdvVel().

Implemented in Nektar::MultiRegions::detail::AdvectionOpImpl< ExecSpace, TData >.

Referenced by Nektar::MultiRegions::AdvectionOp< TData >::SetAdvVel().

◆ v_SetScaleFFT()

template<typename TData >
virtual void Nektar::MultiRegions::AdvectionOp< TData >::v_SetScaleFFT ( const TData &  scale)
protectedpure virtual

Pass the scale factor on to the homogeneous term; called by SetScale().

Implemented in Nektar::MultiRegions::detail::AdvectionOpImpl< ExecSpace, TData >.

Referenced by Nektar::MultiRegions::AdvectionOp< TData >::SetScale().

Friends And Related Symbol Documentation

◆ ElmtOp< FieldState::Phys, FieldState::Phys, TData >

template<typename TData >
friend class ElmtOp< FieldState::Phys, FieldState::Phys, TData >
friend

Definition at line 1 of file AdvectionOp.hpp.

Member Data Documentation

◆ m_blockOp

template<typename TData >
std::vector<std::shared_ptr<AdvectionBlockOp<TData> > > Nektar::MultiRegions::AdvectionOp< TData >::m_blockOp
protected

◆ m_isSetAdvVel

template<typename TData >
bool Nektar::MultiRegions::AdvectionOp< TData >::m_isSetAdvVel = false
protected

◆ name

template<typename TData >
const std::string Nektar::MultiRegions::AdvectionOp< TData >::name = "Advection"
inlinestatic

Operator base name; Create() appends the execution space to it to form the operator-factory key.

Definition at line 133 of file AdvectionOp.hpp.