1 /* ***************************************************************** 2 MESQUITE -- The Mesh Quality Improvement Toolkit 3 4 Copyright 2006 Sandia National Laboratories. Developed at the 5 University of Wisconsin--Madison under SNL contract number 6 624796. The U.S. Government and the University of Wisconsin 7 retain certain rights to this software. 8 9 This library is free software; you can redistribute it and/or 10 modify it under the terms of the GNU Lesser General Public 11 License as published by the Free Software Foundation; either 12 version 2.1 of the License, or (at your option) any later version. 13 14 This library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public License 20 (lgpl.txt) along with this library; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 23 (2006) kraftche@cae.wisc.edu 24 25 ***************************************************************** */ 26 27 28 /** \file TQualityMetric.hpp 29 * \brief 30 * \author Jason Kraftcheck 31 */ 32 33 #ifndef MSQ_T_QUALITY_METRIC_HPP 34 #define MSQ_T_QUALITY_METRIC_HPP 35 36 #include "Mesquite.hpp" 37 #include "TMPQualityMetric.hpp" 38 #include "MsqMatrix.hpp" 39 40 namespace MBMesquite { 41 42 class TMetric; 43 44 /**\brief Compare targets to mapping function Jacobian matrices 45 * 46 * A quality metric defined using 2D and 3D target metrics, 47 * where the active (A) matrix compared to the target by 48 * the underlying metrics is the Jacobian matrix of the 49 * mapping function at a given sample point. For surface 50 * elements, A is rotated to align the normal with W, such that 51 * both matrices can be reduced from 3x2 to 2x2. 52 */ 53 class TQualityMetric : public TMPQualityMetric 54 { 55 public: 56 57 /** Used in tests and other templatized code */ 58 typedef TMetric MetricType; 59 60 /** 61 *\param tc The target calculator 62 *\param wc The weight calculator 63 *\param target_metric The target metric 64 */ TQualityMetric(TargetCalculator * tc,WeightCalculator * wc,TMetric * target_metric)65 TQualityMetric( TargetCalculator* tc, 66 WeightCalculator* wc, 67 TMetric* target_metric ) 68 : TMPQualityMetric(tc,wc), 69 targetMetric(target_metric) 70 {} 71 72 /** 73 *\param tc The target calculator 74 *\param target_metric The target metric 75 */ TQualityMetric(TargetCalculator * tc,TMetric * target_metric)76 TQualityMetric( TargetCalculator* tc, 77 TMetric* target_metric ) 78 : TMPQualityMetric(tc,0), 79 targetMetric(target_metric) 80 {} 81 82 MESQUITE_EXPORT virtual 83 std::string get_name() const; 84 85 MESQUITE_EXPORT virtual 86 bool evaluate_with_gradient( PatchData& pd, 87 size_t handle, 88 double& value, 89 std::vector<size_t>& indices, 90 std::vector<Vector3D>& gradient, 91 MsqError& err ); 92 93 MESQUITE_EXPORT virtual 94 bool evaluate_with_Hessian_diagonal( PatchData& pd, 95 size_t handle, 96 double& value, 97 std::vector<size_t>& indices, 98 std::vector<Vector3D>& gradient, 99 std::vector<SymMatrix3D>& Hessian_diagonal, 100 MsqError& err ); 101 102 MESQUITE_EXPORT virtual 103 bool evaluate_with_Hessian( PatchData& pd, 104 size_t handle, 105 double& value, 106 std::vector<size_t>& indices, 107 std::vector<Vector3D>& gradient, 108 std::vector<Matrix3D>& Hessian, 109 MsqError& err ); 110 get_target_metric() const111 TMetric* get_target_metric() const { return targetMetric; } set_target_metric(TMetric * m)112 void set_target_metric( TMetric* m ) { targetMetric = m; } 113 114 protected: 115 116 MESQUITE_EXPORT virtual 117 bool evaluate_internal( PatchData& pd, 118 size_t handle, 119 double& value, 120 size_t* indices, 121 size_t& num_indices, 122 MsqError& err ); 123 124 private: 125 126 TMetric* targetMetric; 127 }; 128 129 } // namespace MBMesquite 130 131 #endif 132