![]() |
Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 #ifndef MOAB_PARAMETRIZER_HPP
00002 #define MOAB_PARAMETRIZER_HPP
00003 #include "moab/Matrix3.hpp"
00004 #include "moab/CartVect.hpp"
00005 #include "moab/ElemUtil.hpp"
00006 namespace moab
00007 {
00008
00009 namespace element_utility
00010 {
00011 // non-exported functionality
00012 namespace
00013 {
00014
00015 template < typename Moab, typename Entity_handle, typename Points >
00016 void get_moab_points( Moab& moab, Entity_handle eh, Points& points )
00017 {
00018 const Entity_handle* connectivity_begin;
00019 int num_vertices;
00020 moab.get_connectivity( eh, connectivity_begin, num_vertices );
00021 // TODO: This is hacky, it works correctly since
00022 // CartVect is only double d[ 3], with a default
00023 // constructor.. get_coords() should be
00024 // flexible enough to allow other types..
00025 points.resize( num_vertices );
00026 moab.get_coords( connectivity_begin, num_vertices, &( points[0][0] ) );
00027 }
00028
00029 } // namespace
00030
00031 template < typename Element_map >
00032 class Element_parametrizer
00033 {
00034 public:
00035 // public types
00036 typedef Element_map Map;
00037
00038 private:
00039 typedef Element_parametrizer< Map > Self;
00040
00041 public: // public functionality
00042 Element_parametrizer() : map() {}
00043 Element_parametrizer( const Self& f ) : map( f.map ) {}
00044
00045 public:
00046 template < typename Moab, typename Entity_handle, typename Point >
00047 std::pair< bool, Point > operator()( Moab& moab, const Entity_handle& eh, const Point& point, const double tol )
00048 {
00049 typedef std::vector< moab::CartVect > Points;
00050 Points points;
00051 get_moab_points( moab, eh, points );
00052 return map( moab, eh, points, point, tol );
00053 }
00054
00055 private:
00056 Element_map map;
00057 }; // class Element_parametrizer
00058
00059 class Parametrizer
00060 {
00061 private:
00062 typedef Parametrizer Self;
00063 typedef moab::EntityHandle Entity_handle;
00064
00065 public: // public functionality
00066 Parametrizer() : hex_map(), tet_map() {}
00067 Parametrizer( const Self& f ) : hex_map( f.hex_map ), tet_map( f.tet_map ) {}
00068
00069 public:
00070 template < typename Moab, typename Entity_handle, typename Point >
00071 std::pair< bool, Point > operator()( Moab& moab, const Entity_handle& eh, const Point& point )
00072 {
00073 // get entity
00074 typedef std::vector< moab::CartVect > Points;
00075 Points points;
00076 get_moab_points( moab, eh, points );
00077 // get type
00078 switch( moab.type_from_handle( eh ) )
00079 {
00080 case moab::MBHEX:
00081 return hex_map( moab, eh, points, point );
00082 case moab::MBTET:
00083 return tet_map( moab, eh, points, point );
00084 // TODO: not correct..
00085 // TODO: add quadratic hex, and a proper case for
00086 // spectral hex
00087 default:
00088 quadratic_hex_map( moab, eh, points, point );
00089 return spectral_hex_map( moab, eh, points, point );
00090 std::cerr << "Element type not supported" << std::endl;
00091 return make_pair( false, Point( 3, 0.0 ) );
00092 }
00093 }
00094 template < typename Moab, typename Entity_handle, typename Point >
00095 void interpolate( Moab& moab, const Entity_handle& eh, const Point& natural_coords )
00096 {
00097 // get field values from moab tag,
00098 // then
00099 // evaluate_scalar_field();
00100 }
00101
00102 private:
00103 Linear_hex_map< moab::Matrix3 > hex_map;
00104 Linear_tet_map< Entity_handle, moab::Matrix3 > tet_map;
00105 Spectral_hex_map< moab::Matrix3 > spectral_hex_map;
00106 Quadratic_hex_map< moab::Matrix3 > quadratic_hex_map;
00107 }; // class Parametrizer
00108
00109 } // namespace element_utility
00110 } // namespace moab
00111 #endif // MOAB_PARAMETRIZER_HPP