www.mooseframework.org
EllipseCutUserObject.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 "EllipseCutUserObject.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 elliptical cuts on 3D meshes for XFEM");
28  // Return the parameters
29  return params;
30 }
31 
32 EllipseCutUserObject::EllipseCutUserObject(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 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 }
79 
80 bool
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 }
94 
95 const std::vector<Point>
96 EllipseCutUserObject::getCrackFrontPoints(unsigned int /*num_crack_front_points*/) const
97 {
98  mooseError("getCrackFrontPoints() is not implemented for this object.");
99 };
std::vector< Real > _cut_data
virtual bool isInsideCutPlane(Point p) const override
InputParameters validParams< GeometricCut3DUserObject >()
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
InputParameters validParams< EllipseCutUserObject >()
void normalizePoint(Point &p)
Definition: XFEMFuncs.C:628
std::vector< Point > _vertices
EllipseCutUserObject(const InputParameters &parameters)