MOAB: Mesh Oriented datABase  (version 5.4.1)
IdealWeightInverseMeanRatio.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     [email protected], [email protected], [email protected],
00024     [email protected], [email protected], [email protected]
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 IdealWeightInverseMeanRatio.hpp
00031 
00032 Header file for the MBMesquite::IdealWeightInverseMeanRatio class
00033 
00034 \author Michael Brewer
00035 \author Thomas Leurent
00036 \date   2002-06-19
00037  */
00038 
00039 #ifndef IdealWeightInverseMeanRatio_hpp
00040 #define IdealWeightInverseMeanRatio_hpp
00041 
00042 #include "Mesquite.hpp"
00043 #include "ElementQM.hpp"
00044 #include "AveragingQM.hpp"
00045 #include "Vector3D.hpp"
00046 #include "Matrix3D.hpp"
00047 #include "Exponent.hpp"
00048 
00049 namespace MBMesquite
00050 {
00051 class MsqMeshEntity;
00052 class PatchData;
00053 class MsqError;
00054 
00055 /*! \class IdealWeightInverseMeanRatio
00056   \brief Computes the inverse mean ratio of given element.
00057 
00058   The metric does not use the sample point functionality or the
00059   compute_weighted_jacobian.  It evaluates the metric at
00060   the element vertices, and uses the isotropic ideal element.
00061   Optionally, the metric computation can be raised to the
00062   'pow_dbl' power.  This does not necessarily raise the metric
00063   value to the 'pow_dbl' power but instead raises each local
00064   metric.  For example, if the corner inverse mean ratios of a quadraliteral
00065   element were m1,m2,m3, and m4 and we set pow_dbl=2 and
00066   used linear averaging, the metric value would then be
00067   m = .25(m1*m1 + m2*m2 + m3*m3 + m4*m4).  The metric does
00068   require a feasible region, and the metric needs to be minimized
00069   if pow_dbl is greater than zero and maximized if pow_dbl
00070   is less than zero.  pow_dbl being equal to zero is invalid.
00071 */
00072 class IdealWeightInverseMeanRatio : public ElementQM, public AveragingQM
00073 {
00074   public:
00075     MESQUITE_EXPORT IdealWeightInverseMeanRatio( MsqError& err, double power = 1.0 );
00076     MESQUITE_EXPORT IdealWeightInverseMeanRatio();
00077 
00078     //! virtual destructor ensures use of polymorphism during destruction
00079     MESQUITE_EXPORT virtual ~IdealWeightInverseMeanRatio() {}
00080 
00081     virtual std::string get_name() const;
00082 
00083     //! 1 if metric should be minimized, -1 if metric should be maximized.
00084     virtual int get_negate_flag() const;
00085 
00086     virtual bool evaluate( PatchData& pd, size_t handle, double& value, MsqError& err );
00087 
00088     virtual bool evaluate_with_gradient( PatchData& pd,
00089                                          size_t handle,
00090                                          double& value,
00091                                          std::vector< size_t >& indices,
00092                                          std::vector< Vector3D >& gradient,
00093                                          MsqError& err );
00094 
00095     virtual bool evaluate_with_Hessian_diagonal( PatchData& pd,
00096                                                  size_t handle,
00097                                                  double& value,
00098                                                  std::vector< size_t >& indices,
00099                                                  std::vector< Vector3D >& gradient,
00100                                                  std::vector< SymMatrix3D >& Hessian,
00101                                                  MsqError& err );
00102 
00103     virtual bool evaluate_with_Hessian( PatchData& pd,
00104                                         size_t handle,
00105                                         double& value,
00106                                         std::vector< size_t >& indices,
00107                                         std::vector< Vector3D >& gradient,
00108                                         std::vector< Matrix3D >& Hessian,
00109                                         MsqError& err );
00110 
00111   private:
00112     //! Sets the power value in the metric computation.
00113     void set_metric_power( double pow_dbl, MsqError& err );
00114 
00115     // arrays used in Hessian computations
00116     // We allocate them here, so that one allocation only is done.
00117     // This gives a big computation speed increase.
00118     Vector3D mCoords[4];      // Vertex coordinates for the (decomposed) elements
00119     Vector3D mGradients[32];  // Gradient of metric with respect to the coords
00120     Matrix3D mHessians[80];   // Hessian of metric with respect to the coords
00121     double mMetrics[8];       // Metric values for the (decomposed) elements
00122                               // variables used in the definition of the metric (2d and 3d)
00123     double a2Con;
00124     Exponent b2Con;
00125     Exponent c2Con;
00126 
00127     double a3Con;
00128     Exponent b3Con;
00129     Exponent c3Con;
00130 };
00131 }  // namespace MBMesquite
00132 
00133 #endif  // IdealWeightInverseMeanRatio_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines