MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 /* ***************************************************************** 00002 MESQUITE -- The Mesh Quality Improvement Toolkit 00003 00004 Copyright 2004 Sandia Corporation and Argonne National 00005 Laboratory. Under the terms of Contract DE-AC04-94AL85000 00006 with Sandia Corporation, the U.S. Government 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 [email protected], [email protected], [email protected], 00024 [email protected], [email protected], [email protected] 00025 00026 ***************************************************************** */ 00027 /*! 00028 \file ScalarMultiplyQualityMetric.cpp 00029 \brief 00030 00031 \author Todd Munson 00032 \date 2004-12-21 00033 */ 00034 00035 #include "ScalarMultiplyQualityMetric.hpp" 00036 #include "Vector3D.hpp" 00037 #include "Matrix3D.hpp" 00038 #include "MsqError.hpp" 00039 00040 using namespace MBMesquite; 00041 00042 std::string ScalarMultiplyQualityMetric::get_name() const 00043 { 00044 return std::string( "Scale(" ) + mMetric->get_name() + ")"; 00045 } 00046 00047 void ScalarMultiplyQualityMetric::get_evaluations( PatchData& pd, 00048 std::vector< size_t >& handles, 00049 bool free_vertices_only, 00050 MsqError& err ) 00051 { 00052 mMetric->get_evaluations( pd, handles, free_vertices_only, err );MSQ_CHKERR( err ); 00053 } 00054 00055 bool ScalarMultiplyQualityMetric::evaluate( PatchData& pd, size_t handle, double& value, MsqError& err ) 00056 { 00057 bool rval = mMetric->evaluate( pd, handle, value, err ); 00058 value *= mScale; 00059 return rval; 00060 } 00061 00062 bool ScalarMultiplyQualityMetric::evaluate_with_indices( PatchData& pd, 00063 size_t handle, 00064 double& value, 00065 std::vector< size_t >& indices, 00066 MsqError& err ) 00067 { 00068 bool rval = mMetric->evaluate_with_indices( pd, handle, value, indices, err ); 00069 value *= mScale; 00070 return !MSQ_CHKERR( err ) && rval; 00071 } 00072 00073 bool ScalarMultiplyQualityMetric::evaluate_with_gradient( PatchData& pd, 00074 size_t handle, 00075 double& value, 00076 std::vector< size_t >& indices, 00077 std::vector< Vector3D >& gradient, 00078 MsqError& err ) 00079 { 00080 bool rval = mMetric->evaluate_with_gradient( pd, handle, value, indices, gradient, err ); 00081 value *= mScale; 00082 for( std::vector< Vector3D >::iterator i = gradient.begin(); i != gradient.end(); ++i ) 00083 *i *= mScale; 00084 return !MSQ_CHKERR( err ) && rval; 00085 } 00086 00087 bool ScalarMultiplyQualityMetric::evaluate_with_Hessian( PatchData& pd, 00088 size_t handle, 00089 double& value, 00090 std::vector< size_t >& indices, 00091 std::vector< Vector3D >& gradient, 00092 std::vector< Matrix3D >& Hessian, 00093 MsqError& err ) 00094 { 00095 bool rval = mMetric->evaluate_with_Hessian( pd, handle, value, indices, gradient, Hessian, err ); 00096 value *= mScale; 00097 for( std::vector< Vector3D >::iterator i = gradient.begin(); i != gradient.end(); ++i ) 00098 *i *= mScale; 00099 for( std::vector< Matrix3D >::iterator j = Hessian.begin(); j != Hessian.end(); ++j ) 00100 *j *= mScale; 00101 return !MSQ_CHKERR( err ) && rval; 00102 }