LCOV - code coverage report
Current view: top level - src/mesquite/QualityMetric - ElementAvgQM.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 1 29 3.4 %
Date: 2020-07-18 00:09:26 Functions: 2 7 28.6 %
Branches: 2 54 3.7 %

           Branch data     Line data    Source code
       1                 :            : /* *****************************************************************
       2                 :            :     MESQUITE -- The Mesh Quality Improvement Toolkit
       3                 :            : 
       4                 :            :     Copyright 2006 Sandia National Laboratories.  Developed at the
       5                 :            :     University of Wisconsin--Madison under SNL contract number
       6                 :            :     624796.  The U.S. Government and the University of Wisconsin
       7                 :            :     retain certain rights to 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                 :            :   ***************************************************************** */
      24                 :            : 
      25                 :            : /** \file ElementAvgQM.cpp
      26                 :            :  *  \brief
      27                 :            :  *  \author Boyd Tidwell
      28                 :            :  */
      29                 :            : 
      30                 :            : #include "Mesquite.hpp"
      31                 :            : #include "ElementAvgQM.hpp"
      32                 :            : #include "ElemSampleQM.hpp"
      33                 :            : #include "MsqError.hpp"
      34                 :            : #include "PatchData.hpp"
      35                 :            : #include <limits>
      36                 :            : 
      37                 :            : namespace MBMesquite
      38                 :            : {
      39                 :            : 
      40         [ #  # ]:          0 : ElementAvgQM::ElementAvgQM( ElemSampleQM* metric ) : mMetric( metric ) {}
      41                 :            : 
      42         [ #  # ]:          0 : ElementAvgQM::~ElementAvgQM() {}
      43                 :            : 
      44                 :          0 : std::string ElementAvgQM::get_name() const
      45                 :            : {
      46         [ #  # ]:          0 :     std::string result( "ElementAvgQM(" );
      47 [ #  # ][ #  # ]:          0 :     result += mMetric->get_name();
      48         [ #  # ]:          0 :     result += ")";
      49                 :          0 :     return result;
      50                 :            : }
      51                 :            : 
      52                 :          0 : int ElementAvgQM::get_negate_flag() const
      53                 :            : {
      54                 :          0 :     return get_quality_metric()->get_negate_flag();
      55                 :            : }
      56                 :            : 
      57                 :          0 : bool ElementAvgQM::evaluate( PatchData& pd, size_t handle, double& value, MsqError& err )
      58                 :            : {
      59         [ #  # ]:          0 :     ElemSampleQM* qm = get_quality_metric();
      60                 :          0 :     mHandles.clear();
      61         [ #  # ]:          0 :     qm->get_element_evaluations( pd, handle, mHandles, err );
      62 [ #  # ][ #  # ]:          0 :     MSQ_ERRFALSE( err );
         [ #  # ][ #  # ]
                 [ #  # ]
      63                 :            : 
      64                 :          0 :     bool valid = true;
      65                 :            :     double tmpval;
      66                 :          0 :     double accumulate = 0.0;
      67                 :          0 :     int num_values    = 0;
      68                 :            :     bool tmpvalid;
      69                 :            : 
      70                 :          0 :     value = -std::numeric_limits< double >::infinity();
      71 [ #  # ][ #  # ]:          0 :     for( std::vector< size_t >::iterator h = mHandles.begin(); h != mHandles.end(); ++h )
                 [ #  # ]
      72                 :            :     {
      73 [ #  # ][ #  # ]:          0 :         tmpvalid = qm->evaluate( pd, *h, tmpval, err );
      74 [ #  # ][ #  # ]:          0 :         MSQ_ERRZERO( err );
         [ #  # ][ #  # ]
                 [ #  # ]
      75         [ #  # ]:          0 :         if( !tmpvalid )
      76                 :            :         {
      77                 :          0 :             valid = false;
      78                 :          0 :             break;
      79                 :            :         }
      80                 :            :         else
      81                 :            :         {
      82                 :          0 :             accumulate += tmpval;
      83                 :          0 :             num_values++;
      84                 :            :         }
      85                 :            :     }
      86         [ #  # ]:          0 :     if( valid ) value = accumulate / num_values;
      87                 :            : 
      88                 :          0 :     return valid;
      89                 :            : }
      90                 :            : 
      91 [ +  - ][ +  - ]:        120 : }  // namespace MBMesquite

Generated by: LCOV version 1.11