Files
karl/include/simulation/geometry.h
T
csendlinger a6a9ac388c Added a half-cylinder with a cone end as a geometry.
The cone starts at z=0 and has a height H_cone, the
cylinder starts at H_cone and ends at H_cone + H_cyl.
The radii of the cone and the cylinder are matched.
It's important to note that the injector still injects particles
across the whole "bounding cylinder", but particles
outside of the actual region are removed after their
first movement step without being deposited.
2026-04-28 14:00:10 +02:00

63 lines
1.8 KiB
C++
Executable File

#ifndef GEOMETRY_H
#define GEOMETRY_H
#include "simulation/coordinates.h"
enum class GeometryPositioning {
bottom,
top,
hull,
inside
};
class Geometry {
public:
virtual bool isInside(const Coordinate& position) const = 0;
virtual GeometryPositioning isWhere(const Coordinate& position) const = 0;
};
class Cylinder : public Geometry {
public:
Cylinder(double radius, double height);
bool isInside(const Coordinate& position) const;
GeometryPositioning isWhere(const Coordinate& position) const;
private:
const double radius_;
const double height_;
};
/*
/|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾\ ‾‾‾
/ | | \ ^
/ | | \ |
/ | | \ | R_cylinder
/ | | \ ⌄
|<-->|<------------------>|<------------------><---> ---
z=0 ^ ^ |
| | |
H_cone H_cylinder symmetry axis
The geometry will only know 3 regions, "inside", "hull", "top". Meaning the
cone will always have the same boundary condition as the cylinder boundary.
*/
/*
Geometry of a cylinder with a cone as the end at z=0.
*/
class HalfCylinderWithCone : public Geometry {
public:
HalfCylinderWithCone(double radiusCylinder, double heightCylinder,
double heightCone);
bool isInside(const Coordinate& position) const;
GeometryPositioning isWhere(const Coordinate& position) const;
private:
const double cylinder_radius_;
const double cylinder_height_;
const double cone_height_;
double localRadius(double z) const;
};
#endif /* GEOMETRY_H */