www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
XFEMCrackGrowthIncrement2DCut Class Reference

#include <XFEMCrackGrowthIncrement2DCut.h>

Public Member Functions

 XFEMCrackGrowthIncrement2DCut (Real x0, Real y0, Real x1, Real y1, Real t0, Real t1)
 
virtual bool cutElementByCrackGrowthIncrement (const Elem *elem, std::vector< CutEdgeForCrackGrowthIncr > &cut_edges, Real time)
 
Real cutCompletionFraction (Real time)
 

Protected Member Functions

bool IntersectSegmentWithCutLine (const Point &segment_point1, const Point &segment_point2, const std::pair< Point, Point > &cutting_line_points, const Real &cutting_line_fraction, Real &segment_intersection_fraction)
 
Real crossProduct2D (const Point &point_a, const Point &point_b)
 

Protected Attributes

const std::pair< Real, Real > _time_range
 

Private Attributes

const std::pair< Point, Point > _cut_line_endpoints
 

Detailed Description

Definition at line 27 of file XFEMCrackGrowthIncrement2DCut.h.

Constructor & Destructor Documentation

◆ XFEMCrackGrowthIncrement2DCut()

XFEMCrackGrowthIncrement2DCut::XFEMCrackGrowthIncrement2DCut ( Real  x0,
Real  y0,
Real  x1,
Real  y1,
Real  t0,
Real  t1 
)

Definition at line 16 of file XFEMCrackGrowthIncrement2DCut.C.

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)))
20 {
21 }
const std::pair< Point, Point > _cut_line_endpoints
const std::pair< Real, Real > _time_range

Member Function Documentation

◆ crossProduct2D()

Real XFEMCrackGrowthIncrement2DCut::crossProduct2D ( const Point &  point_a,
const Point &  point_b 
)
protected

Definition at line 120 of file XFEMCrackGrowthIncrement2DCut.C.

Referenced by IntersectSegmentWithCutLine().

121 {
122  return (point_a(0) * point_b(1) - point_b(0) * point_a(1));
123 }

◆ cutCompletionFraction()

Real XFEMCrackGrowthIncrement2DCut::cutCompletionFraction ( Real  time)

Definition at line 24 of file XFEMCrackGrowthIncrement2DCut.C.

Referenced by cutElementByCrackGrowthIncrement().

25 {
26  Real fraction = 0.0;
27  if (time >= _time_range.first)
28  {
29  if (time >= _time_range.second)
30  fraction = 1.0;
31  else
32  fraction = (time - _time_range.first) / (_time_range.second - _time_range.first);
33  }
34  return fraction;
35 }
const std::pair< Real, Real > _time_range

◆ cutElementByCrackGrowthIncrement()

bool XFEMCrackGrowthIncrement2DCut::cutElementByCrackGrowthIncrement ( const Elem *  elem,
std::vector< CutEdgeForCrackGrowthIncr > &  cut_edges,
Real  time 
)
virtual

Definition at line 38 of file XFEMCrackGrowthIncrement2DCut.C.

Referenced by XFEM::markCutEdgesByState().

40 {
41  bool cut_elem = false;
42 
43  Real fraction = cutCompletionFraction(time);
44 
45  if (fraction > 0.0)
46  {
47  unsigned int n_sides = elem->n_sides();
48 
49  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  std::unique_ptr<Elem> curr_side = elem->side(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()));
59 
60  const Node * node1 = curr_side->get_node(0);
61  const Node * node2 = curr_side->get_node(1);
62  Real seg_int_frac = 0.0;
63 
64  if (IntersectSegmentWithCutLine(*node1, *node2, _cut_line_endpoints, fraction, seg_int_frac))
65  {
66  cut_elem = true;
68  mycut._id1 = node1->id();
69  mycut._id2 = node2->id();
70  mycut._distance = seg_int_frac;
71  mycut._host_side_id = i;
72  cut_edges.push_back(mycut);
73  }
74  }
75  }
76  return cut_elem;
77 }
const std::pair< Point, Point > _cut_line_endpoints
bool IntersectSegmentWithCutLine(const Point &segment_point1, const Point &segment_point2, const std::pair< Point, Point > &cutting_line_points, const Real &cutting_line_fraction, Real &segment_intersection_fraction)

◆ IntersectSegmentWithCutLine()

bool XFEMCrackGrowthIncrement2DCut::IntersectSegmentWithCutLine ( const Point &  segment_point1,
const Point &  segment_point2,
const std::pair< Point, Point > &  cutting_line_points,
const Real &  cutting_line_fraction,
Real &  segment_intersection_fraction 
)
protected

Definition at line 80 of file XFEMCrackGrowthIncrement2DCut.C.

Referenced by cutElementByCrackGrowthIncrement().

86 {
87  // Use the algorithm described here to determine whether a line segment is intersected
88  // by a cutting line, and to compute the fraction along that line where the intersection
89  // occurs:
90  // http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
91 
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;
96 
97  Real cut_dir_cross_seg_dir = crossProduct2D(cut_dir, seg_dir);
98 
99  if (std::abs(cut_dir_cross_seg_dir) > Xfem::tol)
100  {
101  // Fraction of the distance along the cutting segment where it intersects the edge segment
102  Real cut_int_frac = crossProduct2D(cut_start_to_seg_start, seg_dir) / cut_dir_cross_seg_dir;
103 
104  if (cut_int_frac >= 0.0 && cut_int_frac <= cutting_line_fraction)
105  { // Cutting segment intersects the line of the edge segment, but the intersection point may be
106  // outside the segment
107  Real int_frac = crossProduct2D(cut_start_to_seg_start, cut_dir) / cut_dir_cross_seg_dir;
108  if (int_frac >= 0.0 &&
109  int_frac <= 1.0) // TODO: revisit end cases for intersections with corners
110  {
111  cut_segment = true;
112  segment_intersection_fraction = int_frac;
113  }
114  }
115  }
116  return cut_segment;
117 }
Real crossProduct2D(const Point &point_a, const Point &point_b)
static const double tol
Definition: XFEMFuncs.h:21

Member Data Documentation

◆ _cut_line_endpoints

const std::pair<Point, Point> XFEMCrackGrowthIncrement2DCut::_cut_line_endpoints
private

Definition at line 50 of file XFEMCrackGrowthIncrement2DCut.h.

Referenced by cutElementByCrackGrowthIncrement().

◆ _time_range

const std::pair<Real, Real> XFEMCrackGrowthIncrement2DCut::_time_range
protected

Definition at line 47 of file XFEMCrackGrowthIncrement2DCut.h.

Referenced by cutCompletionFraction().


The documentation for this class was generated from the following files: