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
hypercube.hpp
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
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 __Hypercube_H
30 #define __Hypercube_H 1
31 
32 #include <boost/detail/identifier.hpp>
33 #include <feel/feelcore/traits.hpp>
34 #include <feel/feelmesh/entities.hpp>
35 #include <feel/feelmesh/convex.hpp>
37 
38 
39 namespace Feel
40 {
41 
42 template<uint16_type Dim, uint16_type Order=1, uint16_type RDim = Dim>
43 class Hypercube : public Convex<Dim,Order,RDim>
44 {
45  typedef mpl::vector_c<size_type, SHAPE_POINT, SHAPE_LINE, SHAPE_QUAD, SHAPE_HEXA, SHAPE_SP4, SHAPE_SP5> shapes_t;
46  typedef mpl::vector_c<size_type, GEOMETRY_POINT, GEOMETRY_LINE, GEOMETRY_SURFACE, GEOMETRY_VOLUME, GEOMETRY_4, GEOMETRY_5> geometries_t;
47 
48  typedef mpl::vector_c<size_type, 1, 2, 4, 8, 16, 32> vertices_t;
49  typedef mpl::vector_c<size_type, 0, 1, 4, 12, 32> edges_t;
50  typedef mpl::vector_c<size_type, 0, 2, 4, 6, 24> faces_index_t;
51  typedef mpl::vector_c<uint16_type, 0, 0, 1, 6, 24> geo_faces_index_t;
52  typedef mpl::vector_c<uint16_type, 0, 2, 4, 6, 24> normals_t;
53  typedef mpl::vector_c<uint16_type, 0, 0, 0, 1, 8> volumes_t;
54 
55  typedef mpl::vector_c<size_type, 1, Order+1, ( Order+1 )*( Order+1 ), ( Order+1 )*( Order+1 )*( Order+1 ) , ( Order+1 )*( Order+1 )*( Order+1 )*( Order+1 )> points_t;
56  typedef mpl::vector_c<size_type, 0, Order+1-2, ( Order+1-2 )*( Order+1-2 ), ( Order+1-2 )*( Order+1-2 )*( Order+1-2 ) , ( Order+1-2 )*( Order+1-2 )*( Order+1-2 )*( Order+1-2 )> points_interior_t;
57  typedef mpl::vector_c<size_type, 0, Order+1-2, Order+1-2, ( Order+1-2 ), ( Order+1-2 )> points_edge_t;
58  typedef mpl::vector_c<size_type, 0, 0, ( Order+1-2 )*( Order+1-2 ), ( Order+1-2 )*( Order+1-2 ), ( Order+1-2 )*( Order+1-2 ) > points_face_t;
59  typedef mpl::vector_c<size_type, 0, 0, 0, ( Order+1-2 )*( Order+1-2 )*( Order+1-2 ), ( Order+1-2 )*( Order+1-2 )*( Order+1-2 ) > points_volume_t;
60 
61  template<uint16_type rdim>
62  struct faces_t
63  {
64  typedef mpl::vector<boost::none_t,
65  Hypercube<0, Order, rdim>,
66  Hypercube<1, Order, rdim>,
67  Hypercube<2, Order, rdim> > type;
68  };
69  typedef mpl::vector<Hypercube<1, Order>, Hypercube<2, Order>, Hypercube<3, Order>, Hypercube<4, Order>, boost::none_t > elements_t;
70 
71  typedef mpl::vector_c<uint16_type, 0, 1, 2, 8> permutations_t;
72 
73 public:
74 
75  static const bool is_simplex = false;
76  static const bool is_hypercube = true;
77 
78  static const size_type Shape = mpl::at<shapes_t, mpl::int_<Dim> >::type::value;
79  static const size_type Geometry = mpl::at<geometries_t, mpl::int_<Dim> >::type::value;
80 
81  static const uint16_type nDim = Dim;
82  static const uint16_type nOrder = Order;
83  static const uint16_type nRealDim = RDim;
84 
85  static const uint16_type topological_dimension = nDim;
86  static const uint16_type real_dimension = RDim;
87 
88  typedef typename mpl::at<elements_t, mpl::int_<nDim> >::type element_type;
89  typedef typename mpl::at<typename faces_t<real_dimension>::type, mpl::int_<nDim> >::type topological_face_type;
90 
91  static const uint16_type numVertices = mpl::at<vertices_t, mpl::int_<Dim> >::type::value;
92  static const uint16_type numEdges = mpl::at<edges_t, mpl::int_<Dim> >::type::value;
93  static const uint16_type numFaces = mpl::at<geo_faces_index_t, mpl::int_<Dim> >::type::value;
94  static const uint16_type numGeometricFaces = mpl::at<geo_faces_index_t, mpl::int_<nDim> >::type::value;
95  static const uint16_type numTopologicalFaces = mpl::at<faces_index_t, mpl::int_<nDim> >::type::value;
96  static const uint16_type numNormals = mpl::at<normals_t, mpl::int_<nDim> >::type::value;
97  static const uint16_type numVolumes = mpl::at<volumes_t, mpl::int_<nDim> >::type::value;
98 
99  static const uint16_type nbPtsPerVertex = ( nOrder==0 )?0:1;
100  static const uint16_type nbPtsPerEdge = ( nOrder==0 )?( ( nDim==1 )?1:0 ):mpl::at<points_edge_t, mpl::int_<nDim> >::type::value;
101  static const uint16_type nbPtsPerFace = ( nOrder==0 )?( ( nDim==2 )?1:0 ):mpl::at<points_face_t, mpl::int_<nDim> >::type::value;
102  static const uint16_type nbPtsPerVolume = ( nOrder==0 )?( ( nDim==3 )?1:0 ):mpl::at<points_volume_t, mpl::int_<nDim> >::type::value;
103  static const uint16_type numPoints = ( numVertices * nbPtsPerVertex +
104  numEdges * nbPtsPerEdge +
105  numFaces * nbPtsPerFace +
106  numVolumes * nbPtsPerVolume );
107 
108  static const uint16_type orderSquare = boost::mpl::if_<boost::mpl::greater< boost::mpl::int_<Order>,
109  boost::mpl::int_<5> >,
110  boost::mpl::int_<5>,
111  typename boost::mpl::if_<boost::mpl::less< boost::mpl::int_<Order>,
112  boost::mpl::int_<1> >,
113  boost::mpl::int_<1>,
114  boost::mpl::int_<Order>
115  >::type
116  >::type::value;
117 
118 
119  typedef mpl::vector<boost::none_t, details::line<orderSquare>, details::quad<orderSquare>, details::hexa<orderSquare> > map_entity_to_point_t;
120  typedef typename mpl::at<map_entity_to_point_t, mpl::int_<nDim> >::type edge_to_point_t;
121  typedef typename mpl::at<map_entity_to_point_t, mpl::int_<nDim> >::type face_to_point_t;
122  typedef typename mpl::at<map_entity_to_point_t, mpl::int_<nDim> >::type face_to_edge_t;
123 
124 
125  typedef no_permutation vertex_permutation_type;
126 
127  typedef typename mpl::if_<mpl::greater_equal<mpl::int_<nDim>, mpl::int_<2> >,
128  mpl::identity<line_permutations>,
129  mpl::identity<no_permutation> >::type::type edge_permutation_type;
130 
131 
132  typedef typename mpl::if_<mpl::equal_to<mpl::int_<nDim>, mpl::int_<3> >,
133  mpl::identity<quadrangular_faces>,
134  mpl::identity<no_permutation> >::type::type face_permutation_type;
135 
136  typedef typename mpl::if_<mpl::equal_to<mpl::int_<nDim>, mpl::int_<2> >,
137  mpl::identity<edge_permutation_type>,
138  typename mpl::if_<mpl::equal_to<mpl::int_<nDim>, mpl::int_<3> >,
139  mpl::identity<face_permutation_type>,
140  mpl::identity<no_permutation> >::type>::type::type permutation_type;
141 
142  template<uint16_type shape_dim, uint16_type O = Order, uint16_type R=nDim>
143  struct shape
144  {
145  typedef Hypercube<shape_dim, O, R> type;
146  };
147 
148 
152  uint16_type topologicalDimension() const
153  {
154  return topological_dimension;
155  }
156 
160  uint16_type dimension() const
161  {
162  return real_dimension;
163  }
164 
168  static uint16_type nPointsOnVertex()
169  {
170  return nbPtsPerVertex;
171  }
172 
176  static uint16_type nPointsOnEdge()
177  {
178  return nbPtsPerEdge;
179  }
180 
184  static uint16_type nPointsOnFace()
185  {
186  return nbPtsPerFace;
187  }
188 
192  static uint16_type nPointsOnVolume()
193  {
194  return nbPtsPerVolume;
195  }
196 
204  template<int N>
205  struct PolyDims
206  {
207  static const uint32_type value = mpl::if_<mpl::equal_to<mpl::int_<nDim>,mpl::int_<3> >,
208  mpl::identity<mpl::int_<( N+1 )*( N+1 )*( N+1 )> >,
209  typename mpl::if_<mpl::equal_to<mpl::int_<nDim>,mpl::int_<2> >,
210  mpl::identity<mpl::int_<( N+1 )*( N+1 )> >,
211  mpl::identity<mpl::int_<( N+1 )> > >::type>::type::value;
212  };
213  static uint32_type polyDims( int n )
214  {
215  return uint32_type( math::pow( double( n+1 ), double( nDim ) ) );
216  }
217 
223  static int e2p( int e, int p )
224  {
225  return edge_to_point_t::e2p( e, p );
226  }
227 
233  static int f2e( int f, int e )
234  {
235  return face_to_edge_t::f2e( f, e );
236  }
237 
243  static int f2p( int f, int p )
244  {
245  return face_to_point_t::f2p( f, p );
246  }
247 
251  static std::string name()
252  {
253  std::ostringstream ostr;
254  ostr << "Hypercube"
255  << "_"
256  << nDim
257  << "_"
258  << nOrder
259  << "_"
260  << nRealDim;
261  return ostr.str();
262  }
263  static std::string type()
264  {
265  return "hypercube";
266  }
267 };
268 
269 }
270 #endif /* __Hypercube_H */

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