1 #ifndef MOAB_PARAMETRIZER_HPP
2 #define MOAB_PARAMETRIZER_HPP
3 #include "moab/Matrix3.hpp"
4 #include "moab/CartVect.hpp"
5 #include "moab/ElemUtil.hpp"
6 namespace moab
7 {
8
9 namespace element_utility
10 {
11
12 namespace
13 {
14
15 template < typename Moab, typename Entity_handle, typename Points >
16 void get_moab_points( Moab& moab, Entity_handle eh, Points& points )
17 {
18 const Entity_handle* connectivity_begin;
19 int num_vertices;
20 moab.get_connectivity( eh, connectivity_begin, num_vertices );
21
22
23
24
25 points.resize( num_vertices );
26 moab.get_coords( connectivity_begin, num_vertices, &( points[0][0] ) );
27 }
28
29 }
30
31 template < typename Element_map >
32 class Element_parametrizer
33 {
34 public:
35
36 typedef Element_map Map;
37
38 private:
39 typedef Element_parametrizer< Map > Self;
40
41 public:
42 Element_parametrizer() : map() {}
43 Element_parametrizer( const Self& f ) : map( f.map ) {}
44
45 public:
46 template < typename Moab, typename Entity_handle, typename Point >
47 std::pair< bool, Point > operator()( Moab& moab, const Entity_handle& eh, const Point& point, const double tol )
48 {
49 typedef std::vector< moab::CartVect > Points;
50 Points points;
51 get_moab_points( moab, eh, points );
52 return map( moab, eh, points, point, tol );
53 }
54
55 private:
56 Element_map map;
57 };
58
59 class Parametrizer
60 {
61 private:
62 typedef Parametrizer Self;
63 typedef moab::EntityHandle Entity_handle;
64
65 public:
66 Parametrizer() : hex_map(), tet_map() {}
67 Parametrizer( const Self& f ) : hex_map( f.hex_map ), tet_map( f.tet_map ) {}
68
69 public:
70 template < typename Moab, typename Entity_handle, typename Point >
71 std::pair< bool, Point > operator()( Moab& moab, const Entity_handle& eh, const Point& point )
72 {
73
74 typedef std::vector< moab::CartVect > Points;
75 Points points;
76 get_moab_points( moab, eh, points );
77
78 switch( moab.type_from_handle( eh ) )
79 {
80 case moab::MBHEX:
81 return hex_map( moab, eh, points, point );
82 case moab::MBTET:
83 return tet_map( moab, eh, points, point );
84
85
86
87 default:
88 quadratic_hex_map( moab, eh, points, point );
89 return spectral_hex_map( moab, eh, points, point );
90 std::cerr << "Element type not supported" << std::endl;
91 return make_pair( false, Point( 3, 0.0 ) );
92 }
93 }
94 template < typename Moab, typename Entity_handle, typename Point >
95 void interpolate( Moab& moab, const Entity_handle& eh, const Point& natural_coords )
96 {
97
98
99
100 }
101
102 private:
103 Linear_hex_map< moab::Matrix3 > hex_map;
104 Linear_tet_map< Entity_handle, moab::Matrix3 > tet_map;
105 Spectral_hex_map< moab::Matrix3 > spectral_hex_map;
106 Quadratic_hex_map< moab::Matrix3 > quadratic_hex_map;
107 };
108
109 }
110 }
111 #endif