MOAB: Mesh Oriented datABase
(version 5.2.1)
|
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) kraftche@cae.wisc.edu 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, size_t handle, double& value, std::vector< size_t >& indices, 00069 MsqError& err ) 00070 { 00071 return realMetric->evaluate_with_indices( pd, handle, value, indices, err ); 00072 } 00073 00074 bool NumericalQM::evaluate_with_gradient( PatchData& pd, size_t handle, double& value, std::vector< size_t >& indices, 00075 std::vector< Vector3D >& gradient, MsqError& err ) 00076 { 00077 if( numericGrad ) 00078 return realMetric->QualityMetric::evaluate_with_gradient( pd, handle, value, indices, gradient, err ); 00079 else 00080 return realMetric->evaluate_with_gradient( pd, handle, value, indices, gradient, err ); 00081 } 00082 00083 bool NumericalQM::evaluate_with_Hessian_diagonal( PatchData& pd, size_t handle, double& value, 00084 std::vector< size_t >& indices, std::vector< Vector3D >& gradient, 00085 std::vector< SymMatrix3D >& hess, MsqError& err ) 00086 { 00087 if( numericHess ) 00088 return realMetric->QualityMetric::evaluate_with_Hessian_diagonal( pd, handle, value, indices, gradient, hess, 00089 err ); 00090 else 00091 return realMetric->evaluate_with_Hessian_diagonal( pd, handle, value, indices, gradient, hess, err ); 00092 } 00093 00094 bool NumericalQM::evaluate_with_Hessian( PatchData& pd, size_t handle, double& value, std::vector< size_t >& indices, 00095 std::vector< Vector3D >& gradient, std::vector< Matrix3D >& Hessian, 00096 MsqError& err ) 00097 00098 { 00099 if( numericHess ) 00100 return realMetric->QualityMetric::evaluate_with_Hessian( pd, handle, value, indices, gradient, Hessian, err ); 00101 else 00102 return realMetric->evaluate_with_Hessian( pd, handle, value, indices, gradient, Hessian, err ); 00103 } 00104 00105 } // namespace MBMesquite