www.mooseframework.org
RectangleCutUserObject.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 
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 planar cuts on 3D meshes for XFEM");
28  // Return the parameters
29  return params;
30 }
31 
32 RectangleCutUserObject::RectangleCutUserObject(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 = 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 }
63 
64 bool
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 }
86 
87 const std::vector<Point>
88 RectangleCutUserObject::getCrackFrontPoints(unsigned int /*num_crack_front_points*/) const
89 {
90  mooseError("getCrackFrontPoints() is not implemented for this object.");
91 };
InputParameters validParams< RectangleCutUserObject >()
InputParameters validParams< GeometricCut3DUserObject >()
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
RectangleCutUserObject(const InputParameters &parameters)
void normalizePoint(Point &p)
Definition: XFEMFuncs.C:628
bool isInsideCutPlane(Point p) const override
static unsigned int counter
std::vector< Point > _vertices