LCOV - code coverage report
Current view: top level - src/materials - ADComputeStrainBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 42 46 91.3 %
Date: 2026-05-29 20:40:07 Functions: 8 10 80.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 "ADComputeStrainBase.h"
      11             : #include "RankTwoTensor.h"
      12             : #include "SymmetricRankTwoTensor.h"
      13             : #include "MooseMesh.h"
      14             : #include "Assembly.h"
      15             : 
      16             : template <typename R2>
      17             : InputParameters
      18        3324 : ADComputeStrainBaseTempl<R2>::validParams()
      19             : {
      20        3324 :   InputParameters params = Material::validParams();
      21        6648 :   params.addRequiredCoupledVar(
      22             :       "displacements",
      23             :       "The displacements appropriate for the simulation geometry and coordinate system");
      24        6648 :   params.addParam<std::string>("base_name",
      25             :                                "Optional parameter that allows the user to define "
      26             :                                "multiple mechanics material systems on the same "
      27             :                                "block, i.e. for multiple phases");
      28        6648 :   params.addParam<bool>(
      29        6648 :       "volumetric_locking_correction", false, "Flag to correct volumetric locking");
      30        6648 :   params.addParam<std::vector<MaterialPropertyName>>(
      31             :       "eigenstrain_names", {}, "List of eigenstrains to be applied in this strain calculation");
      32        6648 :   params.addParam<MaterialPropertyName>("global_strain",
      33             :                                         "Optional material property holding a global strain "
      34             :                                         "tensor applied to the mesh as a whole");
      35        3324 :   params.suppressParameter<bool>("use_displaced_mesh");
      36        3324 :   return params;
      37           0 : }
      38             : 
      39             : template <typename R2>
      40        2493 : ADComputeStrainBaseTempl<R2>::ADComputeStrainBaseTempl(const InputParameters & parameters)
      41             :   : Material(parameters),
      42        2493 :     _ndisp(coupledComponents("displacements")),
      43        2493 :     _disp(adCoupledValues("displacements")),
      44        2493 :     _grad_disp(adCoupledGradients("displacements")),
      45        5070 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      46        2493 :     _mechanical_strain(declareADProperty<R2>(_base_name + "mechanical_strain")),
      47        2493 :     _total_strain(declareADProperty<R2>(_base_name + "total_strain")),
      48        4986 :     _eigenstrain_names(getParam<std::vector<MaterialPropertyName>>("eigenstrain_names")),
      49        2493 :     _eigenstrains(_eigenstrain_names.size()),
      50        2493 :     _global_strain(isParamValid("global_strain")
      51        2493 :                        ? &getADMaterialProperty<R2>(_base_name + "global_strain")
      52             :                        : nullptr),
      53        7383 :     _volumetric_locking_correction(getParam<bool>("volumetric_locking_correction") &&
      54             :                                    !this->isBoundaryMaterial()),
      55        4986 :     _current_elem_volume(_assembly.elemVolume())
      56             : {
      57             :   // set unused dimensions to zero
      58        3720 :   for (unsigned i = _ndisp; i < 3; ++i)
      59             :   {
      60        1227 :     _disp.push_back(&_ad_zero);
      61        1227 :     _grad_disp.push_back(&_ad_grad_zero);
      62             :   }
      63             : 
      64        2781 :   for (unsigned int i = 0; i < _eigenstrains.size(); ++i)
      65             :   {
      66         576 :     _eigenstrain_names[i] = _base_name + _eigenstrain_names[i];
      67         288 :     _eigenstrains[i] = &getADMaterialProperty<R2>(_eigenstrain_names[i]);
      68             :   }
      69             : 
      70        2493 :   if (_ndisp == 1 && _volumetric_locking_correction)
      71           0 :     paramError("volumetric_locking_correction", "has to be set to false for 1-D problems.");
      72             : 
      73        4986 :   if (getParam<bool>("use_displaced_mesh"))
      74           0 :     paramError("use_displaced_mesh", "The strain calculator needs to run on the undisplaced mesh.");
      75        2493 : }
      76             : 
      77             : template <typename R2>
      78             : void
      79         582 : ADComputeStrainBaseTempl<R2>::initialSetup()
      80             : {
      81        2199 :   displacementIntegrityCheck();
      82         582 : }
      83             : 
      84             : template <typename R2>
      85             : void
      86        2166 : ADComputeStrainBaseTempl<R2>::displacementIntegrityCheck()
      87             : {
      88             :   // Checking for consistency between mesh size and length of the provided displacements vector
      89        2166 :   if (_ndisp != _mesh.dimension())
      90           0 :     paramError(
      91             :         "displacements",
      92             :         "The number of variables supplied in 'displacements' must match the mesh dimension.");
      93        2166 : }
      94             : 
      95             : template <typename R2>
      96             : void
      97         448 : ADComputeStrainBaseTempl<R2>::initQpStatefulProperties()
      98             : {
      99         448 :   _mechanical_strain[_qp].zero();
     100         448 :   _total_strain[_qp].zero();
     101         448 : }
     102             : 
     103             : template class ADComputeStrainBaseTempl<RankTwoTensor>;
     104             : template class ADComputeStrainBaseTempl<SymmetricRankTwoTensor>;

Generated by: LCOV version 1.14