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

CSGNPolygonUnit is a CSGSurfaceEngUnit that represents a regular N-sided polygon (prismatic region) with its axis aligned with the z-axis. More...

#include <CSGNPolygonUnit.h>

Inheritance diagram for CSG::CSGNPolygonUnit:
[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

 CSGNPolygonUnit (const std::string &name, int n_sides, Real apothem)
 Construct a new CSGNPolygonUnit. More...
 
Real evaluateSurfaceEquationAtPoint (const Point &p) const override
 Evaluate the polygon's surface equation at the given point. More...
 
std::unordered_map< std::string, AttributeVariantgetAttributes () const override
 Return the polygon attributes for this object. More...
 
int getNumSides ()
 Get the number of sides for the polygon. More...
 
Real getApothem ()
 Get the polygon apothem (center-to-flat distance) More...
 
Real getSideLength ()
 Get the polygon side length. More...
 
Real getRadius ()
 Get the the circumradius for the polygon (center-to-vertex distance) More...
 
std::unordered_map< std::string, RealgetCoeffs () const override
 Always throws – coefficients are not defined for a surface engineering unit. More...
 
const std::string & getName () const override
 Satisfy CSGEngUnit::getName() – resolved via CSGSurface::getName() More...
 
bool isEngUnit () const override
 Engineering units report true so comparisons can skip the dynamic_cast fast path. More...
 
bool operator== (const CSGSurfaceEngUnit &other) const
 Disambiguate == and != by forwarding to CSGEngUnit (name/property-based comparison) More...
 
bool operator== (const CSGSurface &other) const
 Operator overload for checking if two CSGSurface objects are equal. More...
 
bool operator== (const CSGEngUnit &other) const
 Operator overload for checking if two CSGEngUnit objects are equal. More...
 
bool operator!= (const CSGSurfaceEngUnit &other) const
 
bool operator!= (const CSGSurface &other) const
 Operator overload for checking if two CSGSurface objects are not equal. More...
 
bool operator!= (const CSGEngUnit &other) const
 Operator overload for checking if two CSGEngUnit objects are not equal. More...
 
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations () const override
 Delegate to CSGSurface (CSGTransformationHelper) More...
 
std::vector< std::pair< std::string, std::tuple< Real, Real, Real > > > getTransformationsAsStrings () const override
 Delegate to CSGSurface (CSGTransformationHelper) 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 getBehavior () const
 Get the behavior of this engineering unit (surface (i.e. More...
 
const std::string getUnitType () const
 Get the type name of this engineering unit. More...
 

Static Public Member Functions

static bool isValidTransformationValue (TransformationType type, const std::tuple< Real, Real, Real > &values)
 Check if the transformation value is valid for the given type. More...
 
static std::string getTransformationTypeString (TransformationType type)
 Get the string representation of the transformation type. More...
 

Protected Member Functions

std::unique_ptr< CSGSurfaceclone () const override
 Return a deep copy of this unit. More...
 
void expandUnit () override
 Create N CSGPlane surfaces in _internal_base, one per polygon side. More...
 
CSGRegion getExpandedRegion () const
 Return the CSGRegion formed by the expanded CSGSurfaces. More...
 
void setName (const std::string &name)
 
void addTransformation (TransformationType type, const std::tuple< Real, Real, Real > &values)
 Add a transformation to the list of transformations. More...
 
Point applyReverseTransformsToPoint (Point p) const
 update the value of point p by applying the inverse of the list of transformations to the point More...
 
CSGBasegetBase ()
 Get the internal CSGBase owned by this engineering unit. More...
 
std::unique_ptr< CSGBasereleaseBase ()
 Transfer ownership of the internal CSGBase out of this unit. More...
 
 FRIEND_TEST (CSGEngUnitTest, testSurfUnit)
 Friends for unit testing. More...
 
 FRIEND_TEST (CSGSurfaceTest, testSetName)
 Friends for unit testing. More...
 
 FRIEND_TEST (CSGSurfaceTest, testSurfaceEquality)
 
 FRIEND_TEST (CSGSurfaceTest, testHalfspaceWithTransform)
 Friends for unit testing. More...
 
 FRIEND_TEST (CSGSurfaceTest, testHalfspaceWithNullTransform)
 
 FRIEND_TEST (CSGEngUnitTest, testEngUnitEqual)
 

Protected Attributes

CSGRegion _expanded_region
 Stores the result of expandUnit(); EMPTY until then. More...
 
std::string _name
 Name of surface. More...
 
std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > _transformations
 List of transformations applied to this object. More...
 
std::unique_ptr< CSGBase_internal_base
 CSGBase populated by expandUnit(); joined into the parent CSGBase by expandEngUnit() More...
 
MooseEnum _behavior {"SURFACE CELL UNIVERSE"}
 The basic CSG type this unit produces: "SURFACE", "CELL", or "UNIVERSE". More...
 

Private Member Functions

 FRIEND_TEST (CSGEngUnitTest, testPolygonUnitExpansion)
 
 FRIEND_TEST (CSGEngUnitTest, testPolygonUnitClone)
 

Private Attributes

const int _n_sides
 Number of sides of the regular polygon. More...
 
const Real _apothem
 Distance from the polygon center to the midpoint of each side. More...
 
std::vector< const CSGSurface * > _planes
 Pointers to the expanded plane surfaces, populated during expandUnit() More...
 

Detailed Description

CSGNPolygonUnit is a CSGSurfaceEngUnit that represents a regular N-sided polygon (prismatic region) with its axis aligned with the z-axis.

The polygon is defined by N infinite planes, one per side, each oriented so that its inward normal points toward the center. The interior of the polygon is the intersection of the N negative half-spaces of those planes.

Implements:

Definition at line 40 of file CSGNPolygonUnit.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

◆ CSGNPolygonUnit()

CSG::CSGNPolygonUnit::CSGNPolygonUnit ( const std::string &  name,
int  n_sides,
Real  apothem 
)

Construct a new CSGNPolygonUnit.

Parameters
nameunique name of the unit
n_sidesnumber of sides of the regular polygon (must be >= 3)
apothemdistance from the center to the midpoint of each side

Definition at line 17 of file CSGNPolygonUnit.C.

18  : CSGSurfaceEngUnit(name), _n_sides(n_sides), _apothem(apothem)
19 {
20  if (_n_sides < 3)
21  mooseError("N-sided polygon engineering unit " + name + " must have 3 or more sides.");
22  if (_apothem <= 0.0)
23  mooseError("N-sided polygon engineering unit " + name + " apothem must be positive.");
24 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGSurfaceEngUnit(const std::string &name)
Construct a new CSGSurfaceEngUnit.
const int _n_sides
Number of sides of the regular polygon.
const Real _apothem
Distance from the polygon center to the midpoint of each side.

Member Function Documentation

◆ addTransformation()

void CSG::CSGTransformationHelper::addTransformation ( TransformationType  type,
const std::tuple< Real, Real, Real > &  values 
)
protectedinherited

Add a transformation to the list of transformations.

Parameters
typeThe type of transformation
valuesThe values for the transformation

Definition at line 16 of file CSGTransformationHelper.C.

Referenced by CSG::CSGBase::expandEngUnit().

18 {
20  mooseError("Invalid transformation values provided for transformation type " +
22  _transformations.emplace_back(type, values);
23 }
static bool isValidTransformationValue(TransformationType type, const std::tuple< Real, Real, Real > &values)
Check if the transformation value is valid for the given type.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
static std::string getTransformationTypeString(TransformationType type)
Get the string representation of the transformation type.
std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > _transformations
List of transformations applied to this object.
std::array< Real, 2 > values
Definition: MortarUtils.C:52

◆ applyReverseTransformsToPoint()

Point CSG::CSGTransformationHelper::applyReverseTransformsToPoint ( Point  p) const
protectedinherited

update the value of point p by applying the inverse of the list of transformations to the point

Parameters
ppoint to transform
Returns
transformed point

Definition at line 74 of file CSGTransformationHelper.C.

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

75 {
76  // iterate list of transformations in reverse and apply the inverse operation
77  for (auto it = _transformations.rbegin(); it != _transformations.rend(); ++it)
78  {
79  auto trans_type = it->first;
80  auto val = it->second;
81 
82  if (trans_type == TransformationType::TRANSLATION)
83  {
84  Point offset(std::get<0>(val), std::get<1>(val), std::get<2>(val));
85  p -= offset;
86  }
87  else if (trans_type == TransformationType::SCALE)
88  {
89  Point scale(std::get<0>(val), std::get<1>(val), std::get<2>(val));
90  for (int i = 0; i < 3; ++i)
91  p(i) /= scale(i);
92  }
93  else if (trans_type == TransformationType::ROTATION)
94  {
95  // get the transpose of the original rotation matrix and apply to point p
96  const auto rot_matrix = RealTensorValue::intrinsic_rotation_matrix(
97  std::get<0>(val), std::get<1>(val), std::get<2>(val));
98  const auto rot_transpose = rot_matrix.transpose();
99  p = rot_transpose * p;
100  }
101  else
102  mooseError("Transformation type is not recognized.");
103  }
104  return p;
105 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
Real scale
Definition: MortarUtils.C:62
std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > _transformations
List of transformations applied to this object.
static TensorValue< Real > intrinsic_rotation_matrix(Real phi, Real theta, Real psi)

◆ clone()

std::unique_ptr<CSGSurface> CSG::CSGNPolygonUnit::clone ( ) const
inlineoverrideprotectedvirtual

Return a deep copy of this unit.

Returns
unique_ptr to a new CSGNPolygonUnit with identical parameters

Implements CSG::CSGSurfaceEngUnit.

Definition at line 109 of file CSGNPolygonUnit.h.

110  {
111  return std::make_unique<CSGNPolygonUnit>(_name, _n_sides, _apothem);
112  }
std::string _name
Name of surface.
Definition: CSGSurface.h:122
const int _n_sides
Number of sides of the regular polygon.
const Real _apothem
Distance from the polygon center to the midpoint of each side.

◆ evaluateSurfaceEquationAtPoint()

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

Evaluate the polygon's surface equation at the given point.

Returns the maximum signed plane-equation value over all N sides. A negative return value means the point lies inside the polygon; positive means outside; zero means on one of the sides.

This can be evaluated before expansion using the stored geometric parameters.

Parameters
ppoint to evaluate
Returns
maximum signed distance from the point to any side (negative = inside)

Implements CSG::CSGSurfaceEngUnit.

Definition at line 27 of file CSGNPolygonUnit.C.

28 {
29  // Condition for interior (negative value) vs exterior (positive value) for the polygon is:
30  // for point (x, y), if the following is true for all values of k, then the point is "interior".
31  // If any one value is positive, then the point is outside the polygon. Therefore, we calculate
32  // the maximum value. If that max value remains negative, then getHalfspaceFromPoint will
33  // correctly determine the point to be interior.
34  //
35  // x*cos(2*pi*k/N) + y*sin(2*pi*k/N) <= apothem, for all k = 0..N-1
36 
37  Real max_val =
38  -std::numeric_limits<Real>::max(); // initialize to extremely large negative (to be updated)
39  for (int k = 0; k < _n_sides; ++k)
40  {
41  auto val =
42  (p(0) * std::cos(2.0 * M_PI * k / _n_sides) + p(1) * std::sin(2.0 * M_PI * k / _n_sides)) -
43  _apothem;
44  if (val > max_val)
45  max_val = val;
46  }
47  return max_val;
48 }
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
auto max(const L &left, const R &right)
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const int _n_sides
Number of sides of the regular polygon.
const Real _apothem
Distance from the polygon center to the midpoint of each side.

◆ expandUnit()

void CSG::CSGNPolygonUnit::expandUnit ( )
overrideprotectedvirtual

Create N CSGPlane surfaces in _internal_base, one per polygon side.

Stores const pointers to the registered surfaces for use in getExpandedRegion().

Implements CSG::CSGSurfaceEngUnit.

Definition at line 57 of file CSGNPolygonUnit.C.

58 {
59  // Polygon orientation assumes an infinite prism oriented with the z-axis.
60  // The right-most face is parallel to the y-axis and is centered at the origin.
61  // Equation for the kth face, where the 0th face is the right-most and A is the apothem, follows
62  // this equation:
63  // x*cos(2*pi*k/N) + y*sin(2*pi*k/N) + z*0 = A
64  // Coefficients for the plane ax + by + cz = d:
65  // a = cos(2*pi*k/N)
66  // b = sin(2*pi*k/N)
67  // c = 0.0
68  // d = A (apothem)
69  //
70  // Surface naming scheme: [UnitName]_expanded_surf_[k]
71 
72  Real a, b; // to be calculated based on side
73  Real c = 0.0;
74  Real d = _apothem;
75 
76  // Initialize region to be added to:
77  Point p(0, 0, 0); // origin used for determining half-space
78 
79  // base name for surfaces
80  std::string base_name = getName() + "_expanded_surf_";
81 
82  for (int k = 0; k < _n_sides; ++k)
83  {
84  auto sname = base_name + std::to_string(k);
85  a = std::cos(2.0 * M_PI * k / _n_sides);
86  b = std::sin(2.0 * M_PI * k / _n_sides);
87  std::unique_ptr<CSG::CSGPlane> s_ptr = std::make_unique<CSG::CSGPlane>(sname, a, b, c, d);
88  auto & surf = _internal_base->addSurface(std::move(s_ptr));
89 
90  // determine the half-space that contains the origin for this surface
91  auto hp_type = surf.getHalfspaceFromPoint(p);
92  // half-space region for this surface only (to be intersected below)
93  auto hp = (hp_type == CSGSurface::Halfspace::POSITIVE) ? +surf : -surf;
94 
95  // start the region with first half-space, otherwise intersect with existing region
97  _expanded_region = hp;
98  else
99  _expanded_region &= hp; // intersect with existing region
100  }
101 }
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
std::unique_ptr< CSGBase > _internal_base
CSGBase populated by expandUnit(); joined into the parent CSGBase by expandEngUnit() ...
Definition: CSGEngUnit.h:130
CSGRegion _expanded_region
Stores the result of expandUnit(); EMPTY until then.
const std::string & getName() const override
Satisfy CSGEngUnit::getName() – resolved via CSGSurface::getName()
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
RegionType getRegionType() const
Get the region type.
Definition: CSGRegion.h:123
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const int _n_sides
Number of sides of the regular polygon.
const Real _apothem
Distance from the polygon center to the midpoint of each side.

◆ FRIEND_TEST() [1/8]

CSG::CSGTransformationHelper::FRIEND_TEST ( CSGSurfaceTest  ,
testHalfspaceWithTransform   
)
protectedinherited

Friends for unit testing.

◆ FRIEND_TEST() [2/8]

CSG::CSGTransformationHelper::FRIEND_TEST ( CSGSurfaceTest  ,
testHalfspaceWithNullTransform   
)
protectedinherited

◆ FRIEND_TEST() [3/8]

CSG::CSGTransformationHelper::FRIEND_TEST ( CSGEngUnitTest  ,
testEngUnitEqual   
)
protectedinherited

◆ FRIEND_TEST() [4/8]

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

Friends for unit testing.

◆ FRIEND_TEST() [5/8]

CSG::CSGNPolygonUnit::FRIEND_TEST ( CSGEngUnitTest  ,
testPolygonUnitExpansion   
)
private

◆ FRIEND_TEST() [6/8]

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

◆ FRIEND_TEST() [7/8]

CSG::CSGNPolygonUnit::FRIEND_TEST ( CSGEngUnitTest  ,
testPolygonUnitClone   
)
private

◆ FRIEND_TEST() [8/8]

CSG::CSGSurfaceEngUnit::FRIEND_TEST ( CSGEngUnitTest  ,
testSurfUnit   
)
protectedinherited

Friends for unit testing.

◆ getApothem()

Real CSG::CSGNPolygonUnit::getApothem ( )
inline

Get the polygon apothem (center-to-flat distance)

Returns
apothem value

Definition at line 87 of file CSGNPolygonUnit.h.

87 { return _apothem; }
const Real _apothem
Distance from the polygon center to the midpoint of each side.

◆ getAttributes()

std::unordered_map< std::string, AttributeVariant > CSG::CSGNPolygonUnit::getAttributes ( ) const
overridevirtual

Return the polygon attributes for this object.

Returns
map containing: num_sides (int), apothem (Real)

Implements CSG::CSGEngUnit.

Definition at line 51 of file CSGNPolygonUnit.C.

52 {
53  return {{"num_sides", _n_sides}, {"apothem", _apothem}};
54 }
const int _n_sides
Number of sides of the regular polygon.
const Real _apothem
Distance from the polygon center to the midpoint of each side.

◆ getBase()

CSGBase& CSG::CSGEngUnit::getBase ( )
inlineprotectedinherited

Get the internal CSGBase owned by this engineering unit.

Returns
reference to the internal CSGBase

Definition at line 117 of file CSGEngUnit.h.

117 { return *_internal_base; }
std::unique_ptr< CSGBase > _internal_base
CSGBase populated by expandUnit(); joined into the parent CSGBase by expandEngUnit() ...
Definition: CSGEngUnit.h:130

◆ getBehavior()

const std::string CSG::CSGEngUnit::getBehavior ( ) const
inlineinherited

Get the behavior of this engineering unit (surface (i.e.

region), cell, or universe).

Returns "SURFACE", "CELL", or "UNIVERSE" depending on which intermediate EngUnit class the concrete type derives from. Set automatically at construction.

Returns
the behavior string

Definition at line 56 of file CSGEngUnit.h.

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

56 { return _behavior; }
MooseEnum _behavior
The basic CSG type this unit produces: "SURFACE", "CELL", or "UNIVERSE".
Definition: CSGEngUnit.h:133

◆ getCoeffs()

std::unordered_map< std::string, Real > CSG::CSGSurfaceEngUnit::getCoeffs ( ) const
overridevirtualinherited

Always throws – coefficients are not defined for a surface engineering unit.

A surface engineering unit is described by its attributes (see getAttributes()), not by surface-equation coefficients, so this inherited CSGSurface method has no meaningful value on a unit. Expansion does not make it callable either: CSGBase::expandEngUnit() replaces the unit with plain CSGSurface object(s), and getCoeffs() is valid on those resulting surfaces, never on the unit itself.

The override exists only to satisfy the pure-virtual CSGSurface::getCoeffs()

Returns
never returns; always raises an error

Implements CSG::CSGSurface.

Definition at line 21 of file CSGSurfaceEngUnit.C.

22 {
23  mooseError("CSGSurfaceEngUnit '",
24  getName(),
25  "' cannot getCoeffs(). Coefficients are only callable on CSGSurface(s) generated by "
26  "expandUnit().");
27 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
const std::string & getName() const override
Satisfy CSGEngUnit::getName() – resolved via CSGSurface::getName()

◆ getExpandedRegion()

CSGRegion CSG::CSGSurfaceEngUnit::getExpandedRegion ( ) const
protectedinherited

Return the CSGRegion formed by the expanded CSGSurfaces.

Checks that expandUnit() has already been called (via _expanded_region) before returning the stored result. Throws if called before expansion.

Returns
CSGRegion representing the negative halfspace of the surface engineering unit

Definition at line 30 of file CSGSurfaceEngUnit.C.

31 {
32  // check if unit has been expanded first to define the region
34  mooseError("getExpandedRegion() cannot be called on CSGSurfaceEngUnit '",
35  getName(),
36  "' before expandUnit() has been called.");
37  return _expanded_region;
38 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGRegion _expanded_region
Stores the result of expandUnit(); EMPTY until then.
const std::string & getName() const override
Satisfy CSGEngUnit::getName() – resolved via CSGSurface::getName()
RegionType getRegionType() const
Get the region type.
Definition: CSGRegion.h:123

◆ 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 23 of file CSGSurface.C.

24 {
25  // if transformations are present on the surface, apply them in reverse to the point and pass that
26  // new point to the evaluation to ensure transformations are considered.
27 
28  // Create a local transformed copy - the original p in the calling scope is NOT modified
29  const Point p_trans = getTransformations().size() ? applyReverseTransformsToPoint(p) : p;
30 
31  auto eval = evaluateSurfaceEquationAtPoint(p_trans);
32  if (MooseUtils::absoluteFuzzyGreaterThan(eval, 0))
33  return Halfspace::POSITIVE;
34  else if (MooseUtils::absoluteFuzzyLessThan(eval, 0))
35  return Halfspace::NEGATIVE;
36  else
37  mooseError("Point ",
38  p,
39  " used to determine halfspace evaluation lies on the surface ",
40  _name,
41  ", leading to an ambiguously defined halfspace.");
42 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
virtual Real evaluateSurfaceEquationAtPoint(const Point &p) const =0
given a point, determine its evaluation based on the surface equation.
Point applyReverseTransformsToPoint(Point p) const
update the value of point p by applying the inverse of the list of transformations to the point ...
std::string _name
Name of surface.
Definition: CSGSurface.h:122
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const
Get the list of transformations.

◆ getName()

const std::string& CSG::CSGSurfaceEngUnit::getName ( ) const
inlineoverridevirtualinherited

Satisfy CSGEngUnit::getName() – resolved via CSGSurface::getName()

Implements CSG::CSGEngUnit.

Definition at line 81 of file CSGSurfaceEngUnit.h.

Referenced by CSG::CSGBase::expandEngUnit(), expandUnit(), CSG::CSGSurfaceEngUnit::getCoeffs(), and CSG::CSGSurfaceEngUnit::getExpandedRegion().

81 { return CSGSurface::getName(); }
const std::string & getName() const
Get the name of surface.
Definition: CSGSurface.h:90

◆ getNumSides()

int CSG::CSGNPolygonUnit::getNumSides ( )
inline

Get the number of sides for the polygon.

Returns
number of sides

Definition at line 80 of file CSGNPolygonUnit.h.

80 { return _n_sides; }
const int _n_sides
Number of sides of the regular polygon.

◆ getRadius()

Real CSG::CSGNPolygonUnit::getRadius ( )
inline

Get the the circumradius for the polygon (center-to-vertex distance)

Returns
radius value

Definition at line 101 of file CSGNPolygonUnit.h.

101 { return _apothem / (std::cos(M_PI / _n_sides)); }
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
const int _n_sides
Number of sides of the regular polygon.
const Real _apothem
Distance from the polygon center to the midpoint of each side.

◆ getSideLength()

Real CSG::CSGNPolygonUnit::getSideLength ( )
inline

Get the polygon side length.

Returns
side length

Definition at line 94 of file CSGNPolygonUnit.h.

94 { return 2.0 * _apothem * std::tan(M_PI / _n_sides); }
const int _n_sides
Number of sides of the regular polygon.
const Real _apothem
Distance from the polygon center to the midpoint of each side.

◆ getSurfaceType()

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

Get the Surface Type.

Returns
type of surface

Definition at line 53 of file CSGSurface.h.

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

54  {
55  return MooseUtils::prettyCppType(libMesh::demangle(typeid(*this).name()));
56  }
std::string demangle(const char *name)
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1151

◆ getTransformations()

const std::vector<std::pair<TransformationType, std::tuple<Real, Real, Real> > >& CSG::CSGSurfaceEngUnit::getTransformations ( ) const
inlineoverridevirtualinherited

Delegate to CSGSurface (CSGTransformationHelper)

Implements CSG::CSGEngUnit.

Definition at line 92 of file CSGSurfaceEngUnit.h.

93  {
95  }
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const
Get the list of transformations.

◆ getTransformationsAsStrings()

std::vector<std::pair<std::string, std::tuple<Real, Real, Real> > > CSG::CSGSurfaceEngUnit::getTransformationsAsStrings ( ) const
inlineoverridevirtualinherited

Delegate to CSGSurface (CSGTransformationHelper)

Implements CSG::CSGEngUnit.

Definition at line 99 of file CSGSurfaceEngUnit.h.

100  {
102  }
std::vector< std::pair< std::string, std::tuple< Real, Real, Real > > > getTransformationsAsStrings() const
Get the transformations of this object with string representations for types.

◆ getTransformationTypeString()

std::string CSG::CSGTransformationHelper::getTransformationTypeString ( TransformationType  type)
staticinherited

Get the string representation of the transformation type.

Parameters
typeThe transformation type
Returns
String name of the transformation type

Definition at line 56 of file CSGTransformationHelper.C.

Referenced by CSG::CSGTransformationHelper::addTransformation(), and CSG::CSGTransformationHelper::getTransformationsAsStrings().

57 {
58  // Set the enum to the value and convert it to string
60  enum_copy = static_cast<int>(type);
61  return std::string(enum_copy);
62 }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:54
static const MooseEnum transformation_type_enum
MooseEnum for transformation types, matching the TransformationType enum values.

◆ getUnitType()

const std::string CSG::CSGEngUnit::getUnitType ( ) const
inlineinherited

Get the type name of this engineering unit.

Returns
the unit type string

Definition at line 63 of file CSGEngUnit.h.

Referenced by CSG::CSGCellEngUnit::getExpandedCell(), CSG::CSGUniverseEngUnit::getExpandedUniverse(), and CSG::CSGEngUnit::operator==().

64  {
65  return MooseUtils::prettyCppType(libMesh::demangle(typeid(*this).name()));
66  }
std::string demangle(const char *name)
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1151

◆ isEngUnit()

bool CSG::CSGSurfaceEngUnit::isEngUnit ( ) const
inlineoverridevirtualinherited

Engineering units report true so comparisons can skip the dynamic_cast fast path.

Reimplemented from CSG::CSGSurface.

Definition at line 84 of file CSGSurfaceEngUnit.h.

84 { return true; }

◆ isValidTransformationValue()

bool CSG::CSGTransformationHelper::isValidTransformationValue ( TransformationType  type,
const std::tuple< Real, Real, Real > &  values 
)
staticinherited

Check if the transformation value is valid for the given type.

Parameters
typeThe type of transformation
valuesThe values for the transformation
Returns
True if the values are valid for the type

Definition at line 26 of file CSGTransformationHelper.C.

Referenced by CSG::CSGTransformationHelper::addTransformation().

28 {
29  // Additional validation specific to each transformation type could be added here
30  switch (type)
31  {
33  // All translation values are inherently valid
34  return true;
35 
37  // Rotation uses euler notation; values are angles in degrees (phi, theta, psi)
38  // For consistency with TransformGenerator, there are no restrictions on the angles
39  // phi: rotation around Z-axis
40  // theta: rotation around new X-axis
41  // psi: rotation around new Z-axis
42  return true;
43 
45  // Scaling factors should be non-zero
46  if (std::get<0>(values) == 0.0 || std::get<1>(values) == 0.0 || std::get<2>(values) == 0.0)
47  return false;
48  return true;
49 
50  default:
51  mooseError("Unknown transformation type");
52  }
53 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::array< Real, 2 > values
Definition: MortarUtils.C:52

◆ operator!=() [1/3]

bool CSG::CSGSurfaceEngUnit::operator!= ( const CSGSurfaceEngUnit other) const
inlineinherited

Definition at line 88 of file CSGSurfaceEngUnit.h.

88 { return CSGEngUnit::operator!=(other); }
bool operator!=(const CSGEngUnit &other) const
Operator overload for checking if two CSGEngUnit objects are not equal.
Definition: CSGEngUnit.C:50

◆ operator!=() [2/3]

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

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

Definition at line 50 of file CSGEngUnit.C.

Referenced by CSG::CSGCellEngUnit::operator!=(), CSG::CSGUniverseEngUnit::operator!=(), and CSG::CSGSurfaceEngUnit::operator!=().

51 {
52  return !(*this == other);
53 }

◆ operator!=() [3/3]

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

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

Definition at line 65 of file CSGSurface.C.

66 {
67  return !(*this == other);
68 }

◆ operator==() [1/3]

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

Operator overload for checking if two CSGEngUnit objects are equal.

Definition at line 34 of file CSGEngUnit.C.

Referenced by CSG::CSGCellEngUnit::operator==(), CSG::CSGUniverseEngUnit::operator==(), and CSG::CSGSurfaceEngUnit::operator==().

35 {
36  if (getName() != other.getName())
37  return false;
38  if (getBehavior() != other.getBehavior())
39  return false;
40  if (getUnitType() != other.getUnitType())
41  return false;
42  if (getAttributes() != other.getAttributes())
43  return false;
44  if (getTransformations() != other.getTransformations())
45  return false;
46  return true;
47 }
virtual const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const =0
Get the list of transformations applied to this engineering unit.
const std::string getUnitType() const
Get the type name of this engineering unit.
Definition: CSGEngUnit.h:63
virtual std::unordered_map< std::string, AttributeVariant > getAttributes() const =0
Get the attributes that define this engineering unit.
const std::string getBehavior() const
Get the behavior of this engineering unit (surface (i.e.
Definition: CSGEngUnit.h:56
virtual const std::string & getName() const =0
Get the unique instance name of this engineering unit.

◆ operator==() [2/3]

bool CSG::CSGSurfaceEngUnit::operator== ( const CSGSurfaceEngUnit other) const
inlineinherited

Disambiguate == and != by forwarding to CSGEngUnit (name/property-based comparison)

Definition at line 87 of file CSGSurfaceEngUnit.h.

87 { return CSGEngUnit::operator==(other); }
bool operator==(const CSGEngUnit &other) const
Operator overload for checking if two CSGEngUnit objects are equal.
Definition: CSGEngUnit.C:34

◆ operator==() [3/3]

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

Operator overload for checking if two CSGSurface objects are equal.

Definition at line 45 of file CSGSurface.C.

46 {
47  // If both objects are engineering units, delegate to CSGEngUnit::operator== to avoid
48  // calling getCoeffs(), which is not supported on engineering unit types. The isEngUnit()
49  // check keeps the common plain-surface path free of any dynamic_cast; the casts below
50  // only run once we know the objects are engineering units.
51  if (isEngUnit())
52  {
53  if (other.isEngUnit())
54  return *dynamic_cast<const CSGEngUnit *>(this) == *dynamic_cast<const CSGEngUnit *>(&other);
55  return false; // an engineering unit cannot equal a plain surface
56  }
57 
58  return (this->getName() == other.getName()) &&
59  (this->getSurfaceType() == other.getSurfaceType()) &&
60  (this->getCoeffs() == other.getCoeffs()) &&
61  (this->getTransformations() == other.getTransformations());
62 }
const std::string & getName() const
Get the name of surface.
Definition: CSGSurface.h:90
const std::string getSurfaceType() const
Get the Surface Type.
Definition: CSGSurface.h:53
virtual std::unordered_map< std::string, Real > getCoeffs() const =0
Get the coefficients that define the surface.
virtual bool isEngUnit() const
Whether this surface is an engineering unit.
Definition: CSGSurface.h:101
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const
Get the list of transformations.

◆ releaseBase()

std::unique_ptr< CSGBase > CSG::CSGEngUnit::releaseBase ( )
protectedinherited

Transfer ownership of the internal CSGBase out of this unit.

Called once by CSGBase::expandEngUnit() to join the internal base into the parent. After this call _internal_base is null.

Returns
unique_ptr to the internal CSGBase

Definition at line 28 of file CSGEngUnit.C.

29 {
30  return std::move(_internal_base);
31 }
std::unique_ptr< CSGBase > _internal_base
CSGBase populated by expandUnit(); joined into the parent CSGBase by expandEngUnit() ...
Definition: CSGEngUnit.h:130

◆ setName()

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

Definition at line 119 of file CSGSurface.h.

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

Member Data Documentation

◆ _apothem

const Real CSG::CSGNPolygonUnit::_apothem
private

Distance from the polygon center to the midpoint of each side.

Definition at line 126 of file CSGNPolygonUnit.h.

Referenced by clone(), CSGNPolygonUnit(), evaluateSurfaceEquationAtPoint(), expandUnit(), getApothem(), getAttributes(), getRadius(), and getSideLength().

◆ _behavior

MooseEnum CSG::CSGEngUnit::_behavior {"SURFACE CELL UNIVERSE"}
protectedinherited

The basic CSG type this unit produces: "SURFACE", "CELL", or "UNIVERSE".

Definition at line 133 of file CSGEngUnit.h.

Referenced by CSG::CSGEngUnit::CSGEngUnit(), and CSG::CSGEngUnit::getBehavior().

◆ _expanded_region

CSGRegion CSG::CSGSurfaceEngUnit::_expanded_region
protectedinherited

Stores the result of expandUnit(); EMPTY until then.

Definition at line 129 of file CSGSurfaceEngUnit.h.

Referenced by expandUnit(), and CSG::CSGSurfaceEngUnit::getExpandedRegion().

◆ _internal_base

std::unique_ptr<CSGBase> CSG::CSGEngUnit::_internal_base
protectedinherited

◆ _n_sides

const int CSG::CSGNPolygonUnit::_n_sides
private

Number of sides of the regular polygon.

Definition at line 123 of file CSGNPolygonUnit.h.

Referenced by clone(), CSGNPolygonUnit(), evaluateSurfaceEquationAtPoint(), expandUnit(), getAttributes(), getNumSides(), getRadius(), and getSideLength().

◆ _name

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

◆ _planes

std::vector<const CSGSurface *> CSG::CSGNPolygonUnit::_planes
private

Pointers to the expanded plane surfaces, populated during expandUnit()

Definition at line 129 of file CSGNPolygonUnit.h.

◆ _transformations

std::vector<std::pair<TransformationType, std::tuple<Real, Real, Real> > > CSG::CSGTransformationHelper::_transformations
protectedinherited

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