MOAB: Mesh Oriented datABase  (version 5.2.1)
AWUntangleBeta.cpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2006 Sandia National Laboratories.  Developed at the
00005     University of Wisconsin--Madison under SNL contract number
00006     624796.  The U.S. Government and the University of Wisconsin
00007     retain certain rights to 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     (2010) kraftche@cae.wisc.edu
00024 
00025   ***************************************************************** */
00026 
00027 /** \file AWUntangleBeta.cpp
00028  *  \brief
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #include "Mesquite.hpp"
00033 #include "AWUntangleBeta.hpp"
00034 #include "MsqMatrix.hpp"
00035 #include "TMPDerivs.hpp"
00036 #include "TMPCommon.hpp"
00037 
00038 namespace MBMesquite
00039 {
00040 
00041 std::string AWUntangleBeta::get_name() const
00042 {
00043     return "AWUntangleBeta";
00044 }
00045 
00046 AWUntangleBeta::~AWUntangleBeta() {}
00047 
00048 const int P = 3;
00049 
00050 template < unsigned DIM >
00051 inline bool AWUntangleBeta::eval( const MsqMatrix< DIM, DIM >& A, const MsqMatrix< DIM, DIM >& W, double& result )
00052 {
00053     const double alpha = det( A );
00054     const double omega = det( W );
00055     double tmp         = alpha - mGamma * omega;
00056     tmp                = fabs( tmp ) - tmp;
00057     result             = tmp;
00058     for( int i = 1; i < P; ++i )
00059         result *= tmp;
00060 
00061     return true;
00062 }
00063 
00064 template < unsigned DIM >
00065 inline bool AWUntangleBeta::grad( const MsqMatrix< DIM, DIM >& A, const MsqMatrix< DIM, DIM >& W, double& result,
00066                                   MsqMatrix< DIM, DIM >& deriv )
00067 {
00068     const double alpha = det( A );
00069     const double omega = det( W );
00070     double tmp         = 2 * ( mGamma * omega - alpha );
00071     if( tmp < 0.0 )
00072     {
00073         result = 0.0;
00074         deriv  = MsqMatrix< DIM, DIM >( 0.0 );
00075         return true;
00076     }
00077 
00078     double prod = 1.0;
00079     for( int i = 1; i < P; ++i )
00080         prod *= tmp;
00081     result = prod * tmp;
00082 
00083     deriv = -2 * P * prod * transpose_adj( A );
00084     return true;
00085 }
00086 /*
00087 template <unsigned DIM> inline
00088 bool AWUntangleBeta::hess( const MsqMatrix<DIM,DIM>& A,
00089                            const MsqMatrix<DIM,DIM>& W,
00090                            double& result,
00091                            MsqMatrix<DIM,DIM>& deriv,
00092                            MsqMatrix<DIM,DIM>* second )
00093 {
00094   result = det(A) - det(W);
00095   deriv = transpose_adj(A);
00096   set_scaled_outer_product( second, 2.0, deriv );
00097   pluseq_scaled_2nd_deriv_of_det( second, 2*result, A );
00098   deriv *= 2*result;
00099   result *= result;
00100   return true;
00101 }
00102 */
00103 TMP_AW_TEMPL_IMPL_COMMON_NO2ND( AWUntangleBeta )
00104 
00105 }  // namespace MBMesquite
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines