83template <
typename TData>
85 :
public ElmtBlockOp<FieldState::Phys, FieldState::Phys, TData>
106 static std::shared_ptr<ExpressionBlockOp<TData>>
Create(
107 const unsigned int block_idx,
110 const std::string &execStr,
const std::string &implStr)
113 template Create<ExpressionBlockOp>(block_idx, exp, dataWarehouse,
119 static inline const std::string
name =
"BlockExpression";
135 std::vector<std::string> vnames;
172 const std::vector<LibUtilities::EquationSharedPtr> &exprs)
182 const std::vector<LibUtilities::EquationSharedPtr> &exprs)
const
275 const std::vector<LibUtilities::EquationSharedPtr> &exprs) = 0;
283 const std::vector<LibUtilities::EquationSharedPtr> &exprs)
const = 0;
301 const auto isName = [](
const char c) {
302 return std::isalnum(
static_cast<unsigned char>(c)) || c ==
'_';
305 std::set<std::string> names;
306 for (
size_t i = 0; i < expr.size();)
308 const char c = expr[i];
309 if (std::isdigit(
static_cast<unsigned char>(c)) || c ==
'.')
311 for (++i; i < expr.size(); ++i)
314 (expr[i] ==
'+' || expr[i] ==
'-') &&
315 (expr[i - 1] ==
'e' || expr[i - 1] ==
'E');
316 if (!isName(expr[i]) && expr[i] !=
'.' && !
sign)
322 else if (std::isalpha(
static_cast<unsigned char>(c)) || c ==
'_')
325 while (j < expr.size() && isName(expr[j]))
330 while (k < expr.size() &&
331 std::isspace(
static_cast<unsigned char>(expr[k])))
335 const NameKind found = k < expr.size() && expr[k] ==
'('
340 names.insert(expr.substr(i, j - i));
Block-level base class, implementation-strategy tags and device launch helpers shared by every elemen...
#define sign(a, b)
return the sign(b)*a
Base class of the per-family block operators: applies one element operation to every element of one b...
Block-level interface of the Expression operator: evaluates the configured expressions at every quadr...
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 f...
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 > GetExpressionFunctions(const std::string &expr)
The functions an expression calls: every name in expr followed by an opening parenthesis.
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,...
void SetComponentMask(const std::vector< bool > &cmask)
Set the per-component enable flags (see the mask notes in ExpressionOp::SetComponentMask,...
void SetExpressions(const std::vector< LibUtilities::EquationSharedPtr > &exprs)
Set the expressions to evaluate (one per component) via the back-end hook v_SetExpressions().
NameKind
Kind of name GetExpressionNames() collects.
@ Variable
A name not called as a function.
@ Function
A name followed by an opening parenthesis.
std::vector< LibUtilities::EquationSharedPtr > m_expressions
Parsed expressions, one per field component.
bool m_append
Accumulate onto the output (true) or overwrite it (false).
bool IsAvailable(const std::vector< LibUtilities::EquationSharedPtr > &exprs) const
Whether this back-end can evaluate exprs under the current component mask.
static const std::string name
Block-operator base name; Create() appends the execution space and implementation to it to form the f...
TData m_time
Value of the built-in time variable t.
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....
void SetNumEvars(const std::vector< unsigned int > &numEvars)
Set the variable count of each expression, as computed by ExpressionOp::GetNumberEvars().
void SetAppend(const bool &append)
Choose between accumulating onto the output and overwriting it.
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().
TData m_scale
Factor applied to every evaluated expression value.
void SetTime(const TData &time)
Set the value substituted for the built-in variable t.
std::vector< bool > m_cmask
Per-component enable flags.
~ExpressionBlockOp() override=default
static std::set< std::string > GetExpressionNames(const std::string &expr, const NameKind kind)
The names of kind kind in expr.
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.
void SetScale(const TData &scale)
Set the factor every evaluated value is multiplied by.
Predicate matching any of a set of characters.
std::shared_ptr< NekDataWarehouse > NekDataWarehouseSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
Container & Split(Container &result, std::string_view input, Pred pred, TokenCompressMode mode=eTokenCompressOff)
Splits input at characters matching pred into result, which is cleared first. An empty input gives a ...
FieldState
Possible states for Field data.