MOAB: Mesh Oriented datABase  (version 5.2.1)
IdealWeightMeanRatio.hpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2004 Sandia Corporation and Argonne National
00005     Laboratory.  Under the terms of Contract DE-AC04-94AL85000
00006     with Sandia Corporation, the U.S. Government retains certain
00007     rights in 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     diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
00024     pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
00025 
00026   ***************************************************************** */
00027 // -*- Mode : c++; tab-width: 3; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 3
00028 // -*-
00029 
00030 /*! \file IdealWeightMeanRatio.hpp
00031 
00032 Header file for the MBMesquite::IdealWeightMeanRatio class
00033 
00034 \author Michael Brewer
00035 \author Todd Munson
00036 \date   2002-11-11
00037  */
00038 
00039 #ifndef IdealWeightMeanRatio_hpp
00040 #define IdealWeightMeanRatio_hpp
00041 
00042 #include "Mesquite.hpp"
00043 #include "MsqError.hpp"
00044 #include "ElementQM.hpp"
00045 #include "AveragingQM.hpp"
00046 #include "Vector3D.hpp"
00047 #include "Matrix3D.hpp"
00048 #include "Exponent.hpp"
00049 
00050 namespace MBMesquite
00051 {
00052 /*! \class IdealWeightMeanRatio
00053   \brief Computes the mean ratio quality metric
00054   of given element.
00055 
00056   The metric does not use the sample point functionality or the
00057   compute_weighted_jacobian.  It evaluates the metric at
00058   the element vertices, and uses the isotropic ideal element.
00059   It does require a feasible region, and the metric needs
00060   to be maximized.
00061 */
00062 class IdealWeightMeanRatio : public ElementQM, public AveragingQM
00063 {
00064   public:
00065     MESQUITE_EXPORT IdealWeightMeanRatio()
00066         : AveragingQM( QualityMetric::LINEAR ), a2Con( 2.0 ), b2Con( -1.0 ), c2Con( 1.0 ), a3Con( 3.0 ), b3Con( -1.0 ),
00067           c3Con( 2.0 / 3.0 )
00068     {
00069     }
00070 
00071     //! virtual destructor ensures use of polymorphism during destruction
00072     MESQUITE_EXPORT virtual ~IdealWeightMeanRatio() {}
00073 
00074     virtual std::string get_name() const;
00075 
00076     //! 1 if metric should be minimized, -1 if metric should be maximized.
00077     virtual int get_negate_flag() const;
00078 
00079     virtual bool evaluate( PatchData& pd, size_t handle, double& value, MsqError& err );
00080 
00081     virtual bool evaluate_with_gradient( PatchData& pd, size_t handle, double& value, std::vector< size_t >& indices,
00082                                          std::vector< Vector3D >& gradient, MsqError& err );
00083 
00084     virtual bool evaluate_with_Hessian_diagonal( PatchData& pd, size_t handle, double& value,
00085                                                  std::vector< size_t >& indices, std::vector< Vector3D >& gradient,
00086                                                  std::vector< SymMatrix3D >& Hessian, MsqError& err );
00087 
00088     virtual bool evaluate_with_Hessian( PatchData& pd, size_t handle, double& value, std::vector< size_t >& indices,
00089                                         std::vector< Vector3D >& gradient, std::vector< Matrix3D >& Hessian,
00090                                         MsqError& err );
00091 
00092   private:
00093     // arrays used in Hessian computations
00094     // We allocate them here, so that one allocation only is done.
00095     // This gives a big computation speed increase.
00096     Vector3D mCoords[4];      // Vertex coordinates for the (decomposed) elements
00097     Vector3D mGradients[32];  // Gradient of metric with respect to the coords
00098     Matrix3D mHessians[80];   // Hessian of metric with respect to the coords
00099     double mMetrics[8];       // Metric values for the (decomposed) elements
00100 
00101     const double a2Con;
00102     const Exponent b2Con;
00103     const Exponent c2Con;
00104 
00105     const double a3Con;
00106     const Exponent b3Con;
00107     const Exponent c3Con;
00108 };
00109 }  // namespace MBMesquite
00110 
00111 #endif  // IdealWeightMeanRatio_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines