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
entities.hpp
1 /*
2  This file is part of the Feel library
3  Copyright (C) 2001,2002,2003,2004 EPFL, INRIA and Politechnico di Milano
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 3.0 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
20 #ifndef _GEOENTITY_HH_
21 #define _GEOENTITY_HH_
22 
23 #include <vector>
24 
25 #include <boost/version.hpp>
26 #if (BOOST_VERSION >= 103400)
27 #include <boost/none.hpp>
28 #else
29 #include <boost/none_t.hpp>
30 #endif /* BOOST_VERSION >= 103400 */
31 
32 #include <boost/mpl/vector.hpp>
33 #include <boost/mpl/vector_c.hpp>
34 #include <boost/operators.hpp>
35 
36 #include <feel/feelcore/feel.hpp>
37 #include <feel/feelcore/context.hpp>
38 
39 namespace Feel
40 {
41 
42 enum FaceLocation { INTERNAL = false, ON_BOUNDARY = true };
43 
48 {
49  MESH_ENTITY_INTERNAL = ( 1<<0 ),
51 };
52 
58 {
59  GEOMETRY_POINT = ( 1<<0 ),
60  GEOMETRY_LINE = ( 1<<1 ),
61  GEOMETRY_SURFACE = ( 1<<2 ),
62  GEOMETRY_VOLUME = ( 1<<3 ),
63  GEOMETRY_4 = ( 1<<4 ),
64  GEOMETRY_5 = ( 1<<5 )
65 };
66 
71 enum ReferenceShapes
72 {
73  SHAPE_LINEAR = ( 1<<0 ),
74  SHAPE_BILINEAR = ( 1<<1 ),
75  SHAPE_QUADRATIC= ( 1<<2 ),
76  SHAPE_NONE = ( 1<<3 ),
77  SHAPE_POINT = ( 1<<4 ),
78  SHAPE_LINE = ( 1<<5 ),
79  SHAPE_TRIANGLE = ( 1<<6 ),
80  SHAPE_QUAD = ( 1<<7 ),
81  SHAPE_HEXA = ( 1<<8 ),
82  SHAPE_PRISM = ( 1<<9 ),
83  SHAPE_TETRA = ( 1<<10 ),
84  SHAPE_SP4 = ( 1<<11 ),
85  SHAPE_SP5 = ( 1<<12 )
86 };
87 
92 
94 
97 template<typename E>
98 class EntityRange
99 {
100  template<uint16_type td>
101  struct num
102  {
103  typedef typename mpl::if_<mpl::equal_to<mpl::int_<td>, mpl::int_<0> >,
104  mpl::int_<E::numVertices>,
105  typename mpl::if_<mpl::equal_to<mpl::int_<td>, mpl::int_<1> >,
106  mpl::int_<E::numEdges>,
107  typename mpl::if_<mpl::equal_to<mpl::int_<td>, mpl::int_<2> >,
108  mpl::int_<E::numGeometricFaces>,
109  mpl::int_<E::numVolumes>
110  >::type // int_<2>
111  >::type // int_<1>
112  >::type type;
113  static const uint16_type value = type::value;
114  };
115  uint16_type d;
116 public:
117  EntityRange( uint16_type td = 0 )
118  :
119  d( td )
120  {
121  check_invariant();
122  }
123  EntityRange( EntityRange const& r ) : d( r.d ) {}
124  ~EntityRange() {}
125 
126  uint16_type topologicalDimension() const
127  {
128  return d;
129  }
130 
131  void setTopologicalDimension( uint16_type td )
132  {
133  d = td;
134  check_invariant();
135  }
136 
137  uint16_type begin() const
138  {
139  return 0;
140  }
141  uint16_type end() const
142  {
143  if ( d == 0 )
144  return num<0>::value;
145 
146  if ( d == 1 )
147  return num<1>::value;
148 
149  if ( d == 2 )
150  return num<2>::value;
151 
152  if ( d == 3 )
153  return num<3>::value;
154 
155  return num<0>::value;
156  }
157 private:
158  void check_invariant()
159  {
160  //FEELPP_ASSERT( d <= E::topological_dimension )( d )( E::topological_dimension ).error( "invalid topological dimension" );
161  }
162 };
163 
164 
165 namespace details
166 {
167 template<int N, int P>
168 struct pow
169 {
170  static const size_type value = N*pow<N, P-1>::value;
171 };
172 template<int N>
173 struct pow<N, 0>
174 {
175  static const size_type value = 1;
176 };
177 }
178 
185 struct no_permutation: public boost::detail::identifier<uint16_type, no_permutation>
186 {
187  static const uint16_type NO_PERMUTATION = 0;
188  static const uint16_type IDENTITY = 1;
189  static const uint16_type N_PERMUTATIONS = 2;
190  typedef boost::detail::identifier<uint16_type, no_permutation> super;
191  typedef super::value_type value_type;
192  no_permutation() : super( IDENTITY ) {}
193  explicit no_permutation( value_type v ) : super( v ) {}
194  no_permutation & operator=( value_type v )
195  {
196  this->assign( v );
197  return *this;
198  }
199  no_permutation& operator++()
200  {
201  this->assign( this->value()+1 );
202  return *this;
203  }
204 };
205 
206 
213 struct line_permutations: public boost::detail::identifier<uint16_type, line_permutations>
214 {
215  static const uint16_type NO_PERMUTATION = 0;
216  static const uint16_type IDENTITY = 1;
217  static const uint16_type REVERSE_PERMUTATION = 2;
218  static const uint16_type N_PERMUTATIONS = 3;
219  typedef boost::detail::identifier<uint16_type, line_permutations> super;
220  typedef super::value_type value_type;
221  line_permutations() : super( IDENTITY ) {}
222  explicit line_permutations( value_type v ) : super( v ) {}
223  line_permutations& operator=( value_type v )
224  {
225  this->assign( v );
226  return *this;
227  }
228  line_permutations& operator++()
229  {
230  this->assign( this->value()+1 );
231  return *this;
232  }
233 };
234 
235 enum line_permutations_dummy {};
236 
237 struct triangular_faces_type: public boost::detail::identifier<uint16_type, triangular_faces_type>
238 {
239  static const uint16_type NO_PERMUTATION = 0;
240  static const uint16_type IDENTITY = 1;
241  static const uint16_type REVERSE_HEIGHT = 2;
242  static const uint16_type REVERSE_BASE = 3;
243  static const uint16_type REVERSE_HYPOTENUSE = 4;
244  static const uint16_type ROTATION_ANTICLOCK = 5;
245  static const uint16_type ROTATION_CLOCKWISE = 6;
246  static const uint16_type N_PERMUTATIONS = 7;
247 
248  static const uint16_type PRINCIPAL_DIAGONAL = 4;
249  static const uint16_type SECOND_DIAGONAL = 7;
250  static const uint16_type ROTATION_TWICE_CLOCKWISE = 8;
251 
252  typedef boost::detail::identifier<uint16_type, triangular_faces_type> super;
253  typedef super::value_type value_type;
254  triangular_faces_type() : super( IDENTITY ) {}
255  explicit triangular_faces_type( value_type v ) : super( v ) {}
257  triangular_faces_type & operator=( value_type v )
258  {
259  this->assign( v );
260  return *this;
261  }
262  triangular_faces_type& operator++()
263  {
264  this->assign( this->value()+1 );
265  return *this;
266  }
267 };
268 
269 struct quadrangular_faces: public boost::detail::identifier<uint16_type, quadrangular_faces>
270 {
271  static const uint16_type NO_PERMUTATION = 0;
272  static const uint16_type IDENTITY = 1;
273  static const uint16_type REVERSE_HEIGHT = 2;
274  static const uint16_type REVERSE_BASE = 3;
275  static const uint16_type PRINCIPAL_DIAGONAL = 4;
276  static const uint16_type ROTATION_ANTICLOCK = 5;
277  static const uint16_type ROTATION_CLOCKWISE = 6;
278  static const uint16_type SECOND_DIAGONAL = 7;
279  static const uint16_type ROTATION_TWICE_CLOCKWISE = 8;
280 
281  static const uint16_type N_PERMUTATIONS = 9;
282 
283  static const uint16_type REVERSE_HYPOTENUSE = 4;
284 
285  typedef boost::detail::identifier<uint16_type, quadrangular_faces> super;
286  typedef super::value_type value_type;
287  quadrangular_faces() : super( IDENTITY ) {}
288  explicit quadrangular_faces( value_type v ) : super( v ) {}
289  //quadrangular_faces( quadrangular_faces const& tft ) : super( tft ) { value( tft.value() ); }
290  quadrangular_faces & operator=( value_type v )
291  {
292  this->assign( v );
293  return *this;
294  }
295  quadrangular_faces& operator++()
296  {
297  this->assign( this->value()+1 );
298  return *this;
299  }
300 };
302 
303 } // Feel
304 #endif

Generated on Sun Oct 20 2013 08:24:56 for Feel++ by doxygen 1.8.4