MOAB: Mesh Oriented datABase
(version 5.4.1)
|
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) [email protected] 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, 00069 size_t elem_index, 00070 std::vector< size_t >& handles, 00071 MsqError& err ) = 0; 00072 00073 /** Misc constants used in defining how element index, side dimension, 00074 * and side number are packed into a single handle describing a logical 00075 * location in the patch at which a sample-based metric is to be 00076 * evaluated. 00077 */ 00078 #ifndef _WIN32 00079 enum { /** the number of bits in a handle that are used to store element index */ 00080 ELEM_INDEX_BITS = sizeof( size_t ) * 8 - Sample::NUMBER_PACKED_BITS, 00081 /** the maximum number of elements in a PatchData without overflowing handle space */ 00082 MAX_ELEM_PER_PATCH = ( (size_t)1 ) << ELEM_INDEX_BITS, 00083 /** Mask to remove sample bits from handle */ 00084 ELEM_SAMPLE_MASK = MAX_ELEM_PER_PATCH - 1 }; 00085 #else /* MS Visual C compiler broken for 64-bit enums */ 00086 static const size_t ELEM_INDEX_BITS = sizeof( size_t ) * 8 - Sample::NUMBER_PACKED_BITS; 00087 static const size_t MAX_ELEM_PER_PATCH = ( (size_t)1 ) << ELEM_INDEX_BITS; 00088 static const size_t ELEM_SAMPLE_MASK = MAX_ELEM_PER_PATCH - 1; 00089 #endif 00090 00091 inline static size_t handle( Sample sample, size_t index ) 00092 { 00093 return ( sample.pack() << ELEM_INDEX_BITS ) | index; 00094 } 00095 00096 inline static Sample sample( size_t handle ) 00097 { 00098 return Sample( handle >> ELEM_INDEX_BITS ); 00099 } 00100 00101 inline static size_t elem( size_t handle ) 00102 { 00103 return handle & ELEM_SAMPLE_MASK; 00104 } 00105 }; 00106 00107 } // namespace MBMesquite 00108 00109 #endif