|
Nektar++
|
Whole-field interface of the Expression operator: evaluates one analytical expression per field component at every quadrature point. More...
#include <ExpressionOp.hpp>
Public Member Functions | |
| void | SetExpressions (const std::vector< LibUtilities::EquationSharedPtr > &exprs) |
| Set the expressions to evaluate, one per field component in component order. | |
| void | SetTime (const TData &time) |
Set the value substituted for the built-in time variable t in every expression (default 0). | |
| void | SetScale (const TData &scale) |
| Set the factor every evaluated expression value is multiplied by before it is written or appended (default 1). | |
| void | SetAppend (const bool &append) |
Choose between accumulating onto the output (out += scale * f) and overwriting it (out = scale * f, the default). | |
| void | SetComponentMask (const std::vector< bool > &cmask) |
| Select which output components the expressions are evaluated for (default: all enabled). | |
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< ExpressionOp< TData > > | Create (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="") |
| Create an Expression operator through the two-stage element-operator factory and initialise its default settings. | |
| static unsigned int | GetNumberEvars (const LibUtilities::EquationSharedPtr &expression) |
| Count the variables of an expression, i.e. the length of its variable list. | |
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 = "Expression" |
| Operator base name; Create() appends the execution space to it to form the factory key. | |
Protected Member Functions | |
| ExpressionOp (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components) | |
| Construct the interface part of a concrete implementation; called by the factory-registered creator functions. | |
| ~ExpressionOp () override=default | |
| void | v_Apply (LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out) override |
| Evaluate the expressions block by block: checks that the fields conform and that expressions have been set, then hands each input/output block pair to its block operator. | |
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_isExpressionsDefined = false |
| Whether SetExpressions() has been called; Apply() asserts this. | |
| std::vector< std::shared_ptr< ExpressionBlockOp< TData > > > | m_blockOp |
| One block operator per element block, filled by ElmtOp::Create. | |
| std::vector< std::shared_ptr< ExpressionBlockOp< TData > > > | m_blockHostOp |
| Host block operator of each block whose own could not evaluate some expressions set, otherwise null. Created by SetExpressions(). | |
| std::vector< bool > | m_useHostOp |
| Whether each block evaluates the current expressions with its host block operator. | |
| bool | m_warnOnceHostOp = false |
| Set once the use of a host block operator has been warned about, for the current expressions. | |
| std::vector< bool > | m_cmask |
| Settings forwarded to the block operators, kept for those of m_blockHostOp, created after them. | |
| TData | m_time = 0.0 |
| TData | m_scale = 1.0 |
| bool | m_append = false |
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 > |
Whole-field interface of the Expression operator: evaluates one analytical expression per field component at every quadrature point.
As with the other element-operator interfaces, deriving from ElmtOp<FieldState::Phys, FieldState::Phys, TData> sets the Apply() parameter types at compile time: both fields must be in physical space. Unusually for an element operator, the input field is not transformed – it supplies the values of any extra expression variables (EVARS) beyond the built-in x, y, z and t, and merely sets the storage layout when there are none. The operator holds one ExpressionBlockOp per element block (m_blockOp) and its v_Apply() delegates each block of the input/output fields to the matching block operator.
The evaluation settings live in the block operators; every setter here simply forwards its value to all of them. The intended workflow is Create(), then optionally SetComponentMask(), then SetExpressions() – mandatory, Apply() asserts otherwise – then optionally SetTime(), SetScale() and SetAppend(), then Apply(). Expressions may be swapped at any time between applications.
SetTime(), SetScale() and SetAppend() are order-free and may be changed between applications. SetComponentMask() is not: the mask must be final before SetExpressions() is called, and changing it afterwards requires calling SetExpressions() again (the in-tree callers in MultiRegions/BndCondOps set the mask first).
| TData | Floating-point type of the field data. |
Definition at line 114 of file ExpressionOp.hpp.
|
inlineprotected |
Construct the interface part of a concrete implementation; called by the factory-registered creator functions.
| expansionList | Expansion list the operator acts on. |
| components | Component names the operator is set up for. |
Definition at line 372 of file ExpressionOp.hpp.
|
overrideprotecteddefault |
|
inlinestatic |
Create an Expression operator through the two-stage element-operator factory and initialise its default settings.
After the interface object and its per-block operators are built by ElmtOp::Create, every block operator is given the defaults: all components enabled in the mask, time 0 and scale 1 (the append flag defaults to false in ExpressionBlockOp). No expressions are set – SetExpressions() must be called before the first Apply().
| expansionList | Expansion list the operator acts on; its Collections define the blocks. |
| components | Names of the field components; their count sizes the default component mask. |
| execStr | Execution space ("Serial", "AVX" or "Device"); if empty, taken from the session's "opExecSpace" command-line argument or, failing that, the build's default (see ElmtOp::Create). |
| implStr | Block implementation part of the factory key. This family registers only "Generic", so any other request falls back to it (see ElmtBlockOp::Create). |
Definition at line 146 of file ExpressionOp.hpp.
References Nektar::MultiRegions::ElmtOp< FieldState::Phys, FieldState::Phys, TData >::Create(), and Nektar::MultiRegions::ExpressionBlockOp< TData >::SetComponentMask().
Referenced by Nektar::detail::HOPressureBndCondOpImpl< ExecSpace, TData >::BuildBoundaryVelocityData(), TestExpression< TData >::RunTestCase(), and Nektar::detail::HOutflowBndCondOpImpl< ExecSpace, TData >::ValidateAndBuildVelocityBoundaryData().
|
inlinestatic |
Count the variables of an expression, i.e. the length of its variable list.
The list contains the built-in x y z t (the LibUtilities::Equation default) plus any extra field variables (EVARS) declared in the session; the count is therefore at least four; the back-ends assume those four are present, and use the count to decide how many input-field components to gather per point.
| expression | Expression whose variable list is counted. |
Definition at line 331 of file ExpressionOp.hpp.
References Nektar::StringUtils::Split().
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions().
|
inline |
Choose between accumulating onto the output (out += scale * f) and overwriting it (out = scale * f, the default).
Definition at line 272 of file ExpressionOp.hpp.
References Nektar::MultiRegions::ExpressionOp< TData >::m_append, Nektar::MultiRegions::ExpressionOp< TData >::m_blockHostOp, and Nektar::MultiRegions::ExpressionOp< TData >::m_blockOp.
|
inline |
Select which output components the expressions are evaluated for (default: all enabled).
| cmask | One flag per component, in component order; Apply() asserts its size matches the number of expressions. |
Definition at line 301 of file ExpressionOp.hpp.
References Nektar::MultiRegions::ExpressionOp< TData >::m_blockHostOp, Nektar::MultiRegions::ExpressionOp< TData >::m_blockOp, and Nektar::MultiRegions::ExpressionOp< TData >::m_cmask.
|
inline |
Set the expressions to evaluate, one per field component in component order.
The variable count of each expression is extracted with GetNumberEvars() and stored on the block operators with SetNumEvars(); the expressions go through their v_SetExpressions() hook. Also marks the operator ready for Apply().
| exprs | Parsed expressions; their number must equal the number of components of the fields later passed to Apply(). |
Definition at line 183 of file ExpressionOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::Create(), Nektar::MultiRegions::GetCollection(), Nektar::MultiRegions::ExpressionOp< TData >::GetNumberEvars(), Nektar::MultiRegions::ExpressionOp< TData >::m_append, Nektar::MultiRegions::ExpressionOp< TData >::m_blockHostOp, Nektar::MultiRegions::ExpressionOp< TData >::m_blockOp, Nektar::MultiRegions::ExpressionOp< TData >::m_cmask, Nektar::MultiRegions::Operator< TData >::m_expansionList, Nektar::MultiRegions::ExpressionOp< TData >::m_isExpressionsDefined, Nektar::MultiRegions::ExpressionOp< TData >::m_scale, Nektar::MultiRegions::ExpressionOp< TData >::m_time, Nektar::MultiRegions::ExpressionOp< TData >::m_useHostOp, and Nektar::MultiRegions::ExpressionOp< TData >::m_warnOnceHostOp.
|
inline |
Set the factor every evaluated expression value is multiplied by before it is written or appended (default 1).
Definition at line 252 of file ExpressionOp.hpp.
References Nektar::MultiRegions::ExpressionOp< TData >::m_blockHostOp, Nektar::MultiRegions::ExpressionOp< TData >::m_blockOp, and Nektar::MultiRegions::ExpressionOp< TData >::m_scale.
|
inline |
Set the value substituted for the built-in time variable t in every expression (default 0).
Definition at line 233 of file ExpressionOp.hpp.
References Nektar::MultiRegions::ExpressionOp< TData >::m_blockHostOp, Nektar::MultiRegions::ExpressionOp< TData >::m_blockOp, and Nektar::MultiRegions::ExpressionOp< TData >::m_time.
|
inlineoverrideprotected |
Evaluate the expressions block by block: checks that the fields conform and that expressions have been set, then hands each input/output block pair to its block operator.
| in | Physical-space field supplying the EVAR values; not modified unless it is the same object as out. |
| out | Physical-space field receiving the evaluated expressions; in append mode its existing values are accumulated onto. |
Definition at line 393 of file ExpressionOp.hpp.
References ASSERTL1, Nektar::MultiRegions::ExpressionOp< TData >::m_useHostOp, Nektar::MultiRegions::ExpressionOp< TData >::m_warnOnceHostOp, and WARNINGL0.
|
friend |
Definition at line 1 of file ExpressionOp.hpp.
|
protected |
Definition at line 362 of file ExpressionOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetAppend(), and Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions().
|
protected |
Host block operator of each block whose own could not evaluate some expressions set, otherwise null. Created by SetExpressions().
Definition at line 349 of file ExpressionOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetAppend(), Nektar::MultiRegions::ExpressionOp< TData >::SetComponentMask(), Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions(), Nektar::MultiRegions::ExpressionOp< TData >::SetScale(), and Nektar::MultiRegions::ExpressionOp< TData >::SetTime().
|
protected |
One block operator per element block, filled by ElmtOp::Create.
Definition at line 346 of file ExpressionOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetAppend(), Nektar::MultiRegions::ExpressionOp< TData >::SetComponentMask(), Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions(), Nektar::MultiRegions::ExpressionOp< TData >::SetScale(), and Nektar::MultiRegions::ExpressionOp< TData >::SetTime().
|
protected |
Settings forwarded to the block operators, kept for those of m_blockHostOp, created after them.
Definition at line 359 of file ExpressionOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetComponentMask(), and Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions().
|
protected |
Whether SetExpressions() has been called; Apply() asserts this.
Definition at line 344 of file ExpressionOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions().
|
protected |
Definition at line 361 of file ExpressionOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions(), and Nektar::MultiRegions::ExpressionOp< TData >::SetScale().
|
protected |
Definition at line 360 of file ExpressionOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions(), and Nektar::MultiRegions::ExpressionOp< TData >::SetTime().
|
protected |
Whether each block evaluates the current expressions with its host block operator.
Definition at line 352 of file ExpressionOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions(), and Nektar::MultiRegions::ExpressionOp< TData >::v_Apply().
|
protected |
Set once the use of a host block operator has been warned about, for the current expressions.
Definition at line 355 of file ExpressionOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions(), and Nektar::MultiRegions::ExpressionOp< TData >::v_Apply().
|
inlinestatic |
Operator base name; Create() appends the execution space to it to form the factory key.
Definition at line 168 of file ExpressionOp.hpp.