LCOV - code coverage report
Current view: top level - src/geom - edge.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 51 65 78.5 %
Date: 2025-08-19 19:27:09 Functions: 11 15 73.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
       3             : 
       4             : // This library is free software; you can redistribute it and/or
       5             : // modify it under the terms of the GNU Lesser General Public
       6             : // License as published by the Free Software Foundation; either
       7             : // version 2.1 of the License, or (at your option) any later version.
       8             : 
       9             : // This library is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             : // Lesser General Public License for more details.
      13             : 
      14             : // You should have received a copy of the GNU Lesser General Public
      15             : // License along with this library; if not, write to the Free Software
      16             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      17             : 
      18             : 
      19             : 
      20             : // Local includes
      21             : #include "libmesh/edge.h"
      22             : #include "libmesh/node_elem.h"
      23             : 
      24             : namespace libMesh
      25             : {
      26             : 
      27             : 
      28             : // ------------------------------------------------------------
      29             : // Edge class static member initializations
      30             : const int Edge::num_sides;
      31             : const int Edge::num_edges;
      32             : const int Edge::num_children;
      33             : const int Edge::nodes_per_side;
      34             : const int Edge::nodes_per_edge;
      35             : 
      36             : // ------------------------------------------------------------
      37             : // Edge class member functions
      38       72455 : unsigned int Edge::local_side_node(unsigned int side,
      39             :                                    unsigned int /*side_node*/) const
      40             : {
      41        6046 :   libmesh_assert_less (side, this->n_sides());
      42       72455 :   return side;
      43             : }
      44             : 
      45             : 
      46             : 
      47           0 : unsigned int Edge::local_edge_node(unsigned int /*edge*/,
      48             :                                    unsigned int /*edge_node*/) const
      49             : {
      50           0 :   libmesh_error_msg("Calling Edge::local_edge_node() does not make sense.");
      51             :   return 0;
      52             : }
      53             : 
      54             : 
      55             : 
      56         431 : std::unique_ptr<Elem> Edge::side_ptr (const unsigned int i)
      57             : {
      58          14 :   libmesh_assert_less (i, 2);
      59         431 :   std::unique_ptr<Elem> nodeelem = std::make_unique<NodeElem>();
      60         445 :   nodeelem->set_node(0, this->node_ptr(i));
      61             : 
      62         431 :   nodeelem->set_interior_parent(this);
      63         417 :   nodeelem->inherit_data_from(*this);
      64             : 
      65         431 :   return nodeelem;
      66           0 : }
      67             : 
      68             : 
      69     1340691 : void Edge::side_ptr (std::unique_ptr<Elem> & side,
      70             :                      const unsigned int i)
      71             : {
      72       42182 :   libmesh_assert_less (i, this->n_sides());
      73             : 
      74     1340691 :   if (!side.get() || side->type() != NODEELEM)
      75      131536 :     side = this->build_side_ptr(i);
      76             :   else
      77             :     {
      78     1233463 :       side->inherit_data_from(*this);
      79     1314931 :       side->set_node(0, this->node_ptr(i));
      80             :     }
      81     1340691 : }
      82             : 
      83             : 
      84             : 
      85             : 
      86      144266 : std::unique_ptr<Elem> Edge::build_side_ptr (const unsigned int i)
      87             : {
      88        7848 :   libmesh_assert_less (i, 2);
      89      144266 :   std::unique_ptr<Elem> nodeelem = std::make_unique<NodeElem>();
      90      152113 :   nodeelem->set_node(0, this->node_ptr(i));
      91             : 
      92      144266 :   nodeelem->set_interior_parent(this);
      93      136419 :   nodeelem->inherit_data_from(*this);
      94             : 
      95      144266 :   return nodeelem;
      96           0 : }
      97             : 
      98             : 
      99        2469 : void Edge::build_side_ptr (std::unique_ptr<Elem> & side,
     100             :                            const unsigned int i)
     101             : {
     102         150 :   libmesh_assert_less (i, this->n_sides());
     103             : 
     104        2469 :   if (!side.get() || side->type() != NODEELEM)
     105        2228 :     side = this->build_side_ptr(i);
     106             :   else
     107             :     {
     108        1310 :       side->set_interior_parent(this);
     109        1250 :       side->inherit_data_from(*this);
     110        1370 :       side->set_node(0, this->node_ptr(i));
     111             :     }
     112        2469 : }
     113             : 
     114             : 
     115             : 
     116             : 
     117      209903 : bool Edge::is_child_on_side(const unsigned int c,
     118             :                             const unsigned int s) const
     119             : {
     120      112457 :   libmesh_assert_less (c, this->n_children());
     121      112457 :   libmesh_assert_less (s, this->n_sides());
     122             : 
     123      209903 :   return (c == s);
     124             : }
     125             : 
     126             : 
     127             : 
     128           0 : unsigned int Edge::opposite_side(const unsigned int side_in) const
     129             : {
     130           0 :   libmesh_assert_less (side_in, 2);
     131           0 :   return 1 - side_in;
     132             : }
     133             : 
     134             : 
     135             : 
     136           0 : unsigned int Edge::opposite_node(const unsigned int node_in,
     137             :                                  const unsigned int libmesh_dbg_var(side_in)) const
     138             : {
     139           0 :   libmesh_assert_less (node_in, 2);
     140           0 :   libmesh_assert_less (side_in, this->n_sides());
     141           0 :   libmesh_assert(this->is_node_on_side(node_in, side_in));
     142             : 
     143           0 :   return 1 - node_in;
     144             : }
     145             : 
     146             : std::vector<unsigned>
     147        4416 : Edge::nodes_on_side(const unsigned int s) const
     148             : {
     149         318 :   libmesh_assert_less(s, 2);
     150        4416 :   return {s};
     151             : }
     152             : 
     153             : std::vector<unsigned>
     154           0 : Edge::nodes_on_edge(const unsigned int e) const
     155             : {
     156           0 :   return nodes_on_side(e);
     157             : }
     158             : 
     159         144 : unsigned int Edge::center_node_on_side(const unsigned short side) const
     160             : {
     161          12 :   libmesh_assert_less (side, this->n_sides());
     162         144 :   return side;
     163             : }
     164             : 
     165        2214 : ElemType Edge::side_type (const unsigned int libmesh_dbg_var(s)) const
     166             : {
     167         178 :   libmesh_assert_less (s, 2);
     168        2214 :   return NODEELEM;
     169             : }
     170             : 
     171             : 
     172             : bool
     173         492 : Edge::is_flipped() const
     174             : {
     175             :   // Don't trigger on 1D elements embedded in 2D/3D
     176             :   return (
     177             : #if LIBMESH_DIM > 2
     178         534 :           !this->point(0)(2) && !this->point(1)(2) &&
     179             : #endif
     180             : #if LIBMESH_DIM > 1
     181        1026 :           !this->point(0)(1) && !this->point(1)(1) &&
     182             : #endif
     183         534 :           this->point(0)(0) > this->point(1)(0));
     184             : }
     185             : 
     186             : 
     187             : 
     188     5069476 : bool Edge::on_reference_element(const Point & p,
     189             :                                 const Real eps) const
     190             : {
     191     5069476 :   return ((p(0) >= -1-eps) && (p(0) <= 1+eps));
     192             : }
     193             : 
     194             : } // namespace libMesh

Generated by: LCOV version 1.14