MOAB: Mesh Oriented datABase  (version 5.4.1)
NumericalQM.cpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2009 Sandia National Laboratories.  Developed at the
00005 University NumericalQM::of Wisconsin--Madison under SNL contract number
00006     624796.  The U.S. Government and the University of Wisconsin
00007 retain NumericalQM::certain rights to this software.
00008 
00009 This NumericalQM::library is free software; you can redistribute it and/or
00010 modify NumericalQM::it under the terms of the GNU Lesser General Public
00011 License NumericalQM::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 NumericalQM::library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY NumericalQM::or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019 You NumericalQM::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     (2009) [email protected]
00024 
00025   ***************************************************************** */
00026 
00027 /** \file NumericalQM.cpp
00028  *  \brief
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #include "Mesquite.hpp"
00033 #include "NumericalQM.hpp"
00034 
00035 namespace MBMesquite
00036 {
00037 
00038 NumericalQM::NumericalQM( QualityMetric* real_metric, bool numerical_gradient, bool numerical_hessian )
00039     : realMetric( real_metric ), numericGrad( numerical_gradient ), numericHess( numerical_hessian )
00040 {
00041 }
00042 
00043 QualityMetric::MetricType NumericalQM::get_metric_type() const
00044 {
00045     return realMetric->get_metric_type();
00046 }
00047 
00048 std::string NumericalQM::get_name() const
00049 {
00050     return realMetric->get_name();
00051 }
00052 
00053 int NumericalQM::get_negate_flag() const
00054 {
00055     return realMetric->get_negate_flag();
00056 }
00057 
00058 void NumericalQM::get_evaluations( PatchData& pd, std::vector< size_t >& handles, bool free, MsqError& err )
00059 {
00060     return realMetric->get_evaluations( pd, handles, free, err );
00061 }
00062 
00063 bool NumericalQM::evaluate( PatchData& pd, size_t handle, double& value, MsqError& err )
00064 {
00065     return realMetric->evaluate( pd, handle, value, err );
00066 }
00067 
00068 bool NumericalQM::evaluate_with_indices( PatchData& pd,
00069                                          size_t handle,
00070                                          double& value,
00071                                          std::vector< size_t >& indices,
00072                                          MsqError& err )
00073 {
00074     return realMetric->evaluate_with_indices( pd, handle, value, indices, err );
00075 }
00076 
00077 bool NumericalQM::evaluate_with_gradient( PatchData& pd,
00078                                           size_t handle,
00079                                           double& value,
00080                                           std::vector< size_t >& indices,
00081                                           std::vector< Vector3D >& gradient,
00082                                           MsqError& err )
00083 {
00084     if( numericGrad )
00085         return realMetric->QualityMetric::evaluate_with_gradient( pd, handle, value, indices, gradient, err );
00086     else
00087         return realMetric->evaluate_with_gradient( pd, handle, value, indices, gradient, err );
00088 }
00089 
00090 bool NumericalQM::evaluate_with_Hessian_diagonal( PatchData& pd,
00091                                                   size_t handle,
00092                                                   double& value,
00093                                                   std::vector< size_t >& indices,
00094                                                   std::vector< Vector3D >& gradient,
00095                                                   std::vector< SymMatrix3D >& hess,
00096                                                   MsqError& err )
00097 {
00098     if( numericHess )
00099         return realMetric->QualityMetric::evaluate_with_Hessian_diagonal( pd, handle, value, indices, gradient, hess,
00100                                                                           err );
00101     else
00102         return realMetric->evaluate_with_Hessian_diagonal( pd, handle, value, indices, gradient, hess, err );
00103 }
00104 
00105 bool NumericalQM::evaluate_with_Hessian( PatchData& pd,
00106                                          size_t handle,
00107                                          double& value,
00108                                          std::vector< size_t >& indices,
00109                                          std::vector< Vector3D >& gradient,
00110                                          std::vector< Matrix3D >& Hessian,
00111                                          MsqError& err )
00112 
00113 {
00114     if( numericHess )
00115         return realMetric->QualityMetric::evaluate_with_Hessian( pd, handle, value, indices, gradient, Hessian, err );
00116     else
00117         return realMetric->evaluate_with_Hessian( pd, handle, value, indices, gradient, Hessian, err );
00118 }
00119 
00120 }  // namespace MBMesquite
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines