LCOV - code coverage report
Current view: top level - src/materials - StressBasedChemicalPotential.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 0 34 0.0 %
Date: 2025-07-25 05:00:39 Functions: 0 4 0.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 "StressBasedChemicalPotential.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", StressBasedChemicalPotential);
      13             : 
      14             : InputParameters
      15           0 : StressBasedChemicalPotential::validParams()
      16             : {
      17           0 :   InputParameters params = Material::validParams();
      18           0 :   params.addClassDescription("Chemical potential from stress");
      19           0 :   params.addRequiredParam<MaterialPropertyName>("property_name",
      20             :                                                 "Name of stress based chemical potential");
      21           0 :   params.addRequiredParam<MaterialPropertyName>("stress_name", "Name of stress property variable");
      22           0 :   params.addRequiredParam<MaterialPropertyName>("direction_tensor_name",
      23             :                                                 "Name of direction tensor variable");
      24           0 :   params.addRequiredParam<MaterialPropertyName>("prefactor_name", "Name of prefactor variable");
      25           0 :   params.addCoupledVar("c", "Concentration variable");
      26           0 :   return params;
      27           0 : }
      28             : 
      29           0 : StressBasedChemicalPotential::StressBasedChemicalPotential(const InputParameters & parameters)
      30             :   : DerivativeMaterialInterface<Material>(parameters),
      31           0 :     _chemical_potential(declareProperty<Real>(getParam<MaterialPropertyName>("property_name"))),
      32           0 :     _stress_old(getMaterialPropertyOld<RankTwoTensor>("stress_name")),
      33           0 :     _direction_tensor(getMaterialProperty<RealTensorValue>("direction_tensor_name")),
      34           0 :     _prefactor(getMaterialProperty<Real>("prefactor_name")),
      35           0 :     _has_coupled_c(isCoupled("c") && !isCoupledConstant("c"))
      36             : {
      37           0 :   if (_has_coupled_c)
      38             :   {
      39           0 :     _dchemical_potential = &declarePropertyDerivative<Real>(
      40           0 :         getParam<MaterialPropertyName>("property_name"), coupledName("c", 0));
      41           0 :     _dprefactor_dc = &getMaterialPropertyDerivative<Real>("prefactor_name", coupledName("c", 0));
      42             :   }
      43           0 : }
      44             : 
      45             : void
      46           0 : StressBasedChemicalPotential::initQpStatefulProperties()
      47             : {
      48           0 :   _chemical_potential[_qp] = 0.0;
      49             : 
      50           0 :   if (_has_coupled_c)
      51           0 :     (*_dchemical_potential)[_qp] = 0.0;
      52           0 : }
      53             : 
      54             : void
      55           0 : StressBasedChemicalPotential::computeQpProperties()
      56             : {
      57           0 :   RankTwoTensor direction_tensor_rank_two = _direction_tensor[_qp];
      58           0 :   _chemical_potential[_qp] =
      59           0 :       -_stress_old[_qp].doubleContraction(direction_tensor_rank_two) * _prefactor[_qp];
      60             : 
      61           0 :   if (_has_coupled_c)
      62           0 :     (*_dchemical_potential)[_qp] =
      63           0 :         -_stress_old[_qp].doubleContraction(direction_tensor_rank_two) * (*_dprefactor_dc)[_qp];
      64           0 : }

Generated by: LCOV version 1.14