LCOV - code coverage report
Current view: top level - src/materials/large_deformation_models - ComputeDeformationGradient.C (source / functions) Hit Total Coverage
Test: coverage.info Lines: 59 69 85.5 %
Date: 2025-02-21 01:06:12 Functions: 6 7 85.7 %

          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 "ComputeDeformationGradient.h"
       6             : 
       7             : registerADMooseObject("raccoonApp", ComputeDeformationGradient);
       8             : 
       9             : InputParameters
      10         202 : ComputeDeformationGradient::validParams()
      11             : {
      12         202 :   InputParameters params = Material::validParams();
      13         202 :   params += BaseNameInterface::validParams();
      14         202 :   params.addClassDescription(
      15             :       "This class computes the deformation gradient. Eigen deformation gradients are extracted "
      16             :       "from the total deformation gradient. The F-bar approach can optionally be used to correct "
      17             :       "volumetric locking.");
      18             : 
      19         404 :   params.addRequiredCoupledVar(
      20             :       "displacements",
      21             :       "The displacements appropriate for the simulation geometry and coordinate system");
      22         404 :   params.addParam<bool>(
      23         404 :       "volumetric_locking_correction", false, "Flag to correct volumetric locking");
      24         404 :   params.addParam<std::vector<MaterialPropertyName>>(
      25             :       "eigen_deformation_gradient_names", {}, "List of eigen deformation gradients to be applied");
      26             : 
      27         202 :   params.suppressParameter<bool>("use_displaced_mesh");
      28         202 :   return params;
      29           0 : }
      30             : 
      31          48 : ComputeDeformationGradient::ComputeDeformationGradient(const InputParameters & parameters)
      32             :   : Material(parameters),
      33             :     BaseNameInterface(parameters),
      34          48 :     _coord_sys(_assembly.coordSystem()),
      35          48 :     _ndisp(coupledComponents("displacements")),
      36          48 :     _disp(adCoupledValues("displacements")),
      37          48 :     _grad_disp(adCoupledGradients("displacements")),
      38         130 :     _volumetric_locking_correction(getParam<bool>("volumetric_locking_correction") &&
      39             :                                    !this->isBoundaryMaterial()),
      40          48 :     _current_elem_volume(_assembly.elemVolume()),
      41          96 :     _F(declareADProperty<RankTwoTensor>(prependBaseName("deformation_gradient"))),
      42          48 :     _Fm(declareADProperty<RankTwoTensor>(prependBaseName("mechanical_deformation_gradient"))),
      43          96 :     _Fg_names(prependBaseName(
      44             :         getParam<std::vector<MaterialPropertyName>>("eigen_deformation_gradient_names"))),
      45          96 :     _Fgs(_Fg_names.size())
      46             : {
      47          51 :   for (unsigned int i = 0; i < _Fgs.size(); ++i)
      48           3 :     _Fgs[i] = &getADMaterialProperty<RankTwoTensor>(_Fg_names[i]);
      49             : 
      50          96 :   if (getParam<bool>("use_displaced_mesh"))
      51           0 :     paramError("use_displaced_mesh", "The strain calculator needs to run on the undisplaced mesh.");
      52          48 : }
      53             : 
      54             : void
      55          48 : ComputeDeformationGradient::initialSetup()
      56             : {
      57          48 :   displacementIntegrityCheck();
      58             : 
      59             :   // set unused dimensions to zero
      60          57 :   for (unsigned i = _ndisp; i < 3; ++i)
      61             :   {
      62           9 :     _disp.push_back(&_ad_zero);
      63           9 :     _grad_disp.push_back(&_ad_grad_zero);
      64             :   }
      65          48 : }
      66             : 
      67             : void
      68          48 : ComputeDeformationGradient::displacementIntegrityCheck()
      69             : {
      70             :   // Checking for consistency between mesh size and length of the provided displacements vector
      71          48 :   if (_ndisp != _mesh.dimension())
      72           0 :     paramError(
      73             :         "displacements",
      74             :         "The number of variables supplied in 'displacements' must match the mesh dimension.");
      75             : 
      76             :   // Don't use F-bar in 1D
      77          48 :   if (_ndisp == 1 && _volumetric_locking_correction)
      78           0 :     paramError("volumetric_locking_correction", "has to be set to false for 1-D problems.");
      79             : 
      80             :   // Check for RZ
      81          48 :   if (getBlockCoordSystem() == Moose::COORD_RZ && _ndisp != 2)
      82           0 :     paramError("displacements",
      83             :                "There must be two displacement variables provided, one in r-direction another in "
      84             :                "z-direction");
      85          48 : }
      86             : 
      87             : void
      88        7440 : ComputeDeformationGradient::initQpStatefulProperties()
      89             : {
      90        7440 :   _F[_qp].setToIdentity();
      91        7440 :   _Fm[_qp].setToIdentity();
      92        7440 : }
      93             : 
      94             : ADReal
      95           0 : ComputeDeformationGradient::computeQpOutOfPlaneGradDisp()
      96             : {
      97           0 :   if (!MooseUtils::absoluteFuzzyEqual(_q_point[_qp](0), 0.0))
      98           0 :     return (*_disp[0])[_qp] / _q_point[_qp](0);
      99             :   else
     100           0 :     return 0.0;
     101             : }
     102             : 
     103             : void
     104       54920 : ComputeDeformationGradient::computeProperties()
     105             : {
     106       54920 :   ADReal ave_F_det = 0;
     107             : 
     108      342056 :   for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
     109             :   {
     110             :     ADRankTwoTensor A = ADRankTwoTensor::initializeFromRows(
     111      287136 :         (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]);
     112      287136 :     if (_coord_sys == Moose::COORD_RZ)
     113           0 :       A(2, 2) = computeQpOutOfPlaneGradDisp();
     114      287136 :     _F[_qp] = A;
     115      287136 :     _F[_qp].addIa(1.0);
     116             : 
     117      287136 :     if (_volumetric_locking_correction)
     118      469056 :       ave_F_det += _F[_qp].det() * _JxW[_qp] * _coord[_qp];
     119             :   }
     120             : 
     121       54920 :   if (_volumetric_locking_correction)
     122       43169 :     ave_F_det /= _current_elem_volume;
     123             : 
     124      342056 :   for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
     125             :   {
     126      287136 :     if (_volumetric_locking_correction)
     127      469056 :       _F[_qp] *= std::cbrt(ave_F_det / _F[_qp].det());
     128             : 
     129             :     // Remove the eigen deformation gradient
     130      287136 :     ADRankTwoTensor Fg(ADRankTwoTensor::initIdentity);
     131      287640 :     for (auto Fgi : _Fgs)
     132         504 :       Fg *= (*Fgi)[_qp];
     133      287136 :     _Fm[_qp] = Fg.inverse() * _F[_qp];
     134             :   }
     135       54920 : }

Generated by: LCOV version 1.16