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