MOAB: Mesh Oriented datABase  (version 5.4.1)
ElementQM.cpp
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) [email protected]
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,
00047                                          std::vector< size_t >& handles,
00048                                          bool free_vertices_only,
00049                                          MsqError& /*err*/ )
00050 {
00051     size_t num_elem = pd.num_elements();
00052     if( !free_vertices_only )
00053     {
00054         handles.resize( num_elem );
00055         for( size_t i = 0; i < num_elem; ++i )
00056             handles[i] = i;
00057         return;
00058     }
00059 
00060     handles.clear();
00061     for( size_t i = 0; i < num_elem; ++i )
00062     {
00063         // check if element has any free vertices
00064         MsqMeshEntity& elem = pd.element_by_index( i );
00065         unsigned num_vtx    = elem.node_count();
00066         size_t* vtx         = elem.get_vertex_index_array();
00067         unsigned j;
00068         for( j = 0; j < num_vtx && vtx[j] >= pd.num_free_vertices(); ++j )
00069             ;
00070         if( j < num_vtx ) handles.push_back( i );
00071     }
00072 }
00073 
00074 bool ElementQM::evaluate_with_indices( PatchData& pd,
00075                                        size_t handle,
00076                                        double& value,
00077                                        std::vector< size_t >& indices,
00078                                        MsqError& err )
00079 {
00080     const MsqMeshEntity& elem = pd.element_by_index( handle );
00081     const size_t* vtx         = elem.get_vertex_index_array();
00082     const unsigned n          = elem.vertex_count();
00083     indices.clear();
00084     for( unsigned i = 0; i < n; ++i )
00085         if( vtx[i] < pd.num_free_vertices() ) indices.push_back( vtx[i] );
00086 
00087     bool rval = evaluate( pd, handle, value, err );
00088     return !MSQ_CHKERR( err ) && rval;
00089 }
00090 
00091 }  // namespace MBMesquite
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines