File indexing completed on 2025-01-18 10:14:15
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDPARALLELEPIPED_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDPARALLELEPIPED_H_
0011
0012 #include "VecGeom/base/Cuda.h"
0013 #include "VecGeom/base/AlignedBase.h"
0014 #include "VecGeom/base/Vector3D.h"
0015 #include "VecGeom/volumes/UnplacedVolume.h"
0016 #include "ParallelepipedStruct.h"
0017 #include "VecGeom/volumes/kernel/ParallelepipedImplementation.h"
0018 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0019
0020 namespace vecgeom {
0021
0022 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedParallelepiped;);
0023 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedParallelepiped);
0024
0025 inline namespace VECGEOM_IMPL_NAMESPACE {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class UnplacedParallelepiped : public SIMDUnplacedVolumeImplHelper<ParallelepipedImplementation>, public AlignedBase {
0036
0037 private:
0038 ParallelepipedStruct<Precision> fPara;
0039
0040 public:
0041 using Kernel = ParallelepipedImplementation;
0042
0043
0044
0045
0046
0047
0048 VECCORE_ATT_HOST_DEVICE
0049 UnplacedParallelepiped(Vector3D<Precision> const &dimensions, const Precision alpha, const Precision theta,
0050 const Precision phi)
0051 : fPara(dimensions, alpha, theta, phi)
0052 {
0053 fGlobalConvexity = true;
0054 ComputeBBox();
0055 }
0056
0057
0058
0059
0060
0061
0062
0063
0064 VECCORE_ATT_HOST_DEVICE
0065 UnplacedParallelepiped(const Precision dx, const Precision dy, const Precision dz, const Precision alpha,
0066 const Precision theta, const Precision phi)
0067 : fPara(dx, dy, dz, alpha, theta, phi)
0068 {
0069 fGlobalConvexity = true;
0070 ComputeBBox();
0071 }
0072
0073
0074 VECCORE_ATT_HOST_DEVICE
0075 UnplacedParallelepiped() : fPara(0., 0., 0., 0., 0., 0.) { fGlobalConvexity = true; }
0076
0077
0078 VECCORE_ATT_HOST_DEVICE
0079 ParallelepipedStruct<Precision> const &GetStruct() const { return fPara; }
0080
0081
0082 VECCORE_ATT_HOST_DEVICE
0083 Vector3D<Precision> const &GetDimensions() const { return fPara.fDimensions; }
0084
0085
0086 VECCORE_ATT_HOST_DEVICE
0087 Vector3D<Precision> const &GetNormal(int i) const { return fPara.fNormals[i]; }
0088
0089
0090 VECCORE_ATT_HOST_DEVICE
0091 Precision GetX() const { return fPara.fDimensions[0]; }
0092
0093
0094 VECCORE_ATT_HOST_DEVICE
0095 Precision GetY() const { return fPara.fDimensions[1]; }
0096
0097
0098 VECCORE_ATT_HOST_DEVICE
0099 Precision GetZ() const { return fPara.fDimensions[2]; }
0100
0101
0102 VECCORE_ATT_HOST_DEVICE
0103 Precision GetAlpha() const { return fPara.fAlpha; }
0104
0105
0106 VECCORE_ATT_HOST_DEVICE
0107 Precision GetTheta() const { return fPara.fTheta; }
0108
0109
0110 VECCORE_ATT_HOST_DEVICE
0111 Precision GetPhi() const { return fPara.fPhi; }
0112
0113
0114 VECCORE_ATT_HOST_DEVICE
0115 Precision GetTanAlpha() const { return fPara.fTanAlpha; }
0116
0117
0118 VECCORE_ATT_HOST_DEVICE
0119 Precision GetTanThetaSinPhi() const { return fPara.fTanThetaSinPhi; }
0120
0121
0122 VECCORE_ATT_HOST_DEVICE
0123 Precision GetTanThetaCosPhi() const { return fPara.fTanThetaCosPhi; }
0124
0125
0126 VECCORE_ATT_HOST_DEVICE
0127 Precision GetCtx() const { return fPara.fCtx; }
0128
0129
0130 VECCORE_ATT_HOST_DEVICE
0131 Precision GetCty() const { return fPara.fCty; }
0132
0133
0134
0135 VECCORE_ATT_HOST_DEVICE
0136 void SetDimensions(Vector3D<Precision> const &dimensions) { fPara.fDimensions = dimensions; }
0137
0138
0139
0140
0141
0142 VECCORE_ATT_HOST_DEVICE
0143 void SetDimensions(const Precision dx, const Precision dy, const Precision dz) { fPara.fDimensions.Set(dx, dy, dz); }
0144
0145
0146
0147 VECCORE_ATT_HOST_DEVICE
0148 void SetAlpha(const Precision alpha) { fPara.SetAlpha(alpha); }
0149
0150
0151
0152 VECCORE_ATT_HOST_DEVICE
0153 void SetTheta(const Precision theta) { fPara.SetTheta(theta); }
0154
0155
0156
0157 VECCORE_ATT_HOST_DEVICE
0158 void SetPhi(const Precision phi) { fPara.SetPhi(phi); }
0159
0160
0161
0162
0163 VECCORE_ATT_HOST_DEVICE
0164 void SetThetaAndPhi(const Precision theta, const Precision phi) { fPara.SetThetaAndPhi(theta, phi); }
0165
0166 virtual int MemorySize() const final { return sizeof(*this); }
0167
0168 VECCORE_ATT_HOST_DEVICE
0169 virtual void Print() const final;
0170
0171 virtual void Print(std::ostream &os) const final;
0172
0173 #ifndef VECCORE_CUDA
0174 virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0175 #endif
0176 VECCORE_ATT_HOST_DEVICE
0177 void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0178
0179
0180 Precision volume() const { return 8.0 * fPara.fDimensions[0] * fPara.fDimensions[1] * fPara.fDimensions[2]; }
0181
0182 Precision Capacity() const override { return volume(); }
0183
0184 Vector3D<Precision> SamplePointOnSurface() const override;
0185
0186 Precision SurfaceArea() const override { return 2. * (fPara.fAreas[0] + fPara.fAreas[1] + fPara.fAreas[2]); }
0187
0188 VECCORE_ATT_HOST_DEVICE
0189 virtual bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override
0190 {
0191 bool valid;
0192 normal = ParallelepipedImplementation::NormalKernel(fPara, point, valid);
0193 return valid;
0194 }
0195
0196
0197
0198 std::string GetEntityType() const { return "parallelepiped"; }
0199
0200
0201 template <TranslationCode transCodeT, RotationCode rotCodeT>
0202 #ifdef VECCORE_CUDA
0203 VECCORE_ATT_DEVICE
0204 #endif
0205 static VPlacedVolume *
0206 Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0207 #ifdef VECCORE_CUDA
0208 const int id, const int copy_no, const int child_id,
0209 #endif
0210 VPlacedVolume *const placement = NULL);
0211
0212 #ifdef VECGEOM_CUDA_INTERFACE
0213 virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedParallelepiped>::SizeOf(); }
0214 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0215 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0216 #endif
0217
0218 #ifdef VECCORE_CUDA
0219 VECCORE_ATT_DEVICE
0220 #endif
0221 virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0222 Transformation3D const *const transformation,
0223 const TranslationCode trans_code, const RotationCode rot_code,
0224 #ifdef VECCORE_CUDA
0225 const int id, const int copy_no, const int child_id,
0226 #endif
0227 VPlacedVolume *const placement = NULL) const final;
0228 };
0229 }
0230 }
0231
0232 #endif