Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
parametrizer.hpp
Go to the documentation of this file.
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  // non-exported functionality
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  // TODO: This is hacky, it works correctly since
22  // CartVect is only double d[ 3], with a default
23  // constructor.. get_coords() should be
24  // flexible enough to allow other types..
25  points.resize( num_vertices );
26  moab.get_coords( connectivity_begin, num_vertices, &( points[0][0] ) );
27  }
28 
29  } // namespace
30 
31  template < typename Element_map >
33  {
34  public:
35  // public types
36  typedef Element_map Map;
37 
38  private:
40 
41  public: // public functionality
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  }; // class Element_parametrizer
58 
60  {
61  private:
62  typedef Parametrizer Self;
64 
65  public: // public functionality
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  // get entity
74  typedef std::vector< moab::CartVect > Points;
75  Points points;
76  get_moab_points( moab, eh, points );
77  // get type
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  // TODO: not correct..
85  // TODO: add quadratic hex, and a proper case for
86  // spectral hex
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  // get field values from moab tag,
98  // then
99  // evaluate_scalar_field();
100  }
101 
102  private:
107  }; // class Parametrizer
108 
109 } // namespace element_utility
110 } // namespace moab
111 #endif // MOAB_PARAMETRIZER_HPP