Branch data Line data Source code
1 : : /* *****************************************************************
2 : : MESQUITE -- The Mesh Quality Improvement Toolkit
3 : :
4 : : Copyright 2009 Sandia National Laboratories. Developed at the
5 : : University of Wisconsin--Madison under SNL contract number
6 : : 624796. The U.S. Government and the University of Wisconsin
7 : : retain certain rights to this software.
8 : :
9 : : This library is free software; you can redistribute it and/or
10 : : modify it under the terms of the GNU Lesser General Public
11 : : License as published by the Free Software Foundation; either
12 : : version 2.1 of the License, or (at your option) any later version.
13 : :
14 : : This library is distributed in the hope that it will be useful,
15 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : Lesser General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU Lesser General Public License
20 : : (lgpl.txt) along with this library; if not, write to the Free Software
21 : : Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : :
23 : : (2009) [email protected]
24 : :
25 : : ***************************************************************** */
26 : :
27 : : /** \file EdgeQM.hpp
28 : : * \brief
29 : : * \author Jason Kraftcheck
30 : : */
31 : :
32 : : #ifndef MSQ_EDGE_QM_HPP
33 : : #define MSQ_EDGE_QM_HPP
34 : :
35 : : #include "Mesquite.hpp"
36 : : #include "QualityMetric.hpp"
37 : :
38 : : namespace MBMesquite
39 : : {
40 : :
41 : : /**\brief Base type for quality metrics evaluated for each edge */
42 : 12 : class EdgeQM : public QualityMetric
43 : : {
44 : : public:
45 : : MESQUITE_EXPORT virtual ~EdgeQM();
46 : :
47 : 18 : MESQUITE_EXPORT virtual MetricType get_metric_type() const
48 : : {
49 : 18 : return VERTEX_BASED;
50 : : }
51 : :
52 : : /**\brief Returns list of edge indices in PatchData
53 : : *
54 : : *This method returns metric evaluation points for every
55 : : *logical edge in the patch if \c free_vertices_only is
56 : : *false. If \c free_vertices_only is true then only the
57 : : *subset of edges adjacent to at least one free vertex are
58 : : *returned.
59 : : */
60 : : MESQUITE_EXPORT virtual void get_evaluations( PatchData& pd, std::vector< size_t >& handles,
61 : : bool free_vertices_only, MsqError& err );
62 : :
63 : : /**\brief Returns list of edge indices in PatchData
64 : : *
65 : : *This method returns metric evaluation points only a subset
66 : : *of the logical edges in a patch such that if one iterates
67 : : *over the mesh using element-on-vertex patches a given edge
68 : : *is returned only once for the set of all patches. This is
69 : : *accomplished by returning only edges adjacent to vertices
70 : : *without the MSQ_PATCH_FIXED flag set, and only if the handle for
71 : : *the opposite vertex is greater than the one with the flag
72 : : *set.
73 : : */
74 : : MESQUITE_EXPORT virtual void get_single_pass( PatchData& pd, std::vector< size_t >& handles,
75 : : bool free_vertices_only, MsqError& err );
76 : :
77 : : MESQUITE_EXPORT static void get_edge_evaluations( PatchData& pd, std::vector< size_t >& handles,
78 : : bool free_vertices_only, bool single_pass_evaluate,
79 : : MsqError& err );
80 : :
81 : : /**\brief Default implementation for all edge-based metrics
82 : : *
83 : : * Fill 'indices' with all free vertex indices in element,
84 : : * and call 'evaluate'.
85 : : */
86 : : MESQUITE_EXPORT virtual bool evaluate_with_indices( PatchData& pd, size_t handle, double& value,
87 : : std::vector< size_t >& indices, MsqError& err );
88 : :
89 : : enum
90 : : {
91 : : ELEM_EDGE_BITS = 4,
92 : : ELEM_INDEX_BITS = 8 * sizeof( size_t ) - ELEM_EDGE_BITS,
93 : : ELEM_EDGE_MASK = ( ( (size_t)1 ) << ELEM_INDEX_BITS ) - 1
94 : : };
95 : :
96 : 146472 : inline static size_t handle( unsigned edge_no, size_t elem_idx )
97 : : {
98 [ - + ]: 146472 : assert( elem_idx <= ELEM_EDGE_MASK );
99 : 146472 : return ( ( (size_t)edge_no ) << ELEM_INDEX_BITS ) | elem_idx;
100 : : }
101 : :
102 : 146472 : inline static unsigned edge( size_t handle )
103 : : {
104 : 146472 : return handle >> ELEM_INDEX_BITS;
105 : : }
106 : :
107 : 146472 : inline static unsigned elem( size_t handle )
108 : : {
109 : 146472 : return handle & ELEM_EDGE_MASK;
110 : : }
111 : : };
112 : :
113 : : } // namespace MBMesquite
114 : :
115 : : #endif
|