LCOV - code coverage report
Current view: top level - src - tetrahedron.cxx (source / functions) Hit Total Coverage
Test: code_coverage_filter.info Lines: 51 80 63.8 %
Date: 2024-03-28 16:04:17 Functions: 11 19 57.9 %
Branches: 32 62 51.6 %

           Branch data     Line data    Source code
       1                 :            : /** 
       2                 :            :  * \file tetrahedron.cxx \brief tetrahedron Implementation
       3                 :            :  *
       4                 :            :  * This source files implements the different methods for the tetrahedron class
       5                 :            :  */
       6                 :            : 
       7                 :            : #include "read_mesh.h"
       8                 :            : 
       9                 :            : // tetrahedron Class
      10                 :            : 
      11                 :            : //! Default Constructor 
      12                 :          0 : tetrahedron::tetrahedron()
      13                 :            : {
      14                 :          0 :     _parent_mesh = NULL;
      15                 :            : 
      16                 :          0 :     _p1_id = -1;
      17                 :          0 :     _p2_id = -1;
      18                 :          0 :     _p3_id = -1;
      19                 :          0 :     _p4_id = -1;
      20                 :            : 
      21                 :          0 :     _material_id = -1;
      22                 :            :     
      23                 :          0 :     _id = -1;
      24                 :          0 : }
      25                 :            : 
      26                 :            : //! Regular Constructor
      27                 :  687562624 : tetrahedron::tetrahedron(int id, int p1_id, int p2_id, int p3_id, int p4_id,
      28                 :            :                             int material_id, mesh* parent_mesh)
      29                 :            : {
      30                 :  687562624 :     _parent_mesh = parent_mesh;
      31                 :            : 
      32                 :            : 
      33                 :  687562624 :     _p1_id = p1_id;
      34                 :  687562624 :     _p2_id = p2_id;
      35                 :  687562624 :     _p3_id = p3_id;
      36                 :  687562624 :     _p4_id = p4_id;
      37                 :            : 
      38                 :  687562624 :     _material_id = material_id;
      39                 :            : 
      40                 :  687562624 :     _id = id;
      41                 :  687562624 : }
      42                 :            : 
      43                 :            : //! Destructor
      44                 :  367490368 : tetrahedron::~tetrahedron()
      45                 :            : {
      46                 :  367490368 : }
      47                 :            : 
      48                 :            : // Getters
      49                 :            : 
      50                 :            : //! This method returns the parent mesh
      51                 :          0 : mesh* tetrahedron::get_parent_mesh()
      52                 :            : {
      53                 :          0 :     return _parent_mesh;
      54                 :            : }
      55                 :            : 
      56                 :            : //! This method returns the id of the first boundary point
      57                 :  402928977 : int tetrahedron::get_p1_id()
      58                 :            : {
      59                 :  402928977 :     return _p1_id;
      60                 :            : }
      61                 :            : 
      62                 :            : //! This method returns the id of the second boundary point
      63                 :  402928977 : int tetrahedron::get_p2_id()
      64                 :            : {
      65                 :  402928977 :     return _p2_id;
      66                 :            : }
      67                 :            : 
      68                 :            : //! This method returns the id of the third boundary point
      69                 :  402928977 : int tetrahedron::get_p3_id()
      70                 :            : {
      71                 :  402928977 :     return _p3_id;
      72                 :            : }
      73                 :            : 
      74                 :            : //! This method returns the id of the forth boundary point
      75                 :  402928977 : int tetrahedron::get_p4_id()
      76                 :            : {
      77                 :  402928977 :     return _p4_id;
      78                 :            : }
      79                 :            : 
      80                 :            : //! This method returns the id of the tetrahedron's material
      81                 : 1835549075 : int tetrahedron::get_material_id()
      82                 :            : {
      83                 : 1835549075 :     return _material_id;
      84                 :            : }
      85                 :            : 
      86                 :            : //! This method returns the id of the tetrahedron
      87                 :    1648920 : int tetrahedron::get_id()
      88                 :            : {
      89                 :    1648920 :     return _id;
      90                 :            : }
      91                 :            : 
      92                 :            : //!
      93                 :            : //! This method sets the id of the first boundary point
      94                 :            : //! @param id [in]: id to be added
      95                 :            : //!
      96                 :          0 : void tetrahedron::set_p1_id(int id)
      97                 :            : {
      98                 :          0 :     _p1_id = id;
      99                 :          0 : }
     100                 :            : 
     101                 :            : //!
     102                 :            : //! This method sets the id of the second boundary point
     103                 :            : //! @param id [in]: id to be added
     104                 :            : //!
     105                 :          0 : void tetrahedron::set_p2_id(int id)
     106                 :            : {
     107                 :          0 :     _p2_id = id;
     108                 :          0 : }
     109                 :            : 
     110                 :            : //!
     111                 :            : //! This method sets the id of the third boundary point
     112                 :            : //! @param id [in]: id to be added
     113                 :            : //!
     114                 :          0 : void tetrahedron::set_p3_id(int id)
     115                 :            : {
     116                 :          0 :     _p3_id = id;
     117                 :          0 : }
     118                 :            : 
     119                 :            : //!
     120                 :            : //! This method sets the id of the forth boundary point
     121                 :            : //! @param id [in]: id to be added
     122                 :            : //!
     123                 :          0 : void tetrahedron::set_p4_id(int id)
     124                 :            : {
     125                 :          0 :     _p4_id = id;
     126                 :          0 : }
     127                 :            : 
     128                 :            : //!
     129                 :            : //! This method sets the id of the material of the tetrahedron
     130                 :            : //! @param id [in]: id to be added
     131                 :            : //!
     132                 :          0 : void tetrahedron::set_material_id(int id)
     133                 :            : {
     134                 :          0 :     _material_id = id;
     135                 :          0 : }
     136                 :            : 
     137                 :            : //!
     138                 :            : //! This method sets the id of the tetrahedron
     139                 :            : //! @param id [in]: id to be added
     140                 :            : //!
     141                 :          0 : void tetrahedron::set_id(int id)
     142                 :            : {
     143                 :          0 :     _id = id;
     144                 :          0 : }
     145                 :            : 
     146                 :            : // Helper functions
     147                 :            : 
     148                 :            : //!
     149                 :            : //! This method returns the centroid of a tetrahedron
     150                 :            : //!
     151                 :   16900232 : SP_Point tetrahedron::compute_centroid_of()
     152                 :            : {
     153                 :            :     /**
     154                 :            :      * The method finds all the 4 points of the tetrahedron 
     155                 :            :      * and then computes the centroid by summing the x-coordinates together and dividing
     156                 :            :      * by 4. We do the same thing for y and z coordinates.
     157                 :            :      */
     158                 :            : 
     159         [ +  - ]:   33800464 :     vector<float> xcoords(4, 0.0);
     160         [ +  - ]:   33800464 :     vector<float> ycoords(4, 0.0);
     161         [ +  - ]:   33800464 :     vector<float> zcoords(4, 0.0);
     162                 :            : 
     163 [ +  - ][ +  - ]:   16900232 :     xcoords[0] = _parent_mesh->get_list_of_points()[_p1_id - 1]->get_xcoord();
     164 [ +  - ][ +  - ]:   16900232 :     xcoords[1] = _parent_mesh->get_list_of_points()[_p2_id - 1]->get_xcoord();
     165 [ +  - ][ +  - ]:   16900232 :     xcoords[2] = _parent_mesh->get_list_of_points()[_p3_id - 1]->get_xcoord();
     166 [ +  - ][ +  - ]:   16900232 :     xcoords[3] = _parent_mesh->get_list_of_points()[_p4_id - 1]->get_xcoord();
     167                 :            : 
     168 [ +  - ][ +  - ]:   16900232 :     ycoords[0] = _parent_mesh->get_list_of_points()[_p1_id - 1]->get_ycoord();
     169 [ +  - ][ +  - ]:   16900232 :     ycoords[1] = _parent_mesh->get_list_of_points()[_p2_id - 1]->get_ycoord();
     170 [ +  - ][ +  - ]:   16900232 :     ycoords[2] = _parent_mesh->get_list_of_points()[_p3_id - 1]->get_ycoord();
     171 [ +  - ][ +  - ]:   16900232 :     ycoords[3] = _parent_mesh->get_list_of_points()[_p4_id - 1]->get_ycoord();
     172                 :            : 
     173 [ +  - ][ +  - ]:   16900232 :     zcoords[0] = _parent_mesh->get_list_of_points()[_p1_id - 1]->get_zcoord();
     174 [ +  - ][ +  - ]:   16900232 :     zcoords[1] = _parent_mesh->get_list_of_points()[_p2_id - 1]->get_zcoord();
     175 [ +  - ][ +  - ]:   16900232 :     zcoords[2] = _parent_mesh->get_list_of_points()[_p3_id - 1]->get_zcoord();
     176 [ +  - ][ +  - ]:   16900232 :     zcoords[3] = _parent_mesh->get_list_of_points()[_p4_id - 1]->get_zcoord();
     177                 :            : 
     178                 :   16900232 :     float centroid_x = 0.0; 
     179                 :   16900232 :     float centroid_y = 0.0;
     180                 :   16900232 :     float centroid_z = 0.0;
     181         [ +  + ]:   84501160 :     for (int i = 0; i < 4; i++)
     182                 :            :     {
     183                 :   67600928 :         centroid_x += xcoords[i];
     184                 :   67600928 :         centroid_y += ycoords[i];
     185                 :   67600928 :         centroid_z += zcoords[i];
     186                 :            :     }
     187                 :            : 
     188                 :   16900232 :     centroid_x = centroid_x/4;
     189                 :   16900232 :     centroid_y = centroid_y/4;
     190                 :   16900232 :     centroid_z = centroid_z/4;
     191                 :            : 
     192         [ +  - ]:   33800464 :     return SP_Point(centroid_x, centroid_y, centroid_z);
     193                 :            : 
     194 [ +  - ][ +  - ]:        112 : }

Generated by: LCOV version 1.12