LCOV - code coverage report
Current view: top level - src/csg - CSGZCylinder.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31825 (c328ac) with base d8769b Lines: 15 15 100.0 %
Date: 2025-11-10 13:32:39 Functions: 4 4 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             : #include "CSGZCylinder.h"
      11             : 
      12             : namespace CSG
      13             : {
      14             : 
      15           6 : CSGZCylinder::CSGZCylinder(const std::string & name, const Real x0, const Real y0, const Real r)
      16           6 :   : CSGSurface(name, MooseUtils::prettyCppType<CSGZCylinder>()), _x0(x0), _y0(y0), _r(r)
      17             : {
      18           6 :   checkRadius();
      19           6 : }
      20             : 
      21             : std::unordered_map<std::string, Real>
      22           2 : CSGZCylinder::getCoeffs() const
      23             : {
      24          10 :   std::unordered_map<std::string, Real> coeffs = {{"x0", _x0}, {"y0", _y0}, {"r", _r}};
      25           2 :   return coeffs;
      26           2 : }
      27             : 
      28             : Real
      29           2 : CSGZCylinder::evaluateSurfaceEquationAtPoint(const Point & p) const
      30             : {
      31             :   // Compute distance from the cylinder center to determine if inside (< r^2)
      32             :   // or outside (> r^2) the cylinder
      33           2 :   const Real dist_sq = Utility::pow<2>((p(0) - _x0)) + Utility::pow<2>((p(1) - _y0));
      34             : 
      35           2 :   return dist_sq - Utility::pow<2>(_r);
      36             : }
      37             : 
      38             : void
      39           6 : CSGZCylinder::checkRadius() const
      40             : {
      41           6 :   if (_r <= 0.0)
      42           2 :     mooseError("Radius of z-cylinder must be positive.");
      43           4 : }
      44             : 
      45             : } // namespace CSG

Generated by: LCOV version 1.14