Line data Source code
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 "CrackTipEnrichmentStressDivergenceTensors.h"
11 : #include "ElasticityTensorTools.h"
12 :
13 : registerMooseObject("XFEMApp", CrackTipEnrichmentStressDivergenceTensors);
14 :
15 : InputParameters
16 192 : CrackTipEnrichmentStressDivergenceTensors::validParams()
17 : {
18 192 : InputParameters params = ALEKernel::validParams();
19 192 : params.addClassDescription("Enrich stress divergence kernel for small-strain simulations");
20 384 : params.addRequiredParam<unsigned int>("component",
21 : "An integer corresponding to the direction the variable "
22 : "this kernel acts in. (0 for x, 1 for y, 2 for z)");
23 384 : params.addRequiredParam<unsigned int>("enrichment_component",
24 : "The component of the enrichement functions");
25 384 : params.addRequiredCoupledVar("displacements",
26 : "The string of displacements suitable for the problem statement");
27 384 : params.addRequiredCoupledVar(
28 : "enrichment_displacements",
29 : "The string of enrichment displacements suitable for the problem statement");
30 384 : params.addParam<std::string>("base_name", "Material property base name");
31 384 : params.addRequiredParam<UserObjectName>("crack_front_definition",
32 : "The CrackFrontDefinition user object name");
33 192 : params.set<bool>("use_displaced_mesh") = false;
34 192 : return params;
35 0 : }
36 :
37 96 : CrackTipEnrichmentStressDivergenceTensors::CrackTipEnrichmentStressDivergenceTensors(
38 96 : const InputParameters & parameters)
39 : : ALEKernel(parameters),
40 96 : EnrichmentFunctionCalculation(&getUserObject<CrackFrontDefinition>("crack_front_definition")),
41 96 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
42 192 : _stress(getMaterialPropertyByName<RankTwoTensor>(_base_name + "stress")),
43 192 : _Jacobian_mult(getMaterialPropertyByName<RankFourTensor>(_base_name + "Jacobian_mult")),
44 192 : _component(getParam<unsigned int>("component")),
45 192 : _enrichment_component(getParam<unsigned int>("enrichment_component")),
46 96 : _nenrich_disp(coupledComponents("enrichment_displacements")),
47 96 : _ndisp(coupledComponents("displacements")),
48 96 : _B(4),
49 96 : _dBX(4),
50 96 : _dBx(4),
51 96 : _BI(4),
52 384 : _BJ(4)
53 : {
54 96 : _enrich_disp_var.resize(_nenrich_disp);
55 864 : for (unsigned int i = 0; i < _nenrich_disp; ++i)
56 768 : _enrich_disp_var[i] = coupled("enrichment_displacements", i);
57 :
58 96 : _disp_var.resize(_ndisp);
59 288 : for (unsigned int i = 0; i < _ndisp; ++i)
60 192 : _disp_var[i] = coupled("displacements", i);
61 96 : }
62 :
63 : Real
64 1016320 : CrackTipEnrichmentStressDivergenceTensors::computeQpResidual()
65 : {
66 1016320 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_i), _BI);
67 :
68 1016320 : crackTipEnrichementFunctionAtPoint(_q_point[_qp], _B);
69 : unsigned int crack_front_point_index =
70 1016320 : crackTipEnrichementFunctionDerivativeAtPoint(_q_point[_qp], _dBx);
71 :
72 5081600 : for (unsigned int i = 0; i < 4; ++i)
73 4065280 : rotateFromCrackFrontCoordsToGlobal(_dBx[i], _dBX[i], crack_front_point_index);
74 :
75 1016320 : RealVectorValue grad_B(_dBX[_enrichment_component]);
76 :
77 1016320 : return _stress[_qp].row(_component) *
78 1016320 : (_grad_test[_i][_qp] * (_B[_enrichment_component] - _BI[_enrichment_component]) +
79 1016320 : _test[_i][_qp] * grad_B);
80 : }
81 :
82 : Real
83 1496064 : CrackTipEnrichmentStressDivergenceTensors::computeQpJacobian()
84 : {
85 1496064 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_i), _BI);
86 1496064 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_j), _BJ);
87 :
88 1496064 : crackTipEnrichementFunctionAtPoint(_q_point[_qp], _B);
89 :
90 : unsigned int crack_front_point_index =
91 1496064 : crackTipEnrichementFunctionDerivativeAtPoint(_q_point[_qp], _dBx);
92 :
93 7480320 : for (unsigned int i = 0; i < 4; ++i)
94 5984256 : rotateFromCrackFrontCoordsToGlobal(_dBx[i], _dBX[i], crack_front_point_index);
95 :
96 1496064 : RealVectorValue grad_B(_dBX[_enrichment_component]);
97 :
98 : RealVectorValue grad_test =
99 1496064 : _grad_test[_i][_qp] * (_B[_enrichment_component] - _BI[_enrichment_component]) +
100 1496064 : _test[_i][_qp] * grad_B;
101 : RealVectorValue grad_phi =
102 1496064 : _grad_phi[_j][_qp] * (_B[_enrichment_component] - _BJ[_enrichment_component]) +
103 1496064 : _phi[_j][_qp] * grad_B;
104 :
105 1496064 : return ElasticityTensorTools::elasticJacobian(
106 1496064 : _Jacobian_mult[_qp], _component, _component, grad_test, grad_phi);
107 : }
108 :
109 : Real
110 13188096 : CrackTipEnrichmentStressDivergenceTensors::computeQpOffDiagJacobian(unsigned int jvar)
111 : {
112 : unsigned int coupled_component = 0;
113 : unsigned int coupled_enrichment_component = 0;
114 : bool active(false);
115 : bool active_enrich(false);
116 :
117 118692864 : for (unsigned int i = 0; i < _enrich_disp_var.size(); ++i)
118 : {
119 105504768 : if (jvar == _enrich_disp_var[i])
120 : {
121 10257408 : coupled_component = i / 4;
122 10257408 : coupled_enrichment_component = i % 4;
123 : active_enrich = true;
124 : }
125 : }
126 :
127 39564288 : for (unsigned int i = 0; i < _disp_var.size(); ++i)
128 : {
129 26376192 : if (jvar == _disp_var[i])
130 : {
131 : coupled_component = i;
132 : active = true;
133 : }
134 : }
135 :
136 13188096 : if (active_enrich)
137 : {
138 10257408 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_i), _BI);
139 10257408 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_j), _BJ);
140 :
141 10257408 : crackTipEnrichementFunctionAtPoint(_q_point[_qp], _B);
142 : unsigned int crack_front_point_index =
143 10257408 : crackTipEnrichementFunctionDerivativeAtPoint(_q_point[_qp], _dBx);
144 :
145 51287040 : for (unsigned int i = 0; i < 4; ++i)
146 41029632 : rotateFromCrackFrontCoordsToGlobal(_dBx[i], _dBX[i], crack_front_point_index);
147 :
148 10257408 : RealVectorValue grad_B_test(_dBX[_enrichment_component]);
149 10257408 : RealVectorValue grad_B_phi(_dBX[coupled_enrichment_component]);
150 :
151 : RealVectorValue grad_test =
152 10257408 : _grad_test[_i][_qp] * (_B[_enrichment_component] - _BI[_enrichment_component]) +
153 10257408 : _test[_i][_qp] * grad_B_test;
154 10257408 : RealVectorValue grad_phi = _grad_phi[_j][_qp] * (_B[coupled_enrichment_component] -
155 : _BJ[coupled_enrichment_component]) +
156 10257408 : _phi[_j][_qp] * grad_B_phi;
157 :
158 10257408 : return ElasticityTensorTools::elasticJacobian(
159 10257408 : _Jacobian_mult[_qp], _component, coupled_component, grad_test, grad_phi);
160 : }
161 2930688 : else if (active)
162 : {
163 2930688 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_i), _BI);
164 :
165 2930688 : crackTipEnrichementFunctionAtPoint(_q_point[_qp], _B);
166 : unsigned int crack_front_point_index =
167 2930688 : crackTipEnrichementFunctionDerivativeAtPoint(_q_point[_qp], _dBx);
168 :
169 14653440 : for (unsigned int i = 0; i < 4; ++i)
170 11722752 : rotateFromCrackFrontCoordsToGlobal(_dBx[i], _dBX[i], crack_front_point_index);
171 :
172 2930688 : RealVectorValue grad_B_test(_dBX[_enrichment_component]);
173 :
174 : RealVectorValue grad_test =
175 2930688 : _grad_test[_i][_qp] * (_B[_enrichment_component] - _BI[_enrichment_component]) +
176 2930688 : _test[_i][_qp] * grad_B_test;
177 :
178 2930688 : return ElasticityTensorTools::elasticJacobian(
179 2930688 : _Jacobian_mult[_qp], _component, coupled_component, grad_test, _grad_phi[_j][_qp]);
180 : }
181 :
182 : return 0;
183 : }
|