LCOV - code coverage report
Current view: top level - src/mesquite/Misc - MeshDomain1D.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 9 99 9.1 %
Date: 2020-07-18 00:09:26 Functions: 4 24 16.7 %
Branches: 6 124 4.8 %

           Branch data     Line data    Source code
       1                 :            : /* *****************************************************************
       2                 :            :     MESQUITE -- The Mesh Quality Improvement Toolkit
       3                 :            : 
       4                 :            :     Copyright 2008 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                 :            :     (2008) [email protected]
      24                 :            : 
      25                 :            :   ***************************************************************** */
      26                 :            : 
      27                 :            : /** \file MeshDomain1D.cpp
      28                 :            :  *  \brief
      29                 :            :  *  \author Jason Kraftcheck
      30                 :            :  */
      31                 :            : 
      32                 :            : #include "Mesquite.hpp"
      33                 :            : #include "MeshDomain1D.hpp"
      34                 :            : #include "MsqError.hpp"
      35                 :            : 
      36                 :            : namespace MBMesquite
      37                 :            : {
      38                 :            : 
      39                 :          0 : void PointDomain::snap_to( Mesh::VertexHandle, Vector3D& coordinate ) const
      40                 :            : {
      41                 :          0 :     coordinate = geom();
      42                 :          0 : }
      43                 :            : 
      44                 :          0 : void PointDomain::vertex_normal_at( Mesh::VertexHandle, Vector3D& coordinate ) const
      45                 :            : {
      46                 :          0 :     coordinate.set( 0, 0, 0 );
      47                 :          0 : }
      48                 :            : 
      49                 :          0 : void PointDomain::element_normal_at( Mesh::ElementHandle, Vector3D& coordinate ) const
      50                 :            : {
      51                 :          0 :     coordinate.set( 0, 0, 0 );
      52                 :          0 : }
      53                 :            : 
      54                 :          0 : void PointDomain::vertex_normal_at( const Mesh::VertexHandle*, Vector3D coordinates[], unsigned count,
      55                 :            :                                     MsqError& err ) const
      56                 :            : {
      57         [ #  # ]:          0 :     std::fill( coordinates, coordinates + count, Vector3D( 0, 0, 0 ) );
      58         [ #  # ]:          0 :     MSQ_SETERR( err )( "Cannot get normal for PointDomain", MsqError::INTERNAL_ERROR );
      59                 :          0 : }
      60                 :            : 
      61                 :          0 : void PointDomain::closest_point( Mesh::VertexHandle, const Vector3D&, Vector3D& closest, Vector3D& normal,
      62                 :            :                                  MsqError& err ) const
      63                 :            : {
      64                 :          0 :     closest = geom();
      65                 :          0 :     normal.set( 0, 0, 0 );
      66         [ #  # ]:          0 :     MSQ_SETERR( err )( "Cannot get normal for PointDomain", MsqError::INTERNAL_ERROR );
      67                 :          0 : }
      68                 :            : 
      69                 :          0 : void PointDomain::domain_DoF( const Mesh::VertexHandle*, unsigned short* dof_array, size_t num_handles,
      70                 :            :                               MsqError& ) const
      71                 :            : {
      72         [ #  # ]:          0 :     std::fill( dof_array, dof_array + num_handles, 0 );
      73                 :          0 : }
      74                 :            : 
      75                 :          0 : void LineDomain::snap_to( Mesh::VertexHandle, Vector3D& coordinate ) const
      76                 :            : {
      77         [ #  # ]:          0 :     coordinate = geom().point( geom().closest( coordinate ) );
      78                 :          0 : }
      79                 :            : 
      80                 :          0 : void LineDomain::vertex_normal_at( Mesh::VertexHandle, Vector3D& coordinate ) const
      81                 :            : // no normal, return tangent instead.
      82                 :            : {
      83                 :          0 :     coordinate = geom().direction();
      84                 :          0 : }
      85                 :            : 
      86                 :          0 : void LineDomain::element_normal_at( Mesh::ElementHandle, Vector3D& coordinate ) const
      87                 :            : // no normal, return tangent instead.
      88                 :            : {
      89                 :          0 :     coordinate = geom().direction();
      90                 :          0 : }
      91                 :            : 
      92                 :          0 : void LineDomain::vertex_normal_at( const Mesh::VertexHandle*, Vector3D coordinates[], unsigned count,
      93                 :            :                                    MsqError& err ) const
      94                 :            : {
      95                 :          0 :     std::fill( coordinates, coordinates + count, geom().direction() );
      96         [ #  # ]:          0 :     MSQ_SETERR( err )( "Cannot get normal for LineDomain", MsqError::INTERNAL_ERROR );
      97                 :          0 : }
      98                 :            : 
      99                 :          0 : void LineDomain::closest_point( Mesh::VertexHandle, const Vector3D& position, Vector3D& closest, Vector3D& normal,
     100                 :            :                                 MsqError& err ) const
     101                 :            : {
     102         [ #  # ]:          0 :     closest = geom().point( geom().closest( position ) );
     103                 :          0 :     normal  = geom().direction();
     104         [ #  # ]:          0 :     MSQ_SETERR( err )( "Cannot get normal for LineDomain", MsqError::INTERNAL_ERROR );
     105                 :          0 : }
     106                 :            : 
     107                 :          0 : void LineDomain::domain_DoF( const Mesh::VertexHandle*, unsigned short* dof_array, size_t num_handles, MsqError& ) const
     108                 :            : {
     109         [ #  # ]:          0 :     std::fill( dof_array, dof_array + num_handles, 1 );
     110                 :          0 : }
     111                 :            : 
     112                 :         12 : double LineDomain::arc_length( const double position1[3], const double position2[3], MsqError& )
     113                 :            : {
     114         [ +  - ]:         12 :     double p1 = mGeom.closest( position1 );
     115         [ +  - ]:         12 :     double p2 = mGeom.closest( position2 );
     116                 :         12 :     return p2 - p1;
     117                 :            : }
     118                 :            : 
     119                 :        192 : void LineDomain::position_from_length( const double from_here[3], double length, double result_point[3], MsqError& )
     120                 :            : {
     121         [ +  - ]:        192 :     const double param = mGeom.closest( from_here );
     122         [ +  - ]:        192 :     mGeom.point( param + length ).get_coordinates( result_point );
     123                 :        192 : }
     124                 :            : 
     125                 :          0 : void CircleDomain::snap_to( Mesh::VertexHandle, Vector3D& coordinate ) const
     126                 :            : {
     127         [ #  # ]:          0 :     coordinate = geom().closest( coordinate );
     128                 :          0 : }
     129                 :            : 
     130                 :          0 : void CircleDomain::vertex_normal_at( Mesh::VertexHandle, Vector3D& coordinate ) const
     131                 :            : {
     132                 :            :     // no normal, return tangent instead.
     133 [ #  # ][ #  # ]:          0 :     Vector3D junk, copy( coordinate );
     134 [ #  # ][ #  # ]:          0 :     if( !geom().closest( copy, junk, coordinate ) )  // at center?
                 [ #  # ]
     135 [ #  # ][ #  # ]:          0 :         coordinate = geom().radial_vector();
                 [ #  # ]
     136                 :          0 : }
     137                 :            : 
     138                 :          0 : void CircleDomain::element_normal_at( Mesh::ElementHandle h, Vector3D& coordinate ) const
     139                 :            : {
     140                 :          0 :     CircleDomain::vertex_normal_at( h, coordinate );
     141                 :          0 : }
     142                 :            : 
     143                 :          0 : void CircleDomain::vertex_normal_at( const Mesh::VertexHandle* handles, Vector3D coordinates[], unsigned count,
     144                 :            :                                      MsqError& err ) const
     145                 :            : {
     146         [ #  # ]:          0 :     for( unsigned i = 0; i < count; ++i )
     147                 :          0 :         vertex_normal_at( handles[i], coordinates[i] );
     148         [ #  # ]:          0 :     MSQ_SETERR( err )( "Cannot get normal for CircleDomain", MsqError::INTERNAL_ERROR );
     149                 :          0 : }
     150                 :            : 
     151                 :          0 : void CircleDomain::closest_point( Mesh::VertexHandle, const Vector3D& position, Vector3D& closest, Vector3D& normal,
     152                 :            :                                   MsqError& err ) const
     153                 :            : {
     154                 :            :     // no normal, get tangent instead
     155         [ #  # ]:          0 :     if( !geom().closest( position, closest, normal ) )
     156                 :            :     {  // at center?
     157         [ #  # ]:          0 :         normal  = geom().radial_vector();
     158         [ #  # ]:          0 :         closest = geom().center() + normal;
     159                 :            :     }
     160         [ #  # ]:          0 :     MSQ_SETERR( err )( "Cannot get normal for CircleDomain", MsqError::INTERNAL_ERROR );
     161                 :          0 : }
     162                 :            : 
     163                 :          0 : void CircleDomain::domain_DoF( const Mesh::VertexHandle*, unsigned short* dof_array, size_t num_handles,
     164                 :            :                                MsqError& ) const
     165                 :            : {
     166         [ #  # ]:          0 :     std::fill( dof_array, dof_array + num_handles, 1 );
     167                 :          0 : }
     168                 :            : 
     169                 :          0 : double CircleDomain::arc_length( const double position1[3], const double position2[3], MsqError& )
     170                 :            : {
     171 [ #  # ][ #  # ]:          0 :     Vector3D p1  = Vector3D( position1 ) - mGeom.center();
                 [ #  # ]
     172 [ #  # ][ #  # ]:          0 :     Vector3D p2  = Vector3D( position2 ) - mGeom.center();
                 [ #  # ]
     173 [ #  # ][ #  # ]:          0 :     Vector3D vy  = mGeom.normal() * p1;
     174 [ #  # ][ #  # ]:          0 :     Vector3D vx  = vy * mGeom.normal();
     175         [ #  # ]:          0 :     double x     = p2 % vx;
     176         [ #  # ]:          0 :     double y     = p2 % vy;
     177                 :          0 :     double angle = atan2( y, x );
     178         [ #  # ]:          0 :     return angle * mGeom.radius();
     179                 :            : }
     180                 :            : 
     181                 :          0 : void CircleDomain::position_from_length( const double from_here[3], double length, double result_point[3], MsqError& )
     182                 :            : {
     183 [ #  # ][ #  # ]:          0 :     Vector3D b   = Vector3D( from_here ) - mGeom.center();
                 [ #  # ]
     184 [ #  # ][ #  # ]:          0 :     Vector3D vy  = mGeom.normal() * b;
     185 [ #  # ][ #  # ]:          0 :     Vector3D vx  = vy * mGeom.normal();
     186         [ #  # ]:          0 :     double angle = length / mGeom.radius();
     187                 :          0 :     double x     = std::cos( angle );
     188                 :          0 :     double y     = std::sin( angle );
     189 [ #  # ][ #  # ]:          0 :     vy *= y / vy.length();
     190 [ #  # ][ #  # ]:          0 :     vx *= x / vx.length();
     191         [ #  # ]:          0 :     Vector3D result = vx + vy;
     192 [ #  # ][ #  # ]:          0 :     result *= mGeom.radius();
     193 [ #  # ][ #  # ]:          0 :     result += mGeom.center();
     194         [ #  # ]:          0 :     result.get_coordinates( result_point );
     195                 :          0 : }
     196                 :            : 
     197 [ +  - ][ +  - ]:          8 : }  // namespace MBMesquite

Generated by: LCOV version 1.11