LCOV - code coverage report
Current view: top level - src/materials - ComputeFiniteStrainElasticStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 37 38 97.4 %
Date: 2024-02-27 11:53:14 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://www.mooseframework.org
       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("TensorMechanicsApp", ComputeFiniteStrainElasticStress);
      13             : 
      14             : InputParameters
      15        5956 : ComputeFiniteStrainElasticStress::validParams()
      16             : {
      17        5956 :   InputParameters params = ComputeStressBase::validParams();
      18        5956 :   params.addClassDescription("Compute stress using elasticity for finite strains");
      19        5956 :   return params;
      20           0 : }
      21             : 
      22        4459 : ComputeFiniteStrainElasticStress::ComputeFiniteStrainElasticStress(
      23        4459 :     const InputParameters & parameters)
      24             :   : ComputeStressBase(parameters),
      25             :     GuaranteeConsumer(this),
      26        4459 :     _elasticity_tensor_name(_base_name + "elasticity_tensor"),
      27        4459 :     _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_elasticity_tensor_name)),
      28        4459 :     _rotation_total(declareProperty<RankTwoTensor>(_base_name + "rotation_total")),
      29        8918 :     _rotation_total_old(getMaterialPropertyOldByName<RankTwoTensor>(_base_name + "rotation_total")),
      30        8918 :     _strain_increment(getMaterialPropertyByName<RankTwoTensor>(_base_name + "strain_increment")),
      31        4459 :     _rotation_increment(
      32        4459 :         getMaterialPropertyByName<RankTwoTensor>(_base_name + "rotation_increment")),
      33        8918 :     _stress_old(getMaterialPropertyOldByName<RankTwoTensor>(_base_name + "stress")),
      34       13377 :     _elastic_strain_old(getMaterialPropertyOldByName<RankTwoTensor>(_base_name + "elastic_strain"))
      35             : {
      36        4459 : }
      37             : 
      38             : void
      39        1768 : ComputeFiniteStrainElasticStress::initialSetup()
      40             : {
      41        1768 : }
      42             : 
      43             : void
      44      391300 : ComputeFiniteStrainElasticStress::initQpStatefulProperties()
      45             : {
      46      391300 :   ComputeStressBase::initQpStatefulProperties();
      47      391300 :   RankTwoTensor identity_rotation(RankTwoTensor::initIdentity);
      48             : 
      49      391300 :   _rotation_total[_qp] = identity_rotation;
      50      391300 : }
      51             : 
      52             : void
      53    15281938 : ComputeFiniteStrainElasticStress::computeQpStress()
      54             : {
      55             :   // Calculate the stress in the intermediate configuration
      56    15281938 :   RankTwoTensor intermediate_stress;
      57             : 
      58    30563876 :   if (hasGuaranteedMaterialProperty(_elasticity_tensor_name, Guarantee::ISOTROPIC))
      59             :   {
      60             :     intermediate_stress =
      61    15250130 :         _elasticity_tensor[_qp] * (_elastic_strain_old[_qp] + _strain_increment[_qp]);
      62             : 
      63             :     // Compute dstress_dstrain
      64    15250130 :     _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       31808 :     RankFourTensor elasticity_tensor_rotated = _elasticity_tensor[_qp];
      73       31808 :     elasticity_tensor_rotated.rotate(_rotation_total_old[_qp]);
      74             : 
      75             :     intermediate_stress =
      76       31808 :         elasticity_tensor_rotated * (_elastic_strain_old[_qp] + _strain_increment[_qp]);
      77             : 
      78             :     // Update current total rotation matrix to be used in next step
      79       31808 :     _rotation_total[_qp] = _rotation_increment[_qp] * _rotation_total_old[_qp];
      80             : 
      81             :     // Compute dstress_dstrain
      82       31808 :     _Jacobian_mult[_qp] = elasticity_tensor_rotated; // This is NOT the exact jacobian
      83             :   }
      84             : 
      85             :   // Rotate the stress state to the current configuration
      86    15281938 :   _stress[_qp] =
      87    15281938 :       _rotation_increment[_qp] * intermediate_stress * _rotation_increment[_qp].transpose();
      88             : 
      89             :   // Assign value for elastic strain, which is equal to the mechanical strain
      90    15281938 :   _elastic_strain[_qp] = _mechanical_strain[_qp];
      91    15281938 : }

Generated by: LCOV version 1.14