MOAB: Mesh Oriented datABase
(version 5.2.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) kraftche@cae.wisc.edu 00024 00025 ***************************************************************** */ 00026 00027 /** \file ElementQM.cpp 00028 * \brief 00029 * \author Jason Kraftcheck 00030 */ 00031 00032 #include "Mesquite.hpp" 00033 #include "ElementQM.hpp" 00034 #include "PatchData.hpp" 00035 00036 namespace MBMesquite 00037 { 00038 00039 ElementQM::~ElementQM() {} 00040 00041 void ElementQM::get_evaluations( PatchData& pd, std::vector< size_t >& handles, bool free_vertices_only, MsqError& err ) 00042 { 00043 get_element_evaluations( pd, handles, free_vertices_only, err ); 00044 } 00045 00046 void ElementQM::get_element_evaluations( PatchData& pd, std::vector< size_t >& handles, bool free_vertices_only, 00047 MsqError& /*err*/ ) 00048 { 00049 size_t num_elem = pd.num_elements(); 00050 if( !free_vertices_only ) 00051 { 00052 handles.resize( num_elem ); 00053 for( size_t i = 0; i < num_elem; ++i ) 00054 handles[i] = i; 00055 return; 00056 } 00057 00058 handles.clear(); 00059 for( size_t i = 0; i < num_elem; ++i ) 00060 { 00061 // check if element has any free vertices 00062 MsqMeshEntity& elem = pd.element_by_index( i ); 00063 unsigned num_vtx = elem.node_count(); 00064 size_t* vtx = elem.get_vertex_index_array(); 00065 unsigned j; 00066 for( j = 0; j < num_vtx && vtx[j] >= pd.num_free_vertices(); ++j ) 00067 ; 00068 if( j < num_vtx ) handles.push_back( i ); 00069 } 00070 } 00071 00072 bool ElementQM::evaluate_with_indices( PatchData& pd, size_t handle, double& value, std::vector< size_t >& indices, 00073 MsqError& err ) 00074 { 00075 const MsqMeshEntity& elem = pd.element_by_index( handle ); 00076 const size_t* vtx = elem.get_vertex_index_array(); 00077 const unsigned n = elem.vertex_count(); 00078 indices.clear(); 00079 for( unsigned i = 0; i < n; ++i ) 00080 if( vtx[i] < pd.num_free_vertices() ) indices.push_back( vtx[i] ); 00081 00082 bool rval = evaluate( pd, handle, value, err ); 00083 return !MSQ_CHKERR( err ) && rval; 00084 } 00085 00086 } // namespace MBMesquite