LCOV - code coverage report
Current view: top level - src/mesquite/QualityMetric/TMP - TargetMetricUtil.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 50 50 100.0 %
Date: 2020-07-18 00:09:26 Functions: 6 6 100.0 %
Branches: 97 172 56.4 %

           Branch data     Line data    Source code
       1                 :            : /* *****************************************************************
       2                 :            :     MESQUITE -- The Mesh Quality Improvement Toolkit
       3                 :            : 
       4                 :            :     Copyright 2007 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                 :            :     (2007) [email protected]
      24                 :            : 
      25                 :            :   ***************************************************************** */
      26                 :            : 
      27                 :            : /** \file TargetMetricUtil.cpp
      28                 :            :  *  \brief
      29                 :            :  *  \author Jason Kraftcheck
      30                 :            :  */
      31                 :            : 
      32                 :            : #include "Mesquite.hpp"
      33                 :            : #include "TargetMetricUtil.hpp"
      34                 :            : #include "MsqMatrix.hpp"
      35                 :            : #include "PatchData.hpp"
      36                 :            : #include "ElementQM.hpp"
      37                 :            : #include "ElemSampleQM.hpp"
      38                 :            : 
      39                 :            : namespace MBMesquite
      40                 :            : {
      41                 :            : 
      42                 :    2596324 : void surface_to_2d( const MsqMatrix< 3, 2 >& A, const MsqMatrix< 3, 2 >& W, MsqMatrix< 2, 2 >& W_22,
      43                 :            :                     MsqMatrix< 3, 2 >& RZ )
      44                 :            : {
      45         [ +  - ]:    2596324 :     MsqMatrix< 3, 1 > W1 = W.column( 0 );
      46         [ +  - ]:    2596324 :     MsqMatrix< 3, 1 > W2 = W.column( 1 );
      47         [ +  - ]:    2596324 :     MsqMatrix< 3, 1 > nw = W1 * W2;
      48 [ +  - ][ +  - ]:    2596324 :     nw *= 1.0 / length( nw );
      49                 :            : 
      50 [ +  - ][ +  + ]:    7788972 :     MsqMatrix< 3, 1 > z[2];
      51 [ +  - ][ +  - ]:    2596324 :     z[0] = W1 * ( 1.0 / length( W1 ) );
      52         [ +  - ]:    2596324 :     z[1] = nw * z[0];
      53         [ +  - ]:    2596324 :     MsqMatrix< 3, 2 > Z( z );
      54                 :            : 
      55 [ +  - ][ +  - ]:    2596324 :     MsqMatrix< 3, 1 > np = A.column( 0 ) * A.column( 1 );
                 [ +  - ]
      56 [ +  - ][ +  - ]:    2596324 :     np *= 1.0 / length( np );
      57         [ +  - ]:    2596324 :     double dot           = np % nw;
      58 [ +  + ][ +  - ]:    2596324 :     MsqMatrix< 3, 1 > nr = ( dot >= 0.0 ) ? nw : -nw;
      59         [ +  - ]:    2596324 :     MsqMatrix< 3, 1 > v  = nr * np;
      60         [ +  - ]:    2596324 :     double vlen          = length( v );
      61         [ +  + ]:    2596324 :     if( vlen < DBL_EPSILON )
      62                 :            :     {
      63                 :    2320312 :         RZ = Z;  // R = I
      64                 :            :     }
      65                 :            :     else
      66                 :            :     {
      67         [ +  - ]:     276012 :         v *= 1.0 / vlen;
      68         [ +  - ]:     276012 :         MsqMatrix< 3, 1 > r1[3] = { v, np, v * np };
      69         [ +  - ]:     276012 :         MsqMatrix< 3, 1 > r2[3] = { v, nr, v * nr };
      70 [ +  - ][ +  - ]:     276012 :         MsqMatrix< 3, 3 > R1( r1 ), R2( r2 );
      71 [ +  - ][ +  - ]:     276012 :         RZ = R1 * transpose( R2 ) * Z;
                 [ +  - ]
      72                 :            :     }
      73                 :            : 
      74 [ +  - ][ +  - ]:    2596324 :     W_22 = transpose( Z ) * W;
      75                 :    2596324 : }
      76                 :            : /*
      77                 :            : void surface_to_2d( const MsqMatrix<3,2>& App,
      78                 :            :                     const MsqMatrix<3,2>& Wp,
      79                 :            :                     MsqMatrix<2,2>& A,
      80                 :            :                     MsqMatrix<2,2>& W )
      81                 :            : {
      82                 :            :   MsqMatrix<3,1> Wp1 = Wp.column(0);
      83                 :            :   MsqMatrix<3,1> Wp2 = Wp.column(1);
      84                 :            :   MsqMatrix<3,1> nwp = Wp1 * Wp2;
      85                 :            :   nwp *= 1.0/length(nwp);
      86                 :            : 
      87                 :            :   MsqMatrix<3,1> z[2];
      88                 :            :   z[0] = Wp1 * (1.0 / length( Wp1 ));
      89                 :            :   z[1] = nwp * z[0];
      90                 :            :   MsqMatrix<3,2> Z(z);
      91                 :            :   W = transpose(Z) * Wp;
      92                 :            : 
      93                 :            :   MsqMatrix<3,1> npp = App.column(0) * App.column(1);
      94                 :            :   npp *= 1.0 / length(npp);
      95                 :            :   double dot = npp % nwp;
      96                 :            :   MsqMatrix<3,1> nr = (dot >= 0.0) ? nwp : -nwp;
      97                 :            :   MsqMatrix<3,1> v = nr * npp;
      98                 :            :   double vlen = length(v);
      99                 :            :   if (vlen > DBL_EPSILON) {
     100                 :            :     v *= 1.0 / vlen;
     101                 :            :     MsqMatrix<3,1> r1[3] = { v, npp, v * npp }, r2[3] = { v, nr, v * nr };
     102                 :            :     MsqMatrix<3,3> R1( r1 ), R2( r2 );
     103                 :            :     MsqMatrix<3,3> RT = R2 * transpose(R1);
     104                 :            :     MsqMatrix<3,2> Ap = RT * App;
     105                 :            :     A = transpose(Z) * Ap;
     106                 :            :   }
     107                 :            :   else {
     108                 :            :     A = transpose(Z) * App;
     109                 :            :   }
     110                 :            : }
     111                 :            : */
     112                 :            : 
     113                 :    7747639 : static inline void append_elem_samples( PatchData& pd, size_t e, std::vector< size_t >& handles )
     114                 :            : {
     115         [ +  - ]:    7747639 :     NodeSet samples     = pd.get_samples( e );
     116 [ +  - ][ +  - ]:    7747639 :     EntityTopology type = pd.element_by_index( e ).get_element_type();
     117                 :    7747639 :     size_t curr_size    = handles.size();
     118 [ +  - ][ +  - ]:    7747639 :     handles.resize( curr_size + samples.num_nodes() );
     119         [ +  - ]:    7747639 :     std::vector< size_t >::iterator i = handles.begin() + curr_size;
     120 [ +  - ][ +  + ]:   38115978 :     for( unsigned j = 0; j < TopologyInfo::corners( type ); ++j )
     121 [ +  - ][ +  + ]:   30368339 :         if( samples.corner_node( j ) ) *( i++ ) = ElemSampleQM::handle( Sample( 0, j ), e );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     122 [ +  - ][ +  + ]:   47470496 :     for( unsigned j = 0; j < TopologyInfo::edges( type ); ++j )
     123 [ +  - ][ +  + ]:   39722857 :         if( samples.mid_edge_node( j ) ) *( i++ ) = ElemSampleQM::handle( Sample( 1, j ), e );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     124 [ +  - ][ +  + ]:   29347477 :     for( unsigned j = 0; j < TopologyInfo::faces( type ); ++j )
     125 [ +  - ][ +  + ]:   21599838 :         if( samples.mid_face_node( j ) ) *( i++ ) = ElemSampleQM::handle( Sample( 2, j ), e );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     126 [ +  - ][ +  + ]:    7747639 :     if( TopologyInfo::dimension( type ) == 3 && samples.mid_region_node() )
         [ +  - ][ +  + ]
                 [ +  + ]
     127 [ +  - ][ +  - ]:    4318103 :         *( i++ ) = ElemSampleQM::handle( Sample( 3, 0 ), e );
         [ +  - ][ +  - ]
     128                 :    7747639 : }
     129                 :            : 
     130                 :     222295 : void get_sample_pt_evaluations( PatchData& pd, std::vector< size_t >& handles, bool free, MsqError& err )
     131                 :            : {
     132                 :     222295 :     handles.clear();
     133         [ +  - ]:     222295 :     std::vector< size_t > elems;
     134 [ +  - ][ +  - ]:     444590 :     ElementQM::get_element_evaluations( pd, elems, free, err );MSQ_ERRRTN( err );
         [ -  + ][ #  # ]
         [ #  # ][ -  + ]
     135 [ +  - ][ +  - ]:    2659547 :     for( std::vector< size_t >::iterator i = elems.begin(); i != elems.end(); ++i )
         [ +  + ][ +  - ]
     136 [ +  - ][ +  - ]:    2659547 :         append_elem_samples( pd, *i, handles );
     137                 :            : }
     138                 :            : 
     139                 :    5310387 : void get_elem_sample_points( PatchData& pd, size_t elem, std::vector< size_t >& handles, MsqError& /*err*/ )
     140                 :            : {
     141                 :    5310387 :     handles.clear();
     142                 :    5310387 :     append_elem_samples( pd, elem, handles );
     143                 :    5310387 : }
     144                 :            : 
     145 [ +  - ][ +  - ]:        120 : }  // namespace MBMesquite

Generated by: LCOV version 1.11