LCOV - code coverage report
Current view: top level - src/materials - ComputeElasticityBeam.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 26 29 89.7 %
Date: 2025-07-25 05:00:39 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 "ComputeElasticityBeam.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", ComputeElasticityBeam);
      14             : 
      15             : InputParameters
      16        1372 : ComputeElasticityBeam::validParams()
      17             : {
      18        1372 :   InputParameters params = Material::validParams();
      19        1372 :   params.addClassDescription("Computes the equivalent of the elasticity tensor for the beam "
      20             :                              "element, which are vectors of material translational and flexural "
      21             :                              "stiffness.");
      22        2744 :   params.addParam<FunctionName>(
      23             :       "elasticity_prefactor",
      24             :       "Optional function to use as a scalar prefactor on the elasticity vector for the beam.");
      25        2744 :   params.addRequiredCoupledVar(
      26             :       "youngs_modulus",
      27             :       "Young's modulus of the material. Can be supplied as either a number or a variable name.");
      28        2744 :   params.addRequiredCoupledVar(
      29             :       "poissons_ratio",
      30             :       "Poisson's ratio of the material. Can be supplied as either a number or a variable name.");
      31        2744 :   params.addCoupledVar(
      32             :       "shear_coefficient",
      33             :       1.0,
      34             :       "Scale factor for the shear modulus. Can be supplied as either a number or a variable name.");
      35        1372 :   return params;
      36           0 : }
      37             : 
      38        1026 : ComputeElasticityBeam::ComputeElasticityBeam(const InputParameters & parameters)
      39             :   : Material(parameters),
      40        1026 :     _material_stiffness(declareProperty<RealVectorValue>("material_stiffness")),
      41        1026 :     _material_flexure(declareProperty<RealVectorValue>("material_flexure")),
      42        2052 :     _prefactor_function(isParamValid("elasticity_prefactor") ? &getFunction("elasticity_prefactor")
      43             :                                                              : nullptr),
      44        1026 :     _youngs_modulus(coupledValue("youngs_modulus")),
      45        1026 :     _poissons_ratio(coupledValue("poissons_ratio")),
      46        2052 :     _shear_coefficient(coupledValue("shear_coefficient"))
      47             : {
      48        1026 : }
      49             : 
      50             : void
      51      660528 : ComputeElasticityBeam::computeQpProperties()
      52             : {
      53      660528 :   const Real shear_modulus = _youngs_modulus[_qp] / (2.0 * (1.0 + _poissons_ratio[_qp]));
      54             : 
      55             :   // material_stiffness relates the translational strains to forces
      56      660528 :   _material_stiffness[_qp](0) = _youngs_modulus[_qp];
      57      660528 :   _material_stiffness[_qp](1) = _shear_coefficient[_qp] * shear_modulus;
      58      660528 :   _material_stiffness[_qp](2) = _material_stiffness[_qp](1);
      59             : 
      60             :   // material_flexure relates the rotational strains to moments
      61      660528 :   _material_flexure[_qp](0) = _shear_coefficient[_qp] * shear_modulus;
      62      660528 :   _material_flexure[_qp](1) = _youngs_modulus[_qp];
      63      660528 :   _material_flexure[_qp](2) = _material_flexure[_qp](1);
      64             : 
      65             :   // Multiply by prefactor
      66      660528 :   if (_prefactor_function)
      67             :   {
      68           0 :     _material_stiffness[_qp] *= _prefactor_function->value(_t, _q_point[_qp]);
      69           0 :     _material_flexure[_qp] *= _prefactor_function->value(_t, _q_point[_qp]);
      70             :   }
      71      660528 : }

Generated by: LCOV version 1.14