13 #include "MooseError.h"
14 #include "libmesh/string_to_enum.h"
17 Real x0, Real y0, Real x1, Real y1, Real t0, Real t1)
18 : _time_range(std::make_pair(t0, t1)),
19 _cut_line_endpoints(std::make_pair(Point(x0, y0, 0.0), Point(x1, y1, 0.0)))
39 const Elem * elem, std::vector<CutEdgeForCrackGrowthIncr> & cut_edges, Real time)
41 bool cut_elem =
false;
47 unsigned int n_sides = elem->n_sides();
49 for (
unsigned int i = 0; i < n_sides; ++i)
53 std::unique_ptr<const Elem> curr_side = elem->side_ptr(i);
54 if (curr_side->type() != EDGE2)
55 mooseError(
"In cutElementByGeometry element side must be EDGE2, but type is: ",
56 libMesh::Utility::enum_to_string(curr_side->type()),
57 " base element type is: ",
58 libMesh::Utility::enum_to_string(elem->type()));
60 const Node * node1 = curr_side->node_ptr(0);
61 const Node * node2 = curr_side->node_ptr(1);
62 Real seg_int_frac = 0.0;
68 mycut.
_id1 = node1->id();
69 mycut.
_id2 = node2->id();
72 cut_edges.push_back(mycut);
81 const Point & segment_point1,
82 const Point & segment_point2,
83 const std::pair<Point, Point> & cutting_line_points,
84 const Real & cutting_line_fraction,
85 Real & segment_intersection_fraction)
92 bool cut_segment =
false;
93 Point seg_dir = segment_point2 - segment_point1;
94 Point cut_dir = cutting_line_points.second - cutting_line_points.first;
95 Point cut_start_to_seg_start = segment_point1 - cutting_line_points.first;
99 if (std::abs(cut_dir_cross_seg_dir) >
Xfem::tol)
102 Real cut_int_frac =
crossProduct2D(cut_start_to_seg_start, seg_dir) / cut_dir_cross_seg_dir;
104 if (cut_int_frac >= 0.0 && cut_int_frac <= cutting_line_fraction)
107 Real int_frac =
crossProduct2D(cut_start_to_seg_start, cut_dir) / cut_dir_cross_seg_dir;
108 if (int_frac >= 0.0 &&
112 segment_intersection_fraction = int_frac;
122 return (point_a(0) * point_b(1) - point_b(0) * point_a(1));