LCOV - code coverage report
Current view: top level - include/SBMBndElement - SBMBndElementBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose shifted_boundary_method: #33416 (b10b36) with base 9fbd27 Lines: 0 1 0.0 %
Date: 2026-07-23 16:20:15 Functions: 0 2 0.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             : #include "MooseMesh.h"
      13             : 
      14             : class Ball;
      15             : class LineSegment;
      16             : 
      17             : /// Base class for SBM boundary elements
      18             : class SBMBndElementBase
      19             : {
      20             : public:
      21             :   /**
      22             :    * Constructor takes a pointer to a boundary element and its precomputed unit
      23             :    * normal. The normal is computed eagerly by derived classes (which know their
      24             :    * geometry) so the base can store it const and shared concurrent reads are safe.
      25             :    */
      26             :   SBMBndElementBase(const Elem * elem, const Point & normal);
      27             : 
      28             :   /// Virtual destructor to ensure proper cleanup in derived classes
      29           0 :   virtual ~SBMBndElementBase() = default;
      30             : 
      31             :   /// Getter for the underlying element
      32             :   const Elem & elem() const { return *_elem; }
      33             : 
      34             :   /// Getter for the normal vector
      35             :   const Point & normal() const { return _normal; }
      36             : 
      37             :   /**
      38             :    * Check if the given line segment intersects this boundary element.
      39             :    * Delegates to the underlying geometry via dynamic_cast.
      40             :    */
      41             :   bool intersect(const LineSegment & line_segment) const;
      42             : 
      43             :   /// Getter of expected embedding solving mesh dimension
      44             :   /// Because the boundary element is a face of the embedding mesh, its dimension is
      45             :   /// one less than the dimension of the embedding mesh.
      46             :   unsigned int expectedEmbeddingMeshDim() const { return _elem->dim() + 1; }
      47             : 
      48             :   /**
      49             :    * Compute the distance vector from an arbitrary point to this boundary element.
      50             :    * Default: normal-based distance vector. Override in derived class if needed.
      51             :    * (a) First calculation of the normal-based distance and the projection point (b) If the
      52             :    * projection point is outside the element, return the distance to the closest vertex.
      53             :    */
      54             :   virtual Point distanceFrom(const Point & pt) const;
      55             : 
      56             :   /**
      57             :    * Compute a bounding ball for this boundary element.
      58             :    * Delegates to the underlying geometry via dynamic_cast.
      59             :    */
      60             :   Ball computeBoundingBall() const;
      61             : 
      62             :   /**
      63             :    * Compute the length of the element bounding-box diagonal projected onto
      64             :    * a plane orthogonal to a given direction.
      65             :    *
      66             :    * The projection plane is defined only by its normal direction; the
      67             :    * specific location (offset) of the plane is irrelevant for this operation.
      68             :    * Equivalently, this function removes the component of the bounding-box
      69             :    * diagonal along the given normal direction and returns the norm of the
      70             :    * remaining tangential component.
      71             :    *
      72             :    * @param normal_dir: A direction vector defining the plane normal.
      73             :    * @return The length of the longest diagonal of the projected rectangle.
      74             :    */
      75             :   Real getProjectedBoundingBoxDiagonal(const Point & normal_dir) const;
      76             : 
      77             : private:
      78             :   ///< Pointer to the libMesh element representing this boundary face. Derived
      79             :   ///< classes access it through elem() rather than this field directly.
      80             :   const Elem * _elem;
      81             :   ///< Unit normal vector of the boundary element, computed eagerly in the
      82             :   ///< derived constructor and passed through the base constructor.
      83             :   const Point _normal;
      84             : };

Generated by: LCOV version 1.14