LCOV - code coverage report
Current view: top level - src/mesquite/QualityMetric - AveragingQM.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 12 12 100.0 %
Date: 2020-07-18 00:09:26 Functions: 6 6 100.0 %
Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* *****************************************************************
       2                 :            :     MESQUITE -- The Mesh Quality Improvement Toolkit
       3                 :            : 
       4                 :            :     Copyright 2004 Sandia Corporation and Argonne National
       5                 :            :     Laboratory.  Under the terms of Contract DE-AC04-94AL85000
       6                 :            :     with Sandia Corporation, the U.S. Government retains certain
       7                 :            :     rights in this software.
       8                 :            : 
       9                 :            :     This library is free software; you can redistribute it and/or
      10                 :            :     modify it under the terms of the GNU Lesser General Public
      11                 :            :     License as published by the Free Software Foundation; either
      12                 :            :     version 2.1 of the License, or (at your option) any later version.
      13                 :            : 
      14                 :            :     This library is distributed in the hope that it will be useful,
      15                 :            :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :            :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :            :     Lesser General Public License for more details.
      18                 :            : 
      19                 :            :     You should have received a copy of the GNU Lesser General Public License
      20                 :            :     (lgpl.txt) along with this library; if not, write to the Free Software
      21                 :            :     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      22                 :            : 
      23                 :            :     [email protected], [email protected], [email protected],
      24                 :            :     [email protected], [email protected], [email protected]
      25                 :            : 
      26                 :            :   ***************************************************************** */
      27                 :            : 
      28                 :            : /*! \file AveragingQM.hpp
      29                 :            :     \brief
      30                 :            : Header file for the MBMesquite::AveragingQM class
      31                 :            : 
      32                 :            :   \author Thomas Leurent
      33                 :            :   \author Michael Brewer
      34                 :            :   \date   2002-05-01
      35                 :            :  */
      36                 :            : 
      37                 :            : #ifndef MSQ_AVERAGING_QM_HPP
      38                 :            : #define MSQ_AVERAGING_QM_HPP
      39                 :            : 
      40                 :            : #include "Mesquite.hpp"
      41                 :            : #include "QualityMetric.hpp"
      42                 :            : 
      43                 :            : namespace MBMesquite
      44                 :            : {
      45                 :            : 
      46                 :            : /*! \class AveragingQM
      47                 :            :   \brief Averaging functionality for use in quality metrics
      48                 :            : */
      49                 :            : class MsqMeshEntity;
      50                 :            : class PatchData;
      51                 :            : class Vector3D;
      52                 :            : class Matrix3D;
      53                 :            : class MsqError;
      54                 :            : 
      55                 :            : class AveragingQM
      56                 :            : {
      57                 :            :   public:
      58                 :         35 :     MESQUITE_EXPORT AveragingQM( QualityMetric::AveragingMethod method ) : avgMethod( method ) {}
      59                 :            : 
      60         [ -  + ]:         66 :     virtual ~AveragingQM() {}
      61                 :            : 
      62                 :            :     /*!Set the averaging method for the quality metric. */
      63                 :          8 :     MESQUITE_EXPORT inline void set_averaging_method( QualityMetric::AveragingMethod method )
      64                 :            :     {
      65                 :          8 :         avgMethod = method;
      66                 :          8 :     }
      67                 :            : 
      68                 :          2 :     MESQUITE_EXPORT inline void set_averaging_method( QualityMetric::AveragingMethod method, MsqError& )
      69                 :            :     {
      70                 :          2 :         set_averaging_method( method );
      71                 :          2 :     }
      72                 :            : 
      73                 :            :     MESQUITE_EXPORT inline QualityMetric::AveragingMethod get_averaging_method() const
      74                 :            :     {
      75                 :            :         return avgMethod;
      76                 :            :     }
      77                 :            : 
      78                 :            :     //! Return true if the requested averaging scheme is supported
      79                 :            :     //! for analytical calculation of gradients.
      80                 :     152783 :     inline bool analytical_average_gradient()
      81                 :            :     {
      82                 :     152783 :         return avgMethod <= QualityMetric::LAST_WITH_GRADIENT;
      83                 :            :     }
      84                 :            : 
      85                 :            :     //! Return true if the requested averaging scheme is supported
      86                 :            :     //! for analytical calculation of Hessians.
      87                 :     139808 :     inline bool analytical_average_hessian()
      88                 :            :     {
      89                 :     139808 :         return avgMethod <= QualityMetric::LAST_WITH_HESSIAN;
      90                 :            :     }
      91                 :            : 
      92                 :            :     //! average_metrics takes an array of length num_values and averages the
      93                 :            :     //! contents using averaging method data member avgMethod .
      94                 :            :     double average_metrics( const double metric_values[], int num_values, MsqError& err );
      95                 :            : 
      96                 :            :     //! Given a list of metric values, calculate the average metric
      97                 :            :     //! valude according to the current avgMethod and write into
      98                 :            :     //! the passed metric_values array the the value weight/count to
      99                 :            :     //! use when averaging gradient vectors for the metric.
     100                 :            :     //!\param metric_values : As input, a set of quality metric values
     101                 :            :     //!                       to average.  As output, the fraction of
     102                 :            :     //!                       the corresponding gradient vector that
     103                 :            :     //!                       contributes to the average gradient.
     104                 :            :     //!\param num_metric_values The number of values in the passed array.
     105                 :            :     double average_metric_and_weights( double metric_values[], int num_metric_values, MsqError& err );
     106                 :            : 
     107                 :            :     /** \brief Average metric values and gradients for per-corner evaluation
     108                 :            :      *
     109                 :            :      *\param element_type   The element type
     110                 :            :      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
     111                 :            :      *                      if the metric couldn't be evaluated for the apex)
     112                 :            :      *\param corner_values  An array of metric values, one per element corner
     113                 :            :      *\param corner_grads   The corner gradients, 4 for each corner
     114                 :            :      *\param vertex_grads   Output.  Gradient at each vertex.
     115                 :            :      *\return average metric value for element
     116                 :            :      */
     117                 :            :     double average_corner_gradients( EntityTopology element_type, uint32_t fixed_vertices, unsigned num_corners,
     118                 :            :                                      double corner_values[], const Vector3D corner_grads[], Vector3D vertex_grads[],
     119                 :            :                                      MsqError& err );
     120                 :            : 
     121                 :            :     /** \brief Average metric values, gradients, and Hessian diagonal
     122                 :            :      *         blocks for per-corner evaluation
     123                 :            :      *
     124                 :            :      *\param element_type   The element type
     125                 :            :      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
     126                 :            :      *                      if the metric couldn't be evaluated for the apex)
     127                 :            :      *\param corner_values  An array of metric values, one per element corner
     128                 :            :      *\param corner_grads   The corner gradients, 4 for each corner
     129                 :            :      *\param corner_hessians The hessians, 10 for each corner
     130                 :            :      *\param vertex_grads   Output.  Gradient at each vertex.
     131                 :            :      *\param vertex_hessians Output.  Hessian diagonal block for each vertex.
     132                 :            :      *\return average metric value for element
     133                 :            :      */
     134                 :            :     double average_corner_hessian_diagonals( EntityTopology element_type, uint32_t fixed_vertices, unsigned num_corners,
     135                 :            :                                              const double corner_values[], const Vector3D corner_grads[],
     136                 :            :                                              const Matrix3D corner_hessians[], Vector3D vertex_grads[],
     137                 :            :                                              SymMatrix3D vertex_hessians[], MsqError& err );
     138                 :            : 
     139                 :            :     /** \brief Average metric values, gradients, and Hessian diagonal
     140                 :            :      *         blocks for per-corner evaluation
     141                 :            :      *
     142                 :            :      *\param element_type   The element type
     143                 :            :      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
     144                 :            :      *                      if the metric couldn't be evaluated for the apex)
     145                 :            :      *\param corner_values  An array of metric values, one per element corner
     146                 :            :      *\param corner_grads   The corner gradients, 4 for each corner
     147                 :            :      *\param corner_hess_diag The diagonal blocks of the Hessian: 4 for each corner.
     148                 :            :      *\param vertex_grads   Output.  Gradient at each vertex.
     149                 :            :      *\param vertex_hessians Output.  Hessian diagonal block for each vertex.
     150                 :            :      *\return average metric value for element
     151                 :            :      */
     152                 :            :     double average_corner_hessian_diagonals( EntityTopology element_type, uint32_t fixed_vertices, unsigned num_corners,
     153                 :            :                                              const double corner_values[], const Vector3D corner_grads[],
     154                 :            :                                              const SymMatrix3D corner_hess_diag[], Vector3D vertex_grads[],
     155                 :            :                                              SymMatrix3D vertex_hessians[], MsqError& err );
     156                 :            : 
     157                 :            :     /** \brief Average metric values, gradients, and Hessians for
     158                 :            :      *         per-corner evaluation
     159                 :            :      *
     160                 :            :      *\param element_type   The element type
     161                 :            :      *\param num_corners    The number of corners (e.g. pass 4 for a pyramid
     162                 :            :      *                      if the metric couldn't be evaluated for the apex)
     163                 :            :      *\param corner_values  An array of metric values, one per element corner
     164                 :            :      *\param corner_grads   The corner gradients, 4 for each corner
     165                 :            :      *\param corner_hessians The hessians, 10 for each corner
     166                 :            :      *\param vertex_grads   Output.  Gradient at each vertex.
     167                 :            :      *\param vertex_hessians Output.  Hessians.  Length must be (n*(n+1))/2,
     168                 :            :      *                       where n is the number of vertices in the element.
     169                 :            :      *\return average metric value for element
     170                 :            :      */
     171                 :            :     double average_corner_hessians( EntityTopology element_type, uint32_t fixed_vertices, unsigned num_corners,
     172                 :            :                                     const double corner_values[], const Vector3D corner_grads[],
     173                 :            :                                     const Matrix3D corner_hessians[], Vector3D vertex_grads[],
     174                 :            :                                     Matrix3D vertex_hessians[], MsqError& err );
     175                 :            : 
     176                 :            :   private:
     177                 :            :     QualityMetric::AveragingMethod avgMethod;
     178                 :            : };
     179                 :            : 
     180                 :            : }  // namespace MBMesquite
     181                 :            : 
     182                 :            : #endif  // MSQ_AVERAGING_QM_HPP

Generated by: LCOV version 1.11