LCOV - code coverage report
Current view: top level - include/csg - CSGSphere.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31782 (615931) with base 7edd10 Lines: 3 3 100.0 %
Date: 2025-11-11 23:21:15 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       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 "CSGSurface.h"
      13             : 
      14             : #include "libmesh/point.h"
      15             : 
      16             : namespace CSG
      17             : {
      18             : 
      19             : /**
      20             :  * CSGSphere creates an internal representation of a Constructive Solid Geometry (CSG)
      21             :  * sphere, represented in the form (x - x0)^2 + (y - y0)^2 + (z - z0)^2 = r^2
      22             :  */
      23             : class CSGSphere : public CSGSurface
      24             : {
      25             : public:
      26             :   /**
      27             :    * @brief Construct a new CSGSphere surface
      28             :    *
      29             :    * @param name unique name for the sphere surface
      30             :    * @param center center point of sphere
      31             :    * @param r radius of sphere
      32             :    */
      33             :   CSGSphere(const std::string & name, const Point & center, const Real r);
      34             : 
      35             :   /**
      36             :    * @brief Construct a new CSGSphere surface
      37             :    *
      38             :    * @param name unique name for the sphere surface
      39             :    * @param r radius of sphere
      40             :    */
      41             :   CSGSphere(const std::string & name, const Real r);
      42             : 
      43             :   /**
      44             :    * Destructor
      45             :    */
      46         234 :   virtual ~CSGSphere() = default;
      47             : 
      48             :   /**
      49             :    * @brief Get the coefficients (x0, y0, z0, r) for the equation of a sphere
      50             :    * (x - x0)^2 + (y - y0)^2 + (z - z0)^2 = r^2
      51             :    *
      52             :    * @return map of coefficients (x0, y0, z0, and r) and their values
      53             :    */
      54             :   virtual std::unordered_map<std::string, Real> getCoeffs() const override;
      55             : 
      56             :   /**
      57             :    * @brief given a point, determine its evaluation based on the equation of the sphere
      58             :    *
      59             :    * @param p point
      60             :    * @return evaluation of point based on surface equation
      61             :    */
      62             :   virtual Real evaluateSurfaceEquationAtPoint(const Point & p) const override;
      63             : 
      64             : protected:
      65             :   /**
      66             :    * @brief create clone of CSGSphere object
      67             :    *
      68             :    * @return std::unordered_map<CSGSurface> unique_ptr to cloned sphere
      69             :    */
      70          22 :   virtual std::unique_ptr<CSGSurface> clone() const override
      71             :   {
      72          22 :     return std::make_unique<CSGSphere>(_name, Point(_x0, _y0, _z0), _r);
      73             :   }
      74             : 
      75             :   // check that radius is positive
      76             :   void checkRadius() const;
      77             : 
      78             :   /// Value of x0 in equation of sphere
      79             :   Real _x0;
      80             : 
      81             :   /// Value of y0 in equation of sphere
      82             :   Real _y0;
      83             : 
      84             :   /// Value of z0 in equation of sphere
      85             :   Real _z0;
      86             : 
      87             :   /// Value of r in equation of sphere
      88             :   Real _r;
      89             : };
      90             : } // namespace CSG

Generated by: LCOV version 1.14