https://mooseframework.inl.gov
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CSG::CSGZCylinder Class Reference

CSGZCylinder creates an internal representation of a Constructive Solid Geometry (CSG) z-axis aligned cylinder, represented in the following form (x - x0)^2 + (y - y0)^2 = r^2. More...

#include <CSGZCylinder.h>

Inheritance diagram for CSG::CSGZCylinder:
[legend]

Public Types

enum  Halfspace { Halfspace::POSITIVE, Halfspace::NEGATIVE }
 Enum for the sign of the half-space being represented by a point and surface. More...
 

Public Member Functions

 CSGZCylinder (const std::string &name, const Real x0, const Real y0, const Real r)
 Construct a cylinder surface aligned with the z axis. More...
 
virtual ~CSGZCylinder ()=default
 Destructor. More...
 
virtual std::unordered_map< std::string, RealgetCoeffs () const override
 Get the coefficients (x0, y0, and r) that define the cylindrical surface with the equation: (x - x0)^2 + (y - y0)^2 = r^2. More...
 
virtual Real evaluateSurfaceEquationAtPoint (const Point &p) const override
 given a point, determine its evaluation based on the equation of the cylinder More...
 
const std::string & getSurfaceType () const
 Get the Surface Type. More...
 
CSGSurface::Halfspace getHalfspaceFromPoint (const Point &p) const
 given a point, determine if it is in the positive or negative half-space for the surface More...
 
const std::string & getName () const
 Get the name of surface. More...
 
bool operator== (const CSGSurface &other) const
 Operator overload for checking if two CSGSurface objects are equal. More...
 
bool operator!= (const CSGSurface &other) const
 Operator overload for checking if two CSGSurface objects are not equal. More...
 

Protected Member Functions

void checkRadius () const
 
void setName (const std::string &name)
 
 FRIEND_TEST (CSGSurfaceTest, testSetName)
 Friends for unit testing. More...
 

Protected Attributes

Real _x0
 Value of x0 in equation of an z-axis aligned cylinder. More...
 
Real _y0
 Value of y0 in equation of an z-axis aligned cylinder. More...
 
Real _r
 Value of r in equation of an z-axis aligned cylinder. More...
 
std::string _name
 Name of surface. More...
 
const std::string _surface_type
 Type of surface that is being represented string is taken directly from the surface class name. More...
 

Detailed Description

CSGZCylinder creates an internal representation of a Constructive Solid Geometry (CSG) z-axis aligned cylinder, represented in the following form (x - x0)^2 + (y - y0)^2 = r^2.

Definition at line 23 of file CSGZCylinder.h.

Member Enumeration Documentation

◆ Halfspace

enum CSG::CSGSurface::Halfspace
stronginherited

Enum for the sign of the half-space being represented by a point and surface.

Enumerator
POSITIVE 
NEGATIVE 

Definition at line 30 of file CSGSurface.h.

31  {
32  POSITIVE,
33  NEGATIVE
34  };

Constructor & Destructor Documentation

◆ CSGZCylinder()

CSG::CSGZCylinder::CSGZCylinder ( const std::string &  name,
const Real  x0,
const Real  y0,
const Real  r 
)

Construct a cylinder surface aligned with the z axis.

Parameters
nameunique name of surface
x0x coordinate of center
y0y coordinate of center
rradius

Definition at line 15 of file CSGZCylinder.C.

16  : CSGSurface(name, MooseUtils::prettyCppType<CSGZCylinder>()), _x0(x0), _y0(y0), _r(r)
17 {
18  checkRadius();
19 }
Real _x0
Value of x0 in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:62
void checkRadius() const
Definition: CSGZCylinder.C:39
CSGSurface(const std::string &name)
Default constructor.
Real _r
Value of r in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:68
Real _y0
Value of y0 in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:65

◆ ~CSGZCylinder()

virtual CSG::CSGZCylinder::~CSGZCylinder ( )
virtualdefault

Destructor.

Member Function Documentation

◆ checkRadius()

void CSG::CSGZCylinder::checkRadius ( ) const
protected

Definition at line 39 of file CSGZCylinder.C.

Referenced by CSGZCylinder().

