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.
constraintlist.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_CONSTRAINT_H
8 #define IGLOO_CONSTRAINT_H
9 
10 namespace snowhouse {
11 
12  struct ConstraintOperator;
13  typedef std::stack<bool> ResultStack;
14  typedef std::stack<ConstraintOperator*> OperatorStack;
15 
16  template <typename HT, typename TT>
18  {
19  typedef HT HeadType;
20  typedef TT TailType;
21 
22  ConstraintList(const HeadType& head, const TailType& tail)
23  : m_head(head), m_tail(tail)
24  {
25  }
26 
27  HeadType m_head;
28  TailType m_tail;
29  };
30 
31  struct Nil
32  {
33  Nil() {}
34  Nil(const Nil&) {}
35  };
36 
37 
38  // ---- These structs defines the resulting types of list concatenation operations
39  template <typename L1, typename L2>
40  struct type_concat
41  {
43  };
44 
45  template <typename L2> struct type_concat<Nil, L2> { typedef L2 t; };
46 
47  template <typename L3> inline L3 tr_concat(const Nil&, const Nil&) { return Nil(); }
48 
49 
50  // ---- These structs define the concatenation operations.
51 
52  template <typename LeftList, typename RightList, typename ResultList>
53  struct ListConcat
54  {
55  static ResultList Concatenate(const LeftList& left, const RightList& right)
56  {
57  return ResultList(left.m_head, ListConcat<typename LeftList::TailType, RightList, typename type_concat< typename LeftList::TailType, RightList>::t>::Concatenate(left.m_tail, right));
58  }
59  };
60 
61  // Concatenating an empty list with a second list yields the second list
62  template <typename RightList, typename ResultList>
63  struct ListConcat<Nil, RightList, ResultList>
64  {
65  static ResultList Concatenate(const Nil&, const RightList& right)
66  {
67  return right;
68  }
69 
70  };
71 
72  // Concatenating two empty lists yields an empty list
73  template <typename ResultList>
74  struct ListConcat<Nil, Nil, ResultList>
75  {
76  static ResultList Concatenate(const Nil&, const Nil&)
77  {
78  return Nil();
79  }
80  };
81 
82  // ---- The concatenation operation
83 
84  template <typename L1, typename L2>
85  inline typename type_concat<L1, L2>::t Concatenate(const L1& list1, const L2& list2)
86  {
87  return ListConcat<L1, L2, typename type_concat<L1, L2>::t>::Concatenate(list1, list2);
88  }
89 }
90 
91 #endif
Definition: assert.h:13
Definition: constraintlist.h:40
Definition: constraintlist.h:17
Definition: constraintlist.h:53
Definition: constraintlist.h:31