MOAB: Mesh Oriented datABase  (version 5.4.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     [email protected], [email protected], [email protected],
00024     [email protected], [email protected], [email protected]
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,
00118                                      uint32_t fixed_vertices,
00119                                      unsigned num_corners,
00120                                      double corner_values[],
00121                                      const Vector3D corner_grads[],
00122                                      Vector3D vertex_grads[],
00123                                      MsqError& err );
00124 
00125     /** \brief Average metric values, gradients, and Hessian diagonal
00126      *         blocks for per-corner evaluation
00127      *
00128      *\param element_type   The element type
00129      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
00130      *                      if the metric couldn't be evaluated for the apex)
00131      *\param corner_values  An array of metric values, one per element corner
00132      *\param corner_grads   The corner gradients, 4 for each corner
00133      *\param corner_hessians The hessians, 10 for each corner
00134      *\param vertex_grads   Output.  Gradient at each vertex.
00135      *\param vertex_hessians Output.  Hessian diagonal block for each vertex.
00136      *\return average metric value for element
00137      */
00138     double average_corner_hessian_diagonals( EntityTopology element_type,
00139                                              uint32_t fixed_vertices,
00140                                              unsigned num_corners,
00141                                              const double corner_values[],
00142                                              const Vector3D corner_grads[],
00143                                              const Matrix3D corner_hessians[],
00144                                              Vector3D vertex_grads[],
00145                                              SymMatrix3D vertex_hessians[],
00146                                              MsqError& err );
00147 
00148     /** \brief Average metric values, gradients, and Hessian diagonal
00149      *         blocks for per-corner evaluation
00150      *
00151      *\param element_type   The element type
00152      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
00153      *                      if the metric couldn't be evaluated for the apex)
00154      *\param corner_values  An array of metric values, one per element corner
00155      *\param corner_grads   The corner gradients, 4 for each corner
00156      *\param corner_hess_diag The diagonal blocks of the Hessian: 4 for each corner.
00157      *\param vertex_grads   Output.  Gradient at each vertex.
00158      *\param vertex_hessians Output.  Hessian diagonal block for each vertex.
00159      *\return average metric value for element
00160      */
00161     double average_corner_hessian_diagonals( EntityTopology element_type,
00162                                              uint32_t fixed_vertices,
00163                                              unsigned num_corners,
00164                                              const double corner_values[],
00165                                              const Vector3D corner_grads[],
00166                                              const SymMatrix3D corner_hess_diag[],
00167                                              Vector3D vertex_grads[],
00168                                              SymMatrix3D vertex_hessians[],
00169                                              MsqError& err );
00170 
00171     /** \brief Average metric values, gradients, and Hessians for
00172      *         per-corner evaluation
00173      *
00174      *\param element_type   The element type
00175      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
00176      *                      if the metric couldn't be evaluated for the apex)
00177      *\param corner_values  An array of metric values, one per element corner
00178      *\param corner_grads   The corner gradients, 4 for each corner
00179      *\param corner_hessians The hessians, 10 for each corner
00180      *\param vertex_grads   Output.  Gradient at each vertex.
00181      *\param vertex_hessians Output.  Hessians.  Length must be (n*(n+1))/2,
00182      *                       where n is the number of vertices in the element.
00183      *\return average metric value for element
00184      */
00185     double average_corner_hessians( EntityTopology element_type,
00186                                     uint32_t fixed_vertices,
00187                                     unsigned num_corners,
00188                                     const double corner_values[],
00189                                     const Vector3D corner_grads[],
00190                                     const Matrix3D corner_hessians[],
00191                                     Vector3D vertex_grads[],
00192                                     Matrix3D vertex_hessians[],
00193                                     MsqError& err );
00194 
00195   private:
00196     QualityMetric::AveragingMethod avgMethod;
00197 };
00198 
00199 }  // namespace MBMesquite
00200 
00201 #endif  // MSQ_AVERAGING_QM_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines