LCOV - code coverage report
Current view: top level - src/materials - ADComputeFiniteStrainElasticStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #31405 (292dce) with base fef103 Lines: 37 38 97.4 %
Date: 2025-09-04 07:57:23 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        4334 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::validParams()
      22             : {
      23        4334 :   InputParameters params = ADComputeStressBase::validParams();
      24        4334 :   params.addClassDescription("Compute stress using elasticity for finite strains");
      25        4334 :   return params;
      26           0 : }
      27             : 
      28             : template <typename R2, typename R4>
      29        3245 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::ADComputeFiniteStrainElasticStressTempl(
      30             :     const InputParameters & parameters)
      31             :   : ADComputeStressBaseTempl<R2>(parameters),
      32             :     GuaranteeConsumer(this),
      33        3245 :     _elasticity_tensor_name(_base_name + "elasticity_tensor"),
      34        3245 :     _elasticity_tensor(this->template getADMaterialProperty<R4>(_elasticity_tensor_name)),
      35        3245 :     _strain_increment(
      36        3245 :         this->template getADMaterialPropertyByName<R2>(_base_name + "strain_increment")),
      37        3245 :     _rotation_total(this->template declareADProperty<RankTwoTensor>(_base_name + "rotation_total")),
      38        3245 :     _rotation_total_old(
      39        3245 :         this->template getMaterialPropertyOldByName<RankTwoTensor>(_base_name + "rotation_total")),
      40        6490 :     _rotation_increment(this->template getADMaterialPropertyByName<RankTwoTensor>(
      41             :         _base_name + "rotation_increment")),
      42        6490 :     _stress_old(this->template getMaterialPropertyOldByName<R2>(_base_name + "stress")),
      43        3245 :     _elastic_strain_old(
      44        6490 :         this->template getMaterialPropertyOldByName<R2>(_base_name + "elastic_strain"))
      45             : {
      46        3245 : }
      47             : 
      48             : template <typename R2, typename R4>
      49             : void
      50        1425 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::initialSetup()
      51             : {
      52        1425 : }
      53             : 
      54             : template <typename R2, typename R4>
      55             : void
      56      188712 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::initQpStatefulProperties()
      57             : {
      58      188712 :   ADComputeStressBaseTempl<R2>::initQpStatefulProperties();
      59      188712 :   _rotation_total[_qp] = RankTwoTensor::Identity();
      60      188712 : }
      61             : 
      62             : template <typename R2, typename R4>
      63             : void
      64     8683820 : ADComputeFiniteStrainElasticStressTempl<R2, R4>::computeQpStress()
      65             : {
      66             :   // Calculate the stress in the intermediate configuration
      67     8683820 :   ADR2 intermediate_stress;
      68             : 
      69    17367640 :   if (hasGuaranteedMaterialProperty(_elasticity_tensor_name, Guarantee::ISOTROPIC))
      70    17263296 :     intermediate_stress =
      71     8631648 :         _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       52172 :     auto elasticity_tensor_rotated = _elasticity_tensor[_qp];
      79       52172 :     elasticity_tensor_rotated.rotate(_rotation_total_old[_qp]);
      80             : 
      81       52172 :     intermediate_stress =
      82       52172 :         elasticity_tensor_rotated * (_elastic_strain_old[_qp] + _strain_increment[_qp]);
      83             : 
      84             :     // Update current total rotation matrix to be used in next step
      85       52172 :     _rotation_total[_qp] = _rotation_increment[_qp] * _rotation_total_old[_qp];
      86             :   }
      87             :   // Rotate the stress state to the current configuration
      88     8683820 :   _stress[_qp] = intermediate_stress;
      89     8683820 :   _stress[_qp].rotate(_rotation_increment[_qp]);
      90             : 
      91             :   // Assign value for elastic strain, which is equal to the mechanical strain
      92     8683820 :   _elastic_strain[_qp] = _mechanical_strain[_qp];
      93     8683820 : }
      94             : 
      95             : template class ADComputeFiniteStrainElasticStressTempl<RankTwoTensor, RankFourTensor>;
      96             : template class ADComputeFiniteStrainElasticStressTempl<SymmetricRankTwoTensor,
      97             :                                                        SymmetricRankFourTensor>;

Generated by: LCOV version 1.14