www.mooseframework.org
LinearViscoelasticityBase.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 #include "Conversion.h"
12 
15 {
16  MooseEnum integration("backward-euler mid-point newmark zienkiewicz", "backward-euler");
17 
19  params.addParam<MooseEnum>("integration_rule",
20  integration,
21  "describes how the viscoelastic behavior is integrated through time");
22  params.addRangeCheckedParam<Real>("theta",
23  1,
24  "theta > 0 & theta <= 1",
25  "coefficient for Newmark integration rule (between 0 and 1)");
26  params.addParam<std::string>("driving_eigenstrain",
27  "name of the eigenstrain that increases the creep strains");
28  params.addParam<std::string>(
29  "elastic_strain_name", "elastic_strain", "name of the true elastic strain of the material");
30  params.addParam<std::string>("creep_strain_name",
31  "creep_strain",
32  "name of the true creep strain of the material"
33  "(computed by LinearViscoelasticStressUpdate or"
34  "ComputeLinearViscoelasticStress)");
35  params.addParam<bool>("force_recompute_properties",
36  false,
37  "forces the computation of the viscoelastic properties at each step of"
38  "the solver (default: false)");
39  params.addParam<bool>(
40  "need_viscoelastic_properties_inverse",
41  false,
42  "checks whether the model requires the computation of the inverse viscoelastic"
43  "properties (default: false)");
44  params.suppressParameter<FunctionName>("elasticity_tensor_prefactor");
45  return params;
46 }
47 
49  : ComputeElasticityTensorBase(parameters),
50  _integration_rule(getParam<MooseEnum>("integration_rule").getEnum<IntegrationRule>()),
51  _theta(getParam<Real>("theta")),
52  _apparent_elasticity_tensor(
53  declareProperty<RankFourTensor>(_base_name + "apparent_elasticity_tensor")),
54  _apparent_elasticity_tensor_inv(
55  declareProperty<RankFourTensor>(_base_name + "apparent_elasticity_tensor_inv")),
56  _elasticity_tensor_inv(declareProperty<RankFourTensor>(_elasticity_tensor_name + "_inv")),
57  _need_viscoelastic_properties_inverse(getParam<bool>("need_viscoelastic_properties_inverse")),
58  _has_longterm_dashpot(false),
59  _components(0),
60  _first_elasticity_tensor(
61  declareProperty<RankFourTensor>(_base_name + "spring_elasticity_tensor_0")),
62  _first_elasticity_tensor_inv(
63  _need_viscoelastic_properties_inverse
64  ? &declareProperty<RankFourTensor>(_base_name + "spring_elasticity_tensor_0_inv")
65  : nullptr),
66  _apparent_creep_strain(declareProperty<RankTwoTensor>(_base_name + "apparent_creep_strain")),
67  _apparent_creep_strain_old(
68  getMaterialPropertyOld<RankTwoTensor>(_base_name + "apparent_creep_strain")),
69  _elastic_strain_old(
70  getMaterialPropertyOld<RankTwoTensor>(getParam<std::string>("elastic_strain_name"))),
71  _creep_strain_old(
72  getMaterialPropertyOld<RankTwoTensor>(getParam<std::string>("creep_strain_name"))),
73  _has_driving_eigenstrain(isParamValid("driving_eigenstrain")),
74  _driving_eigenstrain_name(
75  _has_driving_eigenstrain ? getParam<std::string>("driving_eigenstrain") : ""),
76  _driving_eigenstrain(_has_driving_eigenstrain
77  ? &getMaterialPropertyByName<RankTwoTensor>(_driving_eigenstrain_name)
78  : nullptr),
79  _driving_eigenstrain_old(_has_driving_eigenstrain
80  ? &getMaterialPropertyOld<RankTwoTensor>(_driving_eigenstrain_name)
81  : nullptr),
82  _force_recompute_properties(getParam<bool>("force_recompute_properties")),
83  _step_zero(declareRestartableData<bool>("step_zero", true))
84 {
85  if (_theta < 0.5)
86  mooseWarning("theta parameter for LinearViscoelasticityBase is below 0.5; time integration may "
87  "not converge!");
88 
89  // force material properties to be considered stateful
90  getMaterialPropertyOld<RankFourTensor>(_base_name + "apparent_elasticity_tensor");
91  getMaterialPropertyOld<RankFourTensor>(_base_name + "apparent_elasticity_tensor_inv");
92  getMaterialPropertyOld<RankFourTensor>(_elasticity_tensor_name);
93  getMaterialPropertyOld<RankFourTensor>(_elasticity_tensor_name + "_inv");
94  getMaterialPropertyOld<RankFourTensor>(_base_name + "spring_elasticity_tensor_0");
96  getMaterialPropertyOld<RankFourTensor>(_base_name + "spring_elasticity_tensor_0_inv");
97 }
98 
99 void
101 {
102  for (unsigned int i = 0; i < _components; ++i)
103  {
104  std::string ith = Moose::stringify(i + 1);
105 
106  if (!_has_longterm_dashpot || (_components > 0 && i < _components - 1))
107  {
108  _springs_elasticity_tensors.push_back(
109  &declareProperty<RankFourTensor>(_base_name + "spring_elasticity_tensor_" + ith));
110  getMaterialPropertyOld<RankFourTensor>(_base_name + "spring_elasticity_tensor_" + ith);
111  }
112 
113  _dashpot_viscosities.push_back(&declareProperty<Real>(_base_name + "dashpot_viscosity_" + ith));
114  _dashpot_viscosities_old.push_back(
115  &getMaterialPropertyOld<Real>(_base_name + "dashpot_viscosity_" + ith));
116 
117  _viscous_strains.push_back(
118  &declareProperty<RankTwoTensor>(_base_name + "viscous_strain_" + ith));
119  _viscous_strains_old.push_back(
120  &getMaterialPropertyOld<RankTwoTensor>(_base_name + "viscous_strain_" + ith));
121 
123  {
124  _springs_elasticity_tensors_inv.push_back(&declareProperty<RankFourTensor>(
125  _base_name + "spring_elasticity_tensor_" + ith + "_inv"));
126  _springs_elasticity_tensors_inv_old.push_back(&getMaterialPropertyOld<RankFourTensor>(
127  _base_name + "spring_elasticity_tensor_" + ith + "_inv"));
128  }
129  }
130 }
131 
132 void
134 {
135  if (_components != _viscous_strains.size())
136  mooseError(
137  "inconsistent numbers of dashpots and viscous strains in LinearViscoelasticityBase;"
138  " Make sure declareViscoelasticProperties has been called in the viscoelastic model");
139 
140  _apparent_creep_strain[_qp].zero();
143  _elasticity_tensor_inv[_qp].zero();
146  (*_first_elasticity_tensor_inv)[_qp].zero();
147 
148  for (unsigned int i = 0; i < _components; ++i)
149  {
150  if (!_has_longterm_dashpot || (_components > 0 && i < _components - 1))
151  {
155  }
156 
157  (*_dashpot_viscosities[i])[_qp] = 0.0;
158  (*_viscous_strains[i])[_qp].zero();
159  }
160 }
161 
162 void
164 {
165  unsigned int qp_prev = _qp;
166  _qp = qp;
167 
168  if (_t_step >= 1)
169  _step_zero = false;
170 
171  // 1. we get the viscoelastic properties and their inverse if needed
175 
176  // 2. we update the internal viscous strains from the previous time step
178 
179  // 3. we compute the apparent elasticity tensor
181 
182  // 4. we transform the internal viscous strains in an apparent creep strain
183  if (!_step_zero)
185 
186  _qp = qp_prev;
187 }
188 
189 void
191 {
194 }
195 
196 void
198 {
200  (*_first_elasticity_tensor_inv)[_qp].zero();
201  else
203 
204  for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
205  {
207  (*_springs_elasticity_tensors_inv[i])[_qp].zero();
208  else
210  }
211 }
212 
213 Real
214 LinearViscoelasticityBase::computeTheta(Real dt, Real viscosity) const
215 {
216  if (MooseUtils::absoluteFuzzyEqual(dt, 0.0))
217  mooseError("linear viscoelasticity cannot be integrated over a dt of ", dt);
218 
219  switch (_integration_rule)
220  {
222  return 1.;
224  return 0.5;
226  return _theta;
228  return 1. / (1. - std::exp(-dt / viscosity)) - viscosity / dt;
229  default:
230  return 1.;
231  }
232  return 1.;
233 }
bool & _step_zero
checks whether we are at the first time step
std::vector< MaterialProperty< RankFourTensor > * > _springs_elasticity_tensors_inv
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
T L2norm(const RankTwoTensorTempl< T > &r2tensor)
LinearViscoelasticityBase(const InputParameters &parameters)
ComputeElasticityTensorBase the base class for computing elasticity tensors.
void recomputeQpApparentProperties(unsigned int qp)
Compute the apparent properties at a quadrature point.
std::vector< MaterialProperty< RankFourTensor > * > _springs_elasticity_tensors
List of elasticity tensor of each subsequent spring in the chain.
std::vector< const MaterialProperty< RankTwoTensor > * > _viscous_strains_old
virtual void initQpStatefulProperties() override
const Number zero
void declareViscoelasticProperties()
Declare all necessary MaterialProperties for the model.
static InputParameters validParams()
std::vector< const MaterialProperty< Real > * > _dashpot_viscosities_old
bool _has_longterm_dashpot
Indicates if the spring-dashpot assembly has a single dashpot not associated with a spring...
void mooseWarning(Args &&... args) const
bool _force_recompute_properties
If activated, the time-stepping scheme will be re-initialized at each step of the solver...
void suppressParameter(const std::string &name)
bool _need_viscoelastic_properties_inverse
If active, indicates that we need to call computeQpViscoelasticPropertiesInv()
theta automatically adjusted as a function of the time step and the viscosity
MaterialProperty< RankFourTensor > & _apparent_elasticity_tensor
Apparent elasticity tensor. This is NOT the elasticity tensor of the material.
std::vector< MaterialProperty< Real > * > _dashpot_viscosities
List of viscosities of each subsequent dashpot in the chain.
IntegrationRule
Determines how theta is calculated for the time-integration system.
MaterialProperty< RankFourTensor > & _first_elasticity_tensor
Elasticity tensor of a stand-alone elastic spring in the chain.
MaterialProperty< RankFourTensor > * _first_elasticity_tensor_inv
std::vector< const MaterialProperty< RankFourTensor > * > _springs_elasticity_tensors_inv_old
std::string stringify(const T &t)
Real _theta
User-defined value for theta.
virtual void computeQpApparentElasticityTensors()=0
This method computes the apparent elasticity tensor used in the internal time-stepping scheme...
virtual void computeQpViscoelasticProperties()=0
This method assigns the mechanical properties of each spring and dashpot in the system.
unsigned int _components
This is the number of internal variables required by the model.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void computeQpElasticityTensor() final
Inherited from ComputeElasticityTensorBase.
MaterialProperty< RankTwoTensor > & _apparent_creep_strain
The apparent creep strain resulting from the internal viscous strains.
virtual void computeQpApparentCreepStrain()=0
This method computes the apparent creep strain corresponding to the current viscous_strain of each da...
MaterialProperty< RankFourTensor > & _elasticity_tensor_inv
Instantaneous elasticity tensor. This IS the real elasticity tensor of the material.
void mooseError(Args &&... args) const
IntegrationRule _integration_rule
Determines how theta is computed.
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
std::vector< MaterialProperty< RankTwoTensor > * > _viscous_strains
virtual void computeQpViscoelasticPropertiesInv()
This method computes the inverse elasticity tensor of each spring in the system (if required)...
Real computeTheta(Real dt, Real viscosity) const
Provides theta as a function of the time step and a viscosity.
virtual void updateQpViscousStrains()=0
Update the internal viscous strains at a quadrature point.
MaterialProperty< RankFourTensor > & _apparent_elasticity_tensor_inv
Inverse of the apparent elasticity tensor.
const std::string _base_name
Base name of the material system.