LCOV - code coverage report
Current view: top level - include/geomsearch - PenetrationLocator.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31706 (f8ed4a) with base bb0a08 Lines: 12 12 100.0 %
Date: 2025-11-03 17:23:24 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          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             :   void setUsePointLocator(bool state);
      65             : 
      66             :   int intersect2D_Segments(Point S1P0, Point S1P1, Point S2P0, Point S2P1, Point * I0, Point * I1);
      67             :   int inSegment(Point P, Point SP0, Point SP1);
      68             : 
      69             :   MooseMesh & _mesh;
      70             :   BoundaryID _primary_boundary;
      71             :   BoundaryID _secondary_boundary;
      72             : 
      73             :   libMesh::FEType _fe_type;
      74             : 
      75             :   // One FE for each thread and for each dimension
      76             :   std::vector<std::vector<libMesh::FEBase *>> _fe;
      77             : 
      78             :   NearestNodeLocator & _nearest_node;
      79             : 
      80             :   /// Data structure of nodes and their associated penetration information
      81             :   std::map<dof_id_type, PenetrationInfo *> & _penetration_info;
      82             : 
      83             :   std::set<dof_id_type> &
      84             :       _has_penetrated; // This is only hanging around for legacy code. Don't use it!
      85             : 
      86             :   void setCheckWhetherReasonable(bool state);
      87             :   void setUpdate(bool update);
      88             :   void setTangentialTolerance(Real tangential_tolerance);
      89             :   void setNormalSmoothingDistance(Real normal_smoothing_distance);
      90             :   void setNormalSmoothingMethod(std::string nsmString);
      91             :   Real getTangentialTolerance() { return _tangential_tolerance; }
      92             : 
      93             : protected:
      94             :   /// Check whether found candidates are reasonable
      95             :   bool _check_whether_reasonable;
      96             :   bool & _update_location;         // Update the penetration location for nodes found last time
      97             :   Real _tangential_tolerance;      // Tangential distance a node can be from a face and still be in
      98             :                                    // contact
      99             :   bool _do_normal_smoothing;       // Should we do contact normal smoothing?
     100             :   Real _normal_smoothing_distance; // Distance from edge (in parametric coords) within which to
     101             :                                    // perform normal smoothing
     102             :   NORMAL_SMOOTHING_METHOD _normal_smoothing_method;
     103             :   bool _use_point_locator; // Use a PointLocator rather than relying on mesh connectivity to
     104             :                            // find element patches
     105             : 
     106             :   const Moose::PatchUpdateType _patch_update_strategy; // Contact patch update strategy
     107             : };
     108             : 
     109             : /**
     110             :  * We have to have a specialization for this map because the PenetrationInfo
     111             :  * objects MUST get deleted before the ones are loaded from a file or it's a memory leak.
     112             :  */
     113             : template <>
     114             : inline void
     115         164 : dataLoad(std::istream & stream, std::map<dof_id_type, PenetrationInfo *> & m, void * context)
     116             : {
     117         164 :   std::map<dof_id_type, PenetrationInfo *>::iterator it = m.begin();
     118         164 :   std::map<dof_id_type, PenetrationInfo *>::iterator end = m.end();
     119             : 
     120         178 :   for (; it != end; ++it)
     121          14 :     delete it->second;
     122             : 
     123         164 :   m.clear();
     124             : 
     125             :   // First read the size of the map
     126         164 :   unsigned int size = 0;
     127         164 :   stream.read((char *)&size, sizeof(size));
     128             : 
     129        2173 :   for (unsigned int i = 0; i < size; i++)
     130             :   {
     131             :     dof_id_type key;
     132        2009 :     loadHelper(stream, key, context);
     133        2009 :     loadHelper(stream, m[key], context);
     134             :   }
     135         164 : }

Generated by: LCOV version 1.14