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.
This commit is contained in:
@@ -26,4 +26,37 @@ class Cylinder : public Geometry {
|
||||
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 */
|
||||
|
||||
@@ -23,6 +23,32 @@ std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
|
||||
DEBUG_LEVEL_3("with height: " + std::to_string(height) + " m");
|
||||
#endif
|
||||
return std::shared_ptr<Geometry>(new Cylinder(radius, height));
|
||||
} else if(parameter.jsonObjectFromBase(
|
||||
json_path_append(path_to_geometry, {"HalfCylinderWithCone"}))) {
|
||||
|
||||
#ifdef debug
|
||||
DEBUG("Creating geometry: half cylinder with cone.");
|
||||
#endif
|
||||
double radius =
|
||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||
path_to_geometry, {"HalfCylinderWithCone", "Radius"})),
|
||||
"m");
|
||||
double heightcylinder =
|
||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||
path_to_geometry, {"HalfCylinderWithCone", "HeightCylinder"})),
|
||||
"m");
|
||||
double heightcone =
|
||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||
path_to_geometry, {"HalfCylinderWithCone", "HeightCone"})),
|
||||
"m");
|
||||
|
||||
#ifdef debug
|
||||
std::stringstream out;
|
||||
out << "height cyl: " << heightcylinder << ", height cone: " << heightcone << ", radius: " << radius << "\n";
|
||||
DEBUG(out.str());
|
||||
#endif
|
||||
return std::shared_ptr<Geometry>(
|
||||
new HalfCylinderWithCone(radius, heightcylinder, heightcone));
|
||||
} else {
|
||||
ERROR("This geometry is not implemented.");
|
||||
return nullptr;
|
||||
|
||||
@@ -23,3 +23,38 @@ GeometryPositioning Cylinder::isWhere(const Coordinate& position) const {
|
||||
return GeometryPositioning::inside;
|
||||
}
|
||||
}
|
||||
|
||||
HalfCylinderWithCone::HalfCylinderWithCone(double radiusCylinder, double heightCylinder,
|
||||
double heightCone) :
|
||||
cylinder_height_(heightCylinder),
|
||||
cylinder_radius_(radiusCylinder),
|
||||
cone_height_(heightCone) {}
|
||||
|
||||
bool HalfCylinderWithCone::isInside(const Coordinate& coordinate) const {
|
||||
const blitz::TinyVector<double, 3> cylinder_position = coordinate.cylinderEntries();
|
||||
return (cylinder_position(2) > 0) &&
|
||||
(cylinder_position(2) < (cylinder_height_ + cone_height_)) &&
|
||||
(cylinder_position(0) < localRadius(cylinder_position(2)));
|
||||
}
|
||||
|
||||
GeometryPositioning HalfCylinderWithCone::isWhere(const Coordinate& coordinate) const {
|
||||
const blitz::TinyVector<double, 3> cylinder_position = coordinate.cylinderEntries();
|
||||
if(cylinder_position(0) >= localRadius(cylinder_position(2))) {
|
||||
return GeometryPositioning::hull;
|
||||
} else if (cylinder_position(2) >= (cone_height_ + cylinder_height_)) {
|
||||
return GeometryPositioning::top;
|
||||
} else {
|
||||
return GeometryPositioning::inside;
|
||||
}
|
||||
}
|
||||
|
||||
double HalfCylinderWithCone::localRadius(double z) const {
|
||||
if(z >= cone_height_) {
|
||||
return cylinder_radius_;
|
||||
} else {
|
||||
// can potentially be negative, but that should be fine for a check if
|
||||
// the position is inside the geometry
|
||||
return z/cone_height_*cylinder_radius_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user