MOAB: Mesh Oriented datABase  (version 5.3.0)
ElemSampleQM.hpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2006 Lawrence Livermore National Laboratory.  Under
00005     the terms of Contract B545069 with the University of Wisconsin --
00006     Madison, Lawrence Livermore National Laboratory retains certain
00007     rights in 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     (2006) kraftche@cae.wisc.edu
00024 
00025   ***************************************************************** */
00026 
00027 /** \file ElemSampleQM.hpp
00028  *  \brief
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #ifndef MSQ_ELEM_SAMPLE_QM_HPP
00033 #define MSQ_ELEM_SAMPLE_QM_HPP
00034 
00035 #include "Mesquite.hpp"
00036 #include "QualityMetric.hpp"
00037 #include "Sample.hpp"
00038 
00039 namespace MBMesquite
00040 {
00041 
00042 /**\brief Base type for metrics evaluated at several
00043  *        sample points within each element.
00044  *
00045  * This class defines an interface for metrics that are evaluated
00046  * at multiple sample points within each element.  This interface is
00047  * used by ElemAverageQM and is the base for ElemCornerQM and
00048  * ElemTargetQM.
00049  */
00050 class ElemSampleQM : public QualityMetric
00051 {
00052   public:
00053     MESQUITE_EXPORT virtual ~ElemSampleQM();
00054 
00055     MESQUITE_EXPORT virtual MetricType get_metric_type() const
00056     {
00057         return ELEMENT_BASED;
00058     }
00059 
00060     /**\brief Get evaluation point handles for a given element
00061      *
00062      * Similar to QualityMetric::get_evaluations, this method returns
00063      * a list of handles corresponding to sample points at which the
00064      * metric may be evaluated.  While QualityMetric::get_evaluations
00065      * returns sample points for all elements in a PatchData, this
00066      * method returns only the subset corresponding to a single element.
00067      */
00068     MESQUITE_EXPORT virtual void get_element_evaluations( PatchData& pd, size_t elem_index,
00069                                                           std::vector< size_t >& handles, MsqError& err ) = 0;
00070 
00071     /** Misc constants used in defining how element index, side dimension,
00072      *  and side number are packed into a single handle describing a logical
00073      *  location in the patch at which a sample-based metric is to be
00074      *  evaluated.
00075      */
00076 #ifndef _WIN32
00077     enum { /** the number of bits in a handle that are used to store element index */
00078            ELEM_INDEX_BITS = sizeof( size_t ) * 8 - Sample::NUMBER_PACKED_BITS,
00079            /** the maximum number of elements in a PatchData without overflowing handle space */
00080            MAX_ELEM_PER_PATCH = ( (size_t)1 ) << ELEM_INDEX_BITS,
00081            /** Mask to remove sample bits from handle */
00082            ELEM_SAMPLE_MASK = MAX_ELEM_PER_PATCH - 1
00083     };
00084 #else /* MS Visual C compiler broken for 64-bit enums */
00085     static const size_t ELEM_INDEX_BITS    = sizeof( size_t ) * 8 - Sample::NUMBER_PACKED_BITS;
00086     static const size_t MAX_ELEM_PER_PATCH = ( (size_t)1 ) << ELEM_INDEX_BITS;
00087     static const size_t ELEM_SAMPLE_MASK   = MAX_ELEM_PER_PATCH - 1;
00088 #endif
00089 
00090     inline static size_t handle( Sample sample, size_t index )
00091     {
00092         return ( sample.pack() << ELEM_INDEX_BITS ) | index;
00093     }
00094 
00095     inline static Sample sample( size_t handle )
00096     {
00097         return Sample( handle >> ELEM_INDEX_BITS );
00098     }
00099 
00100     inline static size_t elem( size_t handle )
00101     {
00102         return handle & ELEM_SAMPLE_MASK;
00103     }
00104 };
00105 
00106 }  // namespace MBMesquite
00107 
00108 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines