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
gmshenums.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: 2010-07-15
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 __GmshEnums_H
30 #define __GmshEnums_H 1
31 
32 #include <boost/bimap.hpp>
33 #include <boost/assign/list_of.hpp>
34 namespace Feel
35 {
36 enum GMSH_PARTITIONER
37 {
38  GMSH_PARTITIONER_CHACO = 1,
39  GMSH_PARTITIONER_METIS = 2
40 
41 };
42 
43 extern const GMSH_PARTITIONER GMSH_PARTITIONER_DEFAULT;
44 
45 
46 enum GMSH_ORDER
47 {
48  GMSH_ORDER_ONE = 1,
49  GMSH_ORDER_TWO = 2,
50  GMSH_ORDER_THREE = 3,
51  GMSH_ORDER_FOUR = 4,
52  GMSH_ORDER_FIVE = 5
53 };
54 
55 enum GMSH_FORMAT
56 {
57  GMSH_FORMAT_ASCII = 0,
58  GMSH_FORMAT_BINARY = 1
59 };
60 
61 
68 {
69  GMSH_LINE = 1,
74  GMSH_PRISM = 6,
77  //with the vertices and 1 with the edge).
79  //associated with the vertices and 3 with the
80  //edges).
82  //associated with the vertices, 4 with the
83  //edges and 1 with the face).
85  //4 associated with the vertices and 6
86  //with the edges).
88  //associated with the vertices, 12 with
89  //the edges, 6 with the faces and 1 with
90  //the volume).
91  GMSH_PRISM_2 = 13,
92  //with the vertices, 9 with the edges and 3 with
93  //the quadrangular faces).
95  //associated with the vertices, 8 with the
96  //edges and 1 with the quadrangular face).
97  GMSH_POINT = 15,
98 
105 
109 
113 };
114 
115 template<typename ConvexType>
116 class GmshOrdering
117 {
118 public:
119  typedef boost::bimap<int,int> id_type;
120  GmshOrdering();
121  ~GmshOrdering() {}
122 
126  int type() const
127  {
128  return M_type;
129  }
130 
134  int size() const
135  {
136  return M_id.size();
137  }
138 
142  int fromGmshId( int p ) const
143  {
144  return M_id.right.at( p );
145  }
146 
150  int toGmshId( int p ) const
151  {
152  return M_id.left.at( p );
153  }
154 
158  int id( int p ) const
159  {
160  return M_id.left.at( p );
161  }
162 
163 private:
164 
165  int M_type;
166  id_type M_id;
167 };
168 
170 namespace detail
171 {
172 const int line_type[6] = { 0, GMSH_LINE, GMSH_LINE_2, GMSH_LINE_3, GMSH_LINE_4, GMSH_LINE_5 };
173 const int triangle_type[6] = { 0, GMSH_TRIANGLE, GMSH_TRIANGLE_2, GMSH_TRIANGLE_3, GMSH_TRIANGLE_4, GMSH_TRIANGLE_5 };
175 
176 
177 
178 const int quad_type[6] = { 0, GMSH_QUADRANGLE, GMSH_QUADRANGLE_2, 0, 0, 0 };
179 const int hexa_type[6] = { 0, GMSH_HEXAHEDRON, GMSH_HEXAHEDRON_2, 0, 0, 0 };
180 
181 //int gmshquadtype[5] = { 0, 4, 10, 0, 0 };
182 }
184 
185 template<typename ConvexType>
186 GmshOrdering<ConvexType>::GmshOrdering()
187 {
188  using namespace boost::assign;
189  typedef typename id_type::relation relation;
190 
191  if ( ConvexType::nDim == 0 )
192  {
193  M_type = GMSH_POINT;
194 
195  for ( int i = 0; i < ConvexType::numPoints; ++i )
196  M_id.insert( id_type::value_type( i, i ) );
197  }
198 
199  else if ( ConvexType::is_simplex )
200  {
201  if ( ConvexType::nDim == 1 )
202  {
203  M_type = detail::line_type[ConvexType::nOrder];
204 
205  for ( int i = 0; i < ConvexType::numPoints; ++i )
206  M_id.insert( id_type::value_type( i, i ) );
207  }
208 
209  if ( ConvexType::nDim == 2 )
210  {
211  M_type = detail::triangle_type[ConvexType::nOrder];
212 
213  if ( ConvexType::nOrder == 1 )
214  M_id = list_of<relation>( 0,0 )( 1,1 )( 2,2 );
215 
216  //M_id+=0,1,2;
217  if ( ConvexType::nOrder == 2 )
218  M_id = list_of<relation>( 0,0 )( 1,1 )( 2,2 )( 3,4 )( 4,5 )( 5,3 );
219 
220  //M_id += 0,1,2,5,3,4;
221  if ( ConvexType::nOrder == 3 )
222  M_id = list_of<relation>( 0,0 )( 1,1 )( 2,2 )( 3,5 )( 4,6 )( 5,7 )( 6,8 )( 7,3 )( 8,4 )( 9,9 );
223 
224  //M_id += 0,1,2,7,8,3,4,5,6,9;
225  if ( ConvexType::nOrder == 4 )
226  M_id = list_of<relation>( 0,0 )( 1,1 )( 2,2 )( 3,6 )( 4,7 )( 5,8 )( 6,9 )( 7,10 )( 8,11 )( 9,3 )( 10,4 )( 11,5 )( 12,12 )( 13,13 )( 14,14 );
227 
228  //M_id += 0,1,2,9,10,11,3,4,5,6,7,8,12,13,14;
229  if ( ConvexType::nOrder == 5 )
230  M_id = list_of<relation>( 0,0 )( 1,1 )( 2,2 )( 3,7 )( 4,8 )( 5,9 )( 6,10 )( 7,11 )( 8,12 )( 9,13 )( 10,14 )( 11,3 )( 12,4 )( 13,5 )( 14,6 )( 15,15 )( 16,18 )( 17,16 )( 18,20 )( 19,19 )( 20,17 );
231 
232  //M_id += 0,1,2,11,12,13,14,3,4,5,6,7,8,9,10,15,16,17,19,20,18;
233  }
234 
235  if ( ConvexType::nDim == 3 )
236  {
237  M_type = detail::tetrahedron_type[ConvexType::nOrder];
238 
239  if ( ConvexType::nOrder == 1 )
240  M_id = list_of<relation>
241  ( 0,0 )( 1,1 )( 2,2 )( 3,3 ) // vertices
242  ;
243 
244  //M_id+=0,1,2,3;
245  if ( ConvexType::nOrder == 2 )
246  M_id = list_of<relation>
247  ( 0,0 )( 1,1 )( 2,2 )( 3,3 ) // vertices
248  ( 4,5 ) // edge 0
249  ( 5,6 ) // edge 1
250  ( 6,4 ) // edge 2
251  ( 7,7 ) // edge 3
252  ( 8,9 ) // edge 4
253  ( 9,8 ) // edge 5
254  ;
255 
256  //M_id+=0,1,2,3,6,4,5,7,9,8;
257  if ( ConvexType::nOrder == 3 )
258  M_id = list_of<relation>
259  ( 0,0 )( 1,1 )( 2,2 )( 3,3 ) // vertices
260  ( 4,6 )( 5,7 ) // edge 0
261  ( 6,8 )( 7,9 ) // edge 1
262  ( 8,4 )( 9,5 ) // edge 2
263  ( 10,11 )( 11,10 ) // edge 3
264  ( 12,15 )( 13,14 ) // edge 4
265  ( 14,13 )( 15,12 ) // edge 5
266  ( 16,19 ) // face 0
267  ( 17,18 ) // face 1
268  ( 18,17 ) // face 2
269  ( 19,16 ) // face 3
270  ;
271 
272  if ( ConvexType::nOrder == 4 )
273  M_id = list_of<relation>
274  ( 0,0 )( 1,1 )( 2,2 )( 3,3 ) // vertices
275  ( 4,7 )( 5,8 )( 6,9 ) // edge 0
276  ( 7,10 )( 8,11 )( 9,12 ) // edge 1
277  ( 10,4 )( 11,5 )( 12,6 ) // edge 2
278  ( 13,15 )( 14,14 )( 15,13 ) // edge 3
279  ( 16,21 )( 17,20 )( 18,19 ) // edge 4
280  ( 19,18 )( 20,17 )( 21,16 ) // edge 5
281  ( 22,32 )( 23,33 )( 24,31 ) // face 0
282  ( 25,28 )( 26,30 )( 27,29 ) // face 1
283  ( 28,25 )( 29,26 )( 30,27 ) // face 2
284  ( 31,22 )( 32,24 )( 33,23 ) // face 3
285  ( 34,34 ) // interior point
286  ;
287 
288  if ( ConvexType::nOrder > 4 )
289  for ( int i = 0; i < ConvexType::numPoints; ++i )
290  M_id.insert( id_type::value_type( i, i ) );
291 
292  }
293  }
294 
295  else
296  {
297 
298  if ( ConvexType::nDim == 1 )
299  {
300  M_type = detail::line_type[ConvexType::nOrder];
301 
302  for ( int i = 0; i < ConvexType::numPoints; ++i )
303  M_id.insert( id_type::value_type( i, i ) );
304  }
305 
306  if ( ConvexType::nDim == 2 )
307  {
308  M_type = detail::quad_type[ConvexType::nOrder];
309 
310  if ( ConvexType::nOrder == 1 )
311  M_id = list_of<relation>( 0,0 )( 1,1 )( 2,2 )( 3,3 );
312 
313  //M_id+=0,1,2,3;
314  if ( ConvexType::nOrder == 2 )
315  M_id = list_of<relation>( 0,0 )( 1,1 )( 2,2 )( 3,3 ) // vertices
316  ( 4,4 ) // edge 0
317  ( 5,5 ) // edge 1
318  ( 6,6 ) // edge 2
319  ( 7,7 ) // edge 3
320  ( 8,8 ) // face 0
321  ;
322  }
323 
324  if ( ConvexType::nDim == 3 )
325  {
326  M_type = detail::hexa_type[ConvexType::nOrder];
327 
328  if ( ConvexType::nOrder == 1 )
329  M_id = list_of<relation>( 0,0 )( 1,1 )( 2,2 )( 3,3 )( 4,4 )( 5,5 )( 6,6 )( 7,7 );
330 
331  if ( ConvexType::nOrder == 2 )
332  M_id = list_of<relation>
333  ( 0,0 )( 1,1 )( 2,2 )( 3,3 )( 4,4 )( 5,5 )( 6,6 )( 7,7 ) // vertices
334  ( 8,8 ) // edge 0
335  ( 9,11 ) // edge 1
336  ( 10,13 ) // edge 2
337  ( 11,9 ) // edge 3
338  ( 12,12 ) // edge 4
339  ( 13,16 ) // edge 5
340  ( 14,10 ) // edge 6
341  ( 15,14 ) // edge 7
342  ( 16,18 ) // edge 8
343  ( 17,15 ) // edge 9
344  ( 18,19 ) // edge 10
345  ( 19,17 ) // edge 11
346  ( 20,20 ) // face 0
347  ( 21,21 ) // face 1
348  ( 22,23 ) // face 2
349  ( 23,24 ) // face 3
350  ( 24,22 ) // face 4
351  ( 25,25 ) // face 5
352  ( 26,26 ) // volume 0
353  ;
354 
355  //M_id+=0,1,2,3,4,5,6,7;
356  }
357 
358  }
359 }
360 
361 } // Feel
362 
363 #endif /* __GmshEnums_H */

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