https://mooseframework.inl.gov
CSGSurface.C
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 #include "CSGSurface.h"
11 
12 namespace CSG
13 {
14 
15 CSGSurface::CSGSurface(const std::string & name, const std::string & surf_type)
16  : _name(name), _surface_type(surf_type)
17 {
18 }
19 
21 CSGSurface::getHalfspaceFromPoint(const Point & p) const
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 }
35 
36 bool
37 CSGSurface::operator==(const CSGSurface & other) const
38 {
39  return (this->getName() == other.getName()) &&
40  (this->getSurfaceType() == other.getSurfaceType()) &&
41  (this->getCoeffs() == other.getCoeffs());
42 }
43 
44 bool
45 CSGSurface::operator!=(const CSGSurface & other) const
46 {
47  return !(*this == other);
48 }
49 
50 } // namespace CSG
std::string name(const ElemQuality q)
const std::string & getName() const
Get the name of surface.
Definition: CSGSurface.h:95
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
Halfspace
Enum for the sign of the half-space being represented by a point and surface.
Definition: CSGSurface.h:30
virtual Real evaluateSurfaceEquationAtPoint(const Point &p) const =0
given a point, determine its evaluation based on the surface equation.
bool operator==(const CSGSurface &other) const
Operator overload for checking if two CSGSurface objects are equal.
Definition: CSGSurface.C:37
virtual std::unordered_map< std::string, Real > getCoeffs() const =0
Get the coefficients that define the surface.
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
CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface...
Definition: CSGSurface.h:26
CSGSurface(const std::string &name)
Default constructor.
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:21
bool operator!=(const CSGSurface &other) const
Operator overload for checking if two CSGSurface objects are not equal.
Definition: CSGSurface.C:45
const std::string & getSurfaceType() const
Get the Surface Type.
Definition: CSGSurface.h:61
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