10 const double rmin,
const double rmax,
const double lz)
11 :
Solid(cx, cy, cz,
"SolidTube"),
18 const double rmin,
const double rmax,
const double lz,
19 const double dx,
const double dy,
const double dz)
25 const double r,
const double lz)
29 const double r,
const double lz,
const double dx,
30 const double dy,
const double dz)
31 :
SolidTube(cx, cy, cz, 0., r, lz, dx, dy, dz) {}
35 double u = x, v = y, w = z;
40 std::cout <<
"SolidTube::IsInside: (" << x <<
", " << y <<
", " << z
46 const double r = sqrt(u * u + v * v);
47 if (r >= m_rMin && r <= m_rMax) {
49 std::cout <<
"SolidTube::IsInside: (" << x <<
", " << y <<
", " << z
56 std::cout <<
"SolidTube::IsInside: (" << x <<
", " << y <<
", " << z
63 double& xmax,
double& ymax,
double& zmax)
const {
74 const double dd = sqrt(m_rMax * m_rMax + m_lZ * m_lZ);
86 std::cerr <<
"SolidTube::SetInnerRadius: Radius must be > 0.\n";
90 std::cerr <<
"SolidTube::SetInnerRadius:\n";
91 std::cerr <<
" Inner radius must be smaller than outer radius.\n";
99 std::cerr <<
"SolidTube::SetOuterRadius: Radius must be > 0.\n";
102 if (rmax <= m_rMin) {
103 std::cerr <<
"SolidTube::SetOuterRadius:\n";
104 std::cerr <<
" Outer radius must be greater than inner radius.\n";
112 std::cerr <<
"SolidTube::SetRadius: Radius must be > 0.\n";
120 std::cerr <<
"SolidTube::SetHalfLength: Half-length must be > 0.\n";
128 std::cerr <<
"SolidTube::SetSectors: Number must be > 0.\n";
146 const auto id =
GetId();
147 const unsigned int nPanels = panels.size();
151 std::cerr <<
"SolidTube::SolidPanels:\n"
152 <<
" Zero norm direction vector; no panels generated.\n";
159 const double alpha = Pi / (4. * (m_n - 1.));
160 r = 2 * m_r / (1. + asinh(tan(alpha)) * cos(alpha) / tan(alpha));
163 const unsigned int nPoints = 4 * (m_n - 1);
166 std::vector<double> xv;
167 std::vector<double> yv;
168 std::vector<double> zv;
169 for (
unsigned int i = 1; i <= nPoints; i++) {
170 const double alpha = m_rot + HalfPi * (i - 1.) / (m_n - 1.);
172 ToGlobal(r * cos(alpha), r * sin(alpha), m_lZ, x, y, z);
187 panels.push_back(std::move(newpanel));
191 std::vector<double> xv;
192 std::vector<double> yv;
193 std::vector<double> zv;
194 for (
unsigned int i = 1; i <= nPoints; i++) {
195 const double alpha = m_rot + HalfPi * (i - 1.) / (m_n - 1.);
197 ToGlobal(r * cos(alpha), r * sin(alpha), -m_lZ, x, y, z);
212 panels.push_back(std::move(newpanel));
215 double u = r * cos(m_rot);
216 double v = r * sin(m_rot);
218 double xv0, yv0, zv0;
219 ToGlobal(u, v, -m_lZ, xv0, yv0, zv0);
220 double xv1, yv1, zv1;
221 ToGlobal(u, v, +m_lZ, xv1, yv1, zv1);
223 for (
unsigned int i = 2; i <= nPoints + 1; i++) {
225 double alpha = m_rot + HalfPi * (i - 1.) / (m_n - 1.);
229 double xv2, yv2, zv2;
230 ToGlobal(u, v, +m_lZ, xv2, yv2, zv2);
231 double xv3, yv3, zv3;
232 ToGlobal(u, v, -m_lZ, xv3, yv3, zv3);
235 alpha = m_rot + HalfPi * (i - 1.5) / (m_n - 1.);
236 const double cAlpha = cos(alpha);
237 const double sAlpha = sin(alpha);
241 newpanel.
xv = {xv0, xv1, xv2, xv3};
242 newpanel.
yv = {yv0, yv1, yv2, yv3};
243 newpanel.
zv = {zv0, zv1, zv2, zv3};
246 panels.push_back(std::move(newpanel));
255 std::cout <<
"SolidTube::SolidPanels: " << panels.size() - nPanels
263 double u = 0., v = 0., w = 0.;
266 if (w > std::max(std::abs(u), std::abs(v))) {
268 }
else if (w < -std::max(std::abs(u), std::abs(v))) {
bool SolidPanels(std::vector< Panel > &panels) override
Retrieve the surface panels of the solid.
void SetInnerRadius(const double rmin)
double GetDiscretisationLevel(const Panel &panel) override
Retrieve the discretization level of a panel.
void SetOuterRadius(const double rmax)
void SetSectors(const unsigned int n)
void SetHalfLength(const double lz)
void SetRadius(const double r)
bool IsInside(const double x, const double y, const double z) const override
Check whether a given point is inside the solid.
SolidTube(const double cx, const double cy, const double cz, const double rmin, const double rmax, const double lz)
Constructor from centre, inner/outer radii, and half-length.
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const override
Return the bounding box of the solid.
Abstract base class for solids.
void VectorToLocal(const double x, const double y, const double z, double &u, double &v, double &w)
Transform a vector from global to local coordinates.
double m_cTheta
Polar angle.
double m_dX
Direction vector.
unsigned int GetId() const
Get the ID of the solid.
void ToLocal(const double x, const double y, const double z, double &u, double &v, double &w) const
void SetDirection(const double dx, const double dy, const double dz)
void ToGlobal(const double u, const double v, const double w, double &x, double &y, double &z) const
double m_cX
Centre of the solid.
double m_cPhi
Azimuthal angle.
std::vector< double > zv
Z-coordinates of vertices.
int volume
Reference to solid to which the panel belongs.
double a
Perpendicular vector.
double colour
Colour index.
std::vector< double > xv
X-coordinates of vertices.
std::vector< double > yv
Y-coordinates of vertices.