https://mooseframework.inl.gov
CZMComputeDisplacementJumpBase.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 
11 #include "CohesiveZoneModelTools.h"
12 
13 template <bool is_ad>
16 {
18  params.addClassDescription("Base class used to compute the displacement jump across a czm "
19  "interface in local coordinates");
20  params.addRequiredCoupledVar("displacements",
21  "The string of displacements suitable for the problem statement");
22  params.suppressParameter<bool>("use_displaced_mesh");
23  params.addParam<std::string>("base_name", "Material property base name");
24 
25  return params;
26 }
27 
28 template <bool is_ad>
30  const InputParameters & parameters)
31  : InterfaceMaterial(parameters),
32  _base_name(isParamValid("base_name") && !getParam<std::string>("base_name").empty()
33  ? getParam<std::string>("base_name") + "_"
34  : ""),
35  _ndisp(coupledComponents("displacements")),
36  _disp(3),
37  _disp_neighbor(3),
38  _displacement_jump_global(declareGenericPropertyByName<RealVectorValue, is_ad>(
39  _base_name + "displacement_jump_global")),
40  _interface_displacement_jump(declareGenericPropertyByName<RealVectorValue, is_ad>(
41  _base_name + "interface_displacement_jump")),
42  _czm_total_rotation(
43  declareGenericPropertyByName<RankTwoTensor, is_ad>(_base_name + "czm_total_rotation"))
44 {
45  // Enforce consistency
46  if (_ndisp != _mesh.dimension())
47  paramError("displacements", "Number of displacements must match problem dimension.");
48 
49  if (_ndisp > 3 || _ndisp < 1)
50  mooseError("the CZM material requires 1, 2 or 3 displacement variables");
51 
52  // initializing the displacement vectors
53  for (unsigned int i = 0; i < _ndisp; ++i)
54  {
55  _disp[i] = &coupledGenericValue<is_ad>("displacements", i);
56  _disp_neighbor[i] = &coupledGenericNeighborValue<is_ad>("displacements", i);
57  }
58 
59  // All others zero (so this will work naturally for 2D and 1D problems)
60  for (unsigned int i = _ndisp; i < 3; i++)
61  {
62  if constexpr (is_ad)
63  {
64  _disp[i] = &_ad_zero;
66  }
67  else
68  {
69  _disp[i] = &_zero;
70  _disp_neighbor[i] = &_zero;
71  }
72  }
73 }
74 
75 template <bool is_ad>
76 void
78 {
79  // requried to promote _interface_displacement_jump to stateful in case someone needs it
80  _interface_displacement_jump[_qp] = 0;
81 }
82 
83 template <bool is_ad>
84 void
86 {
87 
88  // computing the displacement jump
89  for (unsigned int i = 0; i < _ndisp; i++)
90  _displacement_jump_global[_qp](i) = (*_disp_neighbor[i])[_qp] - (*_disp[i])[_qp];
91  for (unsigned int i = _ndisp; i < 3; i++)
92  _displacement_jump_global[_qp](i) = 0;
93 
94  computeRotationMatrices();
95  computeLocalDisplacementJump();
96 }
97 
98 template <bool is_ad>
99 void
101 {
102  _czm_total_rotation[_qp] =
103  CohesiveZoneModelTools::computeReferenceRotation<is_ad>(_normals[_qp], _mesh.dimension());
104 }
105 
const VariableValue & _zero
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static InputParameters validParams()
void suppressParameter(const std::string &name)
virtual void computeRotationMatrices()
method computing the required rotation matrices
MooseMesh & _mesh
virtual unsigned int dimension() const
const unsigned int _ndisp
number of displacement components
void paramError(const std::string &param, Args... args) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
std::vector< const GenericVariableValue< is_ad > * > _disp
the coupled displacement and neighbor displacement values
std::vector< const GenericVariableValue< is_ad > * > _disp_neighbor
CZMComputeDisplacementJumpBase(const InputParameters &parameters)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
This interface material class computes the displacement jump in the interface natural coordinate syst...
const MooseArray< ADReal > & _ad_zero