MOAB: Mesh Oriented datABase  (version 5.2.1)
AveragingQM.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 
00028 /*! \file AveragingQM.hpp
00029     \brief
00030 Header file for the MBMesquite::AveragingQM class
00031 
00032   \author Thomas Leurent
00033   \author Michael Brewer
00034   \date   2002-05-01
00035  */
00036 
00037 #ifndef MSQ_AVERAGING_QM_HPP
00038 #define MSQ_AVERAGING_QM_HPP
00039 
00040 #include "Mesquite.hpp"
00041 #include "QualityMetric.hpp"
00042 
00043 namespace MBMesquite
00044 {
00045 
00046 /*! \class AveragingQM
00047   \brief Averaging functionality for use in quality metrics
00048 */
00049 class MsqMeshEntity;
00050 class PatchData;
00051 class Vector3D;
00052 class Matrix3D;
00053 class MsqError;
00054 
00055 class AveragingQM
00056 {
00057   public:
00058     MESQUITE_EXPORT AveragingQM( QualityMetric::AveragingMethod method ) : avgMethod( method ) {}
00059 
00060     virtual ~AveragingQM() {}
00061 
00062     /*!Set the averaging method for the quality metric. */
00063     MESQUITE_EXPORT inline void set_averaging_method( QualityMetric::AveragingMethod method )
00064     {
00065         avgMethod = method;
00066     }
00067 
00068     MESQUITE_EXPORT inline void set_averaging_method( QualityMetric::AveragingMethod method, MsqError& )
00069     {
00070         set_averaging_method( method );
00071     }
00072 
00073     MESQUITE_EXPORT inline QualityMetric::AveragingMethod get_averaging_method() const
00074     {
00075         return avgMethod;
00076     }
00077 
00078     //! Return true if the requested averaging scheme is supported
00079     //! for analytical calculation of gradients.
00080     inline bool analytical_average_gradient()
00081     {
00082         return avgMethod <= QualityMetric::LAST_WITH_GRADIENT;
00083     }
00084 
00085     //! Return true if the requested averaging scheme is supported
00086     //! for analytical calculation of Hessians.
00087     inline bool analytical_average_hessian()
00088     {
00089         return avgMethod <= QualityMetric::LAST_WITH_HESSIAN;
00090     }
00091 
00092     //! average_metrics takes an array of length num_values and averages the
00093     //! contents using averaging method data member avgMethod .
00094     double average_metrics( const double metric_values[], int num_values, MsqError& err );
00095 
00096     //! Given a list of metric values, calculate the average metric
00097     //! valude according to the current avgMethod and write into
00098     //! the passed metric_values array the the value weight/count to
00099     //! use when averaging gradient vectors for the metric.
00100     //!\param metric_values : As input, a set of quality metric values
00101     //!                       to average.  As output, the fraction of
00102     //!                       the corresponding gradient vector that
00103     //!                       contributes to the average gradient.
00104     //!\param num_metric_values The number of values in the passed array.
00105     double average_metric_and_weights( double metric_values[], int num_metric_values, MsqError& err );
00106 
00107     /** \brief Average metric values and gradients for per-corner evaluation
00108      *
00109      *\param element_type   The element type
00110      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
00111      *                      if the metric couldn't be evaluated for the apex)
00112      *\param corner_values  An array of metric values, one per element corner
00113      *\param corner_grads   The corner gradients, 4 for each corner
00114      *\param vertex_grads   Output.  Gradient at each vertex.
00115      *\return average metric value for element
00116      */
00117     double average_corner_gradients( EntityTopology element_type, uint32_t fixed_vertices, unsigned num_corners,
00118                                      double corner_values[], const Vector3D corner_grads[], Vector3D vertex_grads[],
00119                                      MsqError& err );
00120 
00121     /** \brief Average metric values, gradients, and Hessian diagonal
00122      *         blocks for per-corner evaluation
00123      *
00124      *\param element_type   The element type
00125      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
00126      *                      if the metric couldn't be evaluated for the apex)
00127      *\param corner_values  An array of metric values, one per element corner
00128      *\param corner_grads   The corner gradients, 4 for each corner
00129      *\param corner_hessians The hessians, 10 for each corner
00130      *\param vertex_grads   Output.  Gradient at each vertex.
00131      *\param vertex_hessians Output.  Hessian diagonal block for each vertex.
00132      *\return average metric value for element
00133      */
00134     double average_corner_hessian_diagonals( EntityTopology element_type, uint32_t fixed_vertices, unsigned num_corners,
00135                                              const double corner_values[], const Vector3D corner_grads[],
00136                                              const Matrix3D corner_hessians[], Vector3D vertex_grads[],
00137                                              SymMatrix3D vertex_hessians[], MsqError& err );
00138 
00139     /** \brief Average metric values, gradients, and Hessian diagonal
00140      *         blocks for per-corner evaluation
00141      *
00142      *\param element_type   The element type
00143      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
00144      *                      if the metric couldn't be evaluated for the apex)
00145      *\param corner_values  An array of metric values, one per element corner
00146      *\param corner_grads   The corner gradients, 4 for each corner
00147      *\param corner_hess_diag The diagonal blocks of the Hessian: 4 for each corner.
00148      *\param vertex_grads   Output.  Gradient at each vertex.
00149      *\param vertex_hessians Output.  Hessian diagonal block for each vertex.
00150      *\return average metric value for element
00151      */
00152     double average_corner_hessian_diagonals( EntityTopology element_type, uint32_t fixed_vertices, unsigned num_corners,
00153                                              const double corner_values[], const Vector3D corner_grads[],
00154                                              const SymMatrix3D corner_hess_diag[], Vector3D vertex_grads[],
00155                                              SymMatrix3D vertex_hessians[], MsqError& err );
00156 
00157     /** \brief Average metric values, gradients, and Hessians for
00158      *         per-corner evaluation
00159      *
00160      *\param element_type   The element type
00161      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
00162      *                      if the metric couldn't be evaluated for the apex)
00163      *\param corner_values  An array of metric values, one per element corner
00164      *\param corner_grads   The corner gradients, 4 for each corner
00165      *\param corner_hessians The hessians, 10 for each corner
00166      *\param vertex_grads   Output.  Gradient at each vertex.
00167      *\param vertex_hessians Output.  Hessians.  Length must be (n*(n+1))/2,
00168      *                       where n is the number of vertices in the element.
00169      *\return average metric value for element
00170      */
00171     double average_corner_hessians( EntityTopology element_type, uint32_t fixed_vertices, unsigned num_corners,
00172                                     const double corner_values[], const Vector3D corner_grads[],
00173                                     const Matrix3D corner_hessians[], Vector3D vertex_grads[],
00174                                     Matrix3D vertex_hessians[], MsqError& err );
00175 
00176   private:
00177     QualityMetric::AveragingMethod avgMethod;
00178 };
00179 
00180 }  // namespace MBMesquite
00181 
00182 #endif  // MSQ_AVERAGING_QM_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines