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
simplex.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: 2006-02-20
7 
8  Copyright (C) 2006 EPFL
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 __Simplex_H
30 #define __Simplex_H 1
31 
32 #include <boost/detail/identifier.hpp>
33 #include <feel/feelmesh/entities.hpp>
34 #include <feel/feelmesh/convex.hpp>
35 #include <feel/feelmesh/simplexordering.hpp>
36 
37 
38 namespace Feel
39 {
40 namespace details
41 {
42 template<int Order>
43 struct points
44 {
45  typedef mpl::vector_c<size_type, 1, Order+1, ( Order+1 )*( Order+2 )/2, ( Order+1 )*( Order+2 )*( Order+3 )/6 > type;
46  typedef mpl::vector_c<size_type, 0, Order+1-2, ( Order+1-2 )*( Order+2-2 )/2, ( Order+1-2 )*( Order+2-2 )*( Order+3-2 )/6 > interior_type;
47  typedef mpl::vector_c<size_type, 0, Order+1-2, Order+1-2, Order+1-2 > edge_type;
48  typedef mpl::vector_c<size_type, 0, 0, ( Order-1 )*( Order-2 )/2, ( Order-1 )*( Order-2 )/2 > face_type;
49  typedef mpl::vector_c<size_type, 0, 0, 0, ( Order-1 )*( Order-2 )*( Order-3 )/6 > volume_type;
50 };
51 template<>
52 struct points<0>
53 {
54  typedef mpl::vector_c<size_type, 1, 1, 1, 1> type;
55  typedef mpl::vector_c<size_type, 0, 1, 1, 1> interior_type;
56  typedef mpl::vector_c<size_type, 0, 1, 0, 0> edge_type;
57  typedef mpl::vector_c<size_type, 0, 0, 1, 0> face_type;
58  typedef mpl::vector_c<size_type, 0, 0, 0, 1> volume_type;
59 };
60 
61 
62 }
63 
70 template<uint16_type Dim,
71  uint16_type Order = 1,
72  uint16_type RDim = Dim>
73 class Simplex : public Convex<Dim,Order,RDim>
74 {
75 private:
80  typedef mpl::vector_c<uint16_type, 0, 1, 3, ( 4 ) + ( 4 ) - 2> edges_t;
81  typedef mpl::vector_c<uint16_type, 0, 0, 1, 4> geo_faces_index_t;
82  typedef mpl::vector_c<uint16_type, 0, 2, 3, 4> faces_index_t;
83  typedef mpl::vector_c<uint16_type, 0, 0, 0, 1> volumes_t;
84  typedef mpl::vector_c<uint16_type, 0, 2, 3, 4> normals_t;
85 
86  typedef typename details::points<Order>::type points_t;
87  typedef typename details::points<Order>::interior_type points_interior_t;
88  typedef typename details::points<Order>::edge_type points_edge_t;
89  typedef typename details::points<Order>::face_type points_face_t;
90  typedef typename details::points<Order>::volume_type points_volume_t;
91 
92  typedef mpl::vector_c<size_type, SHAPE_POINT, SHAPE_LINE, SHAPE_TRIANGLE, SHAPE_TETRA> shapes_t;
93  typedef mpl::vector_c<size_type, GEOMETRY_POINT, GEOMETRY_LINE, GEOMETRY_SURFACE, GEOMETRY_VOLUME> geometries_t;
94 
95  static const uint16_type orderTriangle = boost::mpl::if_<boost::mpl::greater< boost::mpl::int_<Order>,
96  boost::mpl::int_<5> >,
97  boost::mpl::int_<5>,
98  typename boost::mpl::if_<boost::mpl::less< boost::mpl::int_<Order>,
99  boost::mpl::int_<1> >,
100  boost::mpl::int_<1>,
101  boost::mpl::int_<Order>
102  >::type
103  >::type::value;
104 
105  typedef mpl::vector<boost::none_t, details::line<orderTriangle>, details::triangle<orderTriangle>, details::tetra<orderTriangle> > map_entity_to_point_t;
106 
107  typedef mpl::vector_c<uint16_type, 0, 1, 2, 6> permutations_t;
108 
109  template<uint16_type rdim>
110  struct faces_t
111  {
112  typedef mpl::vector<boost::none_t,
116  };
117  typedef mpl::vector<Simplex<1, Order>, Simplex<2, Order>, Simplex<3, Order>, boost::none_t > elements_t;
118 
119 public:
120 
121  static const bool is_simplex = true;
122  static const bool is_hypercube = false;
123 
124  static const uint16_type nDim = Dim;
125  static const uint16_type nOrder = Order;
126  static const uint16_type nRealDim = RDim;
127 
128  static const uint16_type topological_dimension = nDim;
129  static const uint16_type real_dimension = nRealDim;
130 
131  static const size_type Shape = mpl::at<shapes_t, mpl::int_<nDim> >::type::value;
132  static const size_type Geometry = mpl::at<geometries_t, mpl::int_<nDim> >::type::value;
133 
134  typedef typename mpl::at<elements_t, mpl::int_<nDim> >::type element_type;
135  typedef typename mpl::at<typename faces_t<real_dimension>::type, mpl::int_<nDim> >::type topological_face_type;
136  typedef topological_face_type GeoBShape;
137 
138  static const uint16_type numVertices = nDim+1;
139  static const uint16_type numFaces = mpl::at<geo_faces_index_t, mpl::int_<nDim> >::type::value;
140  static const uint16_type numGeometricFaces = mpl::at<geo_faces_index_t, mpl::int_<nDim> >::type::value;
141  static const uint16_type numTopologicalFaces = mpl::at<faces_index_t, mpl::int_<nDim> >::type::value;
142  static const uint16_type numEdges = mpl::at<edges_t, mpl::int_<nDim> >::type::value;
143  static const uint16_type numVolumes = mpl::at<volumes_t, mpl::int_<nDim> >::type::value;
144 
145  static const uint16_type numNormals = mpl::at<normals_t, mpl::int_<nDim> >::type::value;
146 
147  static const uint16_type nbPtsPerVertex = ( nOrder==0 )?0:1;
148  static const uint16_type nbPtsPerEdge = mpl::at<points_edge_t, mpl::int_<nDim> >::type::value;
149  static const uint16_type nbPtsPerFace = mpl::at<points_face_t, mpl::int_<nDim> >::type::value;
150  static const uint16_type nbPtsPerVolume = mpl::at<points_volume_t, mpl::int_<nDim> >::type::value;
151  static const uint16_type numPoints = ( numVertices * nbPtsPerVertex +
152  numEdges * nbPtsPerEdge +
153  numFaces * nbPtsPerFace +
154  numVolumes * nbPtsPerVolume );
155 
156  typedef typename mpl::at<map_entity_to_point_t, mpl::int_<nDim> >::type edge_to_point_t;
157  typedef typename mpl::at<map_entity_to_point_t, mpl::int_<nDim> >::type face_to_point_t;
158  typedef typename mpl::at<map_entity_to_point_t, mpl::int_<nDim> >::type face_to_edge_t;
159 
160 
161  typedef no_permutation vertex_permutation_type;
162 
163  typedef typename mpl::if_<mpl::greater_equal<mpl::int_<nDim>, mpl::int_<2> >,
164  mpl::identity<line_permutations>,
165  mpl::identity<no_permutation> >::type::type edge_permutation_type;
166 
167 
168  typedef typename mpl::if_<mpl::equal_to<mpl::int_<nDim>, mpl::int_<3> >,
169  mpl::identity<triangular_faces_type>,
170  mpl::identity<no_permutation> >::type::type face_permutation_type;
171 
172  typedef typename mpl::if_<mpl::equal_to<mpl::int_<nDim>, mpl::int_<2> >,
173  mpl::identity<edge_permutation_type>,
174  typename mpl::if_<mpl::equal_to<mpl::int_<nDim>, mpl::int_<3> >,
175  mpl::identity<face_permutation_type>,
176  mpl::identity<no_permutation> >::type>::type::type permutation_type;
177 
178  template<uint16_type shape_dim, uint16_type O = Order, uint16_type R=nDim>
179  struct shape
180  {
181  typedef Simplex<shape_dim, O, R> type;
182  };
183 
184 
185  Simplex()
186  {
187  }
191  uint16_type topologicalDimension() const
192  {
193  return topological_dimension;
194  }
195 
199  uint16_type dimension() const
200  {
201  return real_dimension;
202  }
203 
207  static uint16_type nPointsOnVertex()
208  {
209  return nbPtsPerVertex;
210  }
211 
215  static uint16_type nPointsOnEdge()
216  {
217  return nbPtsPerEdge;
218  }
219 
223  static uint16_type nPointsOnFace()
224  {
225  return nbPtsPerFace;
226  }
227 
231  static uint16_type nPointsOnVolume()
232  {
233  return nbPtsPerVolume;
234  }
235 
244  static uint32_type polyDims( int n )
245  {
246  if ( nDim == 1 )
247  return std::max( 0, n + 1 );
248 
249  if ( nDim == 2 )
250  return std::max( 0, ( n+1 )*( n+2 )/2 );
251 
252  if ( nDim == 3 )
253  return std::max( 0, ( n+1 )*( n+2 )*( n+3 )/6 );
254 
255  BOOST_STATIC_ASSERT( nDim == 1 || nDim == 2 || nDim == 3 );
256  return uint32_type( -1 );
257  }
258 
264  static uint16_type e2p( uint16_type e, uint16_type p )
265  {
266  return edge_to_point_t::e2p( e, p );
267  }
268 
274  static uint16_type f2e( uint16_type f, uint16_type e )
275  {
276  return face_to_edge_t::f2e( f, e );
277  }
278 
284  static uint16_type f2eLoc( uint16_type f, uint16_type e )
285  {
286  return face_to_edge_t::f2eLoc( f, e );
287  }
288 
294  static uint16_type f2p( uint16_type f, uint16_type p )
295  {
296  return face_to_point_t::f2p( f, p );
297  }
298 
302  static std::string name()
303  {
304  std::ostringstream ostr;
305  ostr << "Simplex"
306  << "_"
307  << nDim
308  << "_"
309  << nOrder
310  << "_"
311  << nRealDim;
312  return ostr.str();
313  }
314  static std::string type()
315  {
316  return "simplex";
317  }
318 };
319 
320 template<uint16_type Dim, uint16_type Order, uint16_type RDim >
321 const uint16_type Simplex<Dim, Order, RDim>::topological_dimension;
322 
323 template<int Dim> struct Line : public Simplex<1, Dim> {};
324 template<int Dim> struct Triangle : public Simplex<2, Dim> {};
325 template<int Dim> struct Tetrahedron : public Simplex<3, Dim> {};
326 
327 
328 }
329 
330 #endif /* __Simplex_H */

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