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

#include <EllipseCutUserObject.h>

Inheritance diagram for EllipseCutUserObject:
[legend]

Public Member Functions

 EllipseCutUserObject (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

virtual bool isInsideCutPlane (Point p) const override
 

Private Attributes

std::vector< Point > _vertices
 
Point _unit_vec1
 
Point _unit_vec2
 
Real _long_axis
 
Real _short_axis
 

Detailed Description

Definition at line 19 of file EllipseCutUserObject.h.

Constructor & Destructor Documentation

EllipseCutUserObject::EllipseCutUserObject ( const InputParameters &  parameters)

Definition at line 32 of file EllipseCutUserObject.C.

33  : GeometricCut3DUserObject(parameters), _cut_data(getParam<std::vector<Real>>("cut_data"))
34 {
35  // Set up constant parameters
36  const int cut_data_len = 9;
37 
38  // Throw error if length of cut_data is incorrect
39  if (_cut_data.size() != cut_data_len)
40  mooseError("Length of EllipseCutUserObject cut_data must be 9");
41 
42  // Assign cut_data to vars used to construct cuts
43  _center = Point(_cut_data[0], _cut_data[1], _cut_data[2]);
44  _vertices.push_back(Point(_cut_data[3], _cut_data[4], _cut_data[5]));
45  _vertices.push_back(Point(_cut_data[6], _cut_data[7], _cut_data[8]));
46 
47  std::pair<Point, Point> rays = std::make_pair(_vertices[0] - _center, _vertices[1] - _center);
48 
49  if (std::abs(rays.first * rays.second) > 1e-6)
50  mooseError(
51  "EllipseCutUserObject only works on an elliptic cut. Users should provide two points at "
52  "the long and short axis.");
53 
54  _normal = rays.first.cross(rays.second);
56 
57  std::pair<Real, Real> ray_radii =
58  std::make_pair(std::sqrt(rays.first.norm_sq()), std::sqrt(rays.second.norm_sq()));
59 
60  // Determine which the long and short axes
61  if (ray_radii.first > ray_radii.second)
62  {
63  _unit_vec1 = rays.first;
64  _unit_vec2 = rays.second;
65  _long_axis = ray_radii.first;
66  _short_axis = ray_radii.second;
67  }
68  else
69  {
70  _unit_vec1 = rays.second;
71  _unit_vec2 = rays.first;
72  _long_axis = ray_radii.second;
73  _short_axis = ray_radii.first;
74  }
75 
78 }
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 EllipseCutUserObject::execute ( )
inlineoverridevirtual

Definition at line 25 of file EllipseCutUserObject.h.

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

Definition at line 26 of file EllipseCutUserObject.h.

26 {};
const std::vector< Point > EllipseCutUserObject::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 96 of file EllipseCutUserObject.C.

Referenced by finalize().

97 {
98  mooseError("getCrackFrontPoints() is not implemented for this object.");
99 };
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 EllipseCutUserObject::initialize ( )
inlineoverridevirtual

Definition at line 24 of file EllipseCutUserObject.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 EllipseCutUserObject::isInsideCutPlane ( Point  p) const
overrideprivatevirtual

Implements GeometricCut3DUserObject.

Definition at line 81 of file EllipseCutUserObject.C.

82 {
83  Point ray = p - _center;
84  if (std::abs(ray * _normal) < 1e-6)
85  {
86  std::pair<Real, Real> xy_loc = std::make_pair(ray * _unit_vec1, ray * _unit_vec2);
87 
88  if (std::sqrt(xy_loc.first * xy_loc.first / (_long_axis * _long_axis) +
89  xy_loc.second * xy_loc.second / (_short_axis * _short_axis)) < 1)
90  return true;
91  }
92  return false;
93 }
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> EllipseCutUserObject::_cut_data
protected

Definition at line 31 of file EllipseCutUserObject.h.

Referenced by EllipseCutUserObject().

std::vector<std::pair<Real, Real> > GeometricCutUserObject::_cut_time_ranges
protectedinherited
Real EllipseCutUserObject::_long_axis
private

Definition at line 37 of file EllipseCutUserObject.h.

Referenced by EllipseCutUserObject(), and isInsideCutPlane().

Point GeometricCut3DUserObject::_normal
protectedinherited
Real EllipseCutUserObject::_short_axis
private

Definition at line 38 of file EllipseCutUserObject.h.

Referenced by EllipseCutUserObject(), and isInsideCutPlane().

Point EllipseCutUserObject::_unit_vec1
private

Definition at line 35 of file EllipseCutUserObject.h.

Referenced by EllipseCutUserObject(), and isInsideCutPlane().

Point EllipseCutUserObject::_unit_vec2
private

Definition at line 36 of file EllipseCutUserObject.h.

Referenced by EllipseCutUserObject(), and isInsideCutPlane().

std::vector<Point> EllipseCutUserObject::_vertices
private

Definition at line 34 of file EllipseCutUserObject.h.

Referenced by EllipseCutUserObject().


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