LCOV - code coverage report
Current view: top level - src/materials - ComputeEigenstrainFromFunctionInitialStress.C (source / functions) Hit Total Coverage
Test: coverage.info Lines: 31 39 79.5 %
Date: 2025-02-21 01:06:12 Functions: 3 4 75.0 %

          Line data    Source code
       1             : //* This file is part of the RACCOON application
       2             : //* being developed at Dolbow lab at Duke University
       3             : //* http://dolbow.pratt.duke.edu
       4             : 
       5             : #include "ComputeEigenstrainFromFunctionInitialStress.h"
       6             : 
       7             : registerMooseObject("raccoonApp", ComputeEigenstrainFromFunctionInitialStress);
       8             : 
       9             : InputParameters
      10         142 : ComputeEigenstrainFromFunctionInitialStress::validParams()
      11             : {
      12         142 :   InputParameters params = Material::validParams();
      13         142 :   params += BaseNameInterface::validParams();
      14         142 :   params.addClassDescription(
      15             :       "This class computes the eigenstrain given a predefined intial stress. The eigenstrain is "
      16             :       "defined as $\\strain_0 = - \\mathbb{S} : \\stress_0$, where $\\mathbb{S}$ is the compliance "
      17             :       "tensor. Isotropic linear elasticity is "
      18             :       "assumed.");
      19             : 
      20         284 :   params.addRequiredParam<MaterialPropertyName>("bulk_modulus", "The bulk modulus $\\K$");
      21         284 :   params.addRequiredParam<MaterialPropertyName>("shear_modulus", "The shear modulus $\\G$");
      22         284 :   params.addRequiredParam<MaterialPropertyName>(
      23             :       "eigenstrain_name",
      24             :       "Material property name for the eigenstrain tensor computed "
      25             :       "by this model. IMPORTANT: The name of this property must "
      26             :       "also be provided to the strain calculator.");
      27         284 :   params.addRequiredParam<std::vector<FunctionName>>(
      28             :       "initial_stress", "A list of functions describing the eigen stress.");
      29         142 :   return params;
      30           0 : }
      31             : 
      32           3 : ComputeEigenstrainFromFunctionInitialStress::ComputeEigenstrainFromFunctionInitialStress(
      33           3 :     const InputParameters & parameters)
      34             :   : Material(parameters),
      35             :     BaseNameInterface(parameters),
      36           9 :     _K(getADMaterialPropertyByName<Real>(prependBaseName("bulk_modulus", true))),
      37           6 :     _G(getADMaterialPropertyByName<Real>(prependBaseName("shear_modulus", true))),
      38           3 :     _eigenstrain_name(prependBaseName("eigenstrain_name", true)),
      39           6 :     _eigenstrain(declareADProperty<RankTwoTensor>(_eigenstrain_name))
      40             : {
      41             :   const std::vector<FunctionName> & fcn_names(
      42           6 :       getParam<std::vector<FunctionName>>("initial_stress"));
      43             :   const std::size_t num = fcn_names.size();
      44             : 
      45           3 :   if (num != 1 && num != 3 && num != 6 && num != 9)
      46           0 :     paramError(
      47             :         "initial_stress",
      48           0 :         name() + ": " +
      49           0 :             "Either 1, 3, 6, or 9 initial stress functions should be provided.  You supplied " +
      50           0 :             Moose::stringify(num) + ".");
      51             : 
      52           3 :   _initial_stress_fcn.resize(num);
      53          12 :   for (unsigned i = 0; i < num; ++i)
      54           9 :     _initial_stress_fcn[i] = &getFunctionByName(fcn_names[i]);
      55           3 : }
      56             : 
      57             : void
      58           0 : ComputeEigenstrainFromFunctionInitialStress::initQpStatefulProperties()
      59             : {
      60           0 :   computeQpProperties();
      61           0 : }
      62             : 
      63             : void
      64     7520000 : ComputeEigenstrainFromFunctionInitialStress::computeQpProperties()
      65             : {
      66             :   const std::size_t num = _initial_stress_fcn.size();
      67     7520000 :   std::vector<ADReal> initial_stress_vector(num);
      68    30080000 :   for (unsigned i = 0; i < num; ++i)
      69    22560000 :     initial_stress_vector[i] = _initial_stress_fcn[i]->value(_t, _q_point[_qp]);
      70     7520000 :   ADRankTwoTensor initial_stress;
      71     7520000 :   initial_stress.fillFromInputVector(initial_stress_vector);
      72             : 
      73     7520000 :   const ADRankTwoTensor I2(ADRankTwoTensor::initIdentity);
      74     7520000 :   _eigenstrain[_qp] =
      75    22560000 :       -initial_stress.trace() / 9 / _K[_qp] * I2 - initial_stress.deviatoric() / 2 / _G[_qp];
      76     7520000 : }

Generated by: LCOV version 1.16