MOAB: Mesh Oriented datABase  (version 5.4.0)
EdgeQM.hpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2009 Sandia National Laboratories.  Developed at the
00005     University of Wisconsin--Madison under SNL contract number
00006     624796.  The U.S. Government and the University of Wisconsin
00007     retain certain rights to this software.
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2.1 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     (lgpl.txt) along with this library; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023     (2009) kraftche@cae.wisc.edu
00024 
00025   ***************************************************************** */
00026 
00027 /** \file EdgeQM.hpp
00028  *  \brief
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #ifndef MSQ_EDGE_QM_HPP
00033 #define MSQ_EDGE_QM_HPP
00034 
00035 #include "Mesquite.hpp"
00036 #include "QualityMetric.hpp"
00037 
00038 namespace MBMesquite
00039 {
00040 
00041 /**\brief Base type for quality metrics evaluated for each edge */
00042 class EdgeQM : public QualityMetric
00043 {
00044   public:
00045     MESQUITE_EXPORT virtual ~EdgeQM();
00046 
00047     MESQUITE_EXPORT virtual MetricType get_metric_type() const
00048     {
00049         return VERTEX_BASED;
00050     }
00051 
00052     /**\brief Returns list of edge indices in PatchData
00053      *
00054      *This method returns metric evaluation points for every
00055      *logical edge in the patch if \c free_vertices_only is
00056      *false.  If \c free_vertices_only is true then only the
00057      *subset of edges adjacent to at least one free vertex are
00058      *returned.
00059      */
00060     MESQUITE_EXPORT virtual void get_evaluations( PatchData& pd,
00061                                                   std::vector< size_t >& handles,
00062                                                   bool free_vertices_only,
00063                                                   MsqError& err );
00064 
00065     /**\brief Returns list of edge indices in PatchData
00066      *
00067      *This method returns metric evaluation points only a subset
00068      *of the logical edges in a patch such that if one iterates
00069      *over the mesh using element-on-vertex patches a given edge
00070      *is returned only once for the set of all patches.  This is
00071      *accomplished by returning only edges adjacent to vertices
00072      *without the MSQ_PATCH_FIXED flag set, and only if the handle for
00073      *the opposite vertex is greater than the one with the flag
00074      *set.
00075      */
00076     MESQUITE_EXPORT virtual void get_single_pass( PatchData& pd,
00077                                                   std::vector< size_t >& handles,
00078                                                   bool free_vertices_only,
00079                                                   MsqError& err );
00080 
00081     MESQUITE_EXPORT static void get_edge_evaluations( PatchData& pd,
00082                                                       std::vector< size_t >& handles,
00083                                                       bool free_vertices_only,
00084                                                       bool single_pass_evaluate,
00085                                                       MsqError& err );
00086 
00087     /**\brief Default implementation for all edge-based metrics
00088      *
00089      * Fill 'indices' with all free vertex indices in element,
00090      * and call 'evaluate'.
00091      */
00092     MESQUITE_EXPORT virtual bool evaluate_with_indices( PatchData& pd,
00093                                                         size_t handle,
00094                                                         double& value,
00095                                                         std::vector< size_t >& indices,
00096                                                         MsqError& err );
00097 
00098     enum
00099     {
00100         ELEM_EDGE_BITS  = 4,
00101         ELEM_INDEX_BITS = 8 * sizeof( size_t ) - ELEM_EDGE_BITS,
00102         ELEM_EDGE_MASK  = ( ( (size_t)1 ) << ELEM_INDEX_BITS ) - 1
00103     };
00104 
00105     inline static size_t handle( unsigned edge_no, size_t elem_idx )
00106     {
00107         assert( elem_idx <= ELEM_EDGE_MASK );
00108         return ( ( (size_t)edge_no ) << ELEM_INDEX_BITS ) | elem_idx;
00109     }
00110 
00111     inline static unsigned edge( size_t handle )
00112     {
00113         return handle >> ELEM_INDEX_BITS;
00114     }
00115 
00116     inline static unsigned elem( size_t handle )
00117     {
00118         return handle & ELEM_EDGE_MASK;
00119     }
00120 };
00121 
00122 }  // namespace MBMesquite
00123 
00124 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines