https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CSGSurface.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 "MooseApp.h"
18
19namespace CSG
20{
21
27{
28public:
30 enum class Halfspace
31 {
34 };
35
41 CSGSurface(const std::string & name);
42
46 virtual ~CSGSurface() = default;
47
53 const std::string getSurfaceType() const
54 {
55 return MooseUtils::prettyCppType(libMesh::demangle(typeid(*this).name()));
56 }
57
63 virtual std::unordered_map<std::string, Real> getCoeffs() const = 0; // Pure virtual function
64
74 virtual Real evaluateSurfaceEquationAtPoint(const Point & p) const = 0; // Pure virtual function
75
83 CSGSurface::Halfspace getHalfspaceFromPoint(const Point & p) const;
84
90 const std::string & getName() const { return _name; }
91
101 virtual bool isEngUnit() const { return false; }
102
104 bool operator==(const CSGSurface & other) const;
105
107 bool operator!=(const CSGSurface & other) const;
108
109protected:
115 virtual std::unique_ptr<CSGSurface> clone() const = 0; // Pure virtual function
116
117 // set the name of the surface - intentionally not public because
118 // name needs to be managed at the CSGSurfaceList level
119 void setName(const std::string & name) { _name = name; }
120
122 std::string _name;
123
124 // CSGSurfaceList needs to be friend to access setName()
125 friend class CSGSurfaceList;
126 friend class CSGBase; // needed for addTransformation() access
127
128#ifdef MOOSE_UNIT_TEST
131 FRIEND_TEST(CSGSurfaceTest, testSetName);
132 FRIEND_TEST(CSGSurfaceTest, testSurfaceEquality);
134#endif
135};
136} // namespace CSG
CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model.
Definition CSGBase.h:54
CSGSurfaceList is a container for storing CSGSurface objects in the CSGBase object.
CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface,...
Definition CSGSurface.h:27
virtual ~CSGSurface()=default
Destructor.
FRIEND_TEST(CSGSurfaceTest, testSurfaceEquality)
Halfspace
Enum for the sign of the half-space being represented by a point and surface.
Definition CSGSurface.h:31
bool operator==(const CSGSurface &other) const
Operator overload for checking if two CSGSurface objects are equal.
Definition CSGSurface.C:45
const std::string getSurfaceType() const
Get the Surface Type.
Definition CSGSurface.h:53
FRIEND_TEST(CSGSurfaceTest, testSetName)
Friends for unit testing.
std::string _name
Name of surface.
Definition CSGSurface.h:122
bool operator!=(const CSGSurface &other) const
Operator overload for checking if two CSGSurface objects are not equal.
Definition CSGSurface.C:65
CSGSurface::Halfspace getHalfspaceFromPoint(const Point &p) const
given a point, determine if it is in the positive or negative half-space for the surface
Definition CSGSurface.C:23
virtual bool isEngUnit() const
Whether this surface is an engineering unit.
Definition CSGSurface.h:101
void setName(const std::string &name)
Definition CSGSurface.h:119
virtual Real evaluateSurfaceEquationAtPoint(const Point &p) const =0
given a point, determine its evaluation based on the surface equation.
const std::string & getName() const
Get the name of surface.
Definition CSGSurface.h:90
virtual std::unordered_map< std::string, Real > getCoeffs() const =0
Get the coefficients that define the surface.
virtual std::unique_ptr< CSGSurface > clone() const =0
Create clone of current surface, to be implemented by derived class.
Class for managing transformations in CSG objects.
std::string prettyCppType(const std::string &cpp_type)
std::string demangle(const char *name)