LCOV - code coverage report
Current view: top level - src/base - XFEMCrackGrowthIncrement2DCut.C (source / functions) Hit Total Coverage
Test: idaholab/moose xfem: #31405 (292dce) with base fef103 Lines: 26 30 86.7 %
Date: 2025-09-04 07:58:55 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "XFEMCrackGrowthIncrement2DCut.h"
      11             : #include "XFEMFuncs.h"
      12             : #include "GeometricCutUserObject.h"
      13             : #include "MooseError.h"
      14             : #include "libmesh/string_to_enum.h"
      15             : 
      16           9 : XFEMCrackGrowthIncrement2DCut::XFEMCrackGrowthIncrement2DCut(
      17           9 :     Real x0, Real y0, Real x1, Real y1, Real t0, Real t1)
      18           9 :   : _time_range(std::make_pair(t0, t1)),
      19           9 :     _cut_line_endpoints(std::make_pair(Point(x0, y0, 0.0), Point(x1, y1, 0.0)))
      20             : {
      21           9 : }
      22             : 
      23             : Real
      24        1116 : XFEMCrackGrowthIncrement2DCut::cutCompletionFraction(Real time)
      25             : {
      26             :   Real fraction = 0.0;
      27        1116 :   if (time >= _time_range.first)
      28             :   {
      29        1116 :     if (time >= _time_range.second)
      30             :       fraction = 1.0;
      31             :     else
      32           0 :       fraction = (time - _time_range.first) / (_time_range.second - _time_range.first);
      33             :   }
      34        1116 :   return fraction;
      35             : }
      36             : 
      37             : bool
      38        1116 : XFEMCrackGrowthIncrement2DCut::cutElementByCrackGrowthIncrement(
      39             :     const Elem * elem, std::vector<CutEdgeForCrackGrowthIncr> & cut_edges, Real time)
      40             : {
      41             :   bool cut_elem = false;
      42             : 
      43        1116 :   Real fraction = cutCompletionFraction(time);
      44             : 
      45        1116 :   if (fraction > 0.0)
      46             :   {
      47        1116 :     unsigned int n_sides = elem->n_sides();
      48             : 
      49        5580 :     for (unsigned int i = 0; i < n_sides; ++i)
      50             :     {
      51             :       // This returns the lowest-order type of side, which should always
      52             :       // be an EDGE2 here because this class is for 2D only.
      53        4464 :       std::unique_ptr<const Elem> curr_side = elem->side_ptr(i);
      54        4464 :       if (curr_side->type() != EDGE2)
      55           0 :         mooseError("In cutElementByGeometry element side must be EDGE2, but type is: ",
      56           0 :                    libMesh::Utility::enum_to_string(curr_side->type()),
      57             :                    " base element type is: ",
      58           0 :                    libMesh::Utility::enum_to_string(elem->type()));
      59             : 
      60             :       const Node * node1 = curr_side->node_ptr(0);
      61             :       const Node * node2 = curr_side->node_ptr(1);
      62        4464 :       Real seg_int_frac = 0.0;
      63             : 
      64        4464 :       if (Xfem::intersectSegmentWithCutLine(
      65        4464 :               *node1, *node2, _cut_line_endpoints, fraction, seg_int_frac))
      66             :       {
      67             :         cut_elem = true;
      68             :         CutEdgeForCrackGrowthIncr mycut;
      69          63 :         mycut._id1 = node1->id();
      70          63 :         mycut._id2 = node2->id();
      71          63 :         mycut._distance = seg_int_frac;
      72          63 :         mycut._host_side_id = i;
      73          63 :         cut_edges.push_back(mycut);
      74             :       }
      75        4464 :     }
      76             :   }
      77        1116 :   return cut_elem;
      78             : }

Generated by: LCOV version 1.14