https://mooseframework.inl.gov
ADComputeStressBase.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 "ADComputeStressBase.h"
11 #include "RankTwoTensor.h"
12 #include "SymmetricRankTwoTensor.h"
13 
14 template <typename R2>
17 {
19  params.addParam<std::string>("base_name",
20  "Optional parameter that allows the user to define "
21  "multiple mechanics material systems on the same "
22  "block, i.e. for multiple phases");
23  params.suppressParameter<bool>("use_displaced_mesh");
24  params.addParam<std::vector<MaterialPropertyName>>(
25  "extra_stress_names",
26  std::vector<MaterialPropertyName>(),
27  "Material property names of rank two tensors to be added to the stress.");
28  return params;
29 }
30 
31 template <typename R2>
33  : Material(parameters),
34  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
35  _mechanical_strain(getADMaterialProperty<R2>(_base_name + "mechanical_strain")),
36  _stress(declareADProperty<R2>(_base_name + "stress")),
37  _elastic_strain(declareADProperty<R2>(_base_name + "elastic_strain")),
38  _extra_stresses(getParam<std::vector<MaterialPropertyName>>("extra_stress_names").size())
39 {
40  if (getParam<bool>("use_displaced_mesh"))
41  mooseError("The stress calculator needs to run on the undisplaced mesh.");
42 
43  const std::vector<MaterialPropertyName> extra_stress_names =
44  getParam<std::vector<MaterialPropertyName>>("extra_stress_names");
45  for (MooseIndex(_extra_stresses) i = 0; i < _extra_stresses.size(); ++i)
46  _extra_stresses[i] = &getMaterialProperty<R2>(extra_stress_names[i]);
47 }
48 
49 template <typename R2>
50 void
52 {
53  _elastic_strain[_qp].zero();
54  _stress[_qp].zero();
55 }
56 
57 template <typename R2>
58 void
60 {
61  computeQpStress();
62 
63  // Add in extra stress
64  for (MooseIndex(_extra_stresses) i = 0; i < _extra_stresses.size(); ++i)
65  _stress[_qp] += (*_extra_stresses[i])[_qp];
66 }
67 
virtual void initQpStatefulProperties() override
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual void computeQpProperties() override
void suppressParameter(const std::string &name)
static InputParameters validParams()
static InputParameters validParams()
void mooseError(Args &&... args) const
ADComputeStressBaseTempl is the base class for stress tensors.
ADComputeStressBaseTempl(const InputParameters &parameters)
std::vector< const MaterialProperty< R2 > * > _extra_stresses
Extra stress tensors.