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 "PenetrationInfo.h"
11 : #include "ArbitraryQuadrature.h"
12 : #include "LineSegment.h"
13 : #include "NearestNodeLocator.h"
14 : #include "MooseMesh.h"
15 : #include "SubProblem.h"
16 : #include "GeometricSearchData.h"
17 : #include "PenetrationThread.h"
18 : #include "Moose.h"
19 : #include "MooseMesh.h"
20 :
21 : #include "libmesh/elem.h"
22 :
23 : using namespace libMesh;
24 :
25 852786 : PenetrationInfo::PenetrationInfo(const Elem * elem,
26 : const Elem * side,
27 : unsigned int side_num,
28 : RealVectorValue norm,
29 : Real norm_distance,
30 : Real tangential_distance,
31 : const Point & closest_point,
32 : const Point & closest_point_ref,
33 : const Point & closest_point_on_face_ref,
34 : std::vector<const Node *> off_edge_nodes,
35 : const std::vector<std::vector<Real>> & side_phi,
36 : const std::vector<std::vector<RealGradient>> & side_grad_phi,
37 : const std::vector<RealGradient> & dxyzdxi,
38 : const std::vector<RealGradient> & dxyzdeta,
39 852786 : const std::vector<RealGradient> & d2xyzdxideta)
40 852786 : : _elem(elem),
41 852786 : _side(side),
42 852786 : _side_num(side_num),
43 852786 : _normal(norm),
44 852786 : _distance(norm_distance),
45 852786 : _tangential_distance(tangential_distance),
46 852786 : _closest_point(closest_point),
47 852786 : _closest_point_ref(closest_point_ref),
48 852786 : _closest_point_on_face_ref(closest_point_on_face_ref),
49 852786 : _off_edge_nodes(off_edge_nodes),
50 852786 : _side_phi(side_phi),
51 852786 : _side_grad_phi(side_grad_phi),
52 852786 : _dxyzdxi(dxyzdxi),
53 852786 : _dxyzdeta(dxyzdeta),
54 852786 : _d2xyzdxideta(d2xyzdxideta),
55 852786 : _starting_elem(NULL),
56 852786 : _starting_side_num(libMesh::invalid_uint),
57 852786 : _starting_closest_point_ref(0),
58 852786 : _incremental_slip(0),
59 852786 : _accumulated_slip(0.0),
60 852786 : _accumulated_slip_old(0.0),
61 852786 : _frictional_energy(0.0),
62 852786 : _frictional_energy_old(0.0),
63 852786 : _contact_force(0),
64 852786 : _contact_force_old(0),
65 852786 : _lagrange_multiplier(0),
66 852786 : _lagrange_multiplier_slip(0),
67 852786 : _locked_this_step(0),
68 852786 : _mech_status(MS_NO_CONTACT),
69 852786 : _mech_status_old(MS_NO_CONTACT),
70 852786 : _incremental_slip_prev_iter(0),
71 852786 : _slip_reversed(false),
72 852786 : _slip_tol(0)
73 : {
74 852786 : }
75 :
76 : /*
77 : PenetrationInfo::PenetrationInfo(const PenetrationInfo & p)
78 : : _elem(p._elem),
79 : _side(p._side), // Which one now owns _side? There will be trouble if (when)
80 : // both delete _side
81 : _side_num(p._side_num),
82 : _normal(p._normal),
83 : _distance(p._distance),
84 : _tangential_distance(p._tangential_distance),
85 : _closest_point(p._closest_point),
86 : _closest_point_ref(p._closest_point_ref),
87 : _closest_point_on_face_ref(p._closest_point_on_face_ref),
88 : _off_edge_nodes(p._off_edge_nodes),
89 : _side_phi(p._side_phi),
90 : _side_grad_phi(p._side_grad_phi),
91 : _dxyzdxi(p._dxyzdxi),
92 : _dxyzdeta(p._dxyzdeta),
93 : _d2xyzdxideta(p._d2xyzdxideta),
94 : _starting_elem(p._starting_elem),
95 : _starting_side_num(p._starting_side_num),
96 : _starting_closest_point_ref(p._starting_closest_point_ref),
97 : _incremental_slip(p._incremental_slip),
98 : _accumulated_slip(p._accumulated_slip),
99 : _accumulated_slip_old(p._accumulated_slip_old),
100 : _frictional_energy(p._frictional_energy),
101 : _frictional_energy_old(p._frictional_energy_old),
102 : _contact_force(p._contact_force),
103 : _contact_force_old(p._contact_force_old),
104 : _lagrange_multiplier(p._lagrange_multiplier),
105 : _lagrange_multiplier_slip(p._lagrange_multiplier_slip),
106 :
107 : _locked_this_step(p._locked_this_step),
108 : _mech_status(p._mech_status),
109 : _mech_status_old(p._mech_status_old),
110 : _incremental_slip_prev_iter(p._incremental_slip_prev_iter),
111 : _slip_reversed(p._slip_reversed),
112 : _slip_tol(p._slip_tol)
113 : {
114 : }
115 : */
116 :
117 1124 : PenetrationInfo::PenetrationInfo()
118 1124 : : _elem(NULL),
119 1124 : _side(NULL),
120 1124 : _side_num(0),
121 1124 : _normal(0),
122 1124 : _distance(0),
123 1124 : _tangential_distance(0),
124 1124 : _closest_point(0),
125 1124 : _closest_point_ref(0),
126 1124 : _closest_point_on_face_ref(0),
127 1124 : _off_edge_nodes(0),
128 1124 : _side_phi(0),
129 1124 : _side_grad_phi(0),
130 1124 : _dxyzdxi(0),
131 1124 : _dxyzdeta(0),
132 1124 : _d2xyzdxideta(0),
133 1124 : _starting_elem(NULL),
134 1124 : _starting_side_num(libMesh::invalid_uint),
135 1124 : _starting_closest_point_ref(0),
136 1124 : _incremental_slip(0),
137 1124 : _accumulated_slip(0.0),
138 1124 : _accumulated_slip_old(0.0),
139 1124 : _frictional_energy(0.0),
140 1124 : _frictional_energy_old(0.0),
141 1124 : _contact_force(0),
142 1124 : _contact_force_old(0),
143 1124 : _lagrange_multiplier(0),
144 1124 : _lagrange_multiplier_slip(0),
145 1124 : _locked_this_step(0),
146 1124 : _mech_status(MS_NO_CONTACT),
147 1124 : _mech_status_old(MS_NO_CONTACT),
148 1124 : _incremental_slip_prev_iter(0),
149 1124 : _slip_reversed(false),
150 1124 : _slip_tol(0)
151 : {
152 1124 : }
153 :
154 853890 : PenetrationInfo::~PenetrationInfo() { delete _side; }
155 :
156 : template <>
157 : void
158 16518 : dataStore(std::ostream & stream, PenetrationInfo *& pinfo, void * context)
159 : {
160 16518 : if (!context)
161 0 : mooseError("Can only store PenetrationInfo objects using a MooseMesh context!");
162 :
163 16518 : if (pinfo)
164 : {
165 : // Store 1 so that we know that this pinfo really exists!
166 9731 : unsigned int i = 1;
167 9731 : storeHelper(stream, i, context);
168 :
169 9731 : storeHelper(stream, pinfo->_elem, context);
170 : // Not storing the side element as we will need to recreate it on load
171 9731 : storeHelper(stream, pinfo->_side_num, context);
172 9731 : storeHelper(stream, pinfo->_normal, context);
173 9731 : storeHelper(stream, pinfo->_distance, context);
174 9731 : storeHelper(stream, pinfo->_tangential_distance, context);
175 9731 : storeHelper(stream, pinfo->_closest_point, context);
176 9731 : storeHelper(stream, pinfo->_closest_point_ref, context);
177 9731 : storeHelper(stream, pinfo->_closest_point_on_face_ref, context);
178 9731 : storeHelper(stream, pinfo->_off_edge_nodes, context);
179 9731 : storeHelper(stream, pinfo->_side_phi, context);
180 9731 : storeHelper(stream, pinfo->_side_grad_phi, context);
181 9731 : storeHelper(stream, pinfo->_dxyzdxi, context);
182 9731 : storeHelper(stream, pinfo->_dxyzdeta, context);
183 9731 : storeHelper(stream, pinfo->_d2xyzdxideta, context);
184 9731 : storeHelper(stream, pinfo->_starting_elem, context);
185 9731 : storeHelper(stream, pinfo->_starting_side_num, context);
186 9731 : storeHelper(stream, pinfo->_starting_closest_point_ref, context);
187 9731 : storeHelper(stream, pinfo->_incremental_slip, context);
188 9731 : storeHelper(stream, pinfo->_accumulated_slip, context);
189 9731 : storeHelper(stream, pinfo->_frictional_energy, context);
190 9731 : storeHelper(stream, pinfo->_contact_force, context);
191 9731 : storeHelper(stream, pinfo->_lagrange_multiplier, context);
192 9731 : storeHelper(stream, pinfo->_lagrange_multiplier_slip, context);
193 9731 : storeHelper(stream, pinfo->_mech_status, context);
194 9731 : storeHelper(stream, pinfo->_mech_status_old, context);
195 :
196 : // Don't need frictional_energy_old, accumulated_slip_old, contact_force_old, or
197 : // locked_this_step
198 : // because they are always set by the constraints at the beginning of a new time step.
199 : }
200 : else
201 : {
202 : // Store 0 so that we know that this pinfo is NULL
203 6787 : unsigned int i = 0;
204 6787 : storeHelper(stream, i, context);
205 : }
206 16518 : }
207 :
208 : template <>
209 : void
210 1657 : dataLoad(std::istream & stream, PenetrationInfo *& pinfo, void * context)
211 : {
212 1657 : if (!context)
213 0 : mooseError("Can only load PenetrationInfo objects using a MooseMesh context!");
214 :
215 : // First, see if this is supposed to be NULL
216 1657 : unsigned int i = 0;
217 1657 : loadHelper(stream, i, context);
218 1657 : if (i)
219 : {
220 1124 : pinfo = new PenetrationInfo();
221 :
222 1124 : loadHelper(stream, pinfo->_elem, context);
223 1124 : loadHelper(stream, pinfo->_side_num, context);
224 : // Rebuild the side element.
225 1124 : pinfo->_side = pinfo->_elem->build_side_ptr(pinfo->_side_num).release();
226 :
227 1124 : loadHelper(stream, pinfo->_normal, context);
228 1124 : loadHelper(stream, pinfo->_distance, context);
229 1124 : loadHelper(stream, pinfo->_tangential_distance, context);
230 1124 : loadHelper(stream, pinfo->_closest_point, context);
231 1124 : loadHelper(stream, pinfo->_closest_point_ref, context);
232 1124 : loadHelper(stream, pinfo->_closest_point_on_face_ref, context);
233 1124 : loadHelper(stream, pinfo->_off_edge_nodes, context);
234 1124 : loadHelper(stream, pinfo->_side_phi, context);
235 1124 : loadHelper(stream, pinfo->_side_grad_phi, context);
236 1124 : loadHelper(stream, pinfo->_dxyzdxi, context);
237 1124 : loadHelper(stream, pinfo->_dxyzdeta, context);
238 1124 : loadHelper(stream, pinfo->_d2xyzdxideta, context);
239 1124 : loadHelper(stream, pinfo->_starting_elem, context);
240 1124 : loadHelper(stream, pinfo->_starting_side_num, context);
241 1124 : loadHelper(stream, pinfo->_starting_closest_point_ref, context);
242 1124 : loadHelper(stream, pinfo->_incremental_slip, context);
243 1124 : loadHelper(stream, pinfo->_accumulated_slip, context);
244 1124 : loadHelper(stream, pinfo->_frictional_energy, context);
245 1124 : loadHelper(stream, pinfo->_contact_force, context);
246 1124 : loadHelper(stream, pinfo->_lagrange_multiplier, context);
247 1124 : loadHelper(stream, pinfo->_lagrange_multiplier_slip, context);
248 1124 : loadHelper(stream, pinfo->_mech_status, context);
249 1124 : loadHelper(stream, pinfo->_mech_status_old, context);
250 :
251 : // Don't need frictional_energy_old, accumulated_slip_old, contact_force_old, or
252 : // locked_this_step
253 : // because they are always set by the constraints at the beginning of a new time step.
254 : }
255 : else
256 533 : pinfo = NULL;
257 1657 : }
|