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 : #pragma once 11 : 12 : // Moose includes 13 : #include "MooseTypes.h" 14 : #include "Restartable.h" 15 : #include "PenetrationInfo.h" 16 : #include "PerfGraphInterface.h" 17 : 18 : #include "libmesh/vector_value.h" 19 : #include "libmesh/point.h" 20 : #include "libmesh/fe_base.h" 21 : 22 : // Forward Declarations 23 : class SubProblem; 24 : class MooseMesh; 25 : class GeometricSearchData; 26 : class NearestNodeLocator; 27 : 28 : class PenetrationLocator : Restartable, public PerfGraphInterface 29 : { 30 : public: 31 : PenetrationLocator(SubProblem & subproblem, 32 : GeometricSearchData & geom_search_data, 33 : MooseMesh & mesh, 34 : const unsigned int primary_id, 35 : const unsigned int secondary_id, 36 : Order order, 37 : NearestNodeLocator & nearest_node); 38 : ~PenetrationLocator(); 39 : void detectPenetration(); 40 : 41 : /** 42 : * Completely redo the search from scratch. 43 : * This is probably getting called because of mesh adaptivity. 44 : */ 45 : void reinit(); 46 : 47 : Real penetrationDistance(dof_id_type node_id); 48 : RealVectorValue penetrationNormal(dof_id_type node_id); 49 : 50 : enum NORMAL_SMOOTHING_METHOD 51 : { 52 : NSM_EDGE_BASED, 53 : NSM_NODAL_NORMAL_BASED 54 : }; 55 : 56 : SubProblem & _subproblem; 57 : 58 : Real normDistance(const Elem & elem, 59 : const Elem & side, 60 : const Node & p0, 61 : Point & closest_point, 62 : RealVectorValue & normal); 63 : 64 : int intersect2D_Segments(Point S1P0, Point S1P1, Point S2P0, Point S2P1, Point * I0, Point * I1); 65 : int inSegment(Point P, Point SP0, Point SP1); 66 : 67 : MooseMesh & _mesh; 68 : BoundaryID _primary_boundary; 69 : BoundaryID _secondary_boundary; 70 : 71 : libMesh::FEType _fe_type; 72 : 73 : // One FE for each thread and for each dimension 74 : std::vector<std::vector<libMesh::FEBase *>> _fe; 75 : 76 : NearestNodeLocator & _nearest_node; 77 : 78 : /// Data structure of nodes and their associated penetration information 79 : std::map<dof_id_type, PenetrationInfo *> & _penetration_info; 80 : 81 : std::set<dof_id_type> & 82 : _has_penetrated; // This is only hanging around for legacy code. Don't use it! 83 : 84 : void setCheckWhetherReasonable(bool state); 85 : void setUpdate(bool update); 86 : void setTangentialTolerance(Real tangential_tolerance); 87 : void setNormalSmoothingDistance(Real normal_smoothing_distance); 88 : void setNormalSmoothingMethod(std::string nsmString); 89 : Real getTangentialTolerance() { return _tangential_tolerance; } 90 : 91 : protected: 92 : /// Check whether found candidates are reasonable 93 : bool _check_whether_reasonable; 94 : bool & _update_location; // Update the penetration location for nodes found last time 95 : Real _tangential_tolerance; // Tangential distance a node can be from a face and still be in 96 : // contact 97 : bool _do_normal_smoothing; // Should we do contact normal smoothing? 98 : Real _normal_smoothing_distance; // Distance from edge (in parametric coords) within which to 99 : // perform normal smoothing 100 : NORMAL_SMOOTHING_METHOD _normal_smoothing_method; 101 : 102 : const Moose::PatchUpdateType _patch_update_strategy; // Contact patch update strategy 103 : }; 104 : 105 : /** 106 : * We have to have a specialization for this map because the PenetrationInfo 107 : * objects MUST get deleted before the ones are loaded from a file or it's a memory leak. 108 : */ 109 : template <> 110 : inline void 111 158 : dataLoad(std::istream & stream, std::map<dof_id_type, PenetrationInfo *> & m, void * context) 112 : { 113 158 : std::map<dof_id_type, PenetrationInfo *>::iterator it = m.begin(); 114 158 : std::map<dof_id_type, PenetrationInfo *>::iterator end = m.end(); 115 : 116 172 : for (; it != end; ++it) 117 14 : delete it->second; 118 : 119 158 : m.clear(); 120 : 121 : // First read the size of the map 122 158 : unsigned int size = 0; 123 158 : stream.read((char *)&size, sizeof(size)); 124 : 125 1815 : for (unsigned int i = 0; i < size; i++) 126 : { 127 : dof_id_type key; 128 1657 : loadHelper(stream, key, context); 129 1657 : loadHelper(stream, m[key], context); 130 : } 131 158 : }