LCOV - code coverage report
Current view: top level - src/materials - ADComputeLinearElasticStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 15 17 88.2 %
Date: 2025-07-25 05:00:39 Functions: 8 8 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 "ADComputeLinearElasticStress.h"
      11             : #include "RankTwoTensor.h"
      12             : #include "RankFourTensor.h"
      13             : #include "SymmetricRankTwoTensor.h"
      14             : #include "SymmetricRankFourTensor.h"
      15             : 
      16             : registerMooseObject("SolidMechanicsApp", ADComputeLinearElasticStress);
      17             : registerMooseObject("SolidMechanicsApp", ADSymmetricLinearElasticStress);
      18             : 
      19             : template <typename R2, typename R4>
      20             : InputParameters
      21        1518 : ADComputeLinearElasticStressTempl<R2, R4>::validParams()
      22             : {
      23        1518 :   InputParameters params = ADComputeStressBaseTempl<R2>::validParams();
      24        1518 :   params.addClassDescription("Compute stress using elasticity for small strains");
      25        1518 :   return params;
      26           0 : }
      27             : 
      28             : template <typename R2, typename R4>
      29        1134 : ADComputeLinearElasticStressTempl<R2, R4>::ADComputeLinearElasticStressTempl(
      30             :     const InputParameters & parameters)
      31             :   : ADComputeStressBaseTempl<R2>(parameters),
      32        1134 :     _elasticity_tensor_name(_base_name + "elasticity_tensor"),
      33        1134 :     _elasticity_tensor(this->template getADMaterialProperty<R4>(_elasticity_tensor_name))
      34             : {
      35        1134 : }
      36             : 
      37             : template <typename R2, typename R4>
      38             : void
      39        1134 : ADComputeLinearElasticStressTempl<R2, R4>::initialSetup()
      40             : {
      41        2268 :   if (this->template hasBlockMaterialProperty<R2>(_base_name + "strain_increment"))
      42           0 :     mooseError("This linear elastic stress calculation only works for small strains; use "
      43             :                "ADComputeFiniteStrainElasticStress for simulations using incremental and finite "
      44             :                "strains.");
      45        1134 : }
      46             : 
      47             : template <typename R2, typename R4>
      48             : void
      49     9532420 : ADComputeLinearElasticStressTempl<R2, R4>::computeQpStress()
      50             : {
      51             :   // stress = C * e
      52     9532420 :   _stress[_qp] = _elasticity_tensor[_qp] * _mechanical_strain[_qp];
      53             : 
      54             :   // Assign value for elastic strain, which is equal to the mechanical strain
      55     9532420 :   _elastic_strain[_qp] = _mechanical_strain[_qp];
      56     9532420 : }
      57             : 
      58             : template class ADComputeLinearElasticStressTempl<RankTwoTensor, RankFourTensor>;
      59             : template class ADComputeLinearElasticStressTempl<SymmetricRankTwoTensor, SymmetricRankFourTensor>;

Generated by: LCOV version 1.14