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

#include <RectangleCutUserObject.h>

Inheritance diagram for RectangleCutUserObject:
[legend]

Public Member Functions

 RectangleCutUserObject (const InputParameters &parameters)
 
virtual void initialize () override
 
virtual void execute () override
 
virtual void finalize () override
 
virtual const std::vector< Point > getCrackFrontPoints (unsigned int num_crack_front_points) const override
 get a set of points along a crack front from a XFEM GeometricCutUserObject More...
 
virtual bool active (Real time) const override
 
virtual bool cutElementByGeometry (const Elem *elem, std::vector< CutEdge > &cut_edges, std::vector< CutNode > &cut_nodes, Real time) const override
 
virtual bool cutElementByGeometry (const Elem *elem, std::vector< CutFace > &cut_faces, Real time) const override
 
virtual bool cutFragmentByGeometry (std::vector< std::vector< Point >> &frag_edges, std::vector< CutEdge > &cut_edges, Real time) const override
 
virtual bool cutFragmentByGeometry (std::vector< std::vector< Point >> &frag_faces, std::vector< CutFace > &cut_faces, Real time) const override
 
Real cutFraction (unsigned int cut_num, Real time) const
 

Protected Member Functions

virtual bool intersectWithEdge (const Point &p1, const Point &p2, Point &pint) const
 
bool isInsideEdge (const Point &p1, const Point &p2, const Point &p) const
 
Real getRelativePosition (const Point &p1, const Point &p2, const Point &p) const
 

Protected Attributes

std::vector< Real > _cut_data
 
Point _center
 
Point _normal
 
std::vector< std::pair< Real, Real > > _cut_time_ranges
 

Private Member Functions

bool isInsideCutPlane (Point p) const override
 

Private Attributes

std::vector< Point > _vertices
 

Detailed Description

Definition at line 19 of file RectangleCutUserObject.h.

Constructor & Destructor Documentation

RectangleCutUserObject::RectangleCutUserObject ( const InputParameters &  parameters)

Definition at line 32 of file RectangleCutUserObject.C.

33  : GeometricCut3DUserObject(parameters), _cut_data(getParam<std::vector<Real>>("cut_data"))
34 {
35  // Set up constant parameters
36  const int cut_data_len = 12;
37  const int num_vertices = 4;
38 
39  // Throw error if length of cut_data is incorrect
40  if (_cut_data.size() != cut_data_len)
41  mooseError("Length of RectangleCutUserObject cut_data must be 12");
42 
43  // Assign cut_data to vars used to construct cuts
44  _vertices.push_back(Point(_cut_data[0], _cut_data[1], _cut_data[2]));
45  _vertices.push_back(Point(_cut_data[3], _cut_data[4], _cut_data[5]));
46  _vertices.push_back(Point(_cut_data[6], _cut_data[7], _cut_data[8]));
47  _vertices.push_back(Point(_cut_data[9], _cut_data[10], _cut_data[11]));
48 
49  for (unsigned int i = 0; i < num_vertices; ++i)
50  _center += _vertices[i];
51  _center *= 0.25;
52 
53  for (unsigned int i = 0; i < num_vertices; ++i)
54  {
55  unsigned int iplus1(i < 3 ? i + 1 : 0);
56  std::pair<Point, Point> rays =
57  std::make_pair(_vertices[i] - _center, _vertices[iplus1] - _center);
58  _normal += rays.first.cross(rays.second);
59  }
60  _normal *= 0.25;
62 }
GeometricCut3DUserObject(const InputParameters &parameters)
std::vector< Real > _cut_data
void normalizePoint(Point &p)
Definition: XFEMFuncs.C:628
std::vector< Point > _vertices

Member Function Documentation

bool GeometricCut3DUserObject::active ( Real  time) const
overridevirtualinherited

Implements GeometricCutUserObject.

Definition at line 37 of file GeometricCut3DUserObject.C.

37 { return true; }
bool GeometricCut3DUserObject::cutElementByGeometry ( const Elem *  elem,
std::vector< CutEdge > &  cut_edges,
std::vector< CutNode > &  cut_nodes,
Real  time 
) const
overridevirtualinherited

Implements GeometricCutUserObject.

Definition at line 40 of file GeometricCut3DUserObject.C.

44 {
45  mooseError("Invalid method: must use vector of element faces for 3D mesh cutting");
46  return false;
47 }
bool GeometricCut3DUserObject::cutElementByGeometry ( const Elem *  elem,
std::vector< CutFace > &  cut_faces,
Real  time 
) const
overridevirtualinherited

Implements GeometricCutUserObject.

