Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
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,
00079                                      int num_fine_elems,
00080                                      int dim,
00081                                      Range& output_range,
00082                                      int start_idx     = 0,
00083                                      Range* local_gids = NULL );
00084 
00085     /** \brief Set spectral order for this instance
00086      * \param order Order set on this instance
00087      */
00088     void spectral_order( int order )
00089     {
00090         spectralOrder   = order;
00091         spectralOrderp1 = order + 1;
00092     }
00093 
00094     /** \brief Get spectral order for this instance
00095      * \return order Order set on this instance
00096      */
00097     int spectral_order()
00098     {
00099         return spectralOrder;
00100     }
00101     /*
00102       struct ConnMap
00103       {
00104         const short a[16];
00105       };
00106       */
00107     static const short int permute_array[];
00108 
00109     static const short int lin_permute_array[];
00110 
00111   private:
00112     //! the MB instance that this works with
00113     Interface* mbImpl;
00114 
00115     //! error object for this tool
00116     Error* mError;
00117 
00118     //! SPECTRAL_VERTICES tag
00119     Tag svTag;
00120 
00121     //! SPECTRAL_ORDER tag
00122     Tag soTag;
00123 
00124     //! order of the spectral mesh being accessed
00125     int spectralOrder;
00126 
00127     //! order of the spectral mesh being accessed plus one
00128     int spectralOrderp1;
00129 };
00130 
00131 inline SpectralMeshTool::SpectralMeshTool( Interface* impl, int order )
00132     : mbImpl( impl ), svTag( 0 ), soTag( 0 ), spectralOrder( order ), spectralOrderp1( order + 1 )
00133 {
00134     impl->query_interface( mError );
00135 }
00136 
00137 inline SpectralMeshTool::~SpectralMeshTool() {}
00138 
00139 }  // namespace moab
00140 
00141 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines