File indexing completed on 2025-01-18 10:14:14
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDELLIPSOID_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDELLIPSOID_H_
0011
0012 #include "VecGeom/base/Cuda.h"
0013 #include "VecGeom/base/Global.h"
0014 #include "VecGeom/base/AlignedBase.h"
0015 #include "VecGeom/base/Vector3D.h"
0016 #include "VecGeom/volumes/UnplacedVolume.h"
0017 #include "VecGeom/volumes/EllipsoidStruct.h"
0018 #include "VecGeom/volumes/kernel/EllipsoidImplementation.h"
0019 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0020
0021 namespace vecgeom {
0022
0023 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedEllipsoid;);
0024 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedEllipsoid);
0025
0026 inline namespace VECGEOM_IMPL_NAMESPACE {
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 class UnplacedEllipsoid : public SIMDUnplacedVolumeImplHelper<EllipsoidImplementation>, public AlignedBase {
0038
0039 private:
0040 EllipsoidStruct<Precision> fEllipsoid;
0041
0042
0043 VECCORE_ATT_HOST_DEVICE
0044 void CheckParameters();
0045
0046
0047 VECCORE_ATT_HOST_DEVICE
0048 Precision LateralSurfaceArea() const;
0049
0050 public:
0051
0052 VECCORE_ATT_HOST_DEVICE
0053 UnplacedEllipsoid();
0054
0055
0056
0057
0058
0059
0060
0061 VECCORE_ATT_HOST_DEVICE
0062 UnplacedEllipsoid(Precision dx, Precision dy, Precision dz, Precision zBottomCut = 0., Precision zTopCut = 0.);
0063
0064
0065 VECCORE_ATT_HOST_DEVICE
0066 EllipsoidStruct<Precision> const &GetStruct() const { return fEllipsoid; }
0067
0068
0069 VECCORE_ATT_HOST_DEVICE
0070 VECGEOM_FORCE_INLINE
0071 Precision GetDx() const { return fEllipsoid.fDx; }
0072
0073
0074 VECCORE_ATT_HOST_DEVICE
0075 VECGEOM_FORCE_INLINE
0076 Precision GetDy() const { return fEllipsoid.fDy; }
0077
0078
0079 VECCORE_ATT_HOST_DEVICE
0080 VECGEOM_FORCE_INLINE
0081 Precision GetDz() const { return fEllipsoid.fDz; }
0082
0083
0084 VECCORE_ATT_HOST_DEVICE
0085 VECGEOM_FORCE_INLINE
0086 Precision GetZBottomCut() const { return fEllipsoid.fZBottomCut; }
0087
0088
0089 VECCORE_ATT_HOST_DEVICE
0090 VECGEOM_FORCE_INLINE
0091 Precision GetZTopCut() const { return fEllipsoid.fZTopCut; }
0092
0093
0094
0095
0096
0097 VECCORE_ATT_HOST_DEVICE
0098 VECGEOM_FORCE_INLINE
0099 void SetSemiAxes(Precision dx, Precision dy, Precision dz)
0100 {
0101 fEllipsoid.fDx = dx;
0102 fEllipsoid.fDy = dy;
0103 fEllipsoid.fDz = dz;
0104 CheckParameters();
0105 };
0106
0107
0108
0109
0110 VECCORE_ATT_HOST_DEVICE
0111 VECGEOM_FORCE_INLINE
0112 void SetZCuts(Precision zBottomCut, Precision zTopCut)
0113 {
0114 fEllipsoid.fZBottomCut = zBottomCut;
0115 fEllipsoid.fZTopCut = zTopCut;
0116 CheckParameters();
0117 };
0118
0119 VECCORE_ATT_HOST_DEVICE
0120 void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0121
0122 Precision Capacity() const override { return fEllipsoid.fCubicVolume; }
0123
0124 Precision SurfaceArea() const override { return fEllipsoid.fSurfaceArea; }
0125
0126 Vector3D<Precision> SamplePointOnSurface() const override;
0127
0128 VECCORE_ATT_HOST_DEVICE
0129 virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0130 {
0131 bool valid;
0132 normal = EllipsoidImplementation::NormalKernel(fEllipsoid, p, valid);
0133 return valid;
0134 }
0135
0136
0137 std::string GetEntityType() const { return "Ellipsoid"; }
0138
0139
0140 std::ostream &StreamInfo(std::ostream &os) const;
0141
0142 public:
0143 virtual int MemorySize() const final { return sizeof(*this); }
0144
0145 VECCORE_ATT_HOST_DEVICE
0146 virtual void Print() const override;
0147
0148 virtual void Print(std::ostream &os) const override;
0149
0150 #ifndef VECCORE_CUDA
0151 virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0152 #endif
0153
0154 #ifdef VECGEOM_CUDA_INTERFACE
0155 virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedEllipsoid>::SizeOf(); }
0156 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0157 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0158 #endif
0159
0160
0161 #ifndef VECCORE_CUDA
0162 template <TranslationCode trans_code, RotationCode rot_code>
0163 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0164 VPlacedVolume *const placement = NULL);
0165
0166 VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0167 const TranslationCode trans_code, const RotationCode rot_code,
0168 VPlacedVolume *const placement) const override;
0169 #else
0170 template <TranslationCode trans_code, RotationCode rot_code>
0171 VECCORE_ATT_DEVICE
0172 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0173 const int id, const int copy_no, const int child_id,
0174 VPlacedVolume *const placement = NULL);
0175 VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0176 Transformation3D const *const transformation,
0177 const TranslationCode trans_code, const RotationCode rot_code,
0178 const int id, const int copy_no, const int child_id,
0179 VPlacedVolume *const placement) const override;
0180
0181 #endif
0182 };
0183 }
0184 }
0185
0186 #endif