Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
SpectralMeshTool.hpp
Go to the documentation of this file.
1 #ifndef SPECTRALMESHTOOL_HPP
2 #define SPECTRALMESHTOOL_HPP
3 
4 #include "moab/Interface.hpp" // needs to be here to support inline query_interface
5 #include "moab/Error.hpp" // needs to be here to support inline query_interface
6 #include <vector>
7 
8 namespace moab
9 {
10 
11 /** \class SpectralMeshTool
12  * \brief Class with convenience functions for handling spectral mesh
13  * Class with convenience functions for handling spectral meshes. See description of spectral
14  * mesh handling in doc/metadata_info.doc and in the MOAB user's guide.
15  *
16  * There are two primary representations of spectral meshes:
17  * a) coarse elements: with SPECTRAL_VERTICES lexicographically-ordered array of fine vertices
18  * on each element, and tags on vertices or on elements (with _LEX suffix)
19  * b) fine elements: as linear elements made from fine vertices, with tags on vertices
20  *
21  */
23 {
24  public:
25  /** \brief Constructor
26  * \param impl MOAB Interface instance
27  * \param order Spectral order, defaults to 0
28  */
29  SpectralMeshTool( Interface* impl, int order = 0 );
30 
31  /** \brief Destructor
32  */
34 
35  /** \brief Return tag used to store lexicographically-ordered vertex array
36  * NOTE: If creating this tag with this call, this SpectralMeshTool instance must already have
37  * a non-zero spectral order value set on it; the size of the spectral vertices tag depends on
38  * this order. \param sv_tag Spectral vertices tag \param create_if_missing If true, will create
39  * this tag if it doesn't exist already
40  */
41  Tag spectral_vertices_tag( const bool create_if_missing = false );
42 
43  /** \brief Return tag used to store spectral order
44  * \param so_tag Spectral order tag
45  * \param create_if_missing If true, will create this tag if it doesn't exist already
46  */
47  Tag spectral_order_tag( const bool create_if_missing = false );
48 
49  /** \brief Convert representation from coarse to fine
50  * Each element in set, or in interface if set is not input, is converted to fine elements,
51  * using vertices in SPECTRAL_VERTICES tagged array \param spectral_set Set containing spectral
52  * elements
53  */
54  ErrorCode convert_to_fine( EntityHandle spectral_set );
55 
56  /** \brief Convert representation from fine to coarse
57  * Each element in set, or in interface if set is not input, is converted to coarse elements,
58  * with fine vertices put into SPECTRAL_VERTICES tagged array. NOTE: This function assumes that
59  * each order^d (fine) elements comprise each coarse element, and are in order of fine elements
60  * in each coarse element. If order is input as 0, looks for a SPECTRAL_ORDER tag on the mesh.
61  * \param order Order of the spectral mesh
62  * \param spectral_set Set containing spectral elements
63  */
64  ErrorCode convert_to_coarse( int order = 0, EntityHandle spectral_set = 0 );
65 
66  /** \brief Create coarse spectral elements from fine elements pointed to by conn
67  * This function creates the coarse elements by taking conn (assumed to be in FE ordering)
68  * and picking out the corner vertices to make coarse connectivity, and the other vertices
69  * (along with corners) to make SPECTRAL_VERTICES array pointed to by each entity.
70  * \param conn Connectivity of fine (linear) elements, in FE ordering
71  * \param verts_per_e Vertices per entity
72  * \param num_fine_elems Number of fine elements represented by conn
73  * \param spectral_set Set to which coarse elements should be added, if any
74  * \param start_idx Starting index in conn (for parallel support)
75  * \param local_gids If non-null, will insert all fine vertices into this range
76  */
77  template < class T >
78  ErrorCode create_spectral_elems( const T* conn,
79  int num_fine_elems,
80  int dim,
81  Range& output_range,
82  int start_idx = 0,
83  Range* local_gids = NULL );
84 
85  /** \brief Set spectral order for this instance
86  * \param order Order set on this instance
87  */
88  void spectral_order( int order )
89  {
90  spectralOrder = order;
91  spectralOrderp1 = order + 1;
92  }
93 
94  /** \brief Get spectral order for this instance
95  * \return order Order set on this instance
96  */
98  {
99  return spectralOrder;
100  }
101  /*
102  struct ConnMap
103  {
104  const short a[16];
105  };
106  */
107  static const short int permute_array[];
108 
109  static const short int lin_permute_array[];
110 
111  private:
112  //! the MB instance that this works with
114 
115  //! error object for this tool
117 
118  //! SPECTRAL_VERTICES tag
120 
121  //! SPECTRAL_ORDER tag
123 
124  //! order of the spectral mesh being accessed
126 
127  //! order of the spectral mesh being accessed plus one
129 };
130 
132  : mbImpl( impl ), svTag( 0 ), soTag( 0 ), spectralOrder( order ), spectralOrderp1( order + 1 )
133 {
134  impl->query_interface( mError );
135 }
136 
138 
139 } // namespace moab
140 
141 #endif