40 {
41  if (_r <= 0.0)
42  mooseError("Radius of z-cylinder must be positive.");
43 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
Real _r
Value of r in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:68

◆ evaluateSurfaceEquationAtPoint()

Real CSG::CSGZCylinder::evaluateSurfaceEquationAtPoint ( const Point &  p) const
overridevirtual

given a point, determine its evaluation based on the equation of the cylinder

Parameters
ppoint
Returns
evaluation of point based on surface equation

Implements CSG::CSGSurface.

Definition at line 29 of file CSGZCylinder.C.

30 {
31  // Compute distance from the cylinder center to determine if inside (< r^2)
32  // or outside (> r^2) the cylinder
33  const Real dist_sq = Utility::pow<2>((p(0) - _x0)) + Utility::pow<2>((p(1) - _y0));
34 
35  return dist_sq - Utility::pow<2>(_r);
36 }
Real _x0
Value of x0 in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:62
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real _r
Value of r in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:68
Real _y0
Value of y0 in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:65
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template pow< 2 >(tan(_arg))+1.0) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(sqrt

◆ FRIEND_TEST()

CSG::CSGSurface::FRIEND_TEST ( CSGSurfaceTest  ,
testSetName   
)
protectedinherited

Friends for unit testing.

◆ getCoeffs()

std::unordered_map< std::string, Real > CSG::CSGZCylinder::getCoeffs ( ) const
overridevirtual

Get the coefficients (x0, y0, and r) that define the cylindrical surface with the equation: (x - x0)^2 + (y - y0)^2 = r^2.

Returns
map of coefficients to their value

Implements CSG::CSGSurface.

Definition at line 22 of file CSGZCylinder.C.

23 {
24  std::unordered_map<std::string, Real> coeffs = {{"x0", _x0}, {"y0", _y0}, {"r", _r}};
25  return coeffs;
26 }
Real _x0
Value of x0 in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:62
Real _r
Value of r in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:68
Real _y0
Value of y0 in equation of an z-axis aligned cylinder.
Definition: CSGZCylinder.h:65

◆ getHalfspaceFromPoint()

CSGSurface::Halfspace CSG::CSGSurface::getHalfspaceFromPoint ( const Point &  p) const
inherited

given a point, determine if it is in the positive or negative half-space for the surface

Parameters
ppoint
Returns
sign of the half-space

Definition at line 21 of file CSGSurface.C.

22 {
23  auto eval = evaluateSurfaceEquationAtPoint(p);
25  return Halfspace::POSITIVE;
26  else if (MooseUtils::absoluteFuzzyLessThan(eval, 0))
27  return Halfspace::NEGATIVE;
28  else
29  mooseError("Point ",
30  p,
31  " used to determine halfspace evaluation lies on the surface ",
32  _name,
33  ", leading to an ambiguously defined halfspace.");
34 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
virtual Real evaluateSurfaceEquationAtPoint(const Point &p) const =0
given a point, determine its evaluation based on the surface equation.
bool absoluteFuzzyLessThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is less than another variable within an absolute tolerance...
Definition: MooseUtils.h:477
std::string _name
Name of surface.
Definition: CSGSurface.h:109
bool absoluteFuzzyGreaterThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is greater than another variable within an absolute tolerance...
Definition: MooseUtils.h:430

◆ getName()

const std::string& CSG::CSGSurface::getName ( ) const
inlineinherited

Get the name of surface.

Returns
std::string name of surface

Definition at line 95 of file CSGSurface.h.

Referenced by CSG::CSGSurfaceList::addSurface(), CSG::CSGRegion::CSGRegion(), CSG::CSGSurface::operator==(), and CSG::CSGSurfaceList::renameSurface().

95 { return _name; }
std::string _name
Name of surface.
Definition: CSGSurface.h:109

◆ getSurfaceType()

const std::string& CSG::CSGSurface::getSurfaceType ( ) const
inlineinherited

Get the Surface Type.

Returns
type of surface

Definition at line 61 of file CSGSurface.h.

Referenced by CSG::CSGSurface::operator==().

61 { return _surface_type; }
const std::string _surface_type
Type of surface that is being represented string is taken directly from the surface class name...
Definition: CSGSurface.h:113

◆ operator!=()

bool CSG::CSGSurface::operator!= ( const CSGSurface other) const
inherited

Operator overload for checking if two CSGSurface objects are not equal.

Definition at line 45 of file CSGSurface.C.

46 {
47  return !(*this == other);
48 }

◆ operator==()

bool CSG::CSGSurface::operator== ( const CSGSurface other) const
inherited

Operator overload for checking if two CSGSurface objects are equal.

Definition at line 37 of file CSGSurface.C.

38 {
39  return (this->getName() == other.getName()) &&
40  (this->getSurfaceType() == other.getSurfaceType()) &&
41  (this->getCoeffs() == other.getCoeffs());
42 }
const std::string & getName() const
Get the name of surface.
Definition: CSGSurface.h:95
virtual std::unordered_map< std::string, Real > getCoeffs() const =0
Get the coefficients that define the surface.
const std::string & getSurfaceType() const
Get the Surface Type.
Definition: CSGSurface.h:61

◆ setName()

void CSG::CSGSurface::setName ( const std::string &  name)
inlineprotectedinherited

Definition at line 106 of file CSGSurface.h.

106 { _name = name; }
std::string name(const ElemQuality q)
std::string _name
Name of surface.
Definition: CSGSurface.h:109

Member Data Documentation

◆ _name

std::string CSG::CSGSurface::_name
protectedinherited

Name of surface.

Definition at line 109 of file CSGSurface.h.

Referenced by CSG::CSGSurface::getHalfspaceFromPoint(), CSG::CSGSurface::getName(), and CSG::CSGSurface::setName().

◆ _r

Real CSG::CSGZCylinder::_r
protected

Value of r in equation of an z-axis aligned cylinder.

Definition at line 68 of file CSGZCylinder.h.

Referenced by checkRadius(), evaluateSurfaceEquationAtPoint(), and getCoeffs().

◆ _surface_type

const std::string CSG::CSGSurface::_surface_type
protectedinherited

Type of surface that is being represented string is taken directly from the surface class name.

Definition at line 113 of file CSGSurface.h.

Referenced by CSG::CSGSurface::getSurfaceType().

◆ _x0

Real CSG::CSGZCylinder::_x0
protected

Value of x0 in equation of an z-axis aligned cylinder.

Definition at line 62 of file CSGZCylinder.h.

Referenced by evaluateSurfaceEquationAtPoint(), and getCoeffs().

◆ _y0

Real CSG::CSGZCylinder::_y0
protected

Value of y0 in equation of an z-axis aligned cylinder.

Definition at line 65 of file CSGZCylinder.h.

Referenced by evaluateSurfaceEquationAtPoint(), and getCoeffs().


The documentation for this class was generated from the following files: