Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:16

0001 // This file is part of VecGeom and is distributed under the
0002 // conditions in the file LICENSE.txt in the top directory.
0003 // For the full list of authors see CONTRIBUTORS.txt and `git log`.
0004 
0005 /// Declaration of the unplaced tetrahedron shape
0006 /// @file volumes/UnplaceTet.h
0007 /// @author Raman Sehgal, Evgueni Tcherniaev
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 /// Class for tetrahedron shape primitive
0029 ///
0030 /// Tetrahedron, also known as a triangular pyramid, is a polyhedron composed
0031 /// by four triangular faces. It is completely defined by its four vertices.
0032 class UnplacedTet : public SIMDUnplacedVolumeImplHelper<TetImplementation>, public AlignedBase {
0033 
0034 private:
0035   TetStruct<Precision> fTet; ///< The structure with the tetrahedron data members
0036 
0037 public:
0038   /// Default constructor
0039   VECCORE_ATT_HOST_DEVICE
0040   UnplacedTet();
0041 
0042   /// Constructor from four points
0043   /// @param [in] p0 Point given as 3D vector
0044   /// @param [in] p1 Point given as 3D vector
0045   /// @param [in] p2 Point given as 3D vector
0046   /// @param [in] p3 Point given as 3D vector
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   /// Constructor from four points
0052   /// @param [in] p0 Point given as array
0053   /// @param [in] p1 Point given as array
0054   /// @param [in] p2 Point given as array
0055   /// @param [in] p3 Point given as array
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   /// Getter for the structure storing the tetrahedron data
0064   VECCORE_ATT_HOST_DEVICE
0065   TetStruct<Precision> const &GetStruct() const { return fTet; }
0066 
0067   /// Getter for the tetrahedron vertices
0068   /// @param [out] p0 Point given as 3D vector
0069   /// @param [out] p1 Point given as 3D vector
0070   /// @param [out] p2 Point given as 3D vector
0071   /// @param [out] p3 Point given as 3D vector
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   /// Get the solid type as string
0101   /// @return Name of the solid type
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   /// Templated factory for creating a placed volume
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 } // namespace VECGEOM_IMPL_NAMESPACE
0151 } // namespace vecgeom
0152 
0153 #endif