MOAB: Mesh Oriented datABase  (version 5.2.1)
SpectralMeshTool.hpp
Go to the documentation of this file.
00001 #ifndef SPECTRALMESHTOOL_HPP
00002 #define SPECTRALMESHTOOL_HPP
00003 
00004 #include "moab/Interface.hpp"  // needs to be here to support inline query_interface
00005 #include "moab/Error.hpp"      // needs to be here to support inline query_interface
00006 #include <vector>
00007 
00008 namespace moab
00009 {
00010 
00011 /** \class SpectralMeshTool
00012  * \brief Class with convenience functions for handling spectral mesh
00013  * Class with convenience functions for handling spectral meshes.  See description of spectral
00014  * mesh handling in doc/metadata_info.doc and in the MOAB user's guide.
00015  *
00016  * There are two primary representations of spectral meshes:
00017  * a) coarse elements: with SPECTRAL_VERTICES lexicographically-ordered array of fine vertices
00018  *    on each element, and tags on vertices or on elements (with _LEX suffix)
00019  * b) fine elements: as linear elements made from fine vertices, with tags on vertices
00020  *
00021  */
00022 class SpectralMeshTool
00023 {
00024   public:
00025     /** \brief Constructor
00026      * \param impl MOAB Interface instance
00027      * \param order Spectral order, defaults to 0
00028      */
00029     SpectralMeshTool( Interface* impl, int order = 0 );
00030 
00031     /** \brief Destructor
00032      */
00033     ~SpectralMeshTool();
00034 
00035     /** \brief Return tag used to store lexicographically-ordered vertex array
00036      * NOTE: If creating this tag with this call, this SpectralMeshTool instance must already have
00037      * a non-zero spectral order value set on it; the size of the spectral vertices tag depends on
00038      * this order. \param sv_tag Spectral vertices tag \param create_if_missing If true, will create
00039      * this tag if it doesn't exist already
00040      */
00041     Tag spectral_vertices_tag( const bool create_if_missing = false );
00042 
00043     /** \brief Return tag used to store spectral order
00044      * \param so_tag Spectral order tag
00045      * \param create_if_missing If true, will create this tag if it doesn't exist already
00046      */
00047     Tag spectral_order_tag( const bool create_if_missing = false );
00048 
00049     /** \brief Convert representation from coarse to fine
00050      * Each element in set, or in interface if set is not input, is converted to fine elements,
00051      * using vertices in SPECTRAL_VERTICES tagged array \param spectral_set Set containing spectral
00052      * elements
00053      */
00054     ErrorCode convert_to_fine( EntityHandle spectral_set );
00055 
00056     /** \brief Convert representation from fine to coarse
00057      * Each element in set, or in interface if set is not input, is converted to coarse elements,
00058      * with fine vertices put into SPECTRAL_VERTICES tagged array.  NOTE: This function assumes that
00059      * each order^d (fine) elements comprise each coarse element, and are in order of fine elements
00060      * in each coarse element.  If order is input as 0, looks for a SPECTRAL_ORDER tag on the mesh.
00061      * \param order Order of the spectral mesh
00062      * \param spectral_set Set containing spectral elements
00063      */
00064     ErrorCode convert_to_coarse( int order = 0, EntityHandle spectral_set = 0 );
00065 
00066     /** \brief Create coarse spectral elements from fine elements pointed to by conn
00067      * This function creates the coarse elements by taking conn (assumed to be in FE ordering)
00068      * and picking out the corner vertices to make coarse connectivity, and the other vertices
00069      * (along with corners) to make SPECTRAL_VERTICES array pointed to by each entity.
00070      * \param conn Connectivity of fine (linear) elements, in FE ordering
00071      * \param verts_per_e Vertices per entity
00072      * \param num_fine_elems Number of fine elements represented by conn
00073      * \param spectral_set Set to which coarse elements should be added, if any
00074      * \param start_idx Starting index in conn (for parallel support)
00075      * \param local_gids If non-null, will insert all fine vertices into this range
00076      */
00077     template < class T >
00078     ErrorCode create_spectral_elems( const T* conn, int num_fine_elems, int dim, Range& output_range, int start_idx = 0,
00079                                      Range* local_gids = NULL );
00080 
00081     /** \brief Set spectral order for this instance
00082      * \param order Order set on this instance
00083      */
00084     void spectral_order( int order )
00085     {
00086         spectralOrder   = order;
00087         spectralOrderp1 = order + 1;
00088     }
00089 
00090     /** \brief Get spectral order for this instance
00091      * \return order Order set on this instance
00092      */
00093     int spectral_order()
00094     {
00095         return spectralOrder;
00096     }
00097     /*
00098       struct ConnMap
00099       {
00100         const short a[16];
00101       };
00102       */
00103     static const short int permute_array[];
00104 
00105     static const short int lin_permute_array[];
00106 
00107   private:
00108     //! the MB instance that this works with
00109     Interface* mbImpl;
00110 
00111     //! error object for this tool
00112     Error* mError;
00113 
00114     //! SPECTRAL_VERTICES tag
00115     Tag svTag;
00116 
00117     //! SPECTRAL_ORDER tag
00118     Tag soTag;
00119 
00120     //! order of the spectral mesh being accessed
00121     int spectralOrder;
00122 
00123     //! order of the spectral mesh being accessed plus one
00124     int spectralOrderp1;
00125 };
00126 
00127 inline SpectralMeshTool::SpectralMeshTool( Interface* impl, int order )
00128     : mbImpl( impl ), svTag( 0 ), soTag( 0 ), spectralOrder( order ), spectralOrderp1( order + 1 )
00129 {
00130     impl->query_interface( mError );
00131 }
00132 
00133 inline SpectralMeshTool::~SpectralMeshTool() {}
00134 
00135 }  // namespace moab
00136 
00137 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines