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 64 : CrackTipEnrichmentStressDivergenceTensors::validParams()
17 : {
18 64 : InputParameters params = ALEKernel::validParams();
19 64 : params.addClassDescription("Enrich stress divergence kernel for small-strain simulations");
20 128 : 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 128 : params.addRequiredParam<unsigned int>("enrichment_component",
24 : "The component of the enrichement functions");
25 128 : params.addRequiredCoupledVar("displacements",
26 : "The string of displacements suitable for the problem statement");
27 128 : params.addRequiredCoupledVar(
28 : "enrichment_displacements",
29 : "The string of enrichment displacements suitable for the problem statement");
30 128 : params.addParam<std::string>("base_name", "Material property base name");
31 128 : params.addRequiredParam<UserObjectName>("crack_front_definition",
32 : "The CrackFrontDefinition user object name");
33 64 : params.set<bool>("use_displaced_mesh") = false;
34 64 : return params;
35 0 : }
36 :
37 32 : CrackTipEnrichmentStressDivergenceTensors::CrackTipEnrichmentStressDivergenceTensors(
38 32 : const InputParameters & parameters)
39 : : ALEKernel(parameters),
40 32 : EnrichmentFunctionCalculation(&getUserObject<CrackFrontDefinition>("crack_front_definition")),
41 32 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
42 64 : _stress(getMaterialPropertyByName<RankTwoTensor>(_base_name + "stress")),
43 64 : _Jacobian_mult(getMaterialPropertyByName<RankFourTensor>(_base_name + "Jacobian_mult")),
44 64 : _component(getParam<unsigned int>("component")),
45 64 : _enrichment_component(getParam<unsigned int>("enrichment_component")),
46 32 : _nenrich_disp(coupledComponents("enrichment_displacements")),
47 32 : _ndisp(coupledComponents("displacements")),
48 32 : _B(4),
49 32 : _dBX(4),
50 32 : _dBx(4),
51 32 : _BI(4),
52 128 : _BJ(4)
53 : {
54 32 : _enrich_disp_var.resize(_nenrich_disp);
55 288 : for (unsigned int i = 0; i < _nenrich_disp; ++i)
56 256 : _enrich_disp_var[i] = coupled("enrichment_displacements", i);
57 :
58 32 : _disp_var.resize(_ndisp);
59 96 : for (unsigned int i = 0; i < _ndisp; ++i)
60 64 : _disp_var[i] = coupled("displacements", i);
61 32 : }
62 :
63 : Real
64 673792 : CrackTipEnrichmentStressDivergenceTensors::computeQpResidual()
65 : {
66 673792 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_i), _BI);
67 :
68 673792 : crackTipEnrichementFunctionAtPoint(_q_point[_qp], _B);
69 : unsigned int crack_front_point_index =
70 673792 : crackTipEnrichementFunctionDerivativeAtPoint(_q_point[_qp], _dBx);
71 :
72 3368960 : for (unsigned int i = 0; i < 4; ++i)
73 2695168 : rotateFromCrackFrontCoordsToGlobal(_dBx[i], _dBX[i], crack_front_point_index);
74 :
75 673792 : RealVectorValue grad_B(_dBX[_enrichment_component]);
76 :
77 673792 : return _stress[_qp].row(_component) *
78 673792 : (_grad_test[_i][_qp] * (_B[_enrichment_component] - _BI[_enrichment_component]) +
79 673792 : _test[_i][_qp] * grad_B);
80 : }
81 :
82 : Real
83 288768 : CrackTipEnrichmentStressDivergenceTensors::computeQpJacobian()
84 : {
85 288768 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_i), _BI);
86 288768 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_j), _BJ);
87 :
88 288768 : crackTipEnrichementFunctionAtPoint(_q_point[_qp], _B);
89 :
90 : unsigned int crack_front_point_index =
91 288768 : crackTipEnrichementFunctionDerivativeAtPoint(_q_point[_qp], _dBx);
92 :
93 1443840 : for (unsigned int i = 0; i < 4; ++i)
94 1155072 : rotateFromCrackFrontCoordsToGlobal(_dBx[i], _dBX[i], crack_front_point_index);
95 :
96 288768 : RealVectorValue grad_B(_dBX[_enrichment_component]);
97 :
98 : RealVectorValue grad_test =
99 288768 : _grad_test[_i][_qp] * (_B[_enrichment_component] - _BI[_enrichment_component]) +
100 288768 : _test[_i][_qp] * grad_B;
101 : RealVectorValue grad_phi =
102 288768 : _grad_phi[_j][_qp] * (_B[_enrichment_component] - _BJ[_enrichment_component]) +
103 288768 : _phi[_j][_qp] * grad_B;
104 :
105 288768 : return ElasticityTensorTools::elasticJacobian(
106 288768 : _Jacobian_mult[_qp], _component, _component, grad_test, grad_phi);
107 : }
108 :
109 : Real
110 2598912 : 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 23390208 : for (unsigned int i = 0; i < _enrich_disp_var.size(); ++i)
118 : {
119 20791296 : if (jvar == _enrich_disp_var[i])
120 : {
121 2021376 : coupled_component = i / 4;
122 2021376 : coupled_enrichment_component = i % 4;
123 : active_enrich = true;
124 : }
125 : }
126 :
127 7796736 : for (unsigned int i = 0; i < _disp_var.size(); ++i)
128 : {
129 5197824 : if (jvar == _disp_var[i])
130 : {
131 : coupled_component = i;
132 : active = true;
133 : }
134 : }
135 :
136 2598912 : if (active_enrich)
137 : {
138 2021376 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_i), _BI);
139 2021376 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_j), _BJ);
140 :
141 2021376 : crackTipEnrichementFunctionAtPoint(_q_point[_qp], _B);
142 : unsigned int crack_front_point_index =
143 2021376 : crackTipEnrichementFunctionDerivativeAtPoint(_q_point[_qp], _dBx);
144 :
145 10106880 : for (unsigned int i = 0; i < 4; ++i)
146 8085504 : rotateFromCrackFrontCoordsToGlobal(_dBx[i], _dBX[i], crack_front_point_index);
147 :
148 2021376 : RealVectorValue grad_B_test(_dBX[_enrichment_component]);
149 2021376 : RealVectorValue grad_B_phi(_dBX[coupled_enrichment_component]);
150 :
151 : RealVectorValue grad_test =
152 2021376 : _grad_test[_i][_qp] * (_B[_enrichment_component] - _BI[_enrichment_component]) +
153 2021376 : _test[_i][_qp] * grad_B_test;
154 2021376 : RealVectorValue grad_phi = _grad_phi[_j][_qp] * (_B[coupled_enrichment_component] -
155 : _BJ[coupled_enrichment_component]) +
156 2021376 : _phi[_j][_qp] * grad_B_phi;
157 :
158 2021376 : return ElasticityTensorTools::elasticJacobian(
159 2021376 : _Jacobian_mult[_qp], _component, coupled_component, grad_test, grad_phi);
160 : }
161 577536 : else if (active)
162 : {
163 577536 : crackTipEnrichementFunctionAtPoint(*_current_elem->node_ptr(_i), _BI);
164 :
165 577536 : crackTipEnrichementFunctionAtPoint(_q_point[_qp], _B);
166 : unsigned int crack_front_point_index =
167 577536 : crackTipEnrichementFunctionDerivativeAtPoint(_q_point[_qp], _dBx);
168 :
169 2887680 : for (unsigned int i = 0; i < 4; ++i)
170 2310144 : rotateFromCrackFrontCoordsToGlobal(_dBx[i], _dBX[i], crack_front_point_index);
171 :
172 577536 : RealVectorValue grad_B_test(_dBX[_enrichment_component]);
173 :
174 : RealVectorValue grad_test =
175 577536 : _grad_test[_i][_qp] * (_B[_enrichment_component] - _BI[_enrichment_component]) +
176 577536 : _test[_i][_qp] * grad_B_test;
177 :
178 577536 : return ElasticityTensorTools::elasticJacobian(
179 577536 : _Jacobian_mult[_qp], _component, coupled_component, grad_test, _grad_phi[_j][_qp]);
180 : }
181 :
182 : return 0;
183 : }
|