158{
161
162
165 {
169 }
170
171 const BoundaryInfo & boundary_info =
_mesh.
getMesh().get_boundary_info();
172 std::unique_ptr<PointLocatorBase> point_locator;
175
176 for (const auto & node_id : range)
177 {
179
180
181
182
186
187 std::vector<PenetrationInfo *> p_info;
188 bool info_set(false);
189
190
191 if (info)
192 {
195
197 {
198 const Point contact_ref =
info->_closest_point_ref;
199 bool contact_point_on_side(false);
200
201
202
203 std::vector<Point> points(1);
204 points[0] = contact_ref;
205 const std::vector<Point> & secondary_pos = fe_side->get_xyz();
206 bool search_succeeded = false;
207
209 fe_elem,
210 fe_side,
212 secondary_pos[0],
213 false,
215 contact_point_on_side,
216 search_succeeded);
217
218
219 info->_closest_point_ref = contact_ref;
220
221
222 info->_distance = 0.0;
223 info_set = true;
224 }
225 else
226 {
227 Real old_tangential_distance(
info->_tangential_distance);
228 bool contact_point_on_side(false);
229 bool search_succeeded = false;
230
232 fe_elem,
233 fe_side,
235 node,
236 false,
238 contact_point_on_side,
239 search_succeeded);
240
241 if (contact_point_on_side)
242 {
243 if (
info->_tangential_distance <= 0.0)
244 {
245 info_set = true;
246 }
247 else if (
info->_tangential_distance > 0.0 && old_tangential_distance > 0.0)
248 {
249 if (
info->_side->dim() == 2 &&
info->_off_edge_nodes.size() < 2)
250 {
251
252 }
253 else
254 {
255 info_set = true;
256 }
257 }
258 }
259 }
260 }
261
262 if (!info_set)
263 {
265
266 std::vector<dof_id_type> located_elem_ids;
267 const std::vector<dof_id_type> * closest_elems;
268
270 {
271 std::set<const Elem *> candidate_elements;
272 (*point_locator)(*closest_node, candidate_elements);
273
274 if (candidate_elements.empty())
275 mooseError(
"No proximate elements found at node ",
276 closest_node->id(),
277 " at ",
278 cast_ref<const Point &>(*closest_node),
279 " on boundary ",
281 ". This should never happen.");
282
283 for (const Elem * elem : candidate_elements)
284 {
286 {
287 located_elem_ids.push_back(elem->id());
288 continue;
289 }
290 for (auto s : elem->side_index_range())
292 {
293 located_elem_ids.push_back(elem->id());
294 break;
295 }
296 }
297
298 if (located_elem_ids.empty())
299 mooseError(
"No proximate elements found at node ",
300 closest_node->id(),
301 " at ",
302 cast_ref<const Point &>(*closest_node),
303 " on boundary ",
305 " share that boundary. This may happen if the mesh uses the same boundary id "
306 "for a nodeset and an unrelated sideset.");
307
308 closest_elems = &located_elem_ids;
309 }
310 else
311 {
314 "Missing entry in node to elem map");
315 closest_elems = &(node_to_elem_pair->second);
316 }
317
318 for (const auto & elem_id : *closest_elems)
319 {
321
322 std::vector<PenetrationInfo *> thisElemInfo;
323
324 std::vector<const Node *> nodesThatMustBeOnSide;
325
326
327
328
329
330
331
332
333
335 nodesThatMustBeOnSide.push_back(closest_node);
338 }
339
341 {
342 Real min_distance_sq = std::numeric_limits<Real>::max();
343 Point best_point;
345
346
347 for (unsigned int i = 0; i < p_info.size(); ++i)
348 {
349 const Point closest_point = closest_point_to_side(node, *p_info[i]->_side);
350 const Real distance_sq = (closest_point - node).
norm_sq();
351 if (distance_sq < min_distance_sq)
352 {
353 min_distance_sq = distance_sq;
354 best_point = closest_point;
355 best_i = i;
356 }
357 }
358
359 p_info[best_i]->_closest_point = best_point;
360 p_info[best_i]->_distance =
361 (p_info[best_i]->_distance >= 0.0 ? 1.0 : -1.0) * std::sqrt(min_distance_sq);
363 mooseError(
"Normal smoothing not implemented with point locator code");
364 Point normal = (best_point - node).unit();
365 const Real dot = normal * p_info[best_i]->_normal;
366 if (dot < 0)
367 normal *= -1;
368 p_info[best_i]->_normal = normal;
369
371 info_set = true;
372 }
373 else
374 {
375 if (p_info.size() == 1)
376 {
378 {
380 info_set = true;
381 }
382 }
383 else if (p_info.size() > 1)
384 {
385
386 std::vector<RidgeData> ridgeDataVec;
387 for (unsigned int i = 0; i + 1 < p_info.size(); ++i)
388 for (unsigned int j = i + 1; j < p_info.size(); ++j)
389 {
390 Point closest_coor;
391 Real tangential_distance(0.0);
392 const Node * closest_node_on_ridge = NULL;
393 unsigned int index = 0;
394 Point closest_coor_ref;
396 tangential_distance,
397 closest_node_on_ridge,
398 index,
399 closest_coor_ref,
400 p_info,
401 i,
402 j);
403 if (found_ridge_contact_point)
404 {
405 RidgeData rpd;
406 rpd._closest_coor = closest_coor;
407 rpd._tangential_distance = tangential_distance;
408 rpd._closest_node = closest_node_on_ridge;
409 rpd._index = index;
410 rpd._closest_coor_ref = closest_coor_ref;
411 ridgeDataVec.push_back(rpd);
412 }
413 }
414
415 if (ridgeDataVec.size() > 0)
416 {
417
418
419 std::vector<RidgeSetData> ridgeSetDataVec;
420 for (unsigned int i = 0; i < ridgeDataVec.size(); ++i)
421 {
422 bool foundSetWithMatchingNode = false;
423 for (unsigned int j = 0; j < ridgeSetDataVec.size(); ++j)
424 {
425 if (ridgeDataVec[i]._closest_node != NULL &&
426 ridgeDataVec[i]._closest_node == ridgeSetDataVec[j]._closest_node)
427 {
428 foundSetWithMatchingNode = true;
429 ridgeSetDataVec[j]._ridge_data_vec.push_back(ridgeDataVec[i]);
430 break;
431 }
432 }
433 if (!foundSetWithMatchingNode)
434 {
435 RidgeSetData rsd;
436 rsd._distance = std::numeric_limits<Real>::max();
437 rsd._ridge_data_vec.push_back(ridgeDataVec[i]);
438 rsd._closest_node = ridgeDataVec[i]._closest_node;
439 ridgeSetDataVec.push_back(rsd);
440 }
441 }
442
443 for (unsigned int i = 0; i < ridgeSetDataVec.size(); ++i)
444 {
445 if (ridgeSetDataVec[i]._closest_node !=
446 NULL)
447 {
448 if (ridgeSetDataVec[i]._ridge_data_vec.size() == 1)
449 {
450 if (ridgeSetDataVec[i]._ridge_data_vec[0]._tangential_distance <=
452 {
453 ridgeSetDataVec[i]._closest_coor =
454 ridgeSetDataVec[i]._ridge_data_vec[0]._closest_coor;
455 Point contact_point_vec = node - ridgeSetDataVec[i]._closest_coor;
456 ridgeSetDataVec[i]._distance = contact_point_vec.norm();
457 }
458 }
459 else
460
461 {
462 ridgeSetDataVec[i]._closest_coor = *ridgeSetDataVec[i]._closest_node;
463 Point contact_point_vec = node - ridgeSetDataVec[i]._closest_coor;
464 ridgeSetDataVec[i]._distance = contact_point_vec.norm();
465 }
466 }
467 else
468 {
469 ridgeSetDataVec[i]._closest_coor =
470 ridgeSetDataVec[i]._ridge_data_vec[0]._closest_coor;
471 Point contact_point_vec = node - ridgeSetDataVec[i]._closest_coor;
472 ridgeSetDataVec[i]._distance = contact_point_vec.norm();
473 }
474 }
475
476 unsigned int closest_ridge_set_index(0);
477 Real closest_distance(ridgeSetDataVec[0]._distance);
478 Point closest_point(ridgeSetDataVec[0]._closest_coor);
479 for (unsigned int i = 1; i < ridgeSetDataVec.size(); ++i)
480 {
481 if (ridgeSetDataVec[i]._distance < closest_distance)
482 {
483 closest_ridge_set_index = i;
484 closest_distance = ridgeSetDataVec[i]._distance;
485 closest_point = ridgeSetDataVec[i]._closest_coor;
486 }
487 }
488
489 if (closest_distance <
490 std::numeric_limits<Real>::max())
491 {
492
493
494
495
496
497
498
499 unsigned int face_index(std::numeric_limits<unsigned int>::max());
500 for (unsigned int i = 0;
501 i < ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec.size();
502 ++i)
503 {
504 if (ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec[i]._index < face_index)
505 face_index = ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec[i]._index;
506 }
507
508 mooseAssert(face_index < std::numeric_limits<unsigned int>::max(),
509 "face_index invalid");
510
511 p_info[face_index]->_closest_point = closest_point;
512 p_info[face_index]->_distance =
513 (p_info[face_index]->_distance >= 0.0 ? 1.0 : -1.0) * closest_distance;
514
515
516
518 {
519 Point normal(closest_point - node);
520 const Real len(normal.norm());
521 if (len > 0)
522 {
523 normal /= len;
524 }
525 const Real dot(normal * p_info[face_index]->_normal);
526 if (dot < 0)
527 normal *= -1;
528 p_info[face_index]->_normal = normal;
529 }
530 p_info[face_index]->_tangential_distance = 0.0;
531
532 Point closest_point_ref;
533 if (ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec.size() ==
534 1)
535 {
536 p_info[face_index]->_tangential_distance = ridgeSetDataVec[closest_ridge_set_index]
537 ._ridge_data_vec[0]
538 ._tangential_distance;
539 p_info[face_index]->_closest_point_ref =
540 ridgeSetDataVec[closest_ridge_set_index]._ridge_data_vec[0]._closest_coor_ref;
541 }
542 else
543 {
544 const Node * closest_node_on_face;
546 closest_node_on_face,
547 p_info[face_index]->_side);
548 if (restricted)
549 {
550 if (closest_node_on_face !=
551 ridgeSetDataVec[closest_ridge_set_index]._closest_node)
552 {
553 mooseError(
"Closest node when restricting point to face != closest node from "
554 "RidgeSetData");
555 }
556 }
557 }
558
560 std::vector<Point> points(1);
561 points[0] = p_info[face_index]->_closest_point_ref;
562 fe->reinit(p_info[face_index]->_side, &points);
563 p_info[face_index]->_side_phi = fe->get_phi();
564 p_info[face_index]->_side_grad_phi = fe->get_dphi();
565 p_info[face_index]->_dxyzdxi = fe->get_dxyzdxi();
566 p_info[face_index]->_dxyzdeta = fe->get_dxyzdeta();
567 p_info[face_index]->_d2xyzdxideta = fe->get_d2xyzdxideta();
568
570 info_set = true;
571 }
572 else
573 {
574
575 }
576 }
577
578 if (!info_set)
579 {
580 unsigned int best(0), i(1);
581 do
582 {
585 {
586 i++;
587 }
589 {
590 best = i;
591 i++;
592 }
594 {
595 best = i + 1;
596 i += 2;
597 }
598 } while (i < p_info.size() && best < p_info.size());
599 if (best < p_info.size())
600 {
601
603 {
605 info_set = true;
606 }
607 }
608 }
609 }
610 }
611 }
612
613 if (!info_set)
614 {
615
616
617
618
619
621
624 }
625 else
626 {
630 }
631
632 for (unsigned int j = 0; j < p_info.size(); ++j)
633 {
634 if (p_info[j])
635 {
636 delete p_info[j];
637 p_info[j] = NULL;
638 }
639 }
640 }
641}
Threads::spin_mutex pinfo_mutex
virtual const Node & nodeRef(const dof_id_type i) const
virtual std::unique_ptr< libMesh::PointLocatorBase > getPointLocator() const
Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default),...
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.
void computeSlip(libMesh::FEBase &fe, PenetrationInfo &info)
MooseVariable * _nodal_normal_x
MooseVariable * _nodal_normal_z
MooseVariable * _nodal_normal_y
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)
void switchInfo(PenetrationInfo *&info, PenetrationInfo *&infoNew)
bool restrictPointToFace(libMesh::Point &p, const Node *&closest_node, const Elem *side)
void smoothNormal(PenetrationInfo *info, std::vector< PenetrationInfo * > &p_info, const Node &node)
CompeteInteractionResult competeInteractions(PenetrationInfo *pi1, PenetrationInfo *pi2)
When interactions are identified between a node and two faces, compete between the faces to determine...
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.