https://mooseframework.inl.gov
CSGYCylinder.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 "CSGYCylinder.h"
11 
12 namespace CSG
13 {
14 
15 CSGYCylinder::CSGYCylinder(const std::string & name, const Real x0, const Real z0, const Real r)
16  : CSGSurface(name, MooseUtils::prettyCppType<CSGYCylinder>()), _x0(x0), _z0(z0), _r(r)
17 {
18  checkRadius();
19 }
20 
21 std::unordered_map<std::string, Real>
23 {
24  std::unordered_map<std::string, Real> coeffs = {{"x0", _x0}, {"z0", _z0}, {"r", _r}};
25  return coeffs;
26 }
27 
28 Real
30 {
31  // Compute distance from the cylinder center to determine if inside (< r^2)
32  // or outside (> r^2) the cylinder
33  const Real dist_sq = Utility::pow<2>((p(0) - _x0)) + Utility::pow<2>((p(2) - _z0));
34 
35  return dist_sq - Utility::pow<2>(_r);
36 }
37 
38 void
40 {
41  if (_r <= 0.0)
42  mooseError("Radius of y-cylinder must be positive.");
43 }
44 
45 } // namespace CSG
std::string name(const ElemQuality q)
void checkRadius() const
Definition: CSGYCylinder.C:39
virtual Real evaluateSurfaceEquationAtPoint(const Point &p) const override
given a point, determine its evaluation based on the equation of the cylinder
Definition: CSGYCylinder.C:29
virtual std::unordered_map< std::string, Real > getCoeffs() const override
Get the coefficients (x0, z0, and r) that define the cylindrical surface with the equation: (x - x0)^...
Definition: CSGYCylinder.C:22
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
CSGYCylinder creates an internal representation of a Constructive Solid Geometry (CSG) y-axis aligned...
Definition: CSGYCylinder.h:23
CSGYCylinder(const std::string &name, const Real x0, const Real z0, const Real r)
Construct a cylinder surface aligned with the y axis.
Definition: CSGYCylinder.C:15
Real _z0
Value of z0 in equation of an y-axis aligned cylinder.
Definition: CSGYCylinder.h:65
Real _r
Value of r in equation of an y-axis aligned cylinder.
Definition: CSGYCylinder.h:68
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface...
Definition: CSGSurface.h:26
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template pow< 2 >(tan(_arg))+1.0) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(sqrt
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1151
Real _x0
Value of x0 in equation of an y-axis aligned cylinder.
Definition: CSGYCylinder.h:62