1 /* *****************************************************************
2     MESQUITE -- The Mesh Quality Improvement Toolkit
3 
4     Copyright 2007 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     (2008) kraftche@cae.wisc.edu
24 
25   ***************************************************************** */
26 
27 
28 /** \file TInverseMeanRatio.hpp
29  *  \brief
30  *  \author Jason Kraftcheck
31  */
32 
33 #ifndef MSQ_T_INVERSE_MEAN_RATIO_HPP
34 #define MSQ_T_INVERSE_MEAN_RATIO_HPP
35 
36 #include "Mesquite.hpp"
37 #include "TMetricBarrier.hpp"
38 #include <limits>
39 
40 namespace MBMesquite {
41 
42 /** \f$ \frac{|T|^2}{2 det(T)} - 1 \f$ */
43 class TInverseMeanRatio : public TMetricBarrier {
44 public:
45 
46   MESQUITE_EXPORT virtual
47   ~TInverseMeanRatio();
48 
49   MESQUITE_EXPORT virtual
50   std::string get_name() const;
51 
52   MESQUITE_EXPORT virtual
53   bool evaluate( const MsqMatrix<2,2>& T,
54                  double& result,
55                  MsqError& err );
56 
57   /** \f$ \frac{1}{det(T)} [ T - \frac{|T|^2}{2 det(T)}adj(T) ] \f$ */
58   MESQUITE_EXPORT virtual
59   bool evaluate_with_grad( const MsqMatrix<2,2>& T,
60                            double& result,
61                            MsqMatrix<2,2>& deriv_wrt_T,
62                            MsqError& err );
63 
64   MESQUITE_EXPORT virtual
65   bool evaluate_with_hess( const MsqMatrix<2,2>& T,
66                            double& result,
67                            MsqMatrix<2,2>& deriv_wrt_T,
68                            MsqMatrix<2,2> second_wrt_T[3],
69                            MsqError& err );
70 
71   MESQUITE_EXPORT virtual
72   bool evaluate( const MsqMatrix<3,3>& T,
73                  double& result,
74                  MsqError& err );
75 
76   MESQUITE_EXPORT virtual
77   bool evaluate_with_grad( const MsqMatrix<3,3>& T,
78                            double& result,
79                            MsqMatrix<3,3>& deriv_wrt_T,
80                            MsqError& err );
81 
82   MESQUITE_EXPORT virtual
83   bool evaluate_with_hess( const MsqMatrix<3,3>& T,
84                            double& result,
85                            MsqMatrix<3,3>& deriv_wrt_T,
86                            MsqMatrix<3,3> second_wrt_T[6],
87                            MsqError& err );
88 };
89 
90 
91 } // namespace MBMesquite
92 
93 #endif
94