LCOV - code coverage report
Current view: top level - src/materials - ADComputeLinearElasticStress.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 15 17 88.2 %
Date: 2024-02-27 11:53:14 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://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 "ADComputeLinearElasticStress.h"
      11             : #include "RankTwoTensor.h"
      12             : #include "RankFourTensor.h"
      13             : #include "SymmetricRankTwoTensor.h"
      14             : #include "SymmetricRankFourTensor.h"
      15             : 
      16             : registerMooseObject("TensorMechanicsApp", ADComputeLinearElasticStress);
      17             : registerMooseObject("TensorMechanicsApp", ADSymmetricLinearElasticStress);
      18             : 
      19             : template <typename R2, typename R4>
      20             : InputParameters
      21         759 : ADComputeLinearElasticStressTempl<R2, R4>::validParams()
      22             : {
      23         759 :   InputParameters params = ADComputeStressBaseTempl<R2>::validParams();
      24         759 :   params.addClassDescription("Compute stress using elasticity for small strains");
      25         759 :   return params;
      26           0 : }
      27             : 
      28             : template <typename R2, typename R4>
      29         567 : ADComputeLinearElasticStressTempl<R2, R4>::ADComputeLinearElasticStressTempl(
      30             :     const InputParameters & parameters)
      31             :   : ADComputeStressBaseTempl<R2>(parameters),
      32         567 :     _elasticity_tensor_name(_base_name + "elasticity_tensor"),
      33         567 :     _elasticity_tensor(this->template getADMaterialProperty<R4>(_elasticity_tensor_name))
      34             : {
      35         567 : }
      36             : 
      37             : template <typename R2, typename R4>
      38             : void
      39         567 : ADComputeLinearElasticStressTempl<R2, R4>::initialSetup()
      40             : {
      41        1134 :   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         567 : }
      46             : 
      47             : template <typename R2, typename R4>
      48             : void
      49     4804598 : ADComputeLinearElasticStressTempl<R2, R4>::computeQpStress()
      50             : {
      51             :   // stress = C * e
      52     4804598 :   _stress[_qp] = _elasticity_tensor[_qp] * _mechanical_strain[_qp];
      53             : 
      54             :   // Assign value for elastic strain, which is equal to the mechanical strain
      55     4804598 :   _elastic_strain[_qp] = _mechanical_strain[_qp];
      56     4804598 : }
      57             : 
      58             : template class ADComputeLinearElasticStressTempl<RankTwoTensor, RankFourTensor>;
      59             : template class ADComputeLinearElasticStressTempl<SymmetricRankTwoTensor, SymmetricRankFourTensor>;

Generated by: LCOV version 1.14