Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bases.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2009-01-21
7 
8  Copyright (C) 2009-2011 Universite Joseph Fourier (Grenoble I)
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __Bases_H
30 #define __Bases_H 1
31 
32 #include <boost/mpl/at.hpp>
33 #include <boost/mpl/vector.hpp>
34 #include <boost/fusion/support/is_sequence.hpp>
35 #include <boost/fusion/sequence.hpp>
36 
37 namespace Feel
38 {
39 namespace mpl = boost::mpl;
40 using boost::mpl::_;
42 namespace detail
43 {
44 struct bases_base {};
45 struct meshes_base {};
46 struct periodic_base {};
54 template <class A0=mpl::void_, class A1=mpl::void_, class A2=mpl::void_, class A3=mpl::void_, class A4=mpl::void_>
55 struct bases
56  :
57  public detail::bases_base,
58  public mpl::if_<boost::is_same<A1,mpl::void_>,
59  boost::fusion::vector<A0>,
60  typename mpl::if_<boost::is_same<A2,mpl::void_>,
61  boost::fusion::vector<A0,A1>,
62  typename mpl::if_<boost::is_same<A3,mpl::void_>,
63  boost::fusion::vector<A0,A1,A2>,
64  typename mpl::if_<boost::is_same<A4,mpl::void_>,
65  boost::fusion::vector<A0,A1,A2,A3>,
66  boost::fusion::vector<A0,A1,A2,A3,A4> >::type>::type>::type>::type
67 {
68 };
69 
70 template <class BasisFusionVectorType>
71 struct bases2
72  :
73  public detail::bases_base,
74  public BasisFusionVectorType
75 {
76 };
77 } // namespace detail
79 #if FEELPP_CLANG_AT_LEAST(3,1) || FEELPP_GNUC_AT_LEAST(4,7)
80 
81 struct ChangeBasisTag
82 {
83 public:
84  template<typename Sig>
85  struct result;
86 
87  template<typename Lhs, typename Rhs>
88  struct result<ChangeBasisTag( Lhs,Rhs )>
89  {
90  typedef typename boost::remove_const<typename boost::remove_reference<Lhs>::type>::type lhs_noref_type;
91  typedef typename boost::remove_const<typename boost::remove_reference<Rhs>::type>::type rhs_noref_type;
92 
93  typedef typename fusion::result_of::size<lhs_noref_type>::type index;
94  typedef typename fusion::result_of::push_back<lhs_noref_type, typename rhs_noref_type::template ChangeTag<index::value>::type>::type type;
95  };
96 
97 };
98 template<typename... Args>
99 struct bases
100  :
101  public detail::bases_base,
102  public fusion::result_of::as_vector<typename fusion::result_of::accumulate<fusion::vector<Args...>, fusion::vector<>, ChangeBasisTag >::type>::type
103 {};
104 
105 
106 template<typename... Args>
107 struct meshes
108  :
109  public detail::meshes_base,
110  public boost::fusion::vector<Args...>
111 {
112  typedef boost::fusion::vector<Args...> super;
113  typedef meshes<Args...> this_type;
114  static const int s = sizeof...(Args);
115  meshes( super const& m) : super( m ) {}
116 };
117 
118 template<typename... Args>
119 struct Periodicity
120  :
121  public detail::periodic_base,
122  public detail::periodicity_base,
123  public boost::fusion::vector<Args...>
124 {
125  typedef boost::fusion::vector<Args...> super;
126  typedef Periodicity<Args...> this_type;
127  static const int s = sizeof...(Args);
128  Periodicity() : super() {}
129  Periodicity( super const& m) : super( m ) {}
130  Periodicity( Args... args ) : super( fusion::make_vector(args...) ) {}
131 
132  uint16_type tag1() const { return fusion::at_c<0>(*this).tag1(); }
133  uint16_type tag2() const { return fusion::at_c<0>(*this).tag2(); }
134 };
135 
136 template<typename... Args>
137 Periodicity<Args...> periodicity( Args... args )
138 { return Periodicity<Args...>( args... ); }
139 
140 #else
141 
142 
143 
144 struct void_basis : public mpl::void_
145 {
146  template<uint16_type TheNewTAG>
147  struct ChangeTag
148  {
149  typedef mpl::void_ type;
150  };
151 };
152 
153 template <class A0=void_basis, class A1=void_basis, class A2=void_basis, class A3=void_basis, class A4=void_basis>
154 struct bases
155  :
156  public detail::bases_base,
157  public mpl::if_<boost::is_same<A1,void_basis>,
158  boost::fusion::vector<typename A0::template ChangeTag<0>::type >,
159  typename mpl::if_<boost::is_same<A2,void_basis>,
160  boost::fusion::vector<typename A0::template ChangeTag<0>::type,
161  typename A1::template ChangeTag<1>::type >,
162  typename mpl::if_<boost::is_same<A3,void_basis>,
163  boost::fusion::vector<typename A0::template ChangeTag<0>::type,
164  typename A1::template ChangeTag<1>::type,
165  typename A2::template ChangeTag<2>::type >,
166  typename mpl::if_<boost::is_same<A4,void_basis>,
167  boost::fusion::vector<typename A0::template ChangeTag<0>::type,
168  typename A1::template ChangeTag<1>::type,
169  typename A2::template ChangeTag<2>::type,
170  typename A3::template ChangeTag<3>::type >,
171  boost::fusion::vector<typename A0::template ChangeTag<0>::type,
172  typename A1::template ChangeTag<1>::type,
173  typename A2::template ChangeTag<2>::type,
174  typename A3::template ChangeTag<3>::type,
175  typename A4::template ChangeTag<4>::type > >::type>::type>::type>::type
176 {
177 };
178 
179 template <class A0=mpl::void_, class A1=mpl::void_, class A2=mpl::void_, class A3=mpl::void_, class A4=mpl::void_>
180 struct meshes
181  :
182  public detail::meshes_base,
183  public mpl::if_<boost::is_same<A0,mpl::void_>,
184  boost::fusion::vector<>,
185  typename mpl::if_<boost::is_same<A1,mpl::void_>,
186  boost::fusion::vector<A0>,
187  typename mpl::if_<boost::is_same<A2,mpl::void_>,
188  boost::fusion::vector<A0,A1>,
189  typename mpl::if_<boost::is_same<A3,mpl::void_>,
190  boost::fusion::vector<A0,A1,A2>,
191  typename mpl::if_<boost::is_same<A4,mpl::void_>,
192  boost::fusion::vector<A0,A1,A2,A3>,
193  boost::fusion::vector<A0,A1,A2,A3,A4> >::type>::type>::type>::type>::type
194 
195 {
196  typedef typename mpl::if_<boost::is_same<A0,mpl::void_>,
197  boost::fusion::vector<>,
198  typename mpl::if_<boost::is_same<A1,mpl::void_>,
199  boost::fusion::vector<A0>,
200  typename mpl::if_<boost::is_same<A2,mpl::void_>,
201  boost::fusion::vector<A0,A1>,
202  typename mpl::if_<boost::is_same<A3,mpl::void_>,
203  boost::fusion::vector<A0,A1,A2>,
204  typename mpl::if_<boost::is_same<A4,mpl::void_>,
205  boost::fusion::vector<A0,A1,A2,A3>,
206  boost::fusion::vector<A0,A1,A2,A3,A4> >::type>::type>::type>::type>::type super;
207 
208  typedef meshes<A0,A1,A2,A3,A4> this_type;
209  meshes( super const& m ) : super( m ) {}
210 };
211 
212 template <class A0=mpl::void_, class A1=mpl::void_, class A2=mpl::void_, class A3=mpl::void_, class A4=mpl::void_>
213 struct Periodicity
214  :
215  public detail::periodic_base,
216  public detail::periodicity_base,
217  public mpl::if_<boost::is_same<A0,mpl::void_>,
218  boost::fusion::vector<>,
219  typename mpl::if_<boost::is_same<A1,mpl::void_>,
220  boost::fusion::vector<A0>,
221  typename mpl::if_<boost::is_same<A2,mpl::void_>,
222  boost::fusion::vector<A0,A1>,
223  typename mpl::if_<boost::is_same<A3,mpl::void_>,
224  boost::fusion::vector<A0,A1,A2>,
225  typename mpl::if_<boost::is_same<A4,mpl::void_>,
226  boost::fusion::vector<A0,A1,A2,A3>,
227  boost::fusion::vector<A0,A1,A2,A3,A4> >::type>::type>::type>::type>::type
228 
229 {
230  typedef typename mpl::if_<boost::is_same<A0,mpl::void_>,
231  boost::fusion::vector<>,
232  typename mpl::if_<boost::is_same<A1,mpl::void_>,
233  boost::fusion::vector<A0>,
234  typename mpl::if_<boost::is_same<A2,mpl::void_>,
235  boost::fusion::vector<A0,A1>,
236  typename mpl::if_<boost::is_same<A3,mpl::void_>,
237  boost::fusion::vector<A0,A1,A2>,
238  typename mpl::if_<boost::is_same<A4,mpl::void_>,
239  boost::fusion::vector<A0,A1,A2,A3>,
240  boost::fusion::vector<A0,A1,A2,A3,A4> >::type>::type>::type>::type>::type super;
241 
242  typedef Periodicity<A0,A1,A2,A3,A4> this_type;
243  Periodicity() : super() {}
244  Periodicity( super const& m ) : super( m ) {}
245  Periodicity( A0 a0 ) : super( fusion::make_vector(a0) ) {}
246  Periodicity( A0 a0, A1 a1 ) : super( fusion::make_vector(a0,a1) ) {}
247  Periodicity( A0 a0, A1 a1, A2 a2 ) : super( fusion::make_vector(a0,a1,a2) ) {}
248  Periodicity( A0 a0, A1 a1, A2 a2, A3 a3 ) : super( fusion::make_vector(a0,a1,a2,a3) ) {}
249 
250  uint16_type tag1() const { return fusion::at_c<0>(*this).tag1(); }
251  uint16_type tag2() const { return fusion::at_c<0>(*this).tag2(); }
252 };
253 
254 template<typename A0> Periodicity<A0> periodicity( A0 const& a0 ) { return Periodicity<A0>( a0 ); }
255 template<typename A0,typename A1> Periodicity<A0,A1> periodicity( A0 const& a0, A1 const& a1 ) { return Periodicity<A0,A1>( a0,a1 ); }
256 template<typename A0,typename A1,typename A2> Periodicity<A0,A1,A2> periodicity( A0 const& a0, A1 const& a1, A2 const& a2 ) { return Periodicity<A0,A1,A2>( a0,a1,a2 ); }
257 
258 #endif
259 
260 }// Feel
261 
262 #endif /* __Bases_H */

Generated on Fri Oct 25 2013 14:24:04 for Feel++ by doxygen 1.8.4