YASK
Yet Another Stencil Kit: a software framework for creating HPC stencil code. Copyright 2014-2023 Intel Corporation.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
yask::yc_equation_node Class Referenceabstract

Equation node. More...

#include <yc_node_api.hpp>

+ Inheritance diagram for yask::yc_equation_node:

Public Member Functions

virtual yc_var_point_node_ptr get_lhs ()=0
 Get the left-hand-side operand.
 
virtual yc_number_node_ptr get_rhs ()=0
 Get the right-hand-side operand.
 
virtual yc_bool_node_ptr get_cond ()=0
 Get the condition describing the sub-domain.
 
virtual void set_cond (yc_bool_node_ptr sub_domain_cond)=0
 Set the condition describing the sub-domain for this equation.
 
virtual void set_step_cond (yc_bool_node_ptr step_cond)=0
 Set the condition describing when the equation is valid.
 
virtual yc_equation_node_ptr clone_ast () const =0
 Create a deep copy of AST starting with this node.
 
- Public Member Functions inherited from yask::yc_expr_node
virtual std::string format_simple () const =0
 Create a simple human-readable string.
 
virtual int get_num_nodes () const =0
 Count the size of the AST.
 

Detailed Description

Equation node.

Indicates var point on LHS is equivalent to expression on RHS. This is NOT a test for equality. Created via yc_node_factory::new_equation_node().

Member Function Documentation

◆ get_lhs()

virtual yc_var_point_node_ptr yask::yc_equation_node::get_lhs ( )
pure virtual

Get the left-hand-side operand.

Returns
Var-point node appearing before the EQUALS operator.

◆ get_rhs()

virtual yc_number_node_ptr yask::yc_equation_node::get_rhs ( )
pure virtual

Get the right-hand-side operand.

Returns
Expression node appearing after the EQUALS operator.

◆ get_cond()

virtual yc_bool_node_ptr yask::yc_equation_node::get_cond ( )
pure virtual

Get the condition describing the sub-domain.

Returns
Boolean expression describing sub-domain or nullptr if not defined.

◆ set_cond()

virtual void yask::yc_equation_node::set_cond ( yc_bool_node_ptr  sub_domain_cond)
pure virtual

Set the condition describing the sub-domain for this equation.

See yc_node_factory::new_equation_node() for an overall description of conditions.

Typical C++ usage to create a sub-domain condition:

auto x = node_fac.new_domain_index("x");
// Create boolean expression for a 10-point wide left boundary area.
auto first_x = node_fac.new_first_domain_index(x);
auto left_bc_cond = x < first_x + 10;
// Indicate that an expression is valid only in this area.
// (Assumes left_bc_expr was already defined.)
left_bc_expr.set_cond(left_bc_cond);

Specification of the "interior" part of a 2-D domain could be represented by an expression like (x >= node_fac.new_first_domain_index(x) + 20) && (x <= node_fac.new_last_domain_index(x) - 20) && (y >= node_fac.new_first_domain_index(y) + 20) && (y <= node_fac.new_last_domain_index(y) - 20).

Warning
For performance, sub-domain expressions are only evaluated once when yk_solution::prepare_solution() is called, and the results are analyzed and cached internally. Thus, sub-domain expressions should not include a step index or a reference to any other varible that might change during or between time-steps. See set_step_cond() for the mechanism to enable equations based on variables that can change between time-steps.
Note
The entire domain in dimension "x" would be represented by (x >= node_fac.new_first_domain_index(x)) && (x <= node_fac.new_last_domain_index(x)), but that is the default condition so does not need to be specified.
Be sure to use an expression like x < first_x + 10 instead of merely x < 10 to avoid the assumption that the first index is always zero (0). More importantly, use an expression like x > last_x - 10 instead of hard-coding the last index.
Parameters
[in]sub_domain_condBoolean expression describing where in the sub-domain this expression is valid or nullptr to remove the condition.

◆ set_step_cond()

virtual void yask::yc_equation_node::set_step_cond ( yc_bool_node_ptr  step_cond)
pure virtual

Set the condition describing when the equation is valid.

See yc_node_factory::new_equation_node() for an overall description of conditions.

Typical C++ usage to create a step condition:

auto t = node_fac.new_step_index("t");
// Create boolean expression that is true every third step.
auto my_step_cond = (t % 3 == 0);
// Indicate that an expression is valid only when step_cond is true.
// (Assumes my_expr was already defined.)
my_expr.set_step_cond(my_step_cond);

Step conditions may also refer to elements in variables including scalars (1-D) and arrays (2-D). For non-scalar variables, indices used in a step condition cannot include domain variables like x or y, but constants are allowed. In this way, equations can be enabled or disabled programmatically by setting elements in the tested variables.

Parameters
[in]step_condBoolean expression describing when the expression is valid or nullptr to remove the condition.

The documentation for this class was generated from the following file: