LCOV - code coverage report
Current view: top level - src/materials - ComputeFiniteStrainElasticStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 39 40 97.5 %
Date: 2025-07-25 05:00:39 Functions: 5 5 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 "ComputeFiniteStrainElasticStress.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", ComputeFiniteStrainElasticStress);
      13             : 
      14             : InputParameters
      15       12766 : ComputeFiniteStrainElasticStress::validParams()
      16             : {
      17       12766 :   InputParameters params = ComputeStressBase::validParams();
      18       12766 :   params.addClassDescription("Compute stress using elasticity for finite strains");
      19       12766 :   return params;
      20           0 : }
      21             : 
      22        9554 : ComputeFiniteStrainElasticStress::ComputeFiniteStrainElasticStress(
      23        9554 :     const InputParameters & parameters)
      24             :   : ComputeStressBase(parameters),
      25             :     GuaranteeConsumer(this),
      26        9554 :     _elasticity_tensor_name(_base_name + "elasticity_tensor"),
      27        9554 :     _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_elasticity_tensor_name)),
      28        9554 :     _rotation_total(declareProperty<RankTwoTensor>(_base_name + "rotation_total")),
      29       19108 :     _rotation_total_old(getMaterialPropertyOldByName<RankTwoTensor>(_base_name + "rotation_total")),
      30       19108 :     _strain_increment(getMaterialPropertyByName<RankTwoTensor>(_base_name + "strain_increment")),
      31        9554 :     _rotation_increment(
      32        9554 :         getMaterialPropertyByName<RankTwoTensor>(_base_name + "rotation_increment")),
      33       19108 :     _stress_old(getMaterialPropertyOldByName<RankTwoTensor>(_base_name + "stress")),
      34       28662 :     _elastic_strain_old(getMaterialPropertyOldByName<RankTwoTensor>(_base_name + "elastic_strain"))
      35             : {
      36        9554 : }
      37             : 
      38             : void
      39        3716 : ComputeFiniteStrainElasticStress::initialSetup()
      40             : {
      41        3716 : }
      42             : 
      43             : void
      44      820904 : ComputeFiniteStrainElasticStress::initQpStatefulProperties()
      45             : {
      46      820904 :   ComputeStressBase::initQpStatefulProperties();
      47      820904 :   RankTwoTensor identity_rotation(RankTwoTensor::initIdentity);
      48             : 
      49      820904 :   _rotation_total[_qp] = identity_rotation;
      50      820904 : }
      51             : 
      52             : void
      53    29841848 : ComputeFiniteStrainElasticStress::computeQpStress()
      54             : {
      55             :   // Calculate the stress in the intermediate configuration
      56    29841848 :   RankTwoTensor intermediate_stress;
      57             : 
      58    59683696 :   if (hasGuaranteedMaterialProperty(_elasticity_tensor_name, Guarantee::ISOTROPIC))
      59             :   {
      60    29783384 :     intermediate_stress =
      61    29783384 :         _elasticity_tensor[_qp] * (_elastic_strain_old[_qp] + _strain_increment[_qp]);
      62             : 
      63             :     // Compute dstress_dstrain
      64    29783384 :     _Jacobian_mult[_qp] = _elasticity_tensor[_qp]; // This is NOT the exact jacobian
      65             :   }
      66             :   else
      67             :   {
      68             :     // Rotate elasticity tensor to the intermediate configuration
      69             :     // That is, elasticity tensor is defined in the previous time step
      70             :     // This is consistent with the definition of strain increment
      71             :     // The stress is projected onto the current configuration a few lines below
      72       58464 :     RankFourTensor elasticity_tensor_rotated = _elasticity_tensor[_qp];
      73       58464 :     elasticity_tensor_rotated.rotate(_rotation_total_old[_qp]);
      74             : 
      75       58464 :     intermediate_stress =
      76       58464 :         elasticity_tensor_rotated * (_elastic_strain_old[_qp] + _strain_increment[_qp]);
      77             : 
      78             :     // Update current total rotation matrix to be used in next step
      79       58464 :     _rotation_total[_qp] = _rotation_increment[_qp] * _rotation_total_old[_qp];
      80             : 
      81             :     // Compute dstress_dstrain
      82       58464 :     _Jacobian_mult[_qp] = elasticity_tensor_rotated; // This is NOT the exact jacobian
      83             :   }
      84             : 
      85             :   // Rotate the stress state to the current configuration
      86    29841848 :   _stress[_qp] =
      87    29841848 :       _rotation_increment[_qp] * intermediate_stress * _rotation_increment[_qp].transpose();
      88             : 
      89             :   // Assign value for elastic strain, which is equal to the mechanical strain
      90    29841848 :   _elastic_strain[_qp] = _mechanical_strain[_qp];
      91    29841848 : }

Generated by: LCOV version 1.14