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
hypercubeordering.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 -*-
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2010-11-28
7 
8  Copyright (C) 2010 Université 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 2.1 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 __HyperCubeOrdering_H
30 #define __HyperCubeOrdering_H 1
31 
33 
34 namespace Feel
35 {
36 
38 namespace details
39 {
54 template<uint16_type Order >
55 struct quad
56 {
57  static uint16_type f2e( uint16_type /*f*/, uint16_type e )
58  {
59  return __f2e[e];
60  }
61  static const uint16_type __f2e[4];
62 
63  static uint16_type f2p( uint16_type /*f*/, uint16_type p )
64  {
65  return __f2p[p];
66  }
67  static const uint16_type __f2p[4];
68 
69  static uint16_type e2p( uint16_type e, uint16_type p )
70  {
71  return e2p( e,p,boost::mpl::int_<( Order>3 )?1:Order>() );
72  }
73  static uint16_type e2p( uint16_type e, uint16_type p,boost::mpl::int_<1> )
74  {
75  return __e2p_order1[2*e+p];
76  }
77  static uint16_type e2p( uint16_type e, uint16_type p,boost::mpl::int_<2> )
78  {
79  return __e2p_order1[3*e+p];
80  }
81  static uint16_type e2p( uint16_type e, uint16_type p,boost::mpl::int_<3> )
82  {
83  return __e2p_order1[4*e+p];
84  }
85  static const uint16_type __e2p_order1[8];
86  static const uint16_type __e2p_order2[12];
87  static const uint16_type __e2p_order3[16];
88 
89  std::vector<uint16_type> entity( uint16_type /*topo_dim*/, uint16_type id ) const
90  {
91  std::vector<uint16_type> __entity( 2 );
92  __entity[0] = __e2p_order1[2*id];
93  __entity[1] = __e2p_order1[2*id+1];
94  return __entity;
95  }
96 };
97 
98 template<uint16_type Order >
99 const uint16_type quad<Order>::__e2p_order1[8] =
100 {
101  0, 1, // points in edge 0
102  1, 2, // points in edge 1
103  2, 3, // points in edge 2
104  3, 0 // points in edge 3
105 };
106 
107 template<uint16_type Order >
108 const uint16_type quad<Order>::__e2p_order2[12] =
109 {
110  0, 1, 4, // points in edge 0
111  1, 2, 5, // points in edge 1
112  2, 3, 6, // points in edge 2
113  3, 0, 7 // points in edge 3
114 };
115 
116 template<uint16_type Order >
117 const uint16_type quad<Order>::__e2p_order3[16] =
118 {
119  0, 1, 4, 5, // points in edge 0
120  1, 2, 6, 7, // points in edge 1
121  2, 3, 8, 9, // points in edge 2
122  3, 0, 10, 11 // points in edge 3
123 };
124 
125 
126 template<uint16_type Order >
127 const uint16_type quad<Order>::__f2p[4] =
128 {
129  0, // point 0
130  1, // point 1
131  2, // point 2
132  3 // point 3
133 };
134 template<uint16_type Order >
135 const uint16_type quad<Order>::__f2e[4] =
136 {
137  0, // edge 0
138  1, // edge 1
139  2, // edge 2
140  3 // edge 3
141 };
142 
143 
160 template<uint16_type Order >
161 struct hexa
162 {
163  // face to edge relations
164  static uint16_type f2e( uint16_type f, uint16_type e )
165  {
166  return __f2e[4*f+e];
167  }
168  static const uint16_type __f2e[24];
169  static int16_type f2ePermutation( uint16_type f, uint16_type e )
170  {
171  return __f2e_permutation[4*f+e];
172  }
173  static const int16_type __f2e_permutation[24];
174 
175  // face to point relations
176  static uint16_type f2p( uint16_type e, uint16_type p )
177  {
178  return f2p( e,p,boost::mpl::int_<( Order>3 )?1:Order>() );
179  }
180  static uint16_type f2p( uint16_type f, uint16_type p, boost::mpl::int_<1> )
181  {
182  return __f2p_order1[4*f+p];
183  }
184  static uint16_type f2p( uint16_type f, uint16_type p, boost::mpl::int_<2> )
185  {
186  return __f2p_order2[9*f+p];
187  }
188  static uint16_type f2p( uint16_type f, uint16_type p, boost::mpl::int_<3> )
189  {
190  return __f2p_order3[16*f+p];
191  }
192 
193  static const uint16_type __f2p_order1[24];
194  static const uint16_type __f2p_order2[54];
195  static const uint16_type __f2p_order3[96];
196 
197  // edge to point relations
198  static uint16_type e2p( uint16_type e, uint16_type p )
199  {
200  return e2p( e,p,boost::mpl::int_<( Order>3 )?1:Order>() );
201  }
202  static uint16_type e2p( uint16_type e, uint16_type p,boost::mpl::int_<1> )
203  {
204  return __e2p_order1[2*e+p];
205  }
206  static uint16_type e2p( uint16_type e, uint16_type p,boost::mpl::int_<2> )
207  {
208  return __e2p_order2[3*e+p];
209  }
210  static uint16_type e2p( uint16_type e, uint16_type p,boost::mpl::int_<3> )
211  {
212  return __e2p_order3[4*e+p];
213  }
214 
215  static const uint16_type __e2p_order1[24];
216  static const uint16_type __e2p_order2[36];
217  static const uint16_type __e2p_order3[48];
218 
219 
220  std::vector<uint16_type> entity( uint16_type topo_dim, uint16_type id ) const
221  {
222  std::vector<uint16_type> __entity( 2*topo_dim );
223 
224  if ( topo_dim == 1 )
225  {
226  __entity[0] = __e2p_order1[2*id];
227  __entity[1] = __e2p_order1[2*id+1];
228 
229  }
230 
231  else if ( topo_dim == 2 )
232  {
233  __entity[0] = __f2p_order1[4*id];
234  __entity[1] = __f2p_order1[4*id+1];
235  __entity[2] = __f2p_order1[4*id+2];
236  __entity[3] = __f2p_order1[4*id+3];
237  }
238 
239  return __entity;
240  }
241 };
242 
243 // edge to point relation
244 template<uint16_type Order >
245 const uint16_type hexa<Order>::__e2p_order1[24] =
246 {
247  0, 1, // edge 0
248  1, 2, // edge 1
249  2, 3, // edge 2
250  3, 0, // edge 3
251  1, 5, // edge 4
252  5, 4, // edge 5
253  4, 0, // edge 6
254  2, 6, // edge 7
255  6, 5, // edge 8
256  3, 7, // edge 9
257  7, 6, // edge 10
258  4, 7 // edge 11
259 };
260 
261 template<uint16_type Order >
262 const uint16_type hexa<Order>::__e2p_order2[36] =
263 {
264  0, 1, 8, // edge 0
265  1, 2, 9, // edge 1
266  2, 3, 10, // edge 2
267  3, 0, 11, // edge 3
268  1, 5, 12, // edge 4
269  5, 4, 13, // edge 5
270  4, 0, 14, // edge 6
271  2, 6, 15, // edge 7
272  6, 5, 16, // edge 8
273  3, 7, 17, // edge 9
274  7, 6, 18, // edge 10
275  4, 7, 19 // edge 11
276 };
277 
278 
279 template<uint16_type Order >
280 const uint16_type hexa<Order>::__e2p_order3[48] =
281 {
282  0, 1, 8, 9, // edge 0
283  1, 2, 10, 11, // edge 1
284  2, 3, 12, 13, // edge 2
285  3, 0, 14, 15, // edge 3
286  1, 5, 16, 17, // edge 4
287  5, 4, 18, 19, // edge 5
288  4, 0, 20, 21, // edge 6
289  2, 6, 22, 23, // edge 7
290  6, 5, 24, 25, // edge 8
291  3, 7, 26, 27, // edge 9
292  7, 6, 28, 29, // edge 10
293  4, 7, 30, 31 // edge 11
294 };
295 
296 
297 // face to point relation
298 template<uint16_type Order >
299 const uint16_type hexa<Order>::__f2p_order1[24] =
300 {
301  0, 1, 2, 3, // face 0
302  0, 1, 5, 4, // face 1
303  1, 2, 6, 5, // face 2
304  2, 3, 7, 6, // face 3
305  3, 0, 4, 7, // face 4
306  4, 5, 6, 7 // face 5
307 };
308 
309 template<uint16_type Order >
310 const uint16_type hexa<Order>::__f2p_order2[54] =
311 {
312  0, 1, 2, 3, 8, 9, 10, 11, 20, // face 0
313  0, 1, 5, 4, 8, 12, 13, 14, 21, // face 1
314  1, 2, 6, 5, 9, 15, 16, 12, 22, // face 2
315  2, 3, 7, 6, 10, 17, 18, 15, 23, // face 3
316  3, 0, 4, 7, 11, 14, 19, 17, 24, // face 4
317  4, 5, 6, 7, 13, 16, 18, 19, 25 // face 5
318 };
319 
320 
321 template<uint16_type Order >
322 const uint16_type hexa<Order>::__f2p_order3[96] =
323 {
324  0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15, 32, 33, 34, 35, // face 0
325  0, 1, 5, 4, 8, 9, 16, 17, 18, 19, 20, 21, 36, 37, 38, 39, // face 1
326  1, 2, 6, 5, 10, 11, 22, 23, 24, 25, 17, 16, 40, 41, 42, 43, // face 2
327  2, 3, 7, 6, 12, 13, 26, 27, 28, 29, 23, 22, 44, 45, 46, 47, // face 3
328  3, 0, 4, 7, 14, 15, 21, 20, 30, 31, 27, 26, 48, 49, 50, 51, // face 4
329  4, 5, 6, 7, 19, 18, 25, 24, 29, 28, 31, 30, 52, 53, 54, 55 // face 5
330 };
331 
332 // face to edge relation
333 template<uint16_type Order >
334 const uint16_type hexa<Order>::__f2e[24] =
335 {
336  0, 1, 2, 3, // face 0
337  0, 4, 5, 6, // face 1
338  1, 7, 8, 4, // face 2
339  2, 9, 10, 7, // face 3
340  3, 6, 11, 9, // face 4
341  5, 8, 10, 11 // face 5
342 };
343 
344 // edge permutation in face
345 template<uint16_type Order >
346 const int16_type hexa<Order>::__f2e_permutation[24] =
347 {
348  1, 1, 1, 1, // face 0
349  1, 1, 1, 1, // face 1
350  1, 1, 1, -1, // face 2
351  1, -1, 1, -1, // face 3
352  1, -1, 1, -1, // face 4
353  -1, -1, -1, -1 // face 5
354 };
355 
356 } // details
358 
359 
360 
361 }
362 #endif /* __HyperCubeOrdering_H */

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