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 355 of file ExpressionBuilder.h.

Constructor & Destructor Documentation

ExpressionBuilder::EBTerm::EBTerm ( )
inline

Definition at line 361 of file ExpressionBuilder.h.

361 : _root(new EBTempIDNode(reinterpret_cast<unsigned long>(this))){};
ExpressionBuilder::EBTerm::EBTerm ( const EBTerm term)
inline

Definition at line 363 of file ExpressionBuilder.h.

363 : _root(term.cloneRoot()){};
ExpressionBuilder::EBTerm::~EBTerm ( )
inline

Definition at line 364 of file ExpressionBuilder.h.

364 { delete _root; };
ExpressionBuilder::EBTerm::EBTerm ( EBTermNode root)
inlineprivate

Definition at line 368 of file ExpressionBuilder.h.

368 : _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:58
ExpressionBuilder::EBTerm::EBTerm ( int  number)
inline

Definition at line 372 of file ExpressionBuilder.h.

372 : _root(new EBNumberNode<int>(number)) {}
ExpressionBuilder::EBTerm::EBTerm ( Real  number)
inline

Definition at line 373 of file ExpressionBuilder.h.

373 : _root(new EBNumberNode<Real>(number)) {}
ExpressionBuilder::EBTerm::EBTerm ( const char *  symbol)
inline

Definition at line 374 of file ExpressionBuilder.h.

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

Member Function Documentation

ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( ,
ADD   
)
SUB BINARY_OP_IMPLEMENT MUL ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( ,
DIV   
)
SUB BINARY_OP_IMPLEMENT MUL MOD ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( )
SUB BINARY_OP_IMPLEMENT MUL MOD GREATER ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( <=  ,
LESSEQ   
)
SUB BINARY_OP_IMPLEMENT MUL MOD GREATER GREATEREQ ExpressionBuilder::EBTerm::BINARY_OP_IMPLEMENT ( EQ  )
ExpressionBuilder::EBTerm::BINARYCOMP_OP_IMPLEMENT ( ,
ADD   
)
SUB BINARYCOMP_OP_IMPLEMENT MUL ExpressionBuilder::EBTerm::BINARYCOMP_OP_IMPLEMENT ( ,
DIV   
)
EBTermNode* ExpressionBuilder::EBTerm::cloneRoot ( ) const
inline

Definition at line 402 of file ExpressionBuilder.h.

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

402 { return _root == NULL ? NULL : _root->clone(); }
virtual EBTermNode * clone() const =0
const EBTermNode* ExpressionBuilder::EBTerm::getRoot ( ) const
inline

Definition at line 401 of file ExpressionBuilder.h.

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

401 { return _root; }
ExpressionBuilder::EBTerm::operator std::string ( ) const
inline

Definition at line 387 of file ExpressionBuilder.h.

387 { return _root->stringify(); }
virtual std::string stringify() const =0
EBTerm& ExpressionBuilder::EBTerm::operator= ( const EBTerm term)
inline

Definition at line 390 of file ExpressionBuilder.h.

391  {
392  delete _root;
393  _root = term.cloneRoot();
394  return *this;
395  }
unsigned int ExpressionBuilder::EBTerm::substitute ( const EBSubstitutionRule rule)

Definition at line 411 of file ExpressionBuilder.C.

Referenced by ExpressionBuilder::EBFunction::operator=().

412 {
413  EBSubstitutionRuleList rules(1);
414  rules[0] = &rule;
415  return substitute(rules);
416 }
unsigned int substitute(const EBSubstitutionRule &rule)
std::vector< const EBSubstitutionRule * > EBSubstitutionRuleList
unsigned int ExpressionBuilder::EBTerm::substitute ( const EBSubstitutionRuleList rules)

Definition at line 419 of file ExpressionBuilder.C.

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

Friends And Related Function Documentation

EBTerm abs ( const EBTerm )
friend
EBTerm atan2 ( const EBTerm ,
const EBTerm  
)
friend
EBTerm conditional ( const EBTerm ,
const EBTerm ,
const EBTerm  
)
friend

Ternary functions.

EBTerm cos ( const EBTerm )
friend
EBTerm cosh ( const EBTerm )
friend
EBTerm exp ( const EBTerm )
friend
EBTerm hypot ( const EBTerm ,
const EBTerm  
)
friend
EBTerm log ( const EBTerm )
friend
EBTerm log10 ( const EBTerm )
friend
EBTerm log2 ( const EBTerm )
friend
EBTerm max ( const EBTerm ,
const EBTerm  
)
friend
SUB BINARYCOMP_OP_IMPLEMENT MUL MOD friend EBTerm min ( const EBTerm ,
const EBTerm  
)
friend

Binary functions.

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

Definition at line 10 of file ExpressionBuilder.C.

11 {
12  return {larg, rarg};
13 }
EBTermList operator, ( const ExpressionBuilder::EBTerm larg,
const ExpressionBuilder::EBTermList rargs 
)
friend

Definition at line 16 of file ExpressionBuilder.C.

17 {
18  ExpressionBuilder::EBTermList list = {larg};
19  list.insert(list.end(), rargs.begin(), rargs.end());
20  return list;
21 }
std::vector< EBTerm > EBTermList
EBTermList operator, ( const ExpressionBuilder::EBTermList largs,
const ExpressionBuilder::EBTerm rarg 
)
friend

Definition at line 24 of file ExpressionBuilder.C.

25 {
26  ExpressionBuilder::EBTermList list = largs;
27  list.push_back(rarg);
28  return list;
29 }
std::vector< EBTerm > EBTermList
std::ostream& operator<< ( std::ostream &  os,
const EBTerm term 
)
friend

Definition at line 32 of file ExpressionBuilder.C.

33 {
34  if (term._root != NULL)
35  return os << *term._root;
36  else
37  return os << "[NULL]";
38 }
EBTerm plog ( const EBTerm ,
const EBTerm  
)
friend
EBTerm pow ( const EBTerm ,
const EBTerm  
)
friend
template<typename T >
EBTerm pow ( const EBTerm left,
exponent 
)
friend

Definition at line 671 of file ExpressionBuilder.h.

672 {
674  new ExpressionBuilder::EBBinaryOpTermNode(left.cloneRoot(),
677 }
User facing host object for an expression tree.
Node representing a binary operator.
Template class for leaf nodes holding numbers in the expression tree.
LOGICNOT friend EBTerm sin ( const EBTerm )
friend

Unary functions.

EBTerm sinh ( const EBTerm )
friend
EBTerm tan ( const EBTerm )
friend

Member Data Documentation

EBTermNode* ExpressionBuilder::EBTerm::_root
protected

Definition at line 405 of file ExpressionBuilder.h.

Referenced by operator<<().


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