blitzdg
an open-source project aiming to implement parallel discontinuous Galerkin (dg) solvers for common partial differential equations systems using blitz++ for array and tensor manipulations and MPI for distributed parallelism.
andoperator.h
1 
2 // Copyright Joakim Karlsson & Kim Gräsman 2010-2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #ifndef IGLOO_ANDOPERATOR_H
8 #define IGLOO_ANDOPERATOR_H
9 
10 namespace snowhouse {
11 
13  {
14  template <typename ConstraintListType, typename ActualType>
15  void Evaluate(ConstraintListType& list, ResultStack& result, OperatorStack& operators, const ActualType& actual)
16  {
17  EvaluateOperatorsWithLessOrEqualPrecedence(*this, operators, result);
18 
19  operators.push(this);
20 
21  EvaluateConstraintList(list.m_tail, result, operators, actual);
22  }
23 
24  void PerformOperation(ResultStack& result)
25  {
26  if(result.size() < 2)
27  {
28  throw InvalidExpressionException("The expression contains an and operator with too few operands");
29  }
30 
31  bool right = result.top();
32  result.pop();
33  bool left = result.top();
34  result.pop();
35 
36  result.push(left && right);
37  }
38 
39  int Precedence() const
40  {
41  return 3;
42  }
43  };
44 
45  template<>
47  {
48  static std::string ToString(const AndOperator&)
49  {
50  return "and";
51  }
52  };
53 }
54 #endif
Definition: assert.h:13
Definition: andoperator.h:12
Definition: constraintoperator.h:26
Definition: constraintoperator.h:12
Definition: stringize.h:71