MOAB: Mesh Oriented datABase
(version 5.4.1)
|
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) [email protected] 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, 00066 const MsqMatrix< DIM, DIM >& W, 00067 double& result, 00068 MsqMatrix< DIM, DIM >& deriv ) 00069 { 00070 const double alpha = det( A ); 00071 const double omega = det( W ); 00072 double tmp = 2 * ( mGamma * omega - alpha ); 00073 if( tmp < 0.0 ) 00074 { 00075 result = 0.0; 00076 deriv = MsqMatrix< DIM, DIM >( 0.0 ); 00077 return true; 00078 } 00079 00080 double prod = 1.0; 00081 for( int i = 1; i < P; ++i ) 00082 prod *= tmp; 00083 result = prod * tmp; 00084 00085 deriv = -2 * P * prod * transpose_adj( A ); 00086 return true; 00087 } 00088 /* 00089 template <unsigned DIM> inline 00090 bool AWUntangleBeta::hess( const MsqMatrix<DIM,DIM>& A, 00091 const MsqMatrix<DIM,DIM>& W, 00092 double& result, 00093 MsqMatrix<DIM,DIM>& deriv, 00094 MsqMatrix<DIM,DIM>* second ) 00095 { 00096 result = det(A) - det(W); 00097 deriv = transpose_adj(A); 00098 set_scaled_outer_product( second, 2.0, deriv ); 00099 pluseq_scaled_2nd_deriv_of_det( second, 2*result, A ); 00100 deriv *= 2*result; 00101 result *= result; 00102 return true; 00103 } 00104 */ 00105 TMP_AW_TEMPL_IMPL_COMMON_NO2ND( AWUntangleBeta ) 00106 00107 } // namespace MBMesquite