https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ADComputeStrainBase.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 "ADComputeStrainBase.h"
11#include "RankTwoTensor.h"
13#include "MooseMesh.h"
14#include "Assembly.h"
15
16template <typename R2>
19{
22 "displacements",
23 "The displacements appropriate for the simulation geometry and coordinate system");
24 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 params.addParam<bool>(
29 "volumetric_locking_correction", false, "Flag to correct volumetric locking");
30 params.addParam<std::vector<MaterialPropertyName>>(
31 "eigenstrain_names", {}, "List of eigenstrains to be applied in this strain calculation");
32 params.addParam<MaterialPropertyName>("global_strain",
33 "Optional material property holding a global strain "
34 "tensor applied to the mesh as a whole");
35 params.suppressParameter<bool>("use_displaced_mesh");
36 return params;
37}
38
39template <typename R2>
41 : Material(parameters),
42 _ndisp(coupledComponents("displacements")),
43 _disp(adCoupledValues("displacements")),
44 _grad_disp(adCoupledGradients("displacements")),
45 _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
46 _mechanical_strain(declareADProperty<R2>(_base_name + "mechanical_strain")),
47 _total_strain(declareADProperty<R2>(_base_name + "total_strain")),
48 _eigenstrain_names(getParam<std::vector<MaterialPropertyName>>("eigenstrain_names")),
49 _eigenstrains(_eigenstrain_names.size()),
50 _global_strain(isParamValid("global_strain")
51 ? &getADMaterialProperty<R2>(_base_name + "global_strain")
52 : nullptr),
53 _volumetric_locking_correction(getParam<bool>("volumetric_locking_correction") &&
54 !this->isBoundaryMaterial()),
55 _current_elem_volume(_assembly.elemVolume())
56{
57 // set unused dimensions to zero
58 for (unsigned i = _ndisp; i < 3; ++i)
59 {
60 _disp.push_back(&_ad_zero);
61 _grad_disp.push_back(&_ad_grad_zero);
62 }
63
64 for (unsigned int i = 0; i < _eigenstrains.size(); ++i)
65 {
67 _eigenstrains[i] = &getADMaterialProperty<R2>(_eigenstrain_names[i]);
68 }
69
71 paramError("volumetric_locking_correction", "has to be set to false for 1-D problems.");
72
73 if (getParam<bool>("use_displaced_mesh"))
74 paramError("use_displaced_mesh", "The strain calculator needs to run on the undisplaced mesh.");
75}
76
77template <typename R2>
78void
80{
81 displacementIntegrityCheck();
82}
83
84template <typename R2>
85void
87{
88 // Checking for consistency between mesh size and length of the provided displacements vector
89 if (_ndisp != _mesh.dimension())
90 paramError(
91 "displacements",
92 "The number of variables supplied in 'displacements' must match the mesh dimension.");
93}
94
95template <typename R2>
96void
98{
99 _mechanical_strain[_qp].zero();
100 _total_strain[_qp].zero();
101}
102
ADComputeStrainBase is the base class for strain tensors.
std::vector< const ADVariableValue * > _disp
Displacement variables.
std::vector< const ADVariableGradient * > _grad_disp
Gradient of displacements.
virtual void displacementIntegrityCheck()
std::vector< const ADMaterialProperty< R2 > * > _eigenstrains
const std::string _base_name
Base name of the material system.
ADComputeStrainBaseTempl(const InputParameters &parameters)
const unsigned int _ndisp
Coupled displacement variables.
std::vector< MaterialPropertyName > _eigenstrain_names
virtual void initQpStatefulProperties() override
static InputParameters validParams()
const MooseArray< ADRealVectorValue > & _ad_grad_zero
const MooseArray< ADReal > & _ad_zero
void suppressParameter(const std::string &name)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static InputParameters validParams()
void paramError(const std::string &param, Args... args) const