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