Panzer
Version of the Day
|
Interprets mathematical expressions in a string and evaluates them using Kokkos::View objects as values and Kokkos::parallel_for for the operators. This class is mean to support Kokkos-parallel execution of user-provided mathematical expressions. Example uses include evaluating analytic boundary and initial conditions for a PDE problem. The API of this class (namely Eval::read_string or another read_* function inherited from Teuchos::Reader) is only meant to be called once for a given set of evaluation points. Variables should be predefined with point-dependent values all stored in a single Kokkos::View. For example, X coordinates for all points could be stored in a Kokkos::View<double*>, whose extent is the number of points. Values which are the same for all points are still supported, for example the current time. Then if the expression is for example "x^t", this class launches a single parallel_for to raise the coordinate of all points at once to the "t" power. More...
#include <Panzer_ExprEval.hpp>
Public Types | |
using | original_view_type = Kokkos::View< DT, VP...> |
The corresponding Kokkos::View type, using the same template arguments are were given to Eval. More... | |
using | view_data_type = DT |
The data type, including dimension information. More... | |
using | scalar_type = typename original_view_type::non_const_value_type |
The scalar type. More... | |
using | const_view_type = Kokkos::View< typename RebindDataType< view_data_type, scalar_type const >::type, VP...> |
One scalar for each evaluation point, read-only. More... | |
using | const_bool_view_type = Kokkos::View< typename RebindDataType< view_data_type, bool const >::type, VP...> |
One boolean for each evaluation point, read-only. More... | |
using | single_view_type = Kokkos::View< scalar_type, VP...> |
One scalar (same for all evaluation points) More... | |
using | const_single_view_type = Kokkos::View< scalar_type const, VP...> |
One scalar (same for all evaluation points), read-only. More... | |
using | single_bool_view_type = Kokkos::View< bool, VP...> |
One boolean (same for all evaluation points) More... | |
using | const_single_bool_view_type = Kokkos::View< bool const, VP...> |
One boolean (same for all evaluation points), read-only. More... | |
Public Types inherited from panzer::Expr::EvalBase | |
using | Function = std::function< void(std::string const &name, Teuchos::any &, std::vector< Teuchos::any > &rhs)> |
The type of user-defined functions which are callable in the math language. More... | |
Public Member Functions | |
Eval () | |
void | set (std::string const &name, bool value) |
Assign a boolean value to a variable symbol. More... | |
void | set (std::string const &name, scalar_type const &value) |
Assign a scalar value to a variable symbol. More... | |
void | set (std::string const &name, const_view_type const &value) |
Assign scalar values (one for each evaluation point) to a variable symbol. More... | |
Public Member Functions inherited from panzer::Expr::EvalBase | |
EvalBase () | |
Constructor. More... | |
void | set (std::string const &name, Function const &value) |
Registers an EvalBase::Function, binding it to a name and making it callable. More... | |
template<typename T > | |
T const & | get (std::string const &name) const |
Get the value of a variable in the symbol map. More... | |
Public Member Functions inherited from Teuchos::Reader | |
virtual | ~Reader () |
Reader (ReaderTablesPtr tables_in) | |
void | read_stream (any &result, std::istream &stream, std::string const &stream_name_in) |
void | read_string (any &result, std::string const &string, std::string const &string_name) |
void | read_file (any &result, std::string const &file_name) |
Protected Member Functions | |
void | make_constant (Teuchos::any &result, double const &value) override |
void | inspect_arg (Teuchos::any const &arg, bool &is_many, bool &is_bool) override |
void | single_single_ternary_op (Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override |
void | single_many_ternary_op (Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override |
void | many_single_ternary_op (Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override |
void | many_many_ternary_op (Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override |
void | single_single_binary_op (BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override |
void | single_many_binary_op (BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override |
void | many_single_binary_op (BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override |
void | many_many_binary_op (BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override |
void | many_neg_op (Teuchos::any &result, Teuchos::any &right) override |
void | single_neg_op (Teuchos::any &result, Teuchos::any &right) override |
Protected Member Functions inherited from panzer::Expr::EvalBase | |
void | at_shift (Teuchos::any &result, int token, std::string &text) override |
Called at every parsed token in the math language. More... | |
void | at_reduce (Teuchos::any &result, int prod, std::vector< Teuchos::any > &rhs) override |
Called at every reduced production in the math language. More... | |
void | ternary_op (Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) |
Executes the ternary operator, e.g. (a > b) ? a : b. More... | |
void | binary_op (BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) |
Executes a binary operator. More... | |
void | neg_op (Teuchos::any &result, Teuchos::any &right) |
Executes the only native unary operator in the math language, numeric negation via a minus sign. More... | |
Additional Inherited Members | |
Protected Attributes inherited from panzer::Expr::EvalBase | |
std::map< std::string, Teuchos::any > | symbol_map |
Stores all current symbols including variables and functions. More... | |
Interprets mathematical expressions in a string and evaluates them using Kokkos::View objects as values and Kokkos::parallel_for for the operators. This class is mean to support Kokkos-parallel execution of user-provided mathematical expressions. Example uses include evaluating analytic boundary and initial conditions for a PDE problem. The API of this class (namely Eval::read_string or another read_* function inherited from Teuchos::Reader) is only meant to be called once for a given set of evaluation points. Variables should be predefined with point-dependent values all stored in a single Kokkos::View. For example, X coordinates for all points could be stored in a Kokkos::View<double*>, whose extent is the number of points. Values which are the same for all points are still supported, for example the current time. Then if the expression is for example "x^t", this class launches a single parallel_for to raise the coordinate of all points at once to the "t" power.
Definition at line 197 of file Panzer_ExprEval.hpp.
using panzer::Expr::Eval< DT, VP >::original_view_type = Kokkos::View<DT, VP ...> |
The corresponding Kokkos::View type, using the same template arguments are were given to Eval.
Definition at line 200 of file Panzer_ExprEval.hpp.
using panzer::Expr::Eval< DT, VP >::view_data_type = DT |
The data type, including dimension information.
Definition at line 202 of file Panzer_ExprEval.hpp.
using panzer::Expr::Eval< DT, VP >::scalar_type = typename original_view_type::non_const_value_type |
The scalar type.
This type should be constructible from a value of type "double" and should be usable with the four basic binary operator ('+', '-', '*', '/') and also the pow() function.
Definition at line 209 of file Panzer_ExprEval.hpp.
using panzer::Expr::Eval< DT, VP >::const_view_type = Kokkos::View<typename RebindDataType<view_data_type, scalar_type const>::type, VP ...> |
One scalar for each evaluation point, read-only.
This is the original view type where the scalar type is constant. This means it is a read-only view. and will most likely be the type that is returned from read_string().
Definition at line 217 of file Panzer_ExprEval.hpp.
using panzer::Expr::Eval< DT, VP >::const_bool_view_type = Kokkos::View<typename RebindDataType<view_data_type, bool const>::type, VP ...> |
One boolean for each evaluation point, read-only.
Definition at line 221 of file Panzer_ExprEval.hpp.
using panzer::Expr::Eval< DT, VP >::single_view_type = Kokkos::View<scalar_type, VP ...> |
One scalar (same for all evaluation points)
Definition at line 225 of file Panzer_ExprEval.hpp.
using panzer::Expr::Eval< DT, VP >::const_single_view_type = Kokkos::View<scalar_type const, VP ...> |
One scalar (same for all evaluation points), read-only.
Definition at line 229 of file Panzer_ExprEval.hpp.
using panzer::Expr::Eval< DT, VP >::single_bool_view_type = Kokkos::View<bool, VP ...> |
One boolean (same for all evaluation points)
Definition at line 233 of file Panzer_ExprEval.hpp.
using panzer::Expr::Eval< DT, VP >::const_single_bool_view_type = Kokkos::View<bool const, VP ...> |
One boolean (same for all evaluation points), read-only.
Definition at line 237 of file Panzer_ExprEval.hpp.
panzer::Expr::Eval< DT, VP >::Eval | ( | ) |
Definition at line 349 of file Panzer_ExprEval_impl.hpp.
void panzer::Expr::Eval< DT, VP >::set | ( | std::string const & | name, |
bool | value | ||
) |
Assign a boolean value to a variable symbol.
Definition at line 355 of file Panzer_ExprEval_impl.hpp.
void panzer::Expr::Eval< DT, VP >::set | ( | std::string const & | name, |
scalar_type const & | value | ||
) |
Assign a scalar value to a variable symbol.
Definition at line 364 of file Panzer_ExprEval_impl.hpp.
void panzer::Expr::Eval< DT, VP >::set | ( | std::string const & | name, |
const_view_type const & | value | ||
) |
Assign scalar values (one for each evaluation point) to a variable symbol.
Definition at line 375 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 380 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 391 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 412 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 419 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 427 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 435 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 442 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 462 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 484 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 506 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 587 of file Panzer_ExprEval_impl.hpp.
|
overrideprotectedvirtual |
Implements panzer::Expr::EvalBase.
Definition at line 592 of file Panzer_ExprEval_impl.hpp.