https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RectangleCutUserObject.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
12// MOOSE includes
13#include "MooseError.h"
14
15// XFEM includes
16#include "XFEMFuncs.h"
17
19
22{
23 // Get input parameters from parent class
25
26 // Add required parameters
27 params.addRequiredParam<std::vector<Real>>("cut_data",
28 "Vector of Real values providing cut information");
29 // Class description
30 params.addClassDescription("Creates a UserObject for planar cuts on 3D meshes for XFEM");
31 // Return the parameters
32 return params;
33}
34
36 : GeometricCut3DUserObject(parameters), _cut_data(getParam<std::vector<Real>>("cut_data"))
37{
38 // Set up constant parameters
39 const int cut_data_len = 12;
40 const int num_vertices = 4;
41
42 // Throw error if length of cut_data is incorrect
43 if (_cut_data.size() != cut_data_len)
44 mooseError("Length of RectangleCutUserObject cut_data must be 12");
45
46 // Assign cut_data to vars used to construct cuts
47 _vertices.push_back(Point(_cut_data[0], _cut_data[1], _cut_data[2]));
48 _vertices.push_back(Point(_cut_data[3], _cut_data[4], _cut_data[5]));
49 _vertices.push_back(Point(_cut_data[6], _cut_data[7], _cut_data[8]));
50 _vertices.push_back(Point(_cut_data[9], _cut_data[10], _cut_data[11]));
51
52 for (unsigned int i = 0; i < num_vertices; ++i)
53 _center += _vertices[i];
54 _center *= 0.25;
55
56 for (unsigned int i = 0; i < num_vertices; ++i)
57 {
58 unsigned int iplus1(i < 3 ? i + 1 : 0);
59 std::pair<Point, Point> rays =
60 std::make_pair(_vertices[i] - _center, _vertices[iplus1] - _center);
61 _normal += rays.first.cross(rays.second);
62 }
63 _normal *= 0.25;
65}
66
67bool
69{
70 const int num_vertices = 4;
71
72 bool inside = false;
73 unsigned int counter = 0;
74 for (unsigned int i = 0; i < num_vertices; ++i)
75 {
76 unsigned int iplus1 = (i < 3 ? i + 1 : 0);
77 Point middle2p = p - 0.5 * (_vertices[i] + _vertices[iplus1]);
78 const Point side_tang = _vertices[iplus1] - _vertices[i];
79 Point side_norm = side_tang.cross(_normal);
80 Xfem::normalizePoint(middle2p);
81 Xfem::normalizePoint(side_norm);
82 if (middle2p * side_norm <= 0.0)
83 counter += 1;
84 }
85 if (counter == num_vertices)
86 inside = true;
87 return inside;
88}
89
90const std::vector<Point>
91RectangleCutUserObject::getCrackFrontPoints(unsigned int /*num_crack_front_points*/) const
92{
93 mooseError("getCrackFrontPoints() is not implemented for this object.");
94}
95
96const std::vector<RealVectorValue>
97RectangleCutUserObject::getCrackPlaneNormals(unsigned int /*num_crack_front_points*/) const
98{
99 mooseError("getCrackPlaneNormals() is not implemented for this object.");
100}
const Real p
registerMooseObject("XFEMApp", RectangleCutUserObject)
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
virtual const std::vector< RealVectorValue > getCrackPlaneNormals(unsigned int num_crack_front_points) const override
get a set of normal vectors along a crack front from a XFEM GeometricCutUserObject
RectangleCutUserObject(const InputParameters &parameters)
bool isInsideCutPlane(Point p) const 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
std::vector< Point > _vertices
static InputParameters validParams()
std::vector< Real > _cut_data
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
void normalizePoint(Point &p)
Definition XFEMFuncs.C:621