13 #include "MooseError.h"
15 #include "libmesh/string_to_enum.h"
25 params.addParam<Real>(
"time_start_cut", 0.0,
"Start time of geometric cut propagation");
26 params.addParam<Real>(
"time_end_cut", 0.0,
"End time of geometric cut propagation");
27 params.addClassDescription(
"Base class for 2D XFEM Geometric Cut UserObjects");
35 std::make_pair(getParam<Real>(
"time_start_cut"), getParam<Real>(
"time_end_cut")));
40 std::vector<Xfem::CutEdge> & cut_edges,
41 std::vector<Xfem::CutNode> & cut_nodes,
44 bool cut_elem =
false;
52 unsigned int n_sides = elem->n_sides();
54 for (
unsigned int i = 0; i < n_sides; ++i)
58 std::unique_ptr<const Elem> curr_side = elem->side_ptr(i);
59 if (curr_side->type() != EDGE2)
60 mooseError(
"In cutElementByGeometry element side must be EDGE2, but type is: ",
61 libMesh::Utility::enum_to_string(curr_side->type()),
62 " base element type is: ",
63 libMesh::Utility::enum_to_string(elem->type()));
65 const Node * node1 = curr_side->node_ptr(0);
66 const Node * node2 = curr_side->node_ptr(1);
67 Real seg_int_frac = 0.0;
76 mycut.
_id1 = node1->id();
77 mycut.
_id2 = node2->id();
80 cut_edges.push_back(mycut);
86 mycut.
_id = node1->id();
88 cut_nodes.push_back(mycut);
99 std::vector<Xfem::CutFace> & ,
102 mooseError(
"Invalid method: must use vector of element edges for 2D mesh cutting");
108 std::vector<Xfem::CutEdge> & cut_edges,
111 bool cut_frag =
false;
119 unsigned int n_sides = frag_edges.size();
121 for (
unsigned int i = 0; i < n_sides; ++i)
123 Real seg_int_frac = 0.0;
134 mycut.
_id2 = (i < (n_sides - 1) ? (i + 1) : 0);
137 cut_edges.push_back(mycut);
147 std::vector<Xfem::CutFace> & ,
150 mooseError(
"Invalid method: must use vector of element edges for 2D mesh cutting");
156 const Point & segment_point1,
157 const Point & segment_point2,
158 const std::pair<Point, Point> & cutting_line_points,
159 const Real & cutting_line_fraction,
160 Real & segment_intersection_fraction)
const
167 bool cut_segment =
false;
168 Point seg_dir = segment_point2 - segment_point1;
169 Point cut_dir = cutting_line_points.second - cutting_line_points.first;
170 Point cut_start_to_seg_start = segment_point1 - cutting_line_points.first;
174 if (std::abs(cut_dir_cross_seg_dir) >
Xfem::tol)
177 Real cut_int_frac =
crossProduct2D(cut_start_to_seg_start, seg_dir) / cut_dir_cross_seg_dir;
179 if (cut_int_frac >= 0.0 && cut_int_frac <= cutting_line_fraction)
183 Real int_frac =
crossProduct2D(cut_start_to_seg_start, cut_dir) / cut_dir_cross_seg_dir;
184 if (int_frac >= 0.0 &&
188 segment_intersection_fraction = int_frac;
198 return (point_a(0) * point_b(1) - point_b(0) * point_a(1));
205 "cut_num is outside the bounds of _cut_time_ranges");
216 if (MooseUtils::absoluteFuzzyEqual(denominator, 0.0))
217 mooseError(
"time_start_cut and time_end_cut cannot have the same value");