20 #include "libmesh/threads.h" 31 closest_point_to_edge(
const Point & src,
const Point & p0,
const Point & p1)
33 const Point line01 = p1 - p0;
34 const Real line0c_xi = ((src - p0) * line01) / line01.
norm_sq();
42 return p0 + line0c_xi * line01;
46 closest_point_to_side(
const Point & src,
const Elem & side)
54 "Penetration of elements with curved sides not implemented");
55 return closest_point_to_edge(src, side.
point(0), side.
point(1));
60 "Penetration of elements with curved sides not implemented");
62 const Point l01 = p1 - p0, l02 = p2 - p0;
63 const Point tri_normal = (l01.
cross(l02)).unit();
64 const Point linecs = ((src - p0) * tri_normal) / tri_normal.
norm_sq() * tri_normal;
65 const Point in_plane = src - linecs;
66 const Point planar_offset = in_plane - p0;
69 if (planar_offset.
cross(l01) * tri_normal > 0)
70 return closest_point_to_edge(src, p0, p1);
73 if (planar_offset.
cross(l02) * tri_normal < 0)
74 return closest_point_to_edge(src, p0, p2);
77 if ((in_plane - p1).cross(p2 - p1) * tri_normal > 0)
78 return closest_point_to_edge(src, p1, p2);
103 std::map<dof_id_type, PenetrationInfo *> & penetration_info,
104 bool check_whether_reasonable,
105 bool update_location,
106 Real tangential_tolerance,
107 bool do_normal_smoothing,
108 Real normal_smoothing_distance,
110 bool use_point_locator,
111 std::vector<std::vector<FEBase *>> & fes,
114 const std::unordered_map<
dof_id_type, std::vector<dof_id_type>> & node_to_elem_map)
115 : _subproblem(subproblem),
117 _primary_boundary(primary_boundary),
118 _secondary_boundary(secondary_boundary),
119 _penetration_info(penetration_info),
120 _check_whether_reasonable(check_whether_reasonable),
121 _update_location(update_location),
122 _tangential_tolerance(tangential_tolerance),
123 _do_normal_smoothing(do_normal_smoothing),
124 _normal_smoothing_distance(normal_smoothing_distance),
125 _normal_smoothing_method(normal_smoothing_method),
126 _use_point_locator(use_point_locator),
127 _nodal_normal_x(NULL),
128 _nodal_normal_y(NULL),
129 _nodal_normal_z(NULL),
132 _nearest_node(nearest_node),
133 _node_to_elem_map(node_to_elem_map)
139 : _subproblem(x._subproblem),
141 _primary_boundary(x._primary_boundary),
142 _secondary_boundary(x._secondary_boundary),
143 _penetration_info(x._penetration_info),
144 _check_whether_reasonable(x._check_whether_reasonable),
145 _update_location(x._update_location),
146 _tangential_tolerance(x._tangential_tolerance),
147 _do_normal_smoothing(x._do_normal_smoothing),
148 _normal_smoothing_distance(x._normal_smoothing_distance),
149 _normal_smoothing_method(x._normal_smoothing_method),
150 _use_point_locator(x._use_point_locator),
152 _fe_type(x._fe_type),
153 _nearest_node(x._nearest_node),
154 _node_to_elem_map(x._node_to_elem_map)
174 std::unique_ptr<PointLocatorBase> point_locator;
178 for (
const auto & node_id : range)
189 std::vector<PenetrationInfo *> p_info;
190 bool info_set(
false);
200 const Point contact_ref =
info->_closest_point_ref;
201 bool contact_point_on_side(
false);
205 std::vector<Point> points(1);
206 points[0] = contact_ref;
207 const std::vector<Point> & secondary_pos = fe_side->
get_xyz();
208 bool search_succeeded =
false;
217 contact_point_on_side,
221 info->_closest_point_ref = contact_ref;
224 info->_distance = 0.0;
229 Real old_tangential_distance(
info->_tangential_distance);
230 bool contact_point_on_side(
false);
231 bool search_succeeded =
false;
240 contact_point_on_side,
243 if (contact_point_on_side)
245 if (
info->_tangential_distance <= 0.0)
249 else if (
info->_tangential_distance > 0.0 && old_tangential_distance > 0.0)
251 if (
info->_side->dim() == 2 &&
info->_off_edge_nodes.size() < 2)
268 std::vector<dof_id_type> located_elem_ids;
269 const std::vector<dof_id_type> * closest_elems;
273 std::set<const Elem *> candidate_elements;
274 (*point_locator)(*closest_node, candidate_elements);
276 if (candidate_elements.empty())
277 mooseError(
"No proximate elements found at node ",
280 static_cast<const Point &
>(*closest_node),
283 ". This should never happen.");
285 for (
const Elem * elem : candidate_elements)
287 for (
auto s : elem->side_index_range())
290 located_elem_ids.push_back(elem->id());
295 if (located_elem_ids.empty())
296 mooseError(
"No proximate elements found at node ",
299 static_cast<const Point &
>(*closest_node),
302 " share that boundary. This may happen if the mesh uses the same boundary id " 303 "for a nodeset and an unrelated sideset.");
305 closest_elems = &located_elem_ids;
311 "Missing entry in node to elem map");
312 closest_elems = &(node_to_elem_pair->second);
315 for (
const auto & elem_id : *closest_elems)
319 std::vector<PenetrationInfo *> thisElemInfo;
321 std::vector<const Node *> nodesThatMustBeOnSide;
332 nodesThatMustBeOnSide.push_back(closest_node);
344 for (
unsigned int i = 0; i < p_info.size(); ++i)
346 const Point closest_point = closest_point_to_side(node, *p_info[i]->_side);
347 const Real distance_sq = (closest_point - node).
norm_sq();
348 if (distance_sq < min_distance_sq)
350 min_distance_sq = distance_sq;
351 best_point = closest_point;
356 p_info[best_i]->_closest_point = best_point;
357 p_info[best_i]->_distance =
358 (p_info[best_i]->_distance >= 0.0 ? 1.0 : -1.0) *
std::sqrt(min_distance_sq);
360 mooseError(
"Normal smoothing not implemented with point locator code");
361 Point normal = (best_point - node).unit();
362 const Real dot = normal * p_info[best_i]->_normal;
365 p_info[best_i]->_normal = normal;
372 if (p_info.size() == 1)
380 else if (p_info.size() > 1)
383 std::vector<RidgeData> ridgeDataVec;
384 for (
unsigned int i = 0; i + 1 < p_info.size(); ++i)
385 for (
unsigned int j = i + 1; j < p_info.size(); ++j)
388 Real tangential_distance(0.0);
389 const Node * closest_node_on_ridge = NULL;
390 unsigned int index = 0;
391 Point closest_coor_ref;
394 closest_node_on_ridge,
400 if (found_ridge_contact_point)
408 ridgeDataVec.push_back(rpd);
412 if (ridgeDataVec.size() > 0)
416 std::vector<RidgeSetData> ridgeSetDataVec;
417 for (
unsigned int i = 0; i < ridgeDataVec.size(); ++i)
419 bool foundSetWithMatchingNode =
false;
420 for (
unsigned int j = 0; j < ridgeSetDataVec.size(); ++j)
422 if (ridgeDataVec[i]._closest_node != NULL &&
423 ridgeDataVec[i]._closest_node == ridgeSetDataVec[j]._closest_node)
425 foundSetWithMatchingNode =
true;
426 ridgeSetDataVec[j]._ridge_data_vec.push_back(ridgeDataVec[i]);
430 if (!foundSetWithMatchingNode)
436 ridgeSetDataVec.push_back(rsd);
440 for (
unsigned int i = 0; i < ridgeSetDataVec.size(); ++i)
442 if (ridgeSetDataVec[i]._closest_node !=
445 if (ridgeSetDataVec[i]._ridge_data_vec.size() == 1)
447 if (ridgeSetDataVec[i]._ridge_data_vec[0]._tangential_distance <=
450 ridgeSetDataVec[i]._closest_coor =
451 ridgeSetDataVec[i]._ridge_data_vec[0]._closest_coor;
452 Point contact_point_vec = node - ridgeSetDataVec[i]._closest_coor;
453 ridgeSetDataVec[i]._distance = contact_point_vec.
norm();
459 ridgeSetDataVec[i]._closest_coor = *ridgeSetDataVec[i]._closest_node;
460 Point contact_point_vec = node - ridgeSetDataVec[i]._closest_coor;
461 ridgeSetDataVec[i]._distance = contact_point_vec.
norm();
466 ridgeSetDataVec[i]._closest_coor =
467 ridgeSetDataVec[i]._ridge_data_vec[0]._closest_coor;
468 Point contact_point_vec = node - ridgeSetDataVec[i]._closest_coor;
469 ridgeSetDataVec[i]._distance = contact_point_vec.
norm();
473 unsigned int closest_ridge_set_index(0);
474 Real closest_distance(ridgeSetDataVec[0]._distance);
475 Point closest_point(ridgeSetDataVec[0]._closest_coor);
476 for (
unsigned int i = 1; i < ridgeSetDataVec.size(); ++i)
478 if (ridgeSetDataVec[i]._distance < closest_distance)
480 closest_ridge_set_index = i;
481 closest_distance = ridgeSetDataVec[i]._distance;
482 closest_point = ridgeSetDataVec[i]._closest_coor;
486 if (closest_distance <
497 for (
unsigned int i = 0;
498 i < ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec.size();
501 if (ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec[i]._index < face_index)
502 face_index = ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec[i]._index;
506 "face_index invalid");
508 p_info[face_index]->_closest_point = closest_point;
509 p_info[face_index]->_distance =
510 (p_info[face_index]->_distance >= 0.0 ? 1.0 : -1.0) * closest_distance;
516 Point normal(closest_point - node);
522 const Real dot(normal * p_info[face_index]->_normal);
525 p_info[face_index]->_normal = normal;
527 p_info[face_index]->_tangential_distance = 0.0;
529 Point closest_point_ref;
530 if (ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec.size() ==
533 p_info[face_index]->_tangential_distance = ridgeSetDataVec[closest_ridge_set_index]
535 ._tangential_distance;
536 p_info[face_index]->_closest_point_ref =
537 ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec[0]._closest_coor_ref;
541 const Node * closest_node_on_face;
543 closest_node_on_face,
544 p_info[face_index]->_side);
547 if (closest_node_on_face !=
548 ridgeSetDataVec[closest_ridge_set_index]._closest_node)
550 mooseError(
"Closest node when restricting point to face != closest node from " 557 std::vector<Point> points(1);
558 points[0] = p_info[face_index]->_closest_point_ref;
559 fe->
reinit(p_info[face_index]->_side, &points);
560 p_info[face_index]->_side_phi = fe->
get_phi();
561 p_info[face_index]->_side_grad_phi = fe->
get_dphi();
577 unsigned int best(0), i(1);
595 }
while (i < p_info.size() && best < p_info.size());
596 if (best < p_info.size())
629 for (
unsigned int j = 0; j < p_info.size(); ++j)
651 mooseAssert(infoNew != NULL,
"infoNew object is null");
778 const std::vector<const Node *> & off_edge_nodes1 = pi1->
_off_edge_nodes;
779 const std::vector<const Node *> & off_edge_nodes2 = pi2->
_off_edge_nodes;
780 const unsigned dim1 = pi1->
_side->
dim();
784 mooseAssert(pi2->
_side->
dim() == 1,
"Incompatible dimensions.");
785 mooseAssert(off_edge_nodes1.size() < 2 && off_edge_nodes2.size() < 2,
786 "off_edge_nodes size should be <2 for 2D contact");
787 if (off_edge_nodes1.size() == 1 && off_edge_nodes2.size() == 1 &&
788 off_edge_nodes1[0] == off_edge_nodes2[0])
793 mooseAssert(dim1 == 2 && pi2->
_side->
dim() == 2,
"Incompatible dimensions.");
794 mooseAssert(off_edge_nodes1.size() < 3 && off_edge_nodes2.size() < 3,
795 "off_edge_nodes size should be <3 for 3D contact");
796 if (off_edge_nodes1.size() == 1)
798 if (off_edge_nodes2.size() == 1)
800 if (off_edge_nodes1[0] == off_edge_nodes2[0])
803 else if (off_edge_nodes2.size() == 2)
805 if (off_edge_nodes1[0] == off_edge_nodes2[0] || off_edge_nodes1[0] == off_edge_nodes2[1])
809 else if (off_edge_nodes1.size() == 2)
811 if (off_edge_nodes2.size() == 1)
813 if (off_edge_nodes1[0] == off_edge_nodes2[0] || off_edge_nodes1[1] == off_edge_nodes2[0])
816 else if (off_edge_nodes2.size() == 2)
818 if ((off_edge_nodes1[0] == off_edge_nodes2[0] &&
819 off_edge_nodes1[1] == off_edge_nodes2[1]) ||
820 (off_edge_nodes1[1] == off_edge_nodes2[0] && off_edge_nodes1[0] == off_edge_nodes2[1]))
830 Real & tangential_distance,
831 const Node *& closest_node,
832 unsigned int & index,
833 Point & contact_point_ref,
834 std::vector<PenetrationInfo *> & p_info,
835 const unsigned int index1,
836 const unsigned int index2)
838 tangential_distance = 0.0;
842 const unsigned sidedim(pi1->
_side->
dim());
843 mooseAssert(sidedim == pi2->
_side->
dim(),
"Incompatible dimensionalities");
846 std::vector<const Node *> side1_nodes;
848 std::vector<const Node *> side2_nodes;
851 std::sort(side1_nodes.begin(), side1_nodes.end());
852 std::sort(side2_nodes.begin(), side2_nodes.end());
855 std::vector<const Node *> common_nodes;
856 std::set_intersection(side1_nodes.begin(),
860 std::inserter(common_nodes, common_nodes.end()));
862 if (common_nodes.size() != sidedim)
865 bool found_point1, found_point2;
867 const Node * closest_node1;
869 closest_coor_ref1, closest_node1, pi1->
_side, common_nodes);
872 const Node * closest_node2;
874 closest_coor_ref2, closest_node2, pi2->
_side, common_nodes);
876 if (!found_point1 || !found_point2)
889 std::vector<Point> points(1);
902 contact_point_ref = closest_coor_ref1;
903 points[0] = closest_coor_ref1;
910 contact_point_ref = closest_coor_ref2;
911 points[0] = closest_coor_ref2;
916 contact_point = fe->
get_xyz()[0];
922 mooseAssert((closest_node1 == closest_node2 || closest_node2 == NULL),
923 "If off edge of ridge, closest node must be the same on both elements");
924 closest_node = closest_node1;
927 tangential_distance = off_face.
norm();
938 corner_nodes.clear();
940 corner_nodes.push_back(side->
node_ptr(0));
941 corner_nodes.push_back(side->
node_ptr(1));
955 corner_nodes.push_back(side->
node_ptr(2));
963 corner_nodes.push_back(side->
node_ptr(2));
964 corner_nodes.push_back(side->
node_ptr(3));
978 const Node *& closest_node,
980 const std::vector<const Node *> & edge_nodes)
987 std::vector<unsigned int> local_node_indices;
988 for (
const auto & edge_node : edge_nodes)
993 local_node_indices.push_back(local_index);
995 mooseAssert(local_node_indices.size() == side->
dim(),
996 "Number of edge nodes must match side dimensionality");
997 std::sort(local_node_indices.begin(), local_node_indices.end());
999 bool off_of_this_edge =
false;
1007 if (local_node_indices[0] == 0)
1012 off_of_this_edge =
true;
1016 else if (local_node_indices[0] == 1)
1021 off_of_this_edge =
true;
1036 if ((local_node_indices[0] == 0) && (local_node_indices[1] == 1))
1041 off_of_this_edge =
true;
1048 else if ((local_node_indices[0] == 1) && (local_node_indices[1] == 2))
1050 if ((xi + eta) > 1.0)
1052 Real delta = (xi + eta - 1.0) / 2.0;
1055 off_of_this_edge =
true;
1062 else if ((local_node_indices[0] == 0) && (local_node_indices[1] == 2))
1067 off_of_this_edge =
true;
1086 if ((local_node_indices[0] == 0) && (local_node_indices[1] == 1))
1091 off_of_this_edge =
true;
1098 else if ((local_node_indices[0] == 1) && (local_node_indices[1] == 2))
1103 off_of_this_edge =
true;
1110 else if ((local_node_indices[0] == 2) && (local_node_indices[1] == 3))
1115 off_of_this_edge =
true;
1122 else if ((local_node_indices[0] == 0) && (local_node_indices[1] == 3))
1127 off_of_this_edge =
true;
1147 return off_of_this_edge;
1156 closest_node = NULL;
1158 bool off_of_this_face(
false);
1169 off_of_this_face =
true;
1175 off_of_this_face =
true;
1188 off_of_this_face =
true;
1202 else if ((xi + eta) > 1.0)
1204 Real delta = (xi + eta - 1.0) / 2.0;
1207 off_of_this_face =
true;
1230 off_of_this_face =
true;
1254 off_of_this_face =
true;
1271 off_of_this_face =
true;
1288 off_of_this_face =
true;
1305 off_of_this_face =
true;
1328 return off_of_this_face;
1335 const Point * secondary_point,
1336 const Real tangential_tolerance)
1338 unsigned int dim = primary_elem->
dim();
1340 const std::vector<Point> & phys_point = fe->
get_xyz();
1342 const std::vector<RealGradient> & dxyz_dxi = fe->
get_dxyzdxi();
1343 const std::vector<RealGradient> & dxyz_deta = fe->
get_dxyzdeta();
1347 std::vector<Point> points(1);
1349 fe->
reinit(side, &points);
1353 const Real twosqrt2 = 2.8284;
1354 Real max_face_length = side->
hmax() + twosqrt2 * tangential_tolerance;
1359 normal = dxyz_dxi[0].
cross(dxyz_deta[0]);
1361 else if (
dim - 1 == 1)
1363 const Node *
const * elem_nodes = primary_elem->
get_nodes();
1364 const Point in_plane_vector1 = *elem_nodes[1] - *elem_nodes[0];
1365 const Point in_plane_vector2 = *elem_nodes[2] - *elem_nodes[0];
1367 Point out_of_plane_normal = in_plane_vector1.
cross(in_plane_vector2);
1368 out_of_plane_normal /= out_of_plane_normal.
norm();
1370 normal = dxyz_dxi[0].
cross(out_of_plane_normal);
1376 normal /= normal.
norm();
1378 const Real dot(d * normal);
1383 const Real tangdist = tangcomp.
norm();
1387 const Real faceExpansionFactor = 2.0 * (1.0 + normcomp.norm() / d.
norm());
1389 bool isReasonableCandidate =
true;
1390 if (tangdist > faceExpansionFactor * max_face_length)
1392 isReasonableCandidate =
false;
1394 return isReasonableCandidate;
1402 std::vector<Point> points(1);
1403 points[0] =
info._starting_closest_point_ref;
1405 fe.
reinit(&side, &points);
1406 const std::vector<Point> & starting_point = fe.
get_xyz();
1407 info._incremental_slip =
info._closest_point - starting_point[0];
1408 if (
info.isCaptured())
1410 info._frictional_energy =
1411 info._frictional_energy_old +
info._contact_force *
info._incremental_slip;
1412 info._accumulated_slip =
info._accumulated_slip_old +
info._incremental_slip.norm();
1418 std::vector<PenetrationInfo *> & p_info,
1427 std::vector<Real> edge_face_weights;
1428 std::vector<PenetrationInfo *> edge_face_info;
1432 mooseAssert(edge_face_info.size() == edge_face_weights.size(),
1433 "edge_face_info.size() != edge_face_weights.size()");
1435 if (edge_face_info.size() > 0)
1439 Real this_face_weight = 1.0;
1441 for (
unsigned int efwi = 0; efwi < edge_face_weights.size(); ++efwi)
1445 new_normal += npi->
_normal * edge_face_weights[efwi];
1447 this_face_weight -= edge_face_weights[efwi];
1449 mooseAssert(this_face_weight >= (0.25 - 1e-8),
1450 "Sum of weights of other faces shouldn't exceed 0.75");
1451 new_normal +=
info->_normal * this_face_weight;
1453 const Real len = new_normal.
norm();
1457 info->_normal = new_normal;
1467 const Real len(
info->_normal.norm());
1469 info->_normal /= len;
1476 std::vector<PenetrationInfo *> & edge_face_info,
1477 std::vector<Real> & edge_face_weights,
1478 std::vector<PenetrationInfo *> & p_info,
1479 const Node & secondary_node)
1482 const Point & p =
info->_closest_point_ref;
1483 std::set<dof_id_type> elems_to_exclude;
1484 elems_to_exclude.insert(
info->_elem->id());
1486 std::vector<std::vector<const Node *>> edge_nodes;
1490 std::vector<Elem *> edge_neighbor_elems;
1491 edge_face_info.resize(edge_nodes.size(), NULL);
1493 std::vector<unsigned int> edges_without_neighbors;
1495 for (
unsigned int i = 0; i < edge_nodes.size(); ++i)
1498 std::sort(edge_nodes[i].begin(), edge_nodes[i].end());
1500 std::vector<PenetrationInfo *> face_info_comm_edge;
1502 &secondary_node, elems_to_exclude, edge_nodes[i], face_info_comm_edge, p_info);
1504 if (face_info_comm_edge.size() == 0)
1505 edges_without_neighbors.push_back(i);
1506 else if (face_info_comm_edge.size() > 1)
1507 mooseError(
"Only one neighbor allowed per edge");
1509 edge_face_info[i] = face_info_comm_edge[0];
1513 std::vector<unsigned int>::reverse_iterator rit;
1514 for (rit = edges_without_neighbors.rbegin(); rit != edges_without_neighbors.rend(); ++rit)
1516 unsigned int index = *rit;
1517 edge_nodes.erase(edge_nodes.begin() + index);
1518 edge_face_weights.erase(edge_face_weights.begin() + index);
1519 edge_face_info.erase(edge_face_info.begin() + index);
1523 if (edge_nodes.size() > 1)
1525 if (edge_nodes.size() != 2)
1526 mooseError(
"Invalid number of smoothing edges");
1529 std::vector<const Node *> common_nodes;
1530 std::set_intersection(edge_nodes[0].begin(),
1531 edge_nodes[0].end(),
1532 edge_nodes[1].begin(),
1533 edge_nodes[1].end(),
1534 std::inserter(common_nodes, common_nodes.end()));
1536 if (common_nodes.size() != 1)
1537 mooseError(
"Invalid number of common nodes");
1539 for (
const auto & pinfo : edge_face_info)
1540 elems_to_exclude.insert(pinfo->_elem->id());
1542 std::vector<PenetrationInfo *> face_info_comm_edge;
1544 &secondary_node, elems_to_exclude, common_nodes, face_info_comm_edge, p_info);
1546 unsigned int num_corner_neighbors = face_info_comm_edge.size();
1548 if (num_corner_neighbors > 0)
1550 Real fw0 = edge_face_weights[0];
1551 Real fw1 = edge_face_weights[1];
1554 Real fw_corner = (fw0 * fw1) / static_cast<Real>(num_corner_neighbors);
1557 edge_face_weights[0] *= (1.0 - fw1);
1558 edge_face_weights[1] *= (1.0 - fw0);
1560 for (
unsigned int i = 0; i < num_corner_neighbors; ++i)
1562 edge_face_weights.push_back(fw_corner);
1563 edge_face_info.push_back(face_info_comm_edge[i]);
1573 std::vector<std::vector<const Node *>> & edge_nodes,
1574 std::vector<Real> & edge_face_weights)
1577 const Real & xi = p(0);
1578 const Real & eta = p(1);
1588 if (xi < -smooth_limit)
1590 std::vector<const Node *> en;
1592 edge_nodes.push_back(en);
1596 edge_face_weights.push_back(fw);
1598 else if (xi > smooth_limit)
1600 std::vector<const Node *> en;
1602 edge_nodes.push_back(en);
1606 edge_face_weights.push_back(fw);
1615 if (eta < -smooth_limit)
1617 std::vector<const Node *> en;
1620 edge_nodes.push_back(en);
1624 edge_face_weights.push_back(fw);
1626 if ((xi + eta) > smooth_limit)
1628 std::vector<const Node *> en;
1631 edge_nodes.push_back(en);
1635 edge_face_weights.push_back(fw);
1637 if (xi < -smooth_limit)
1639 std::vector<const Node *> en;
1642 edge_nodes.push_back(en);
1646 edge_face_weights.push_back(fw);
1655 if (eta < -smooth_limit)
1657 std::vector<const Node *> en;
1660 edge_nodes.push_back(en);
1664 edge_face_weights.push_back(fw);
1666 if (xi > smooth_limit)
1668 std::vector<const Node *> en;
1671 edge_nodes.push_back(en);
1675 edge_face_weights.push_back(fw);
1677 if (eta > smooth_limit)
1679 std::vector<const Node *> en;
1682 edge_nodes.push_back(en);
1686 edge_face_weights.push_back(fw);
1688 if (xi < -smooth_limit)
1690 std::vector<const Node *> en;
1693 edge_nodes.push_back(en);
1697 edge_face_weights.push_back(fw);
1712 const Node * secondary_node,
1713 const std::set<dof_id_type> & elems_to_exclude,
1714 const std::vector<const Node *> edge_nodes,
1715 std::vector<PenetrationInfo *> & face_info_comm_edge,
1716 std::vector<PenetrationInfo *> & p_info)
1722 mooseAssert(node_to_elem_pair !=
_node_to_elem_map.end(),
"Missing entry in node to elem map");
1723 const std::vector<dof_id_type> & elems_connected_to_node = node_to_elem_pair->second;
1725 std::vector<const Elem *> elems_connected_to_edge;
1727 for (
unsigned int ecni = 0; ecni < elems_connected_to_node.size(); ecni++)
1729 if (elems_to_exclude.find(elems_connected_to_node[ecni]) != elems_to_exclude.end())
1733 std::vector<const Node *> nodevec;
1734 for (
unsigned int ni = 0; ni < elem->
n_nodes(); ++ni)
1736 nodevec.push_back(elem->
node_ptr(ni));
1738 std::vector<const Node *> common_nodes;
1739 std::sort(nodevec.begin(), nodevec.end());
1740 std::set_intersection(edge_nodes.begin(),
1744 std::inserter(common_nodes, common_nodes.end()));
1746 if (common_nodes.size() == edge_nodes.size())
1747 elems_connected_to_edge.push_back(elem);
1750 if (elems_connected_to_edge.size() > 0)
1760 bool allowMultipleNeighbors =
false;
1762 if (elems_connected_to_edge[0]->
dim() == 3)
1764 if (edge_nodes.size() == 1)
1766 allowMultipleNeighbors =
true;
1770 for (
unsigned int i = 0; i < elems_connected_to_edge.size(); ++i)
1772 std::vector<PenetrationInfo *> thisElemInfo;
1773 getInfoForElem(thisElemInfo, p_info, elems_connected_to_edge[i]);
1774 if (thisElemInfo.size() > 0 && !allowMultipleNeighbors)
1776 if (thisElemInfo.size() > 1)
1778 "Found multiple neighbors to current edge/face on surface when only one is allowed");
1779 face_info_comm_edge.push_back(thisElemInfo[0]);
1784 thisElemInfo, p_info, secondary_node, elems_connected_to_edge[i], edge_nodes);
1785 if (thisElemInfo.size() > 0 && !allowMultipleNeighbors)
1787 if (thisElemInfo.size() > 1)
1789 "Found multiple neighbors to current edge/face on surface when only one is allowed");
1790 face_info_comm_edge.push_back(thisElemInfo[0]);
1794 for (
unsigned int j = 0; j < thisElemInfo.size(); ++j)
1795 face_info_comm_edge.push_back(thisElemInfo[j]);
1802 std::vector<PenetrationInfo *> & p_info,
1805 for (
const auto &
pi : p_info)
1810 if (
pi->_elem == elem)
1811 thisElemInfo.push_back(
pi);
1817 std::vector<PenetrationInfo *> & p_info,
1818 const Node * secondary_node,
1820 const std::vector<const Node *> & nodes_that_must_be_on_side,
1821 const bool check_whether_reasonable)
1831 bool already_have_info_this_side =
false;
1832 for (
const auto &
pi : thisElemInfo)
1833 if (
pi->_side_num == s)
1835 already_have_info_this_side =
true;
1839 if (already_have_info_this_side)
1846 std::vector<const Node *> nodevec;
1847 for (
unsigned int ni = 0; ni < side->
n_nodes(); ++ni)
1848 nodevec.push_back(side->
node_ptr(ni));
1850 std::sort(nodevec.begin(), nodevec.end());
1851 std::vector<const Node *> common_nodes;
1852 std::set_intersection(nodes_that_must_be_on_side.begin(),
1853 nodes_that_must_be_on_side.end(),
1856 std::inserter(common_nodes, common_nodes.end()));
1857 if (common_nodes.size() != nodes_that_must_be_on_side.size())
1868 if (check_whether_reasonable)
1877 Point contact_on_face_ref;
1879 Real tangential_distance = 0.;
1881 bool contact_point_on_side;
1882 std::vector<const Node *> off_edge_nodes;
1883 std::vector<std::vector<Real>> side_phi;
1884 std::vector<std::vector<RealGradient>> side_grad_phi;
1885 std::vector<RealGradient> dxyzdxi;
1886 std::vector<RealGradient> dxyzdeta;
1887 std::vector<RealGradient> d2xyzdxideta;
1889 std::unique_ptr<PenetrationInfo> pen_info =
1890 std::make_unique<PenetrationInfo>(elem,
1895 tangential_distance,
1898 contact_on_face_ref,
1906 bool search_succeeded =
false;
1914 contact_point_on_side,
1918 if (search_succeeded)
1920 thisElemInfo.push_back(pen_info.get());
1921 p_info.push_back(pen_info.release());
MooseVariable * _nodal_normal_z
void getSmoothingEdgeNodesAndWeights(const libMesh::Point &p, const Elem *side, std::vector< std::vector< const Node *>> &edge_nodes, std::vector< Real > &edge_face_weights)
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
const unsigned int invalid_uint
unsigned int get_node_index(const Node *node_ptr) const
Real _accumulated_slip_old
virtual_for_inffe const std::vector< RealGradient > & get_dxyzdeta() const
virtual Elem * elemPtr(const dof_id_type i)
bool findRidgeContactPoint(libMesh::Point &contact_point, Real &tangential_distance, const Node *&closest_node, unsigned int &index, libMesh::Point &contact_point_ref, std::vector< PenetrationInfo *> &p_info, const unsigned int index1, const unsigned int index2)
OutputType getValue(const Elem *elem, const std::vector< std::vector< OutputShape >> &phi) const
Compute the variable value at a point on an element.
IntRange< unsigned short > side_index_range() const
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...
Data structure used to hold penetration information.
NearestNodeLocator & _nearest_node
Finds the nearest node to each node in boundary1 to each node in boundary2 and the other way around...
virtual bool has_affine_map() const
Real _normal_smoothing_distance
const Elem * _starting_elem
bool _check_whether_reasonable
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
virtual_for_inffe const std::vector< RealGradient > & get_d2xyzdxideta() const
void createInfoForElem(std::vector< PenetrationInfo *> &thisElemInfo, std::vector< PenetrationInfo *> &p_info, const Node *secondary_node, const Elem *elem, const std::vector< const Node *> &nodes_that_must_be_on_side, const bool check_whether_reasonable=false)
unsigned int _stick_locked_this_step
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void getSideCornerNodes(const Elem *side, std::vector< const Node *> &corner_nodes)
Threads::spin_mutex pinfo_mutex
virtual Real hmax() const
const BoundaryInfo & get_boundary_info() const
RealVectorValue _contact_force_old
Real distance(const Point &p)
virtual const Node & nodeRef(const dof_id_type i) const
void smoothNormal(PenetrationInfo *info, std::vector< PenetrationInfo *> &p_info, const Node &node)
libMesh::FEType & _fe_type
void getInfoForFacesWithCommonNodes(const Node *secondary_node, const std::set< dof_id_type > &elems_to_exclude, const std::vector< const Node *> edge_nodes, std::vector< PenetrationInfo *> &face_info_comm_edge, std::vector< PenetrationInfo *> &p_info)
auto max(const L &left, const R &right)
void getSmoothingFacesAndWeights(PenetrationInfo *info, std::vector< PenetrationInfo *> &edge_face_info, std::vector< Real > &edge_face_weights, std::vector< PenetrationInfo *> &p_info, const Node &secondary_node)
unsigned int _locked_this_step
BoundaryID _primary_boundary
PenetrationThread(SubProblem &subproblem, const MooseMesh &mesh, BoundaryID primary_boundary, BoundaryID secondary_boundary, std::map< dof_id_type, PenetrationInfo *> &penetration_info, bool check_whether_reasonable, bool update_location, Real tangential_tolerance, bool do_normal_smoothing, Real normal_smoothing_distance, PenetrationLocator::NORMAL_SMOOTHING_METHOD normal_smoothing_method, bool use_point_locator, std::vector< std::vector< libMesh::FEBase *>> &fes, libMesh::FEType &fe_type, NearestNodeLocator &nearest_node, const std::unordered_map< dof_id_type, std::vector< dof_id_type >> &node_to_elem_map)
Real _tangential_distance
const std::vector< std::vector< OutputGradient > > & get_dphi() const
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
virtual unsigned int n_nodes() const=0
unsigned int _starting_side_num
boundary_id_type BoundaryID
CompeteInteractionResult competeInteractions(PenetrationInfo *pi1, PenetrationInfo *pi2)
When interactions are identified between a node and two faces, compete between the faces to determine...
void operator()(const NodeIdRange &range)
const Node * _closest_node
const Node *const * get_nodes() const
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
void computeSlip(libMesh::FEBase &fe, PenetrationInfo &info)
const Node * _closest_node
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)=0
void findContactPoint(PenetrationInfo &p_info, libMesh::FEBase *fe_elem, libMesh::FEBase *fe_side, libMesh::FEType &fe_side_type, const libMesh::Point &secondary_point, bool start_with_centroid, const Real tangential_tolerance, bool &contact_point_on_side, bool &search_succeeded)
Finds the closest point (called the contact point) on the primary_elem on side "side" to the secondar...
std::vector< dof_id_type > _recheck_secondary_nodes
List of secondary nodes for which penetration was not detected in the current patch and for which pat...
virtual MooseVariable & getStandardVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the variable reference for requested MooseVariable which may be in any system.
libMesh::Point _closest_coor
virtual_for_inffe const std::vector< Point > & get_xyz() const
bool restrictPointToSpecifiedEdgeOfFace(libMesh::Point &p, const Node *&closest_node, const Elem *side, const std::vector< const Node *> &edge_nodes)
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
RealVectorValue _contact_force
Real _frictional_energy_old
MECH_STATUS_ENUM _mech_status
void join(const PenetrationThread &other)
Real _tangential_tolerance
std::vector< const Node * > _off_edge_nodes
Point _starting_closest_point_ref
Real _tangential_distance
bool restrictPointToFace(libMesh::Point &p, const Node *&closest_node, const Elem *side)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Generic class for solving transient nonlinear problems.
Real _lagrange_multiplier
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
const Node * nearestNode(dof_id_type node_id)
Valid to call this after findNodes() has been called to get a pointer to the nearest node...
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
virtual unsigned short dim() const=0
MooseVariable * _nodal_normal_y
const Node * node_ptr(const unsigned int i) const
virtual bool is_vertex(const unsigned int i) const=0
libMesh::ElemSideBuilder _elem_side_builder
Helper for building element sides without extraneous allocation.
void getInfoForElem(std::vector< PenetrationInfo *> &thisElemInfo, std::vector< PenetrationInfo *> &p_info, const Elem *elem)
bool _do_normal_smoothing
MECH_STATUS_ENUM _mech_status_old
libMesh::Point _closest_coor_ref
virtual std::unique_ptr< libMesh::PointLocatorBase > getPointLocator() const
Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default)...
void switchInfo(PenetrationInfo *&info, PenetrationInfo *&infoNew)
virtual_for_inffe const std::vector< RealGradient > & get_dxyzdxi() const
RealVectorValue _lagrange_multiplier_slip
MooseVariable * _nodal_normal_x
const std::unordered_map< dof_id_type, std::vector< dof_id_type > > & _node_to_elem_map
std::vector< std::vector< libMesh::FEBase * > > & _fes
virtual ElemType type() const=0
CompeteInteractionResult competeInteractionsBothOnFace(PenetrationInfo *pi1, PenetrationInfo *pi2)
Determine whether first (pi1) or second (pi2) interaction is stronger when it is known that the node ...
const Point & point(const unsigned int i) const
CommonEdgeResult interactionsOffCommonEdge(PenetrationInfo *pi1, PenetrationInfo *pi2)
bool isFaceReasonableCandidate(const Elem *primary_elem, const Elem *side, libMesh::FEBase *fe, const libMesh::Point *secondary_point, const Real tangential_tolerance)
PenetrationLocator::NORMAL_SMOOTHING_METHOD _normal_smoothing_method
const std::vector< std::vector< OutputShape > > & get_phi() const
std::vector< RidgeData > _ridge_data_vec