LCOV - code coverage report
Current view: top level - src/materials - ADComputeFiniteStrainElasticStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 37 38 97.4 %
Date: 2025-07-25 05:00:39 Functions: 10 10 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 "ADComputeFiniteStrainElasticStress.h"
      11             : #include "RankTwoTensor.h"
      12             : #include "RankFourTensor.h"
      13             : #include "SymmetricRankTwoTensor.h"
      14             : #include "SymmetricRankFourTensor.h"
      15             : 
      16             : registerMooseObject("SolidMechanicsApp", ADComputeFiniteStrainElasticStress);
      17             : registerMooseObject("SolidMechanicsApp", ADSymmetricFiniteStrainElasticStress);
      18             : 
      19             : template <typename R2, typename R4>
      20             : InputParameters
      21        3882 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::validParams()
      22             : {
      23        3882 :   InputParameters params = ADComputeStressBase::validParams();
      24        3882 :   params.addClassDescription("Compute stress using elasticity for finite strains");
      25        3882 :   return params;
      26           0 : }
      27             : 
      28             : template <typename R2, typename R4>
      29        2906 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::ADComputeFiniteStrainElasticStressTempl(
      30             :     const InputParameters & parameters)
      31             :   : ADComputeStressBaseTempl<R2>(parameters),
      32             :     GuaranteeConsumer(this),
      33        2906 :     _elasticity_tensor_name(_base_name + "elasticity_tensor"),
      34        2906 :     _elasticity_tensor(this->template getADMaterialProperty<R4>(_elasticity_tensor_name)),
      35        2906 :     _strain_increment(
      36        2906 :         this->template getADMaterialPropertyByName<R2>(_base_name + "strain_increment")),
      37        2906 :     _rotation_total(this->template declareADProperty<RankTwoTensor>(_base_name + "rotation_total")),
      38        2906 :     _rotation_total_old(
      39        2906 :         this->template getMaterialPropertyOldByName<RankTwoTensor>(_base_name + "rotation_total")),
      40        5812 :     _rotation_increment(this->template getADMaterialPropertyByName<RankTwoTensor>(
      41             :         _base_name + "rotation_increment")),
      42        5812 :     _stress_old(this->template getMaterialPropertyOldByName<R2>(_base_name + "stress")),
      43        2906 :     _elastic_strain_old(
      44        5812 :         this->template getMaterialPropertyOldByName<R2>(_base_name + "elastic_strain"))
      45             : {
      46        2906 : }
      47             : 
      48             : template <typename R2, typename R4>
      49             : void
      50        1278 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::initialSetup()
      51             : {
      52        1278 : }
      53             : 
      54             : template <typename R2, typename R4>
      55             : void
      56      157440 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::initQpStatefulProperties()
      57             : {
      58      157440 :   ADComputeStressBaseTempl<R2>::initQpStatefulProperties();
      59      157440 :   _rotation_total[_qp] = RankTwoTensor::Identity();
      60      157440 : }
      61             : 
      62             : template <typename R2, typename R4>
      63             : void
      64     8132634 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::computeQpStress()
      65             : {
      66             :   // Calculate the stress in the intermediate configuration
      67     8132634 :   ADR2 intermediate_stress;
      68             : 
      69    16265268 :   if (hasGuaranteedMaterialProperty(_elasticity_tensor_name, Guarantee::ISOTROPIC))
      70    16181940 :     intermediate_stress =
      71     8090970 :         _elasticity_tensor[_qp] * (_strain_increment[_qp] + _elastic_strain_old[_qp]);
      72             :   else
      73             :   {
      74             :     // Rotate elasticity tensor to the intermediate configuration
      75             :     // That is, elasticity tensor is defined in the previous time step
      76             :     // This is consistent with the definition of strain increment
      77             :     // The stress is projected onto the current configuration a few lines below
      78       41664 :     auto elasticity_tensor_rotated = _elasticity_tensor[_qp];
      79       41664 :     elasticity_tensor_rotated.rotate(_rotation_total_old[_qp]);
      80             : 
      81       41664 :     intermediate_stress =
      82       41664 :         elasticity_tensor_rotated * (_elastic_strain_old[_qp] + _strain_increment[_qp]);
      83             : 
      84             :     // Update current total rotation matrix to be used in next step
      85       41664 :     _rotation_total[_qp] = _rotation_increment[_qp] * _rotation_total_old[_qp];
      86             :   }
      87             :   // Rotate the stress state to the current configuration
      88     8132634 :   _stress[_qp] = intermediate_stress;
      89     8132634 :   _stress[_qp].rotate(_rotation_increment[_qp]);
      90             : 
      91             :   // Assign value for elastic strain, which is equal to the mechanical strain
      92     8132634 :   _elastic_strain[_qp] = _mechanical_strain[_qp];
      93     8132634 : }
      94             : 
      95             : template class ADComputeFiniteStrainElasticStressTempl<RankTwoTensor, RankFourTensor>;
      96             : template class ADComputeFiniteStrainElasticStressTempl<SymmetricRankTwoTensor,
      97             :                                                        SymmetricRankFourTensor>;

Generated by: LCOV version 1.14