LCOV - code coverage report
Current view: top level - src/userobjects - LineSegmentCutUserObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose xfem: #31405 (292dce) with base fef103 Lines: 19 30 63.3 %
Date: 2025-09-04 07:58:55 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14