www.mooseframework.org
CircleCutUserObject.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "CircleCutUserObject.h"
9 
10 // MOOSE includes
11 #include "MooseError.h"
12 
13 // XFEM includes
14 #include "XFEMFuncs.h"
15 
16 template <>
17 InputParameters
19 {
20  // Get input parameters from parent class
21  InputParameters params = validParams<GeometricCut3DUserObject>();
22 
23  // Add required parameters
24  params.addRequiredParam<std::vector<Real>>("cut_data",
25  "Vector of Real values providing cut information");
26  // Class description
27  params.addClassDescription("Creates a UserObject for circular cuts on 3D meshes for XFEM");
28  // Return the parameters
29  return params;
30 }
31 
32 CircleCutUserObject::CircleCutUserObject(const InputParameters & parameters)
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 CircleCutUserObject 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  _normal = rays.first.cross(rays.second);
51 
52  std::pair<Real, Real> ray_radii =
53  std::make_pair(std::sqrt(rays.first.norm_sq()), std::sqrt(rays.second.norm_sq()));
54 
55  if (std::abs(ray_radii.first - ray_radii.second) > 1e-10)
56  mooseError("CircleCutUserObject only works for a circular cut");
57 
58  _radius = 0.5 * (ray_radii.first + ray_radii.second);
59  _angle = std::acos((rays.first * rays.second) / (ray_radii.first * ray_radii.second));
60 }
61 
62 bool
64 {
65  Point ray = p - _center;
66  if (std::abs(ray * _normal) < 1e-15 && std::sqrt(ray.norm_sq()) < _radius)
67  return true;
68  return false;
69 }
70 
71 const std::vector<Point>
72 CircleCutUserObject::getCrackFrontPoints(unsigned int number_crack_front_points) const
73 {
74  std::vector<Point> crack_front_points(number_crack_front_points);
75  Point v1 = _vertices[0] - _center;
76  Point v2 = _normal.cross(v1);
77  v1 /= v1.norm();
78  v2 /= v2.norm();
79  // parametric circle in 3D: center + r * cos(theta) * v1 + r * sin(theta) * v2
80  for (unsigned int i = 0; i < number_crack_front_points; ++i)
81  {
82  Real theta = 2.0 * libMesh::pi / number_crack_front_points * i;
83  crack_front_points[i] =
84  _center + _radius * std::cos(theta) * v1 + _radius * std::sin(theta) * v2;
85  }
86 
87  return crack_front_points;
88 }
InputParameters validParams< CircleCutUserObject >()
InputParameters validParams< GeometricCut3DUserObject >()
CircleCutUserObject(const InputParameters &parameters)
std::vector< Real > _cut_data
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
std::vector< Point > _vertices
void normalizePoint(Point &p)
Definition: XFEMFuncs.C:628
virtual bool isInsideCutPlane(Point p) const override