Definition at line 50 of file GeometricCut3DUserObject.C.

54 {
55  bool cut_elem = false;
56 
57  for (unsigned int i = 0; i < elem->n_sides(); ++i)
58  {
59  // This returns the lowest-order type of side.
60  std::unique_ptr<Elem> curr_side = elem->side(i);
61  if (curr_side->dim() != 2)
62  mooseError("In cutElementByGeometry dimension of side must be 2, but it is ",
63  curr_side->dim());
64  unsigned int n_edges = curr_side->n_sides();
65 
66  std::vector<unsigned int> cut_edges;
67  std::vector<Real> cut_pos;
68 
69  for (unsigned int j = 0; j < n_edges; j++)
70  {
71  // This returns the lowest-order type of side.
72  std::unique_ptr<Elem> curr_edge = curr_side->side(j);
73  if (curr_edge->type() != EDGE2)
74  mooseError("In cutElementByGeometry face edge must be EDGE2, but type is: ",
75  libMesh::Utility::enum_to_string(curr_edge->type()),
76  " base element type is: ",
77  libMesh::Utility::enum_to_string(elem->type()));
78  Node * node1 = curr_edge->get_node(0);
79  Node * node2 = curr_edge->get_node(1);
80 
81  Point intersection;
82  if (intersectWithEdge(*node1, *node2, intersection))
83  {
84  cut_edges.push_back(j);
85  cut_pos.push_back(getRelativePosition(*node1, *node2, intersection));
86  }
87  }
88 
89  if (cut_edges.size() == 2)
90  {
91  cut_elem = true;
92  CutFace mycut;
93  mycut.face_id = i;
94  mycut.face_edge.push_back(cut_edges[0]);
95  mycut.face_edge.push_back(cut_edges[1]);
96  mycut.position.push_back(cut_pos[0]);
97  mycut.position.push_back(cut_pos[1]);
98  cut_faces.push_back(mycut);
99  }
100  }
101 
102  return cut_elem;
103 }
virtual bool intersectWithEdge(const Point &p1, const Point &p2, Point &pint) const
Real getRelativePosition(const Point &p1, const Point &p2, const Point &p) const
std::vector< Real > position
unsigned int face_id
std::vector< unsigned int > face_edge
Real GeometricCutUserObject::cutFraction ( unsigned int  cut_num,
Real  time 
) const
inherited

Definition at line 39 of file GeometricCutUserObject.C.

Referenced by GeometricCut2DUserObject::active(), GeometricCut2DUserObject::cutElementByGeometry(), and GeometricCut2DUserObject::cutFragmentByGeometry().

40 {
41  Real fraction = 0.0;
42 
43  if (time >= _cut_time_ranges[cut_num].first)
44  {
45  if (time >= _cut_time_ranges[cut_num].second)
46  fraction = 1.0;
47  else
48  fraction = (time - _cut_time_ranges[cut_num].first) /
49  (_cut_time_ranges[cut_num].second - _cut_time_ranges[cut_num].first);
50  }
51  return fraction;
52 }
std::vector< std::pair< Real, Real > > _cut_time_ranges
bool GeometricCut3DUserObject::cutFragmentByGeometry ( std::vector< std::vector< Point >> &  frag_edges,
std::vector< CutEdge > &  cut_edges,
Real  time 
) const
overridevirtualinherited

Implements GeometricCutUserObject.

Definition at line 106 of file GeometricCut3DUserObject.C.

109 {
110  mooseError("Invalid method: must use vector of element faces for 3D mesh cutting");
111  return false;
112 }
bool GeometricCut3DUserObject::cutFragmentByGeometry ( std::vector< std::vector< Point >> &  frag_faces,
std::vector< CutFace > &  cut_faces,
Real  time 
) const
overridevirtualinherited

Implements GeometricCutUserObject.

Definition at line 115 of file GeometricCut3DUserObject.C.

118 {
119  // TODO: Need this for branching in 3D
120  mooseError("cutFragmentByGeometry not yet implemented for 3D mesh cutting");
121  return false;
122 }
virtual void RectangleCutUserObject::execute ( )
inlineoverridevirtual

Definition at line 25 of file RectangleCutUserObject.h.

25 {};
virtual void RectangleCutUserObject::finalize ( )
inlineoverridevirtual

Definition at line 26 of file RectangleCutUserObject.h.

26 {};
const std::vector< Point > RectangleCutUserObject::getCrackFrontPoints ( unsigned int  int) const
overridevirtual

get a set of points along a crack front from a XFEM GeometricCutUserObject

