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 /** \class SpectralMeshTool
11 * \brief Class with convenience functions for handling spectral mesh
12 * Class with convenience functions for handling spectral meshes. See description of spectral
13 * mesh handling in doc/metadata_info.doc and in the MOAB user's guide.
14 *
15 * There are two primary representations of spectral meshes:
16 * a) coarse elements: with SPECTRAL_VERTICES lexicographically-ordered array of fine vertices
17 * on each element, and tags on vertices or on elements (with _LEX suffix)
18 * b) fine elements: as linear elements made from fine vertices, with tags on vertices
19 *
20 */
21 class SpectralMeshTool
22 {
23 public:
24
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 */
33 ~SpectralMeshTool();
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 this order.
38 * \param sv_tag Spectral vertices tag
39 * \param create_if_missing If true, will create 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, using
51 * vertices in SPECTRAL_VERTICES tagged array
52 * \param spectral_set Set containing spectral 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, with
58 * fine vertices put into SPECTRAL_VERTICES tagged array. NOTE: This function assumes that each
59 * order^d (fine) elements comprise each coarse element, and are in order of fine elements in each
60 * 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, int num_fine_elems, int dim,
79 Range &output_range, int start_idx = 0, Range *local_gids = NULL);
80
81 /** \brief Set spectral order for this instance
82 * \param order Order set on this instance
83 */
spectral_order(int order)84 void spectral_order(int order) {spectralOrder = order; spectralOrderp1 = order+1;}
85
86 /** \brief Get spectral order for this instance
87 * \return order Order set on this instance
88 */
spectral_order()89 int spectral_order() {return spectralOrder;}
90 /*
91 struct ConnMap
92 {
93 const short a[16];
94 };
95 */
96 static const short int permute_array[];
97
98 static const short int lin_permute_array[];
99
100 private:
101
102 //! the MB instance that this works with
103 Interface* mbImpl;
104
105 //! error object for this tool
106 Error *mError;
107
108 //! SPECTRAL_VERTICES tag
109 Tag svTag;
110
111 //! SPECTRAL_ORDER tag
112 Tag soTag;
113
114 //! order of the spectral mesh being accessed
115 int spectralOrder;
116
117 //! order of the spectral mesh being accessed plus one
118 int spectralOrderp1;
119 };
120
SpectralMeshTool(Interface * impl,int order)121 inline SpectralMeshTool::SpectralMeshTool(Interface *impl, int order)
122 : mbImpl(impl), svTag(0), soTag(0), spectralOrder(order), spectralOrderp1(order+1)
123 {
124 impl->query_interface(mError);
125 }
126
~SpectralMeshTool()127 inline SpectralMeshTool::~SpectralMeshTool()
128 {}
129
130 } // namespace moab
131
132 #endif
133
134