https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CSGNPolygonUnit.h
Go to the documentation of this file.
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#ifdef MOOSE_UNIT_TEST
13#include "gtest/gtest.h"
14#endif
15
16#include "CSGSurfaceEngUnit.h"
17
18namespace CSG
19{
20
21class CSGBase;
22
41{
42public:
50 CSGNPolygonUnit(const std::string & name, int n_sides, Real apothem);
51
64 Real evaluateSurfaceEquationAtPoint(const Point & p) const override;
65
71 std::unordered_map<std::string, AttributeVariant> getAttributes() const override;
72
73 // helper getter functions to get additional polygon dimensions/attributes
74
80 int getNumSides() { return _n_sides; }
81
87 Real getApothem() { return _apothem; }
88
94 Real getSideLength() { return 2.0 * _apothem * std::tan(M_PI / _n_sides); }
95
101 Real getRadius() { return _apothem / (std::cos(M_PI / _n_sides)); }
102
103protected:
109 std::unique_ptr<CSGSurface> clone() const override
110 {
111 return std::make_unique<CSGNPolygonUnit>(_name, _n_sides, _apothem);
112 }
113
119 void expandUnit() override;
120
121private:
123 const int _n_sides;
124
126 const Real _apothem;
127
129 std::vector<const CSGSurface *> _planes;
130
131#ifdef MOOSE_UNIT_TEST
132 FRIEND_TEST(CSGEngUnitTest, testPolygonUnitExpansion);
133 FRIEND_TEST(CSGEngUnitTest, testPolygonUnitClone);
134#endif
135};
136
137} // namespace CSG
CSGNPolygonUnit is a CSGSurfaceEngUnit that represents a regular N-sided polygon (prismatic region) w...
int getNumSides()
Get the number of sides for the polygon.
std::vector< const CSGSurface * > _planes
Pointers to the expanded plane surfaces, populated during expandUnit()
std::unique_ptr< CSGSurface > clone() const override
Return a deep copy of this unit.
Real getApothem()
Get the polygon apothem (center-to-flat distance)
Real evaluateSurfaceEquationAtPoint(const Point &p) const override
Evaluate the polygon's surface equation at the given point.
std::unordered_map< std::string, AttributeVariant > getAttributes() const override
Return the polygon attributes for this object.
FRIEND_TEST(CSGEngUnitTest, testPolygonUnitExpansion)
const int _n_sides
Number of sides of the regular polygon.
Real getRadius()
Get the the circumradius for the polygon (center-to-vertex distance)
Real getSideLength()
Get the polygon side length.
void expandUnit() override
Create N CSGPlane surfaces in _internal_base, one per polygon side.
const Real _apothem
Distance from the polygon center to the midpoint of each side.
FRIEND_TEST(CSGEngUnitTest, testPolygonUnitClone)
CSGSurfaceEngUnit is an abstract base class for "engineering units" that can be used as surfaces in c...
std::string _name
Name of surface.
Definition CSGSurface.h:122