https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CSGSphere.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 "CSGSphere.h"
11
12namespace CSG
13{
14
15CSGSphere::CSGSphere(const std::string & name, const Point & center, const Real r)
16 : CSGSurface(name), _x0(center(0)), _y0(center(1)), _z0(center(2)), _r(r)
17{
19}
20
21CSGSphere::CSGSphere(const std::string & name, const Real r)
22 : CSGSurface(name), _x0(0.0), _y0(0.0), _z0(0.0), _r(r)
23{
25}
26
27std::unordered_map<std::string, Real>
29{
30 std::unordered_map<std::string, Real> coeffs = {{"x0", _x0}, {"y0", _y0}, {"z0", _z0}, {"r", _r}};
31 return coeffs;
32}
33
34Real
36{
37 // Compute distance from the sphere center to determine if inside (< r^2)
38 // or outside (> r^2) the sphere
39 const Real dist_sq =
40 Utility::pow<2>((p(0) - _x0)) + Utility::pow<2>((p(1) - _y0)) + Utility::pow<2>((p(2) - _z0));
41
42 return dist_sq - Utility::pow<2>(_r);
43}
44
45void
47{
48 if (_r <= 0.0)
49 mooseError("Radius of sphere must be positive.");
50}
51
52} // namespace CSG
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Point center
Definition MortarUtils.C:58
Real _r
Value of r in equation of sphere.
Definition CSGSphere.h:88
Real _z0
Value of z0 in equation of sphere.
Definition CSGSphere.h:85
void checkRadius() const
Definition CSGSphere.C:46
virtual std::unordered_map< std::string, Real > getCoeffs() const override
Get the coefficients (x0, y0, z0, r) for the equation of a sphere (x - x0)^2 + (y - y0)^2 + (z - z0)^...
Definition CSGSphere.C:28
CSGSphere(const std::string &name, const Point &center, const Real r)
Construct a new CSGSphere surface.
Definition CSGSphere.C:15
Real _x0
Value of x0 in equation of sphere.
Definition CSGSphere.h:79
virtual Real evaluateSurfaceEquationAtPoint(const Point &p) const override
given a point, determine its evaluation based on the equation of the sphere
Definition CSGSphere.C:35
Real _y0
Value of y0 in equation of sphere.
Definition CSGSphere.h:82
CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface,...
Definition CSGSurface.h:27