https://mooseframework.inl.gov
PenetrationInfo.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 
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 
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  const std::vector<RealGradient> & d2xyzdxideta)
40  : _elem(elem),
41  _side(side),
42  _side_num(side_num),
43  _normal(norm),
44  _distance(norm_distance),
45  _tangential_distance(tangential_distance),
46  _closest_point(closest_point),
47  _closest_point_ref(closest_point_ref),
48  _closest_point_on_face_ref(closest_point_on_face_ref),
49  _off_edge_nodes(off_edge_nodes),
50  _side_phi(side_phi),
51  _side_grad_phi(side_grad_phi),
52  _dxyzdxi(dxyzdxi),
53  _dxyzdeta(dxyzdeta),
54  _d2xyzdxideta(d2xyzdxideta),
55  _starting_elem(NULL),
56  _starting_side_num(libMesh::invalid_uint),
57  _starting_closest_point_ref(0),
58  _incremental_slip(0),
59  _accumulated_slip(0.0),
60  _accumulated_slip_old(0.0),
61  _frictional_energy(0.0),
62  _frictional_energy_old(0.0),
63  _contact_force(0),
64  _contact_force_old(0),
65  _lagrange_multiplier(0),
66  _lagrange_multiplier_slip(0),
67  _locked_this_step(0),
68  _mech_status(MS_NO_CONTACT),
69  _mech_status_old(MS_NO_CONTACT),
70  _incremental_slip_prev_iter(0),
71  _slip_reversed(false),
72  _slip_tol(0)
73 {
74 }
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 
118  : _elem(NULL),
119  _side(NULL),
120  _side_num(0),
121  _normal(0),
122  _distance(0),
123  _tangential_distance(0),
124  _closest_point(0),
125  _closest_point_ref(0),
126  _closest_point_on_face_ref(0),
127  _off_edge_nodes(0),
128  _side_phi(0),
129  _side_grad_phi(0),
130  _dxyzdxi(0),
131  _dxyzdeta(0),
132  _d2xyzdxideta(0),
133  _starting_elem(NULL),
134  _starting_side_num(libMesh::invalid_uint),
135  _starting_closest_point_ref(0),
136  _incremental_slip(0),
137  _accumulated_slip(0.0),
138  _accumulated_slip_old(0.0),
139  _frictional_energy(0.0),
140  _frictional_energy_old(0.0),
141  _contact_force(0),
142  _contact_force_old(0),
143  _lagrange_multiplier(0),
144  _lagrange_multiplier_slip(0),
145  _locked_this_step(0),
146  _mech_status(MS_NO_CONTACT),
147  _mech_status_old(MS_NO_CONTACT),
148  _incremental_slip_prev_iter(0),
149  _slip_reversed(false),
150  _slip_tol(0)
151 {
152 }
153 
155 
156 template <>
157 void
158 dataStore(std::ostream & stream, PenetrationInfo *& pinfo, void * context)
159 {
160  if (!context)
161  mooseError("Can only store PenetrationInfo objects using a MooseMesh context!");
162 
163  if (pinfo)
164  {
165  // Store 1 so that we know that this pinfo really exists!
166  unsigned int i = 1;
167  storeHelper(stream, i, context);
168 
169  storeHelper(stream, pinfo->_elem, context);
170  // Not storing the side element as we will need to recreate it on load
171  storeHelper(stream, pinfo->_side_num, context);
172  storeHelper(stream, pinfo->_normal, context);
173  storeHelper(stream, pinfo->_distance, context);
174  storeHelper(stream, pinfo->_tangential_distance, context);
175  storeHelper(stream, pinfo->_closest_point, context);
176  storeHelper(stream, pinfo->_closest_point_ref, context);
177  storeHelper(stream, pinfo->_closest_point_on_face_ref, context);
178  storeHelper(stream, pinfo->_off_edge_nodes, context);
179  storeHelper(stream, pinfo->_side_phi, context);
180  storeHelper(stream, pinfo->_side_grad_phi, context);
181  storeHelper(stream, pinfo->_dxyzdxi, context);
182  storeHelper(stream, pinfo->_dxyzdeta, context);
183  storeHelper(stream, pinfo->_d2xyzdxideta, context);
184  storeHelper(stream, pinfo->_starting_elem, context);
185  storeHelper(stream, pinfo->_starting_side_num, context);
186  storeHelper(stream, pinfo->_starting_closest_point_ref, context);
187  storeHelper(stream, pinfo->_incremental_slip, context);
188  storeHelper(stream, pinfo->_accumulated_slip, context);
189  storeHelper(stream, pinfo->_frictional_energy, context);
190  storeHelper(stream, pinfo->_contact_force, context);
191  storeHelper(stream, pinfo->_lagrange_multiplier, context);
192  storeHelper(stream, pinfo->_lagrange_multiplier_slip, context);
193  storeHelper(stream, pinfo->_mech_status, context);
194  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  unsigned int i = 0;
204  storeHelper(stream, i, context);
205  }
206 }
207 
208 template <>
209 void
210 dataLoad(std::istream & stream, PenetrationInfo *& pinfo, void * context)
211 {
212  if (!context)
213  mooseError("Can only load PenetrationInfo objects using a MooseMesh context!");
214 
215  // First, see if this is supposed to be NULL
216  unsigned int i = 0;
217  loadHelper(stream, i, context);
218  if (i)
219  {
220  pinfo = new PenetrationInfo();
221 
222  loadHelper(stream, pinfo->_elem, context);
223  loadHelper(stream, pinfo->_side_num, context);
224  // Rebuild the side element.
225  pinfo->_side = pinfo->_elem->build_side_ptr(pinfo->_side_num).release();
226 
227  loadHelper(stream, pinfo->_normal, context);
228  loadHelper(stream, pinfo->_distance, context);
229  loadHelper(stream, pinfo->_tangential_distance, context);
230  loadHelper(stream, pinfo->_closest_point, context);
231  loadHelper(stream, pinfo->_closest_point_ref, context);
232  loadHelper(stream, pinfo->_closest_point_on_face_ref, context);
233  loadHelper(stream, pinfo->_off_edge_nodes, context);
234  loadHelper(stream, pinfo->_side_phi, context);
235  loadHelper(stream, pinfo->_side_grad_phi, context);
236  loadHelper(stream, pinfo->_dxyzdxi, context);
237  loadHelper(stream, pinfo->_dxyzdeta, context);
238  loadHelper(stream, pinfo->_d2xyzdxideta, context);
239  loadHelper(stream, pinfo->_starting_elem, context);
240  loadHelper(stream, pinfo->_starting_side_num, context);
241  loadHelper(stream, pinfo->_starting_closest_point_ref, context);
242  loadHelper(stream, pinfo->_incremental_slip, context);
243  loadHelper(stream, pinfo->_accumulated_slip, context);
244  loadHelper(stream, pinfo->_frictional_energy, context);
245  loadHelper(stream, pinfo->_contact_force, context);
246  loadHelper(stream, pinfo->_lagrange_multiplier, context);
247  loadHelper(stream, pinfo->_lagrange_multiplier_slip, context);
248  loadHelper(stream, pinfo->_mech_status, context);
249  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  pinfo = NULL;
257 }
std::vector< RealGradient > _d2xyzdxideta
const unsigned int invalid_uint
RealVectorValue _normal
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i)=0
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
Data structure used to hold penetration information.
void dataStore(std::ostream &stream, PenetrationInfo *&pinfo, void *context)
const Elem * _starting_elem
Point _closest_point_on_face_ref
std::vector< std::vector< RealGradient > > _side_grad_phi
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
std::vector< std::vector< Real > > _side_phi
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:893
const Elem * _elem
unsigned int _starting_side_num
unsigned int _side_num
std::vector< RealGradient > _dxyzdxi
const Elem * _side
auto norm(const T &a) -> decltype(std::abs(a))
RealVectorValue _contact_force
MECH_STATUS_ENUM _mech_status
std::vector< const Node * > _off_edge_nodes
Point _starting_closest_point_ref
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< RealGradient > _dxyzdeta
void dataLoad(std::istream &stream, PenetrationInfo *&pinfo, void *context)
MECH_STATUS_ENUM _mech_status_old
RealVectorValue _lagrange_multiplier_slip
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:985