www.mooseframework.org
Public Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
ExpressionBuilder::EBTerm Class Reference

User facing host object for an expression tree. More...

#include <ExpressionBuilder.h>

Public Member Functions

 EBTerm ()
 
 EBTerm (const EBTerm &term)
 
 ~EBTerm ()
 
 EBTerm (int number)
 
 EBTerm (Real number)
 
 EBTerm (const char *symbol)
 
 operator std::string () const
 
EBTermoperator= (const EBTerm &term)
 
unsigned int substitute (const EBSubstitutionRule &rule)
 
unsigned int substitute (const EBSubstitutionRuleList &rules)
 
const EBTermNodegetRoot () const
 
EBTermNodecloneRoot () const
 
 UNARY_OP_IMPLEMENT (-, NEG) UNARY_OP_IMPLEMENT(!
 
 BINARY_OP_IMPLEMENT (+, ADD) BINARY_OP_IMPLEMENT(-
 
SUB BINARY_OP_IMPLEMENT MUL BINARY_OP_IMPLEMENT (/, DIV) BINARY_OP_IMPLEMENT(%
 
SUB BINARY_OP_IMPLEMENT MUL MOD BINARY_OP_IMPLEMENT (<, LESS) BINARY_OP_IMPLEMENT(>
 
SUB BINARY_OP_IMPLEMENT MUL MOD GREATER BINARY_OP_IMPLEMENT (<=, LESSEQ) BINARY_OP_IMPLEMENT(>
 
SUB BINARY_OP_IMPLEMENT MUL MOD GREATER GREATEREQ BINARY_OP_IMPLEMENT (==, EQ) BINARY_OP_IMPLEMENT(!
 
 BINARYCOMP_OP_IMPLEMENT (+=, ADD) BINARYCOMP_OP_IMPLEMENT(-
 
SUB BINARYCOMP_OP_IMPLEMENT MUL BINARYCOMP_OP_IMPLEMENT (/=, DIV) BINARYCOMP_OP_IMPLEMENT(%
 

Protected Attributes

EBTermNode_root
 

Private Member Functions

 EBTerm (EBTermNode *root)
 

Friends

EBTermList operator, (const ExpressionBuilder::EBTerm &larg, const ExpressionBuilder::EBTerm &rarg)
 
EBTermList operator, (const ExpressionBuilder::EBTerm &larg, const ExpressionBuilder::EBTermList &rargs)
 
EBTermList operator, (const ExpressionBuilder::EBTermList &largs, const ExpressionBuilder::EBTerm &rarg)
 
std::ostream & operator<< (std::ostream &os, const EBTerm &term)
 
LOGICNOT friend EBTerm sin (const EBTerm &)
 Unary functions. More...
 
EBTerm cos (const EBTerm &)
 
EBTerm tan (const EBTerm &)
 
EBTerm abs (const EBTerm &)
 
EBTerm log (const EBTerm &)
 
EBTerm log2 (const EBTerm &)
 
EBTerm log10 (const EBTerm &)
 
EBTerm exp (const EBTerm &)
 
EBTerm sinh (const EBTerm &)
 
EBTerm cosh (const EBTerm &)
 
EBTerm conditional (const EBTerm &, const EBTerm &, const EBTerm &)
 Ternary functions. More...
 
SUB BINARYCOMP_OP_IMPLEMENT MUL MOD friend EBTerm min (const EBTerm &, const EBTerm &)
 Binary functions. More...
 
EBTerm max (const EBTerm &, const EBTerm &)
 
EBTerm pow (const EBTerm &, const EBTerm &)
 
template<typename T >
EBTerm pow (const EBTerm &, T exponent)
 
EBTerm atan2 (const EBTerm &, const EBTerm &)
 
EBTerm hypot (const EBTerm &, const EBTerm &)
 
EBTerm plog (const EBTerm &, const EBTerm &)
 

Detailed Description

User facing host object for an expression tree.

Each EBTerm contains a _root node pointer to an EBTermNode object. The _root pointer should never be NULL, but it should be safe if it ever is. The default constructor assigns a EBTempIDNode to _root with a unique ID.

Definition at line 358 of file ExpressionBuilder.h.

Constructor & Destructor Documentation

◆ EBTerm() [1/6]

ExpressionBuilder::EBTerm::EBTerm ( )
inline

Definition at line 364 of file ExpressionBuilder.h.

364 : _root(new EBTempIDNode(reinterpret_cast<unsigned long>(this))){};

◆ EBTerm() [2/6]

ExpressionBuilder::EBTerm::EBTerm ( const EBTerm term)
inline

Definition at line 366 of file ExpressionBuilder.h.

366 : _root(term.cloneRoot()){};

◆ ~EBTerm()

ExpressionBuilder::EBTerm::~EBTerm ( )
inline

Definition at line 367 of file ExpressionBuilder.h.

367 { delete _root; };

◆ EBTerm() [3/6]

ExpressionBuilder::EBTerm::EBTerm ( EBTermNode root)
inlineprivate

Definition at line 371 of file ExpressionBuilder.h.

371 : _root(root){};
Real root(std::function< Real(Real)> const &f, Real x1, Real x2, Real tol=1.0e-12)
Finds the root of a function using Brent&#39;s method.
Definition: BrentsMethod.C:61

◆ EBTerm() [4/6]

ExpressionBuilder::EBTerm::EBTerm ( int  number)
inline

Definition at line 375 of file ExpressionBuilder.h.

375 : _root(new EBNumberNode<int>(number)) {}

◆ EBTerm() [5/6]

ExpressionBuilder::EBTerm::EBTerm ( Real  number)
inline

Definition at line 376 of file ExpressionBuilder.h.

376 : _root(new EBNumberNode<Real>(number)) {}

◆ EBTerm() [6/6]

ExpressionBuilder::EBTerm::EBTerm ( const char *  symbol)
inline

Definition at line 377 of file ExpressionBuilder.h.

377 : _root(new EBSymbolNode(symbol)) {}

Member Function Documentation

◆ BINARY_OP_IMPLEMENT() [1/5]

ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( ,
ADD   
)

◆ BINARY_OP_IMPLEMENT() [2/5]

SUB BINARY_OP_IMPLEMENT MUL ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( ,
DIV   
)

◆ BINARY_OP_IMPLEMENT() [3/5]

SUB BINARY_OP_IMPLEMENT MUL MOD ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( )

◆ BINARY_OP_IMPLEMENT() [4/5]

SUB BINARY_OP_IMPLEMENT MUL MOD GREATER ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( <=  ,
LESSEQ   
)

◆ BINARY_OP_IMPLEMENT() [5/5]

SUB BINARY_OP_IMPLEMENT MUL MOD GREATER GREATEREQ ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( EQ  )

◆ BINARYCOMP_OP_IMPLEMENT() [1/2]

ExpressionBuilder::EBTerm::BINARYCOMP_OP_IMPLEMENT ( ,
ADD   
)

◆ BINARYCOMP_OP_IMPLEMENT() [2/2]

SUB BINARYCOMP_OP_IMPLEMENT MUL ExpressionBuilder::EBTerm::BINARYCOMP_OP_IMPLEMENT ( ,
DIV   
)

◆ cloneRoot()

EBTermNode* ExpressionBuilder::EBTerm::cloneRoot ( ) const
inline

Definition at line 405 of file ExpressionBuilder.h.

Referenced by BINARY_FUNC_IMPLEMENT(), ExpressionBuilder::EBTermSubstitution::EBTermSubstitution(), operator=(), and pow().

405 { return _root == NULL ? NULL : _root->clone(); }
virtual EBTermNode * clone() const =0

◆ getRoot()

const EBTermNode* ExpressionBuilder::EBTerm::getRoot ( ) const
inline

Definition at line 404 of file ExpressionBuilder.h.

Referenced by ExpressionBuilder::EBTermSubstitution::EBTermSubstitution().

404 { return _root; }

◆ operator std::string()

ExpressionBuilder::EBTerm::operator std::string ( ) const
inline

Definition at line 390 of file ExpressionBuilder.h.

390 { return _root->stringify(); }
virtual std::string stringify() const =0

◆ operator=()

EBTerm& ExpressionBuilder::EBTerm::operator= ( const EBTerm term)
inline

Definition at line 393 of file ExpressionBuilder.h.

394  {
395  delete _root;
396  _root = term.cloneRoot();
397  return *this;
398  }

◆ substitute() [1/2]

unsigned int ExpressionBuilder::EBTerm::substitute ( const EBSubstitutionRule rule)

Definition at line 414 of file ExpressionBuilder.C.

415 {
416  EBSubstitutionRuleList rules(1);
417  rules[0] = &rule;
418  return substitute(rules);
419 }
unsigned int substitute(const EBSubstitutionRule &rule)
std::vector< const EBSubstitutionRule * > EBSubstitutionRuleList

◆ substitute() [2/2]

unsigned int ExpressionBuilder::EBTerm::substitute ( const EBSubstitutionRuleList rules)

Definition at line 422 of file ExpressionBuilder.C.

423 {
424  unsigned int nrule = rules.size();
425 
426  if (_root == NULL)
427  return 0;
428 
429  for (unsigned int i = 0; i < nrule; ++i)
430  {
431  EBTermNode * replace = rules[i]->apply(_root);
432  if (replace != NULL)
433  {
434  delete _root;
435  _root = replace;
436  return 1;
437  }
438  }
439 
440  return _root->substitute(rules);
441 }
virtual unsigned int substitute(const EBSubstitutionRuleList &)

◆ UNARY_OP_IMPLEMENT()

ExpressionBuilder::EBTerm::UNARY_OP_IMPLEMENT ( ,
NEG   
)

Friends And Related Function Documentation

◆ abs

EBTerm abs ( const EBTerm )
friend

◆ atan2

EBTerm atan2 ( const EBTerm ,
const EBTerm  
)
friend

◆ conditional

EBTerm conditional ( const EBTerm ,
const EBTerm ,
const EBTerm  
)
friend

Ternary functions.

◆ cos

EBTerm cos ( const EBTerm )
friend

◆ cosh

EBTerm cosh ( const EBTerm )
friend

◆ exp

EBTerm exp ( const EBTerm )
friend

◆ hypot

EBTerm hypot ( const EBTerm ,
const EBTerm  
)
friend

◆ log

EBTerm log ( const EBTerm )
friend

◆ log10

EBTerm log10 ( const EBTerm )
friend

◆ log2

EBTerm log2 ( const EBTerm )
friend

◆ max

EBTerm max ( const EBTerm ,
const EBTerm  
)
friend

◆ min

SUB BINARYCOMP_OP_IMPLEMENT MUL MOD friend EBTerm min ( const EBTerm ,
const EBTerm  
)
friend

Binary functions.

◆ operator, [1/3]

EBTermList operator, ( const ExpressionBuilder::EBTerm larg,
const ExpressionBuilder::EBTerm rarg 
)
friend

Definition at line 13 of file ExpressionBuilder.C.

14 {
15  return {larg, rarg};
16 }

◆ operator, [2/3]

EBTermList operator, ( const ExpressionBuilder::EBTerm larg,
const ExpressionBuilder::EBTermList rargs 
)
friend

Definition at line 19 of file ExpressionBuilder.C.

20 {
21  ExpressionBuilder::EBTermList list = {larg};
22  list.insert(list.end(), rargs.begin(), rargs.end());
23  return list;
24 }
std::vector< EBTerm > EBTermList

◆ operator, [3/3]

EBTermList operator, ( const ExpressionBuilder::EBTermList largs,
const ExpressionBuilder::EBTerm rarg 
)
friend

Definition at line 27 of file ExpressionBuilder.C.

28 {
29  ExpressionBuilder::EBTermList list = largs;
30  list.push_back(rarg);
31  return list;
32 }
std::vector< EBTerm > EBTermList

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const EBTerm term 
)
friend

Definition at line 35 of file ExpressionBuilder.C.

36 {
37  if (term._root != NULL)
38  return os << *term._root;
39  else
40  return os << "[NULL]";
41 }

◆ plog

EBTerm plog ( const EBTerm ,
const EBTerm  
)
friend

◆ pow [1/2]

EBTerm pow ( const EBTerm ,
const EBTerm  
)
friend

◆ pow [2/2]

template<typename T >
EBTerm pow ( const EBTerm left,
exponent 
)
friend

Definition at line 674 of file ExpressionBuilder.h.

675 {
677  new ExpressionBuilder::EBBinaryOpTermNode(left.cloneRoot(),
680 }
User facing host object for an expression tree.
Node representing a binary operator.
Template class for leaf nodes holding numbers in the expression tree.

◆ sin

LOGICNOT friend EBTerm sin ( const EBTerm )
friend

Unary functions.

◆ sinh

EBTerm sinh ( const EBTerm )
friend

◆ tan

EBTerm tan ( const EBTerm )
friend

Member Data Documentation

◆ _root

EBTermNode* ExpressionBuilder::EBTerm::_root
protected

Definition at line 408 of file ExpressionBuilder.h.

Referenced by BINARY_FUNC_IMPLEMENT(), and operator<<().


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