https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CZMInterfaceKernelBase.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
14{
16 params.addRequiredParam<unsigned int>("component",
17 "the component of the "
18 "displacement vector this kernel is working on:"
19 " component == 0, ==> X"
20 " component == 1, ==> Y"
21 " component == 2, ==> Z");
22 params.suppressParameter<bool>("use_displaced_mesh");
23 params.addRequiredCoupledVar("displacements", "the string containing displacement variables");
24 params.addParam<std::string>("base_name", "Material property base name");
25 params.set<std::string>("traction_global_name") = "traction_global";
26
27 return params;
28}
29
32 _base_name(isParamValid("base_name") && !getParam<std::string>("base_name").empty()
33 ? getParam<std::string>("base_name") + "_"
34 : ""),
35 _component(getParam<unsigned int>("component")),
36 _ndisp(coupledComponents("displacements")),
37 _disp_var(_ndisp),
38 _disp_neighbor_var(_ndisp),
39 _vars(_ndisp),
40 _traction_global(getMaterialPropertyByName<RealVectorValue>(
41 _base_name + getParam<std::string>("traction_global_name"))),
42 _dtraction_djump_global(
43 getMaterialPropertyByName<RankTwoTensor>(_base_name + "dtraction_djump_global"))
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 for (unsigned int i = 0; i < _ndisp; ++i)
53 {
54 _disp_var[i] = coupled("displacements", i);
55 _disp_neighbor_var[i] = coupled("displacements", i);
56 _vars[i] = getVar("displacements", i);
57 }
58}
59
60Real
62{
63 Real r = _traction_global[_qp](_component);
64
65 switch (type)
66 {
67 // [test_secondary-test_primary]*T where T represents the traction.
68 case Moose::Element:
69 r *= -_test[_i][_qp];
70 break;
71 case Moose::Neighbor:
72 r *= _test_neighbor[_i][_qp];
73 break;
74 }
75 return r;
76}
77
78Real
80{
81 // retrieve the diagonal Jacobian coefficient dependning on the displacement
82 // component (_component) this kernel is working on
84}
85
86Real
88{
89 // bail out if jvar is not coupled
90 if (getJvarMap()[jvar] < 0)
91 return 0.0;
92
93 // Jacobian of the residul[_component] w.r.t to the coupled displacement
94 // component[off_diag_component]
95 for (unsigned int off_diag_component = 0; off_diag_component < _ndisp; ++off_diag_component)
96 {
97 if (jvar == _disp_var[off_diag_component])
98 return computeDResidualDDisplacement(off_diag_component, type);
99 }
100 // this is the place where one should implement derivatives of the residual w.r.t. other variables
101 return 0.0;
102}
void mooseError(Args &&... args)
void ErrorVector unsigned int
std::vector< MooseVariable * > _vars
const unsigned int _component
the displacement component this kernel is operating on (0=x, 1=y, 2 =z)
std::vector< unsigned int > _disp_var
Coupled displacement component variable IDs.
const MaterialProperty< RealVectorValue > & _traction_global
Real computeQpOffDiagJacobian(Moose::DGJacobianType type, unsigned int jvar) override
static InputParameters validParams()
Real computeQpResidual(Moose::DGResidualType type) override
std::vector< unsigned int > _disp_neighbor_var
virtual Real computeDResidualDDisplacement(const unsigned int &component_j, const Moose::DGJacobianType &type) const =0
method computing the derivative of residual[_component] w.r.t displacement[component_j]
CZMInterfaceKernelBase(const InputParameters &parameters)
const unsigned int _ndisp
number of displacement components
Real computeQpJacobian(Moose::DGJacobianType type) override
void suppressParameter(const std::string &name)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(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)
T & set(const std::string &name, bool quiet_mode=false)
static InputParameters validParams()
DGResidualType
DGJacobianType