LCOV - code coverage report
Current view: top level - src/materials - GeneralizedMaxwellModel.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 45 56 80.4 %
Date: 2025-07-25 05:00:39 Functions: 3 4 75.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 "GeneralizedMaxwellModel.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", GeneralizedMaxwellModel);
      13             : 
      14             : InputParameters
      15          48 : GeneralizedMaxwellModel::validParams()
      16             : {
      17          48 :   InputParameters params = GeneralizedMaxwellBase::validParams();
      18          48 :   params.addClassDescription(
      19             :       "Generalized Maxwell model composed of a parallel assembly of unit Maxwell modules");
      20          96 :   params.addRequiredParam<Real>("young_modulus", "initial elastic modulus of the material");
      21          96 :   params.addRequiredParam<Real>("poisson_ratio", "initial poisson ratio of the material");
      22          96 :   params.addRequiredParam<std::vector<Real>>(
      23             :       "creep_modulus", "list of the elastic moduli of the different springs in the material");
      24          96 :   params.addRequiredParam<std::vector<Real>>(
      25             :       "creep_viscosity",
      26             :       "list of the characteristic times of the different dashpots in the material");
      27          96 :   params.addParam<std::vector<Real>>(
      28             :       "creep_ratio", "list of the poisson ratios of the different springs in the material");
      29          48 :   params.set<bool>("force_recompute_properties") = false;
      30          48 :   params.suppressParameter<bool>("force_recompute_properties");
      31          48 :   return params;
      32           0 : }
      33             : 
      34          36 : GeneralizedMaxwellModel::GeneralizedMaxwellModel(const InputParameters & parameters)
      35             :   : GeneralizedMaxwellBase(parameters),
      36          72 :     _Ci(getParam<std::vector<Real>>("creep_modulus").size()),
      37          72 :     _eta_i(getParam<std::vector<Real>>("creep_viscosity")),
      38         108 :     _Si(getParam<std::vector<Real>>("creep_modulus").size())
      39             : {
      40          72 :   Real young_modulus = getParam<Real>("young_modulus");
      41          72 :   Real poisson_ratio = getParam<Real>("poisson_ratio");
      42             : 
      43          36 :   _C0.fillFromInputVector({young_modulus, poisson_ratio}, RankFourTensor::symmetric_isotropic_E_nu);
      44             : 
      45         108 :   std::vector<Real> creep_modulus = getParam<std::vector<Real>>("creep_modulus");
      46             :   std::vector<Real> creep_ratio;
      47          72 :   if (isParamValid("creep_ratio"))
      48           0 :     creep_ratio = getParam<std::vector<Real>>("creep_ratio");
      49             :   else
      50          36 :     creep_ratio.resize(_Ci.size(), poisson_ratio);
      51             : 
      52          36 :   if (creep_modulus.size() != _Ci.size())
      53           0 :     mooseError("incompatible number of creep moduli and viscosities");
      54          36 :   if (creep_ratio.size() != _Ci.size())
      55           0 :     mooseError("incompatible number of creep ratios and viscosities");
      56          36 :   if (_Ci.size() != _eta_i.size())
      57           0 :     mooseError("incompatible number of creep ratios and viscosities");
      58             : 
      59          90 :   for (unsigned int i = 0; i < _Ci.size(); ++i)
      60             :   {
      61         108 :     _Ci[i].fillFromInputVector({creep_modulus[i], creep_ratio[i]},
      62             :                                RankFourTensor::symmetric_isotropic_E_nu);
      63          54 :     _Si[i] = _Ci[i].invSymm();
      64          54 :     _C0 -= _Ci[i];
      65             :   }
      66             : 
      67          36 :   if (MooseUtils::absoluteFuzzyEqual(_C0.L2norm(), 0.0))
      68          18 :     _S0.zero();
      69             :   else
      70          18 :     _S0 = _C0.invSymm();
      71             : 
      72          90 :   for (unsigned int i = 0; i < _eta_i.size(); ++i)
      73             :   {
      74          54 :     if (_eta_i[i] < 0 || MooseUtils::absoluteFuzzyEqual(_eta_i[i], 0.0))
      75           0 :       mooseError("material viscosity must be strictly > 0");
      76             :   }
      77             : 
      78          36 :   _components = _eta_i.size();
      79          36 :   _has_longterm_dashpot = (_eta_i.size() == _Ci.size() + 1);
      80             : 
      81          36 :   issueGuarantee(_elasticity_tensor_name, Guarantee::ISOTROPIC);
      82          36 :   declareViscoelasticProperties();
      83          36 : }
      84             : 
      85             : void
      86        1984 : GeneralizedMaxwellModel::computeQpViscoelasticProperties()
      87             : {
      88        1984 :   _first_elasticity_tensor[_qp] = _C0;
      89             : 
      90        4960 :   for (unsigned int i = 0; i < _Ci.size(); ++i)
      91        2976 :     (*_springs_elasticity_tensors[i])[_qp] = _Ci[i];
      92             : 
      93        4960 :   for (unsigned int i = 0; i < _eta_i.size(); ++i)
      94        2976 :     (*_dashpot_viscosities[i])[_qp] = _eta_i[i];
      95        1984 : }
      96             : 
      97             : void
      98           0 : GeneralizedMaxwellModel::computeQpViscoelasticPropertiesInv()
      99             : {
     100           0 :   (*_first_elasticity_tensor_inv)[_qp] = _S0;
     101             : 
     102           0 :   for (unsigned int i = 0; i < _Si.size(); ++i)
     103           0 :     (*_springs_elasticity_tensors_inv[i])[_qp] = _Si[i];
     104           0 : }

Generated by: LCOV version 1.14