www.mooseframework.org
LineSegmentCutSetUserObject.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 template <>
14 InputParameters
16 {
17  // Get input parameters from parent class
18  InputParameters params = validParams<GeometricCut2DUserObject>();
19 
20  // Add required parameters
21  params.addRequiredParam<std::vector<Real>>("cut_data",
22  "Vector of Real values providing cut information");
23  // Add optional parameters
24  params.addParam<std::vector<Real>>("cut_scale", "X,Y scale factors for geometric cuts");
25  params.addParam<std::vector<Real>>("cut_translate", "X,Y translations for geometric cuts");
26  // Class description
27  params.addClassDescription("Creates a UserObject for a line segment cut on 2D meshes for XFEM");
28  // Return the parameters
29  return params;
30 }
31 
33  : GeometricCut2DUserObject(parameters), _cut_data(getParam<std::vector<Real>>("cut_data"))
34 {
35  // Set up constant parameters
36  const int line_cut_data_len = 6;
37 
38  // Throw error if length of cut_data is incorrect
39  if (_cut_data.size() % line_cut_data_len != 0)
40  mooseError("Length of LineSegmentCutSetUserObject cut_data must be a multiple of 6.");
41 
42  unsigned int num_cuts = _cut_data.size() / line_cut_data_len;
43 
44  // Assign scale and translate parameters
45  std::pair<Real, Real> scale;
46  if (isParamValid("cut_scale"))
47  {
48  auto vec_scale = getParam<std::vector<Real>>("cut_scale");
49  scale = std::make_pair(vec_scale[0], vec_scale[1]);
50  }
51  else
52  {
53  scale = std::make_pair(1.0, 1.0);
54  }
55 
56  std::pair<Real, Real> trans;
57  if (isParamValid("cut_translate"))
58  {
59  auto vec_trans = getParam<std::vector<Real>>("cut_translate");
60  trans = std::make_pair(vec_trans[0], vec_trans[1]);
61  }
62  else
63  {
64  trans = std::make_pair(0.0, 0.0);
65  }
66 
67  // Clear _start_times & _end_times vectors initialized from
68  // time_start_cut & time_end_cut values
69  _cut_time_ranges.clear();
70 
71  for (unsigned int i = 0; i < num_cuts; ++i)
72  {
73  Real x0 = (_cut_data[i * line_cut_data_len + 0] + trans.first) * scale.first;
74  Real y0 = (_cut_data[i * line_cut_data_len + 1] + trans.second) * scale.second;
75  Real x1 = (_cut_data[i * line_cut_data_len + 2] + trans.first) * scale.first;
76  Real y1 = (_cut_data[i * line_cut_data_len + 3] + trans.second) * scale.second;
77  _cut_line_endpoints.push_back(std::make_pair(Point(x0, y0, 0.0), Point(x1, y1, 0.0)));
78 
79  _cut_time_ranges.push_back(
80  std::make_pair(_cut_data[i * line_cut_data_len + 4], _cut_data[i * line_cut_data_len + 5]));
81  }
82 }
83 
84 const std::vector<Point>
85 LineSegmentCutSetUserObject::getCrackFrontPoints(unsigned int /*num_crack_front_points*/) const
86 {
87  mooseError("getCrackFrontPoints() is not implemented for this object.");
88 };
std::vector< std::pair< Point, Point > > _cut_line_endpoints
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< std::pair< Real, Real > > _cut_time_ranges
LineSegmentCutSetUserObject(const InputParameters &parameters)
InputParameters validParams< GeometricCut2DUserObject >()
InputParameters validParams< LineSegmentCutSetUserObject >()