www.mooseframework.org
XFEMCrackGrowthIncrement2DCut.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 #include "XFEMFuncs.h"
12 #include "GeometricCutUserObject.h"
13 #include "MooseError.h"
14 #include "libmesh/string_to_enum.h"
15 
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)))
20 {
21 }
22 
23 Real
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 }
36 
37 bool
39  const Elem * elem, std::vector<CutEdgeForCrackGrowthIncr> & cut_edges, Real time)
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<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()));
59 
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;
63 
65  *node1, *node2, _cut_line_endpoints, fraction, seg_int_frac))
66  {
67  cut_elem = true;
69  mycut._id1 = node1->id();
70  mycut._id2 = node2->id();
71  mycut._distance = seg_int_frac;
72  mycut._host_side_id = i;
73  cut_edges.push_back(mycut);
74  }
75  }
76  }
77  return cut_elem;
78 }
const std::pair< Point, Point > _cut_line_endpoints
const std::pair< Real, Real > _time_range
void mooseError(Args &&... args)
XFEMCrackGrowthIncrement2DCut(Real x0, Real y0, Real x1, Real y1, Real t0, Real t1)
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)
Determine whether a line segment is intersected by a cutting line, and compute the fraction along tha...
Definition: XFEMFuncs.C:774
std::string enum_to_string(const T e)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
EDGE2
virtual bool cutElementByCrackGrowthIncrement(const Elem *elem, std::vector< CutEdgeForCrackGrowthIncr > &cut_edges, Real time)