LCOV - code coverage report
Current view: top level - src/mesquite/Mesh - IdealElements.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 15 91 16.5 %
Date: 2020-07-18 00:09:26 Functions: 2 11 18.2 %
Branches: 22 98 22.4 %

           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                 :            :     (2006) [email protected]
      24                 :            : 
      25                 :            :   ***************************************************************** */
      26                 :            : 
      27                 :            : /** \file IdealElements.cpp
      28                 :            :  *  \brief
      29                 :            :  *  \author Jason Kraftcheck
      30                 :            :  */
      31                 :            : 
      32                 :            : #include "Mesquite.hpp"
      33                 :            : #include "IdealElements.hpp"
      34                 :            : #include "Vector3D.hpp"
      35                 :            : 
      36                 :            : namespace MBMesquite
      37                 :            : {
      38                 :            : 
      39                 :         31 : static Vector3D unit_quad[4] = { Vector3D( -0.5, -0.5, 0.0 ), Vector3D( 0.5, -0.5, 0.0 ), Vector3D( 0.5, 0.5, 0.0 ),
      40                 :         31 :                                  Vector3D( -0.5, 0.5, 0.0 ) };
      41                 :            : 
      42                 :         31 : static Vector3D unit_hex[8] = { Vector3D( 0.5, -0.5, -0.5 ),  Vector3D( 0.5, 0.5, -0.5 ), Vector3D( -0.5, 0.5, -0.5 ),
      43                 :            :                                 Vector3D( -0.5, -0.5, -0.5 ), Vector3D( 0.5, -0.5, 0.5 ), Vector3D( 0.5, 0.5, 0.5 ),
      44                 :         31 :                                 Vector3D( -0.5, 0.5, 0.5 ),   Vector3D( -0.5, -0.5, 0.5 ) };
      45                 :            : 
      46         [ +  + ]:        124 : static Vector3D unit_edge_tri[3];
      47         [ +  + ]:        155 : static Vector3D unit_edge_tet[4];
      48         [ +  + ]:        186 : static Vector3D unit_edge_pyr[5];
      49         [ +  + ]:        217 : static Vector3D unit_edge_wdg[6];
      50         [ +  + ]:        186 : static Vector3D unit_height_pyr[5];
      51                 :            : 
      52         [ +  + ]:        124 : static Vector3D unit_tri[3];
      53         [ +  + ]:        155 : static Vector3D unit_tet[4];
      54         [ +  + ]:        186 : static Vector3D unit_pyr[5];
      55         [ +  + ]:        217 : static Vector3D unit_wdg[6];
      56         [ +  + ]:        186 : static Vector3D unit_hex_pyr[5];
      57                 :            : 
      58                 :            : static void init_tri( Vector3D* coords, double side );
      59                 :            : static void init_tet( Vector3D* coords, double side );
      60                 :            : static void init_pyr( Vector3D* coords, double side );
      61                 :            : static void init_wdg( Vector3D* coords, double side );
      62                 :            : static void init_hex_pyr( Vector3D* coords, double height );
      63                 :            : 
      64                 :            : static const Vector3D* const* init_unit_edge( Vector3D** );
      65                 :            : static const Vector3D* const* init_unit_elem( Vector3D** );
      66                 :            : 
      67                 :          0 : const Vector3D* unit_edge_element( EntityTopology ptype, bool punit_pyr )
      68                 :            : {
      69                 :            :     static Vector3D* values[MIXED + 1];
      70 [ #  # ][ #  # ]:          0 :     static const Vector3D* const* data = init_unit_edge( values );
         [ #  # ][ #  # ]
      71 [ #  # ][ #  # ]:          0 :     return ( ptype == PYRAMID && punit_pyr ) ? data[MIXED] : data[ptype];
      72                 :            : }
      73                 :            : 
      74                 :          0 : const Vector3D* unit_element( EntityTopology ptype, bool punit_pyr )
      75                 :            : {
      76                 :            :     static Vector3D* values[MIXED + 1];
      77 [ #  # ][ #  # ]:          0 :     static const Vector3D* const* data = init_unit_elem( values );
         [ #  # ][ #  # ]
      78 [ #  # ][ #  # ]:          0 :     return ( ptype == PYRAMID && punit_pyr ) ? data[MIXED] : data[ptype];
      79                 :            : }
      80                 :            : 
      81                 :          0 : static const Vector3D* const* init_unit_edge( Vector3D** ptr )
      82                 :            : {
      83         [ #  # ]:          0 :     for( unsigned i = 0; i < MIXED; ++i )
      84                 :          0 :         ptr[i] = 0;
      85                 :            : 
      86                 :          0 :     init_tri( unit_edge_tri, 1.0 );
      87                 :          0 :     init_tet( unit_edge_tet, 1.0 );
      88                 :          0 :     init_pyr( unit_edge_pyr, 1.0 );
      89                 :          0 :     init_wdg( unit_edge_wdg, 1.0 );
      90                 :          0 :     init_hex_pyr( unit_height_pyr, 1.0 );
      91                 :            : 
      92                 :          0 :     ptr[TRIANGLE]      = unit_edge_tri;
      93                 :          0 :     ptr[QUADRILATERAL] = unit_quad;
      94                 :          0 :     ptr[TETRAHEDRON]   = unit_edge_tet;
      95                 :          0 :     ptr[PYRAMID]       = unit_edge_pyr;
      96                 :          0 :     ptr[PRISM]         = unit_edge_wdg;
      97                 :          0 :     ptr[HEXAHEDRON]    = unit_hex;
      98                 :          0 :     ptr[MIXED]         = unit_height_pyr;
      99                 :          0 :     return ptr;
     100                 :            : }
     101                 :            : 
     102                 :          0 : static const Vector3D* const* init_unit_elem( Vector3D** ptr )
     103                 :            : {
     104         [ #  # ]:          0 :     for( unsigned i = 0; i < MIXED; ++i )
     105                 :          0 :         ptr[i] = 0;
     106                 :            : 
     107                 :          0 :     init_tri( unit_tri, 2.0 * pow( 3.0, -0.25 ) );
     108                 :          0 :     init_tet( unit_tet, MBMesquite::cbrt( 3.0 ) * sqrt( 2.0 ) );
     109                 :          0 :     init_pyr( unit_pyr, pow( 18.0, 1.0 / 6.0 ) );
     110                 :          0 :     init_wdg( unit_wdg, MBMesquite::cbrt( 4.0 ) * pow( 3.0, -1.0 / 6.0 ) );
     111                 :          0 :     init_hex_pyr( unit_hex_pyr, MBMesquite::cbrt( 3.0 ) );
     112                 :            : 
     113                 :          0 :     ptr[TRIANGLE]      = unit_tri;
     114                 :          0 :     ptr[QUADRILATERAL] = unit_quad;
     115                 :          0 :     ptr[TETRAHEDRON]   = unit_tet;
     116                 :          0 :     ptr[PYRAMID]       = unit_pyr;
     117                 :          0 :     ptr[PRISM]         = unit_wdg;
     118                 :          0 :     ptr[HEXAHEDRON]    = unit_hex;
     119                 :          0 :     ptr[MIXED]         = unit_hex_pyr;
     120                 :          0 :     return ptr;
     121                 :            : }
     122                 :            : 
     123                 :          0 : static void init_tri( Vector3D* coords, double side )
     124                 :            : {
     125                 :          0 :     const double third_height = side * sqrt( 3.0 ) / 6.0;
     126         [ #  # ]:          0 :     coords[1]                 = Vector3D( -0.5 * side, -third_height, 0.0 );
     127         [ #  # ]:          0 :     coords[2]                 = Vector3D( 0.5 * side, -third_height, 0.0 );
     128         [ #  # ]:          0 :     coords[0]                 = Vector3D( 0.0, 2 * third_height, 0.0 );
     129                 :          0 : }
     130                 :            : 
     131                 :          0 : static void init_tet( Vector3D* coords, double side )
     132                 :            : {
     133                 :          0 :     const double height     = side * sqrt( 2.0 / 3.0 );
     134                 :          0 :     const double third_base = side * sqrt( 3.0 ) / 6.0;
     135         [ #  # ]:          0 :     coords[0]               = Vector3D( -0.5 * side, -third_base, -0.25 * height );
     136         [ #  # ]:          0 :     coords[1]               = Vector3D( 0.5 * side, -third_base, -0.25 * height );
     137         [ #  # ]:          0 :     coords[2]               = Vector3D( 0.0, 2 * third_base, -0.25 * height );
     138         [ #  # ]:          0 :     coords[3]               = Vector3D( 0.0, 0.0, 0.75 * height );
     139                 :          0 : }
     140                 :            : 
     141                 :          0 : static void init_pyr( Vector3D* coords, double side )
     142                 :            : {
     143                 :          0 :     const double height = side * sqrt( 2.0 ) * 0.5;
     144         [ #  # ]:          0 :     coords[0]           = Vector3D( 0.5 * side, -0.5 * side, -0.25 * height );
     145         [ #  # ]:          0 :     coords[1]           = Vector3D( 0.5 * side, 0.5 * side, -0.25 * height );
     146         [ #  # ]:          0 :     coords[2]           = Vector3D( -0.5 * side, 0.5 * side, -0.25 * height );
     147         [ #  # ]:          0 :     coords[3]           = Vector3D( -0.5 * side, -0.5 * side, -0.25 * height );
     148         [ #  # ]:          0 :     coords[4]           = Vector3D( 0.0, 0.0, 0.75 * height );
     149                 :          0 : }
     150                 :            : 
     151                 :          0 : static void init_wdg( Vector3D* coords, double side )
     152                 :            : {
     153                 :          0 :     const double third_height = side * sqrt( 3.0 ) / 6.0;
     154         [ #  # ]:          0 :     coords[0]                 = Vector3D( -0.5 * side, -third_height, -0.5 * side );
     155         [ #  # ]:          0 :     coords[1]                 = Vector3D( 0.5 * side, -third_height, -0.5 * side );
     156         [ #  # ]:          0 :     coords[2]                 = Vector3D( 0.0, 2 * third_height, -0.5 * side );
     157         [ #  # ]:          0 :     coords[3]                 = Vector3D( -0.5 * side, -third_height, 0.5 * side );
     158         [ #  # ]:          0 :     coords[4]                 = Vector3D( 0.5 * side, -third_height, 0.5 * side );
     159         [ #  # ]:          0 :     coords[5]                 = Vector3D( 0.0, 2 * third_height, 0.5 * side );
     160                 :          0 : }
     161                 :            : 
     162                 :          0 : static void init_hex_pyr( Vector3D* coords, double side )
     163                 :            : {
     164         [ #  # ]:          0 :     coords[0] = Vector3D( 0.5 * side, -0.5 * side, -0.25 * side );
     165         [ #  # ]:          0 :     coords[1] = Vector3D( 0.5 * side, 0.5 * side, -0.25 * side );
     166         [ #  # ]:          0 :     coords[2] = Vector3D( -0.5 * side, 0.5 * side, -0.25 * side );
     167         [ #  # ]:          0 :     coords[3] = Vector3D( -0.5 * side, -0.5 * side, -0.25 * side );
     168         [ #  # ]:          0 :     coords[4] = Vector3D( 0.0, 0.0, 0.75 * side );
     169                 :          0 : }
     170                 :            : 
     171 [ +  - ][ +  - ]:        124 : }  // namespace MBMesquite

Generated by: LCOV version 1.11