LCOV - code coverage report
Current view: top level - src/auxkernels - GlobalDisplacementAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #31405 (292dce) with base fef103 Lines: 38 41 92.7 %
Date: 2025-09-04 07:57:23 Functions: 3 3 100.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 "GlobalDisplacementAux.h"
      11             : #include "GlobalStrainUserObjectInterface.h"
      12             : 
      13             : // MOOSE includes
      14             : #include "Assembly.h"
      15             : #include "SystemBase.h"
      16             : #include "RankTwoTensor.h"
      17             : 
      18             : registerMooseObject("SolidMechanicsApp", GlobalDisplacementAux);
      19             : 
      20             : InputParameters
      21         350 : GlobalDisplacementAux::validParams()
      22             : {
      23         350 :   InputParameters params = AuxKernel::validParams();
      24         350 :   params.addClassDescription(
      25             :       "AuxKernel to visualize the displacements generated by the global strain tensor");
      26         700 :   params.addCoupledVar("scalar_global_strain",
      27             :                        "Scalar variable providing global strain components");
      28         700 :   params.addCoupledVar("displacements", "The name of the displacement variables");
      29         700 :   params.addRequiredParam<unsigned int>("component",
      30             :                                         "The displacement component to consider for this kernel");
      31         700 :   params.addParam<bool>(
      32         700 :       "output_global_displacement", false, "Option to output global displacement only");
      33         700 :   params.addRequiredParam<UserObjectName>("global_strain_uo",
      34             :                                           "The name of the GlobalStrainUserObject");
      35         350 :   params.addParam<Point>("reference_point",
      36         350 :                          Point(0, 0, 0),
      37             :                          "The coordinate of the center/fixed point of the simulation");
      38             : 
      39             :   // Default this object to get executed before the displaced mesh update.
      40             :   // This way the AuxVars set by this object can be used as mesh displacements.
      41         350 :   params.set<ExecFlagEnum>("execute_on") = EXEC_PRE_DISPLACE;
      42             : 
      43         350 :   return params;
      44           0 : }
      45             : 
      46         175 : GlobalDisplacementAux::GlobalDisplacementAux(const InputParameters & parameters)
      47             :   : AuxKernel(parameters),
      48         175 :     _scalar_global_strain(coupledScalarValue("scalar_global_strain")),
      49         350 :     _component(getParam<unsigned int>("component")),
      50         350 :     _output_global_disp(getParam<bool>("output_global_displacement")),
      51         175 :     _pst(dynamic_cast<const GlobalStrainUserObjectInterface &>(
      52         175 :         getUserObjectBase("global_strain_uo"))),
      53         175 :     _periodic_dir(_pst.getPeriodicDirections()),
      54         175 :     _ref_point(parameters.get<Point>("reference_point")),
      55         175 :     _dim(_mesh.dimension()),
      56         175 :     _ndisp(coupledComponents("displacements")),
      57         525 :     _disp(coupledValues("displacements"))
      58             : {
      59         175 :   if (!isNodal())
      60           0 :     paramError("variable", "GlobalDisplacementAux must be used on a nodal auxiliary variable");
      61             : 
      62         175 :   if (_component >= _dim)
      63           0 :     paramError("component",
      64             :                "The component ",
      65             :                _component,
      66             :                " does not exist for ",
      67             :                _dim,
      68             :                " dimensional problems");
      69         175 : }
      70             : 
      71             : Real
      72       33841 : GlobalDisplacementAux::computeValue()
      73             : {
      74       33841 :   RankTwoTensor strain;
      75       33841 :   strain.fillFromScalarVariable(_scalar_global_strain);
      76             : 
      77      120240 :   for (unsigned int dir = 0; dir < _dim; ++dir)
      78       86399 :     if (!_periodic_dir(dir))
      79       85482 :       for (unsigned int var = 0; var < _ndisp; ++var)
      80       63900 :         strain(dir, var) = 0.0;
      81             : 
      82       33841 :   const RealVectorValue & global_disp = strain * ((*_current_node) - _ref_point);
      83             : 
      84       33841 :   if (_output_global_disp)
      85         891 :     return global_disp(_component);
      86             :   else
      87       32950 :     return global_disp(_component) + (*_disp[_component])[_qp];
      88             : }

Generated by: LCOV version 1.14