LCOV - code coverage report
Current view: top level - src/materials - ComputeDeformGradBasedStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 25 29 86.2 %
Date: 2025-07-25 05:00:39 Functions: 4 5 80.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 "ComputeDeformGradBasedStress.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", ComputeDeformGradBasedStress);
      13             : 
      14             : InputParameters
      15          96 : ComputeDeformGradBasedStress::validParams()
      16             : {
      17          96 :   InputParameters params = Material::validParams();
      18          96 :   params.addClassDescription("Computes stress based on Lagrangian strain");
      19         192 :   params.addRequiredParam<MaterialPropertyName>("deform_grad_name",
      20             :                                                 "Name of deformation gradient variable");
      21         192 :   params.addRequiredParam<MaterialPropertyName>("elasticity_tensor_name",
      22             :                                                 "Name of elasticity tensor variable");
      23         192 :   params.addRequiredParam<MaterialPropertyName>("stress_name", "Name of stress variable");
      24         192 :   params.addRequiredParam<MaterialPropertyName>("jacobian_name", "Name of Jacobian variable");
      25          96 :   return params;
      26           0 : }
      27             : 
      28          72 : ComputeDeformGradBasedStress::ComputeDeformGradBasedStress(const InputParameters & parameters)
      29             :   : DerivativeMaterialInterface<Material>(parameters),
      30          72 :     _deformation_gradient(getMaterialProperty<RankTwoTensor>("deform_grad_name")),
      31         144 :     _elasticity_tensor(getMaterialProperty<RankFourTensor>("elasticity_tensor_name")),
      32         144 :     _stress(declareProperty<RankTwoTensor>(getParam<MaterialPropertyName>("stress_name"))),
      33         216 :     _Jacobian_mult(declareProperty<RankFourTensor>(getParam<MaterialPropertyName>("jacobian_name")))
      34             : {
      35          72 : }
      36             : 
      37             : void
      38           0 : ComputeDeformGradBasedStress::initQpStatefulProperties()
      39             : {
      40           0 :   _stress[_qp].zero();
      41           0 : }
      42             : 
      43             : void
      44       30720 : ComputeDeformGradBasedStress::computeQpProperties()
      45             : {
      46       30720 :   computeQpStress();
      47       30720 : }
      48             : 
      49             : void
      50       30720 : ComputeDeformGradBasedStress::computeQpStress()
      51             : {
      52       30720 :   const RankTwoTensor iden(RankTwoTensor::initIdentity);
      53             :   RankTwoTensor ee =
      54       30720 :       0.5 * (_deformation_gradient[_qp].transpose() * _deformation_gradient[_qp] - iden);
      55       30720 :   RankTwoTensor pk2 = _elasticity_tensor[_qp] * ee;
      56             : 
      57       30720 :   _stress[_qp] = _deformation_gradient[_qp] * pk2 * _deformation_gradient[_qp].transpose() /
      58       30720 :                  _deformation_gradient[_qp].det();
      59       30720 :   _Jacobian_mult[_qp] = _elasticity_tensor[_qp];
      60       30720 : }

Generated by: LCOV version 1.14