https://mooseframework.inl.gov
Loading...
Searching...
No Matches
EllipseCutUserObject.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 elliptical 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 = 9;
40
41 // Throw error if length of cut_data is incorrect
42 if (_cut_data.size() != cut_data_len)
43 mooseError("Length of EllipseCutUserObject cut_data must be 9");
44
45 // Assign cut_data to vars used to construct cuts
46 _center = Point(_cut_data[0], _cut_data[1], _cut_data[2]);
47 _vertices.push_back(Point(_cut_data[3], _cut_data[4], _cut_data[5]));
48 _vertices.push_back(Point(_cut_data[6], _cut_data[7], _cut_data[8]));
49
50 std::pair<Point, Point> rays = std::make_pair(_vertices[0] - _center, _vertices[1] - _center);
51
52 if (std::abs(rays.first * rays.second) > 1e-6)
54 "EllipseCutUserObject only works on an elliptic cut. Users should provide two points at "
55 "the long and short axis.");
56
57 _normal = rays.first.cross(rays.second);
59
60 std::pair<Real, Real> ray_radii =
61 std::make_pair(std::sqrt(rays.first.norm_sq()), std::sqrt(rays.second.norm_sq()));
62
63 // Determine which the long and short axes
64 if (ray_radii.first > ray_radii.second)
65 {
66 _unit_vec1 = rays.first;
67 _unit_vec2 = rays.second;
68 _long_axis = ray_radii.first;
69 _short_axis = ray_radii.second;
70 }
71 else
72 {
73 _unit_vec1 = rays.second;
74 _unit_vec2 = rays.first;
75 _long_axis = ray_radii.second;
76 _short_axis = ray_radii.first;
77 }
78
81}
82
83bool
85{
86 Point ray = p - _center;
87 if (std::abs(ray * _normal) < 1e-6)
88 {
89 std::pair<Real, Real> xy_loc = std::make_pair(ray * _unit_vec1, ray * _unit_vec2);
90
91 if (std::sqrt(xy_loc.first * xy_loc.first / (_long_axis * _long_axis) +
92 xy_loc.second * xy_loc.second / (_short_axis * _short_axis)) < 1)
93 return true;
94 }
95 return false;
96}
97
98const std::vector<Point>
99EllipseCutUserObject::getCrackFrontPoints(unsigned int number_crack_front_points) const
100{
101 std::vector<Point> crack_front_points(number_crack_front_points);
102 for (unsigned int i = 0; i < number_crack_front_points; ++i)
103 {
104 Real theta = 2.0 * libMesh::pi / number_crack_front_points * i;
105 crack_front_points[i] = _center + _long_axis * std::sin(theta) * _unit_vec1 +
106 _short_axis * std::cos(theta) * _unit_vec2;
107 }
108 return crack_front_points;
109}
110
111const std::vector<RealVectorValue>
112EllipseCutUserObject::getCrackPlaneNormals(unsigned int /*num_crack_front_points*/) const
113{
114 mooseError("getCrackPlaneNormals() is not implemented for this object.");
115}
registerMooseObject("XFEMApp", EllipseCutUserObject)
const Real p
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
virtual bool isInsideCutPlane(Point p) const override
EllipseCutUserObject(const InputParameters &parameters)
static InputParameters validParams()
std::vector< Real > _cut_data
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
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
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
void normalizePoint(Point &p)
Definition XFEMFuncs.C:621
const Real pi