File indexing completed on 2025-01-18 10:14:16
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDTET_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDTET_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/TetStruct.h" // the pure Tet struct
0018 #include "VecGeom/volumes/kernel/TetImplementation.h"
0019 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0020
0021 namespace vecgeom {
0022
0023 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedTet;);
0024 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedTet);
0025
0026 inline namespace VECGEOM_IMPL_NAMESPACE {
0027
0028
0029
0030
0031
0032 class UnplacedTet : public SIMDUnplacedVolumeImplHelper<TetImplementation>, public AlignedBase {
0033
0034 private:
0035 TetStruct<Precision> fTet;
0036
0037 public:
0038
0039 VECCORE_ATT_HOST_DEVICE
0040 UnplacedTet();
0041
0042
0043
0044
0045
0046
0047 VECCORE_ATT_HOST_DEVICE
0048 UnplacedTet(const Vector3D<Precision> &p0, const Vector3D<Precision> &p1, const Vector3D<Precision> &p2,
0049 const Vector3D<Precision> &p3);
0050
0051
0052
0053
0054
0055
0056 VECCORE_ATT_HOST_DEVICE
0057 UnplacedTet(const Precision p0[], const Precision p1[], const Precision p2[], const Precision p3[])
0058 : fTet(p0, p1, p2, p3)
0059 {
0060 fGlobalConvexity = true;
0061 }
0062
0063
0064 VECCORE_ATT_HOST_DEVICE
0065 TetStruct<Precision> const &GetStruct() const { return fTet; }
0066
0067
0068
0069
0070
0071
0072 VECCORE_ATT_HOST_DEVICE
0073 VECGEOM_FORCE_INLINE
0074 void GetVertices(Vector3D<Precision> &p0, Vector3D<Precision> &p1, Vector3D<Precision> &p2,
0075 Vector3D<Precision> &p3) const
0076 {
0077 p0 = fTet.fVertex[0];
0078 p1 = fTet.fVertex[1];
0079 p2 = fTet.fVertex[2];
0080 p3 = fTet.fVertex[3];
0081 }
0082
0083 VECCORE_ATT_HOST_DEVICE
0084 void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0085
0086 Precision Capacity() const override { return fTet.fCubicVolume; }
0087
0088 Precision SurfaceArea() const override { return fTet.fSurfaceArea; }
0089
0090 Vector3D<Precision> SamplePointOnSurface() const override;
0091
0092 VECCORE_ATT_HOST_DEVICE
0093 virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0094 {
0095 bool valid;
0096 normal = TetImplementation::NormalKernel(fTet, p, valid);
0097 return valid;
0098 }
0099
0100
0101
0102 std::string GetEntityType() const;
0103
0104 VECCORE_ATT_HOST_DEVICE
0105 void GetParametersList(int aNumber, Precision *aArray) const;
0106
0107 std::ostream &StreamInfo(std::ostream &os) const;
0108
0109 public:
0110 virtual int MemorySize() const final { return sizeof(*this); }
0111
0112 VECCORE_ATT_HOST_DEVICE
0113 virtual void Print() const override;
0114
0115 virtual void Print(std::ostream &os) const override;
0116
0117 #ifndef VECCORE_CUDA
0118 virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0119 #endif
0120
0121 #ifdef VECGEOM_CUDA_INTERFACE
0122 virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedTet>::SizeOf(); }
0123 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0124 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0125 #endif
0126
0127
0128 #ifndef VECCORE_CUDA
0129 template <TranslationCode trans_code, RotationCode rot_code>
0130 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0131 VPlacedVolume *const placement = NULL);
0132
0133 VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0134 const TranslationCode trans_code, const RotationCode rot_code,
0135 VPlacedVolume *const placement) const override;
0136 #else
0137 template <TranslationCode trans_code, RotationCode rot_code>
0138 VECCORE_ATT_DEVICE
0139 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0140 const int id, const int copy_no, const int child_id,
0141 VPlacedVolume *const placement = NULL);
0142 VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0143 Transformation3D const *const transformation,
0144 const TranslationCode trans_code, const RotationCode rot_code,
0145 const int id, const int copy_no, const int child_id,
0146 VPlacedVolume *const placement) const override;
0147
0148 #endif
0149 };
0150 }
0151 }
0152
0153 #endif