MOAB: Mesh Oriented datABase  (version 5.2.1)
ScalarMultiplyQualityMetric.cpp
Go to the documentation of this file.
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     diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
00024     pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
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, std::vector< size_t >& handles,
00048                                                    bool free_vertices_only, MsqError& err )
00049 {
00050     mMetric->get_evaluations( pd, handles, free_vertices_only, err );MSQ_CHKERR( err );
00051 }
00052 
00053 bool ScalarMultiplyQualityMetric::evaluate( PatchData& pd, size_t handle, double& value, MsqError& err )
00054 {
00055     bool rval = mMetric->evaluate( pd, handle, value, err );
00056     value *= mScale;
00057     return rval;
00058 }
00059 
00060 bool ScalarMultiplyQualityMetric::evaluate_with_indices( PatchData& pd, size_t handle, double& value,
00061                                                          std::vector< size_t >& indices, MsqError& err )
00062 {
00063     bool rval = mMetric->evaluate_with_indices( pd, handle, value, indices, err );
00064     value *= mScale;
00065     return !MSQ_CHKERR( err ) && rval;
00066 }
00067 
00068 bool ScalarMultiplyQualityMetric::evaluate_with_gradient( PatchData& pd, size_t handle, double& value,
00069                                                           std::vector< size_t >& indices,
00070                                                           std::vector< Vector3D >& gradient, MsqError& err )
00071 {
00072     bool rval = mMetric->evaluate_with_gradient( pd, handle, value, indices, gradient, err );
00073     value *= mScale;
00074     for( std::vector< Vector3D >::iterator i = gradient.begin(); i != gradient.end(); ++i )
00075         *i *= mScale;
00076     return !MSQ_CHKERR( err ) && rval;
00077 }
00078 
00079 bool ScalarMultiplyQualityMetric::evaluate_with_Hessian( PatchData& pd, size_t handle, double& value,
00080                                                          std::vector< size_t >& indices,
00081                                                          std::vector< Vector3D >& gradient,
00082                                                          std::vector< Matrix3D >& Hessian, MsqError& err )
00083 {
00084     bool rval = mMetric->evaluate_with_Hessian( pd, handle, value, indices, gradient, Hessian, err );
00085     value *= mScale;
00086     for( std::vector< Vector3D >::iterator i = gradient.begin(); i != gradient.end(); ++i )
00087         *i *= mScale;
00088     for( std::vector< Matrix3D >::iterator j = Hessian.begin(); j != Hessian.end(); ++j )
00089         *j *= mScale;
00090     return !MSQ_CHKERR( err ) && rval;
00091 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines