https://mooseframework.inl.gov
StrainAdjustedDensity.C
Go to the documentation of this file.
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 "StrainAdjustedDensity.h"
11 
12 registerMooseObject("SolidMechanicsApp", StrainAdjustedDensity);
13 registerMooseObject("SolidMechanicsApp", ADStrainAdjustedDensity);
14 
15 template <bool is_ad>
18 {
20 
21  params.addRequiredCoupledVar(
22  "displacements",
23  "The displacements appropriate for the simulation geometry and coordinate system. If "
24  "displacements are not coupled, a different material class such as GenericMaterialProperty "
25  "or ParsedMaterial should be used.");
26 
27  params.addParam<std::string>("base_name",
28  "Optional parameter that allows the user to define "
29  "multiple material systems on the same block, "
30  "e.g. for multiple phases");
31  params.addRequiredParam<MaterialPropertyName>("strain_free_density",
32  "Material property for strain-free density");
33  params.addClassDescription("Creates density material property");
34 
35  return params;
36 }
37 
38 template <bool is_ad>
40  : Material(parameters),
41  _coord_system(getBlockCoordSystem()),
42  _disp_r(this->template coupledGenericValue<is_ad>("displacements", 0)),
43  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
44  _strain_free_density(
45  this->template getGenericMaterialProperty<Real, is_ad>("strain_free_density")),
46  _grad_disp(this->template coupledGenericGradients<is_ad>("displacements")),
47  _density(declareGenericProperty<Real, is_ad>(_base_name + "density"))
48 {
49  if (getParam<bool>("use_displaced_mesh"))
50  paramError("use_displaced_mesh",
51  "StrainAdjustedDensity needs to act on an undisplaced mesh. Use of a displaced mesh "
52  "leads to "
53  "incorrect gradient values");
54 
55  // fill remaining components with zero
56  _grad_disp.resize(3, &genericZeroGradient<is_ad>());
57 }
58 
59 template <bool is_ad>
60 void
62 {
63  computeQpProperties();
64 }
65 
66 template <bool is_ad>
67 void
69 {
71  (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]);
72  A.addIa(1.0);
73 
74  switch (_coord_system)
75  {
76  case Moose::COORD_XYZ:
77  break;
78 
79  case Moose::COORD_RZ:
80  if (_q_point[_qp](0) != 0.0)
81  A(2, 2) = _disp_r[_qp] / _q_point[_qp](0) + 1.0;
82  break;
83 
85  if (_q_point[_qp](0) != 0.0)
86  A(1, 1) = A(2, 2) = _disp_r[_qp] / _q_point[_qp](0) + 1.0;
87  break;
88  }
89 
90  _density[_qp] = _strain_free_density[_qp] / A.det();
91 }
92 
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual void computeQpProperties() override
Compute density depending on strains from deforming mesh.
COORD_RSPHERICAL
void addRequiredParam(const std::string &name, const std::string &doc_string)
StrainAdjustedDensityTempl(const InputParameters &params)
static InputParameters validParams()
static InputParameters validParams()
void paramError(const std::string &param, Args... args) const
std::vector< const GenericVariableGradient< is_ad > * > _grad_disp
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
registerMooseObject("SolidMechanicsApp", StrainAdjustedDensity)
virtual void initQpStatefulProperties() override
Moose::GenericType< RankTwoTensor, is_ad > GenericRankTwoTensor