|
Nektar++
|
Block-level interface of the Expression operator: evaluates the configured expressions at every quadrature point of one element block. More...
#include <ExpressionBlockOp.hpp>
Public Member Functions | |
| void | SetExpressions (const std::vector< LibUtilities::EquationSharedPtr > &exprs) |
| Set the expressions to evaluate (one per component) via the back-end hook v_SetExpressions(). | |
| bool | IsAvailable (const std::vector< LibUtilities::EquationSharedPtr > &exprs) const |
Whether this back-end can evaluate exprs under the current component mask. | |
| void | SetTime (const TData &time) |
Set the value substituted for the built-in variable t. | |
| void | SetScale (const TData &scale) |
| Set the factor every evaluated value is multiplied by. | |
| void | SetAppend (const bool &append) |
| Choose between accumulating onto the output and overwriting it. | |
| void | SetNumEvars (const std::vector< unsigned int > &numEvars) |
| Set the variable count of each expression, as computed by ExpressionOp::GetNumberEvars(). | |
| void | SetComponentMask (const std::vector< bool > &cmask) |
| Set the per-component enable flags (see the mask notes in ExpressionOp::SetComponentMask, including the requirement that the mask be final before SetExpressions()). | |
Public Member Functions inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Phys, FieldState::Phys, TData > | |
| void | Apply (LibUtilities::BlockAccessor< TData, TFieldIn > &inblock, LibUtilities::BlockAccessor< TData, TFieldOut > &outblock) |
| Apply the element operation to every element of the block. | |
| void | operator() (LibUtilities::BlockAccessor< TData, TFieldIn > &inblock, LibUtilities::BlockAccessor< TData, TFieldOut > &outblock) |
| Call operator; equivalent to Apply(). | |
Public Member Functions inherited from Nektar::MultiRegions::BlockOperator< TData > | |
| virtual | ~BlockOperator ()=default |
Static Public Member Functions | |
| static std::shared_ptr< ExpressionBlockOp< TData > > | Create (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse, const std::string &execStr, const std::string &implStr) |
| Create one block operator through the block-operator factory. | |
| static std::vector< std::string > | GetEvarsNames (const LibUtilities::EquationSharedPtr &expression) |
| Split an expression's variable list into the individual variable names. | |
| static std::set< std::string > | GetExpressionVariables (const std::string &expr) |
The variables an expression uses: every name in expr that is not called as a function, so also its parameters and constants. | |
| static std::set< std::string > | GetExpressionFunctions (const std::string &expr) |
The functions an expression calls: every name in expr followed by an opening parenthesis. | |
Static Public Member Functions inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Phys, FieldState::Phys, TData > | |
| static std::shared_ptr< TOperator< TData > > | Create (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse, const std::string &execStr, const std::string &implStr) |
| Create one block operator through the block-operator factory. | |
Static Public Member Functions inherited from Nektar::MultiRegions::BlockOperator< TData > | |
| template<template< typename > typename TOperator> | |
| static std::shared_ptr< TOperator< TData > > | Create (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse, const std::string &execStr) |
| Create a concrete block-operator instance through the block-operator factory. | |
Static Public Attributes | |
| static const std::string | name = "BlockExpression" |
| Block-operator base name; Create() appends the execution space and implementation to it to form the factory key. | |
Protected Member Functions | |
| ExpressionBlockOp (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse) | |
| Construct the interface part of a concrete block operator; called by the factory-registered creator functions. | |
| ~ExpressionBlockOp () override=default | |
| virtual void | v_SetExpressions (const std::vector< LibUtilities::EquationSharedPtr > &exprs)=0 |
| Implementation hook for SetExpressions(). | |
| virtual bool | v_IsAvailable (const std::vector< LibUtilities::EquationSharedPtr > &exprs) const =0 |
| Implementation hook for IsAvailable(). | |
Protected Member Functions inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Phys, FieldState::Phys, TData > | |
| ElmtBlockOp (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse) | |
| Construct the interface part of a concrete block operator; called by the factory-registered creator functions. | |
| ~ElmtBlockOp () override=default | |
| virtual void | v_Apply (LibUtilities::BlockAccessor< TData, TFieldIn > &inblock, LibUtilities::BlockAccessor< TData, TFieldOut > &outblock)=0 |
| Implementation hook for Apply(). | |
Protected Member Functions inherited from Nektar::MultiRegions::BlockOperator< TData > | |
| BlockOperator (const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse) | |
| Construct the interface part of a concrete block operator; called by the factory-registered creator functions. | |
Protected Attributes | |
| std::vector< LibUtilities::EquationSharedPtr > | m_expressions |
| Parsed expressions, one per field component. | |
| std::vector< unsigned int > | m_numEvars |
| Variable-list length of each expression: the built-in x, y, z and t plus any field-valued EVARS. The implementations read entry 0 only, assuming all expressions share one variable list. | |
| std::vector< bool > | m_cmask |
| Per-component enable flags. | |
| TData | m_time = 0.0 |
Value of the built-in time variable t. | |
| TData | m_scale = 1.0 |
| Factor applied to every evaluated expression value. | |
| bool | m_append = false |
| Accumulate onto the output (true) or overwrite it (false). | |
Protected Attributes inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Phys, FieldState::Phys, TData > | |
| bool | m_warnOnceTemplate |
| Set once the generated ShapeBlock switch code has warned that an element size outside the templated switch range fell back to the runtime-sized OperatorND call, so that the warning is issued only once per block operator (see the BlockOpSwitch templates in LibUtilities/BasicUtils/Switch). | |
Protected Attributes inherited from Nektar::MultiRegions::BlockOperator< TData > | |
| unsigned int | m_block_idx |
| Index of the block within the expansion list's Collections. | |
| LocalRegions::ExpansionSharedPtr | m_exp |
| Representative expansion of the block (its first element). | |
| LibUtilities::NekDataWarehouseSharedPtr | m_dataWarehouse |
| Data warehouse shared with the other operators on the expansion list. | |
Private Types | |
| enum class | NameKind { Variable , Function } |
| Kind of name GetExpressionNames() collects. More... | |
Static Private Member Functions | |
| static std::set< std::string > | GetExpressionNames (const std::string &expr, const NameKind kind) |
The names of kind kind in expr. | |
Additional Inherited Members | |
Public Types inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Phys, FieldState::Phys, TData > | |
| using | InBlock = LibUtilities::BlockAccessor< TData, TFieldIn > |
| Accessor type of this operator's input block. | |
| using | OutBlock = LibUtilities::BlockAccessor< TData, TFieldOut > |
| Accessor type of this operator's output block; see InBlock. | |
Static Protected Member Functions inherited from Nektar::MultiRegions::ElmtBlockOp< FieldState::Phys, FieldState::Phys, TData > | |
| static void | ShapeSwitch (const LibUtilities::ShapeType shape, TFunc &&func) |
Call func with the runtime shape as a compile-time constant, std::integral_constant<LibUtilities::ShapeType, ...>. | |
| static void | DispatchAppendFlag (const bool append, TFunc &&func) |
Call func with std::true_type if append and std::false_type otherwise. | |
| static void | DispatchScaleFlag (const TData scale, TFunc &&func) |
Call func with std::false_type if scale is one and std::true_type otherwise. | |
| static void | DispatchDeformedFlag (const bool deformed, TFunc &&func) |
Call func with std::true_type if deformed and std::false_type otherwise. | |
Static Protected Member Functions inherited from Nektar::MultiRegions::BlockOperator< TData > | |
| template<typename MemSpace > | |
| static TData * | GetStaticWorkSpace (const size_t size, const unsigned int streamID=0) |
Return a per-stream scratch buffer in MemSpace, sized to hold at least size elements of TData, growing and reallocating it as needed. | |
Block-level interface of the Expression operator: evaluates the configured expressions at every quadrature point of one element block.
Besides setting the BlockAccessor states accepted by Apply() to physical space on both sides, this class holds the evaluation settings – expressions, per-expression variable counts, component mask, time, scale and append flag. One instance per block is created by ElmtOp::Create via ExpressionOp::Create, and the settings are written through the whole-field ExpressionOp setters, which forward to every block.
All setters are plain stores except SetExpressions(), which goes through the virtual v_SetExpressions() so a back-end can prepare for evaluation.
| TData | Floating-point type of the field data. |
Definition at line 84 of file ExpressionBlockOp.hpp.
|
strongprivate |
Kind of name GetExpressionNames() collects.
| Enumerator | |
|---|---|
| Variable | A name not called as a function. |
| Function | A name followed by an opening parenthesis. |
Definition at line 287 of file ExpressionBlockOp.hpp.
|
inlineprotected |
Construct the interface part of a concrete block operator; called by the factory-registered creator functions.
| block_idx | Index of the block within the expansion list's Collections. |
| exp | Representative expansion of the block. |
| dataWarehouse | Data warehouse shared with the other operators on the expansion list. |
Definition at line 254 of file ExpressionBlockOp.hpp.
|
overrideprotecteddefault |
|
inlinestatic |
Create one block operator through the block-operator factory.
The factory key is name + execStr + implStr; since the family registers only "Generic" implementations, any other implStr falls back to the Generic key of the same execution space (see ElmtBlockOp::Create).
| block_idx | Index of the block within the expansion list's Collections. |
| exp | Representative expansion of the block. |
| dataWarehouse | Data warehouse shared with the other operators on the expansion list. |
| execStr | Execution-space part of the factory key. |
| implStr | Implementation part of the factory key. |
Definition at line 106 of file ExpressionBlockOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::SetExpressions().
|
inlinestatic |
Split an expression's variable list into the individual variable names.
Entries 0-3 are the built-in x, y, z and t; entries from 4 onwards name the extra field variables (EVARS).
| expression | Expression whose variable list is split. |
Definition at line 132 of file ExpressionBlockOp.hpp.
References Nektar::StringUtils::Split().
Referenced by Nektar::MultiRegions::detail::GetExpressionKernelSource().
|
inlinestatic |
The functions an expression calls: every name in expr followed by an opening parenthesis.
| expr | Expression to scan. |
expr. Definition at line 162 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::Function, and Nektar::MultiRegions::ExpressionBlockOp< TData >::GetExpressionNames().
Referenced by Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_IsAvailable().
|
inlinestaticprivate |
The names of kind kind in expr.
Numbers are skipped, so that an exponent is not read as a name.
Definition at line 298 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::Function, sign, and Nektar::MultiRegions::ExpressionBlockOp< TData >::Variable.
Referenced by Nektar::MultiRegions::ExpressionBlockOp< TData >::GetExpressionFunctions(), and Nektar::MultiRegions::ExpressionBlockOp< TData >::GetExpressionVariables().
|
inlinestatic |
The variables an expression uses: every name in expr that is not called as a function, so also its parameters and constants.
| expr | Expression to scan. |
expr. Definition at line 149 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::GetExpressionNames(), and Nektar::MultiRegions::ExpressionBlockOp< TData >::Variable.
Referenced by Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_IsAvailable(), and Nektar::detail::HOutflowBndCondOpImpl< ExecSpace, TData >::ValidateAndBuildVelocityBoundaryData().
|
inline |
Whether this back-end can evaluate exprs under the current component mask.
Definition at line 181 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::v_IsAvailable().
|
inline |
Choose between accumulating onto the output and overwriting it.
Definition at line 203 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::m_append.
|
inline |
Set the per-component enable flags (see the mask notes in ExpressionOp::SetComponentMask, including the requirement that the mask be final before SetExpressions()).
Definition at line 222 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::m_cmask.
Referenced by Nektar::MultiRegions::ExpressionOp< TData >::Create().
|
inline |
Set the expressions to evaluate (one per component) via the back-end hook v_SetExpressions().
Definition at line 171 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::v_SetExpressions().
|
inline |
Set the variable count of each expression, as computed by ExpressionOp::GetNumberEvars().
Definition at line 212 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::m_numEvars.
|
inline |
Set the factor every evaluated value is multiplied by.
Definition at line 194 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::m_scale.
|
inline |
Set the value substituted for the built-in variable t.
Definition at line 188 of file ExpressionBlockOp.hpp.
References Nektar::MultiRegions::ExpressionBlockOp< TData >::m_time.
|
protectedpure virtual |
Implementation hook for IsAvailable().
| exprs | Parsed expressions, one per component. |
Implemented in Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >, and Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >.
Referenced by Nektar::MultiRegions::ExpressionBlockOp< TData >::IsAvailable().
|
protectedpure virtual |
Implementation hook for SetExpressions().
Overrides must arrange that m_expressions, and whatever the back-end derives from them, are in place before the work queued by the next Apply() runs; that work need not have finished by the time this call returns.
| exprs | Parsed expressions, one per component. |
Implemented in Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >, and Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >.
Referenced by Nektar::MultiRegions::ExpressionBlockOp< TData >::SetExpressions().
|
protected |
Accumulate onto the output (true) or overwrite it (false).
Definition at line 242 of file ExpressionBlockOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionBlockOp< TData >::SetAppend(), and Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_Apply().
|
protected |
Per-component enable flags.
Definition at line 235 of file ExpressionBlockOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionBlockOp< TData >::SetComponentMask(), Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_Apply(), Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_IsAvailable(), and Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_SetExpressions().
|
protected |
Parsed expressions, one per field component.
Definition at line 229 of file ExpressionBlockOp.hpp.
Referenced by Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_Apply(), and Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_SetExpressions().
|
protected |
Variable-list length of each expression: the built-in x, y, z and t plus any field-valued EVARS. The implementations read entry 0 only, assuming all expressions share one variable list.
Definition at line 233 of file ExpressionBlockOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionBlockOp< TData >::SetNumEvars(), and Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_Apply().
|
protected |
Factor applied to every evaluated expression value.
Definition at line 240 of file ExpressionBlockOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionBlockOp< TData >::SetScale(), and Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_Apply().
|
protected |
Value of the built-in time variable t.
Definition at line 238 of file ExpressionBlockOp.hpp.
Referenced by Nektar::MultiRegions::ExpressionBlockOp< TData >::SetTime(), and Nektar::MultiRegions::detail::ExpressionBlockOpImpl< ExecSpace, Implementation, TData >::v_Apply().
|
inlinestatic |
Block-operator base name; Create() appends the execution space and implementation to it to form the factory key.
Definition at line 119 of file ExpressionBlockOp.hpp.