https://mooseframework.inl.gov
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 
18 namespace CSG
19 {
20 
21 class CSGBase;
22 
41 {
42 public:
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 
103 protected:
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 
121 private:
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
std::string name(const ElemQuality q)
CSGNPolygonUnit(const std::string &name, int n_sides, Real apothem)
Construct a new CSGNPolygonUnit.
FRIEND_TEST(CSGEngUnitTest, testPolygonUnitExpansion)
Real evaluateSurfaceEquationAtPoint(const Point &p) const override
Evaluate the polygon&#39;s surface equation at the given point.
std::vector< const CSGSurface * > _planes
Pointers to the expanded plane surfaces, populated during expandUnit()
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
std::unique_ptr< CSGSurface > clone() const override
Return a deep copy of this unit.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::string _name
Name of surface.
Definition: CSGSurface.h:122
Real getSideLength()
Get the polygon side length.
Real getRadius()
Get the the circumradius for the polygon (center-to-vertex distance)
Real getApothem()
Get the polygon apothem (center-to-flat distance)
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.
CSGNPolygonUnit is a CSGSurfaceEngUnit that represents a regular N-sided polygon (prismatic region) w...
std::unordered_map< std::string, AttributeVariant > getAttributes() const override
Return the polygon attributes for this object.
CSGSurfaceEngUnit is an abstract base class for "engineering units" that can be used as surfaces in c...
int getNumSides()
Get the number of sides for the polygon.
void expandUnit() override
Create N CSGPlane surfaces in _internal_base, one per polygon side.