LCOV - code coverage report
Current view: top level - src/materials - ComputeLinearElasticStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 18 19 94.7 %
Date: 2025-07-25 05:00:39 Functions: 4 4 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 "ComputeLinearElasticStress.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", ComputeLinearElasticStress);
      13             : 
      14             : InputParameters
      15        3888 : ComputeLinearElasticStress::validParams()
      16             : {
      17        3888 :   InputParameters params = ComputeStressBase::validParams();
      18        3888 :   params.addClassDescription("Compute stress using elasticity for small strains");
      19        3888 :   return params;
      20           0 : }
      21             : 
      22        2904 : ComputeLinearElasticStress::ComputeLinearElasticStress(const InputParameters & parameters)
      23             :   : ComputeStressBase(parameters),
      24        2904 :     _elasticity_tensor_name(_base_name + "elasticity_tensor"),
      25        2904 :     _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_elasticity_tensor_name))
      26             : {
      27        2904 : }
      28             : 
      29             : void
      30        2776 : ComputeLinearElasticStress::initialSetup()
      31             : {
      32             :   // _base_name + "unstabilized_deformation_gradient" is only declared if we're
      33             :   // using the Lagrangian kernels.  It's okay to invoke this small strain
      34             :   // material if you are using that kernel system and the
      35             :   // ComputeLagrangianWrappedStress wrapper
      36        5590 :   if (hasBlockMaterialProperty<RankTwoTensor>(_base_name + "strain_increment") &&
      37        2814 :       !hasBlockMaterialProperty<RankTwoTensor>(_base_name + "unstabilized_deformation_gradient"))
      38           2 :     mooseError("This linear elastic stress calculation only works for small strains; use "
      39             :                "ComputeFiniteStrainElasticStress for simulations using incremental and finite "
      40             :                "strains.");
      41        2774 : }
      42             : 
      43             : void
      44    24221340 : ComputeLinearElasticStress::computeQpStress()
      45             : {
      46             :   // stress = C * e
      47    24221340 :   _stress[_qp] = _elasticity_tensor[_qp] * _mechanical_strain[_qp];
      48             : 
      49             :   // Assign value for elastic strain, which is equal to the mechanical strain
      50    24221340 :   _elastic_strain[_qp] = _mechanical_strain[_qp];
      51             : 
      52             :   // Compute dstress_dstrain
      53    24221340 :   _Jacobian_mult[_qp] = _elasticity_tensor[_qp];
      54    24221340 : }

Generated by: LCOV version 1.14