Returns
A vector which contains all crack front points

Implements CrackFrontPointsProvider.

Definition at line 88 of file RectangleCutUserObject.C.

Referenced by finalize().

89 {
90  mooseError("getCrackFrontPoints() is not implemented for this object.");
91 };
Real GeometricCut3DUserObject::getRelativePosition ( const Point &  p1,
const Point &  p2,
const Point &  p 
) const
protectedinherited

Definition at line 156 of file GeometricCut3DUserObject.C.

Referenced by GeometricCut3DUserObject::cutElementByGeometry().

159 {
160  // get the relative position of p from p1
161  Real full_len = (p2 - p1).norm();
162  Real len_p1_p = (p - p1).norm();
163  return len_p1_p / full_len;
164 }
virtual void RectangleCutUserObject::initialize ( )
inlineoverridevirtual

Definition at line 24 of file RectangleCutUserObject.h.

24 {};
bool GeometricCut3DUserObject::intersectWithEdge ( const Point &  p1,
const Point &  p2,
Point &  pint 
) const
protectedvirtualinherited

Definition at line 125 of file GeometricCut3DUserObject.C.

Referenced by GeometricCut3DUserObject::cutElementByGeometry().

126 {
127  bool has_intersection = false;
128  double plane_point[3] = {_center(0), _center(1), _center(2)};
129  double plane_normal[3] = {_normal(0), _normal(1), _normal(2)};
130  double edge_point1[3] = {p1(0), p1(1), p1(2)};
131  double edge_point2[3] = {p2(0), p2(1), p2(2)};
132  double cut_point[3] = {0.0, 0.0, 0.0};
133 
135  plane_point, plane_normal, edge_point1, edge_point2, cut_point) == 1)
136  {
137  Point temp_p(cut_point[0], cut_point[1], cut_point[2]);
138  if (isInsideCutPlane(temp_p) && isInsideEdge(p1, p2, temp_p))
139  {
140  pint = temp_p;
141  has_intersection = true;
142  }
143  }
144  return has_intersection;
145 }
int plane_normal_line_exp_int_3d(double pp[3], double normal[3], double p1[3], double p2[3], double pint[3])
Definition: XFEMFuncs.C:408
virtual bool isInsideCutPlane(Point p) const =0
bool isInsideEdge(const Point &p1, const Point &p2, const Point &p) const
bool RectangleCutUserObject::isInsideCutPlane ( Point  p) const
overrideprivatevirtual

Implements GeometricCut3DUserObject.

Definition at line 65 of file RectangleCutUserObject.C.

66 {
67  const int num_vertices = 4;
68 
69  bool inside = false;
70  unsigned int counter = 0;
71  for (unsigned int i = 0; i < num_vertices; ++i)
72  {
73  unsigned int iplus1 = (i < 3 ? i + 1 : 0);
74  Point middle2p = p - 0.5 * (_vertices[i] + _vertices[iplus1]);
75  const Point side_tang = _vertices[iplus1] - _vertices[i];
76  Point side_norm = side_tang.cross(_normal);
77  Xfem::normalizePoint(middle2p);
78  Xfem::normalizePoint(side_norm);
79  if (middle2p * side_norm <= 0.0)
80  counter += 1;
81  }
82  if (counter == num_vertices)
83  inside = true;
84  return inside;
85 }
void normalizePoint(Point &p)
Definition: XFEMFuncs.C:628
static unsigned int counter
std::vector< Point > _vertices
bool GeometricCut3DUserObject::isInsideEdge ( const Point &  p1,
const Point &  p2,
const Point &  p 
) const
protectedinherited

Definition at line 148 of file GeometricCut3DUserObject.C.

Referenced by GeometricCut3DUserObject::intersectWithEdge().

149 {
150  Real dotp1 = (p1 - p) * (p2 - p1);
151  Real dotp2 = (p2 - p) * (p2 - p1);
152  return (dotp1 * dotp2 <= 0.0);
153 }

Member Data Documentation

Point GeometricCut3DUserObject::_center
protectedinherited
std::vector<Real> RectangleCutUserObject::_cut_data
protected

Definition at line 31 of file RectangleCutUserObject.h.

Referenced by RectangleCutUserObject().

std::vector<std::pair<Real, Real> > GeometricCutUserObject::_cut_time_ranges
protectedinherited
Point GeometricCut3DUserObject::_normal
protectedinherited
std::vector<Point> RectangleCutUserObject::_vertices
private

Definition at line 34 of file RectangleCutUserObject.h.

Referenced by isInsideCutPlane(), and RectangleCutUserObject().


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