Branch data Line data Source code
1 : : /* *****************************************************************
2 : : MESQUITE -- The Mesh Quality Improvement Toolkit
3 : :
4 : : Copyright 2006 Lawrence Livermore National Laboratory. Under
5 : : the terms of Contract B545069 with the University of Wisconsin --
6 : : Madison, Lawrence Livermore National Laboratory retains certain
7 : : rights in 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 : : (2006) [email protected]
24 : :
25 : : ***************************************************************** */
26 : :
27 : : /** \file ElementQM.cpp
28 : : * \brief
29 : : * \author Jason Kraftcheck
30 : : */
31 : :
32 : : #include "Mesquite.hpp"
33 : : #include "ElementQM.hpp"
34 : : #include "PatchData.hpp"
35 : :
36 : : namespace MBMesquite
37 : : {
38 : :
39 [ - + ]: 154 : ElementQM::~ElementQM() {}
40 : :
41 : 678318 : void ElementQM::get_evaluations( PatchData& pd, std::vector< size_t >& handles, bool free_vertices_only, MsqError& err )
42 : : {
43 : 678318 : get_element_evaluations( pd, handles, free_vertices_only, err );
44 : 678318 : }
45 : :
46 : 900613 : void ElementQM::get_element_evaluations( PatchData& pd, std::vector< size_t >& handles, bool free_vertices_only,
47 : : MsqError& /*err*/ )
48 : : {
49 : 900613 : size_t num_elem = pd.num_elements();
50 [ + + ]: 900613 : if( !free_vertices_only )
51 : : {
52 : 23 : handles.resize( num_elem );
53 [ + + ]: 18467 : for( size_t i = 0; i < num_elem; ++i )
54 : 18444 : handles[i] = i;
55 : 900613 : return;
56 : : }
57 : :
58 : 900590 : handles.clear();
59 [ + + ]: 11302934 : for( size_t i = 0; i < num_elem; ++i )
60 : : {
61 : : // check if element has any free vertices
62 [ + - ]: 10402344 : MsqMeshEntity& elem = pd.element_by_index( i );
63 [ + - ]: 10402344 : unsigned num_vtx = elem.node_count();
64 [ + - ]: 10402344 : size_t* vtx = elem.get_vertex_index_array();
65 : : unsigned j;
66 [ + + ][ + - ]: 20953545 : for( j = 0; j < num_vtx && vtx[j] >= pd.num_free_vertices(); ++j )
[ + + ][ + + ]
67 : : ;
68 [ + + ][ + - ]: 10402344 : if( j < num_vtx ) handles.push_back( i );
69 : : }
70 : : }
71 : :
72 : 331322 : bool ElementQM::evaluate_with_indices( PatchData& pd, size_t handle, double& value, std::vector< size_t >& indices,
73 : : MsqError& err )
74 : : {
75 : 331322 : const MsqMeshEntity& elem = pd.element_by_index( handle );
76 : 331322 : const size_t* vtx = elem.get_vertex_index_array();
77 : 331322 : const unsigned n = elem.vertex_count();
78 : 331322 : indices.clear();
79 [ + + ]: 1658578 : for( unsigned i = 0; i < n; ++i )
80 [ + + ]: 1327256 : if( vtx[i] < pd.num_free_vertices() ) indices.push_back( vtx[i] );
81 : :
82 : 331322 : bool rval = evaluate( pd, handle, value, err );
83 [ - + ][ # # ]: 331322 : return !MSQ_CHKERR( err ) && rval;
[ + - ]
84 : : }
85 : :
86 [ + - ][ + - ]: 120 : } // namespace MBMesquite
|