www.mooseframework.org
LineSegmentCutUserObject.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
13 
14 template <>
15 InputParameters
17 {
18  // Get input parameters from parent class
19  InputParameters params = validParams<GeometricCut2DUserObject>();
20 
21  // Add required parameters
22  params.addRequiredParam<std::vector<Real>>("cut_data",
23  "Vector of Real values providing cut information");
24  // Add optional parameters
25  params.addParam<std::vector<Real>>("cut_scale", "X,Y scale factors for geometric cuts");
26  params.addParam<std::vector<Real>>("cut_translate", "X,Y translations for geometric cuts");
27  // Class description
28  params.addClassDescription("Creates a UserObject for a line segment cut on 2D meshes for XFEM");
29  // Return the parameters
30  return params;
31 }
32 
33 LineSegmentCutUserObject::LineSegmentCutUserObject(const InputParameters & parameters)
34  : GeometricCut2DUserObject(parameters), _cut_data(getParam<std::vector<Real>>("cut_data"))
35 {
36  // Set up constant parameters
37  const int cut_data_len = 4;
38 
39  // Throw error if length of cut_data is incorrect
40  if (_cut_data.size() != cut_data_len)
41  mooseError("Length of LineSegmentCutUserObject cut_data must be 4");
42 
43  // Assign scale and translate parameters
44  std::pair<Real, Real> scale;
45  if (isParamValid("cut_scale"))
46  {
47  auto vec_scale = getParam<std::vector<Real>>("cut_scale");
48  scale = std::make_pair(vec_scale[0], vec_scale[1]);
49  }
50  else
51  {
52  scale = std::make_pair(1.0, 1.0);
53  }
54 
55  std::pair<Real, Real> trans;
56  if (isParamValid("cut_translate"))
57  {
58  auto vec_trans = getParam<std::vector<Real>>("cut_translate");
59  trans = std::make_pair(vec_trans[0], vec_trans[1]);
60  }
61  else
62  {
63  trans = std::make_pair(0.0, 0.0);
64  }
65 
66  // Assign translated and scaled cut_data to vars used to construct cuts
67  Real x0 = (_cut_data[0] + trans.first) * scale.first;
68  Real y0 = (_cut_data[1] + trans.second) * scale.second;
69  Real x1 = (_cut_data[2] + trans.first) * scale.first;
70  Real y1 = (_cut_data[3] + trans.second) * scale.second;
71 
72  _cut_line_endpoints.push_back(std::make_pair(Point(x0, y0, 0.0), Point(x1, y1, 0.0)));
73 
74  if (_cut_line_endpoints.size() != _cut_time_ranges.size())
75  mooseError("Number of start/end times must match number of cut line endpoint sets");
76 }
77 
78 const std::vector<Point>
79 LineSegmentCutUserObject::getCrackFrontPoints(unsigned int /*num_crack_front_points*/) const
80 {
81  mooseError("getCrackFrontPoints() is not implemented for this object.");
82 }
registerMooseObject
registerMooseObject("XFEMApp", LineSegmentCutUserObject)
GeometricCut2DUserObject::_cut_time_ranges
std::vector< std::pair< Real, Real > > _cut_time_ranges
Vector of start/end times for each cut segment.
Definition: GeometricCut2DUserObject.h:61
LineSegmentCutUserObject.h
LineSegmentCutUserObject::LineSegmentCutUserObject
LineSegmentCutUserObject(const InputParameters &parameters)
Definition: LineSegmentCutUserObject.C:33
GeometricCut2DUserObject
Definition: GeometricCut2DUserObject.h:20
LineSegmentCutUserObject::getCrackFrontPoints
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
Definition: LineSegmentCutUserObject.C:79
LineSegmentCutUserObject
Definition: LineSegmentCutUserObject.h:20
GeometricCut2DUserObject::_cut_line_endpoints
std::vector< std::pair< Point, Point > > _cut_line_endpoints
Definition: GeometricCut2DUserObject.h:41
validParams< GeometricCut2DUserObject >
InputParameters validParams< GeometricCut2DUserObject >()
Definition: GeometricCut2DUserObject.C:22
validParams< LineSegmentCutUserObject >
InputParameters validParams< LineSegmentCutUserObject >()
Definition: LineSegmentCutUserObject.C:16
LineSegmentCutUserObject::_cut_data
std::vector< Real > _cut_data
Definition: LineSegmentCutUserObject.h:29