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