GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSSolid.hh
Go to the documentation of this file.
1 #ifndef GUARD_GGEMS_GEOMETRIES_GGEMSSOLID_HH
2 #define GUARD_GGEMS_GEOMETRIES_GGEMSSOLID_HH
3 
4 // ************************************************************************
5 // * This file is part of GGEMS. *
6 // * *
7 // * GGEMS is free software: you can redistribute it and/or modify *
8 // * it under the terms of the GNU General Public License as published by *
9 // * the Free Software Foundation, either version 3 of the License, or *
10 // * (at your option) any later version. *
11 // * *
12 // * GGEMS is distributed in the hope that it will be useful, *
13 // * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 // * GNU General Public License for more details. *
16 // * *
17 // * You should have received a copy of the GNU General Public License *
18 // * along with GGEMS. If not, see <https://www.gnu.org/licenses/>. *
19 // * *
20 // ************************************************************************
21 
34 #include <limits>
35 
40 
42 
47 class GGEMS_EXPORT GGEMSSolid
48 {
49  public:
53  GGEMSSolid(void);
54 
58  virtual ~GGEMSSolid(void);
59 
65  GGEMSSolid(GGEMSSolid const& solid) = delete;
66 
72  GGEMSSolid& operator=(GGEMSSolid const& solid) = delete;
73 
79  GGEMSSolid(GGEMSSolid const&& solid) = delete;
80 
86  GGEMSSolid& operator=(GGEMSSolid const&& solid) = delete;
87 
92  void EnableTracking(void);
93 
100  inline cl::Buffer* GetSolidData(GGsize const& thread_index) const {return solid_data_[thread_index];};
101 
108  inline cl::Buffer* GetLabelData(GGsize const& thread_index) const {return label_data_[thread_index];};
109 
115  void SetRotation(GGfloat3 const& rotation_xyz);
116 
122  void SetPosition(GGfloat3 const& position_xyz);
123 
130  template<typename T>
131  void SetSolidID(GGsize const& solid_id, GGsize const& thread_index);
132 
138  virtual void UpdateTransformationMatrix(GGsize const& thread_index) = 0;
139 
145  virtual void Initialize(GGEMSMaterials* materials) = 0;
146 
151  virtual void EnableScatter(void) = 0;
152 
157  virtual void PrintInfos(void) const = 0;
158 
164  inline std::string GetRegisteredDataType(void) const {return data_reg_type_;};
165 
172  inline cl::Kernel* GetKernelParticleSolidDistance(GGsize const& thread_index) const {return kernel_particle_solid_distance_[thread_index];}
173 
180  inline cl::Kernel* GetKernelProjectToSolid(GGsize const& thread_index) const {return kernel_project_to_solid_[thread_index];}
181 
188  inline cl::Kernel* GetKernelTrackThroughSolid(GGsize const& thread_index) const {return kernel_track_through_solid_[thread_index];}
189 
196  inline cl::Buffer* GetHistogram(GGsize const& thread_index) const {return histogram_.histogram_[thread_index];}
197 
204  inline cl::Buffer* GetScatterHistogram(GGsize const& thread_index) const {return histogram_.scatter_[thread_index];}
205 
206  protected:
211  virtual void InitializeKernel(void) = 0;
212 
213  protected:
214  // Solid data infos and label (for voxelized solid)
215  cl::Buffer** solid_data_;
216  cl::Buffer** label_data_;
219  // Geometric transformation applyied to solid
222  // OpenCL kernels and options for kernel
226  std::string kernel_option_;
228  // Output data
229  std::string data_reg_type_;
231  bool is_scatter_;
232 };
233 
237 
238 template<typename T>
239 void GGEMSSolid::SetSolidID(GGsize const& solid_id, GGsize const& thread_index)
240 {
241  // Get the OpenCL manager
243 
244  // Get pointer on OpenCL device
245  T* solid_data_device = opencl_manager.GetDeviceBuffer<T>(solid_data_[thread_index], sizeof(T), thread_index);
246 
247  solid_data_device->solid_id_ = static_cast<GGint>(solid_id);
248 
249  // Release the pointer
250  opencl_manager.ReleaseDeviceBuffer(solid_data_[thread_index], solid_data_device, thread_index);
251 }
252 
253 #endif // End of GUARD_GGEMS_GEOMETRIES_GGEMSSOLID_HH
GGEMSRAMManager.hh
GGEMS class handling RAM memory.
GGEMSSolid::label_data_
cl::Buffer ** label_data_
Definition: GGEMSSolid.hh:216
GGEMSSolid::operator=
GGEMSSolid & operator=(GGEMSSolid const &&solid)=delete
Avoid copy by rvalue reference.
GGEMSNavigatorManager.hh
GGEMS class handling the navigators (detector + phantom) in GGEMS.
GGEMSGeometryTransformation
This class handles everything about geometry transformation.
Definition: GGEMSGeometryTransformation.hh:42
GGEMSSolid::EnableScatter
virtual void EnableScatter(void)=0
Activate scatter registration.
GGEMSSolid::GetKernelProjectToSolid
cl::Kernel * GetKernelProjectToSolid(GGsize const &thread_index) const
get the pointer to kernel associated to a device
Definition: GGEMSSolid.hh:180
GGEMSSolid::solid_data_
cl::Buffer ** solid_data_
Definition: GGEMSSolid.hh:215
GGEMSMaterials
GGEMS class handling material(s) for a specific navigator.
Definition: GGEMSMaterials.hh:49
GGEMSHistogramMode_t
Structure storing histogram infos.
Definition: GGEMSHistogramMode.hh:43
GGEMSSolid
GGEMS class for solid informations.
Definition: GGEMSSolid.hh:48
GGEMSSolid::GetSolidData
cl::Buffer * GetSolidData(GGsize const &thread_index) const
get the informations about the solid geometry
Definition: GGEMSSolid.hh:100
GGEMSSolid::kernel_project_to_solid_
cl::Kernel ** kernel_project_to_solid_
Definition: GGEMSSolid.hh:224
GGEMSOpenCLManager::ReleaseDeviceBuffer
void ReleaseDeviceBuffer(cl::Buffer *const device_ptr, T *host_ptr, GGsize const &thread_index)
Get the device pointer on host to write on it. Mandatory after a GetDeviceBufferWrite ou GetDeviceBuf...
Definition: GGEMSOpenCLManager.hh:495
GGEMSSolid::GetScatterHistogram
cl::Buffer * GetScatterHistogram(GGsize const &thread_index) const
return the point on scatter histogram
Definition: GGEMSSolid.hh:204
GGEMSSolid::kernel_track_through_solid_
cl::Kernel ** kernel_track_through_solid_
Definition: GGEMSSolid.hh:225
GGEMSSolid::GetKernelParticleSolidDistance
cl::Kernel * GetKernelParticleSolidDistance(GGsize const &thread_index) const
get the pointer to kernel associated to a device
Definition: GGEMSSolid.hh:172
GGEMSSolid::operator=
GGEMSSolid & operator=(GGEMSSolid const &solid)=delete
Avoid assignement by reference.
GGsize
#define GGsize
Definition: GGEMSTypes.hh:252
GGint
#define GGint
Definition: GGEMSTypes.hh:224
GGEMSSolid::geometry_transformation_
GGEMSGeometryTransformation * geometry_transformation_
Definition: GGEMSSolid.hh:220
GGEMSSolid::kernel_particle_solid_distance_
cl::Kernel ** kernel_particle_solid_distance_
Definition: GGEMSSolid.hh:223
GGEMSSolid::PrintInfos
virtual void PrintInfos(void) const =0
printing infos about solid
GGEMSSolid::histogram_
GGEMSHistogramMode histogram_
Definition: GGEMSSolid.hh:230
GGEMSSolid::GetRegisteredDataType
std::string GetRegisteredDataType(void) const
get the type of registered data
Definition: GGEMSSolid.hh:164
GGEMSSolid::GGEMSSolid
GGEMSSolid(GGEMSSolid const &solid)=delete
Avoid copy by reference.
GGEMSSolid::GetLabelData
cl::Buffer * GetLabelData(GGsize const &thread_index) const
get buffer to label buffer
Definition: GGEMSSolid.hh:108
GGEMSSolid::SetSolidID
void SetSolidID(GGsize const &solid_id, GGsize const &thread_index)
set the global solid index
Definition: GGEMSSolid.hh:239
GGfloat3
#define GGfloat3
Definition: GGEMSTypes.hh:275
GGEMSTextReader.hh
Namespaces for different useful fonctions reading input text file. Namespaces for material database f...
GGEMSSolid::GetKernelTrackThroughSolid
cl::Kernel * GetKernelTrackThroughSolid(GGsize const &thread_index) const
get the pointer to kernel associated to a device
Definition: GGEMSSolid.hh:188
GGEMSSolid::GetHistogram
cl::Buffer * GetHistogram(GGsize const &thread_index) const
return the point on histogram
Definition: GGEMSSolid.hh:196
GGEMSSolid::UpdateTransformationMatrix
virtual void UpdateTransformationMatrix(GGsize const &thread_index)=0
Update transformation matrix for solid object.
GGEMSSolid::number_activated_devices_
GGsize number_activated_devices_
Definition: GGEMSSolid.hh:217
GGEMSSolid::is_scatter_
bool is_scatter_
Definition: GGEMSSolid.hh:231
GGEMSSolid::Initialize
virtual void Initialize(GGEMSMaterials *materials)=0
Initialize solid for geometric navigation.
GGEMSSolid::GGEMSSolid
GGEMSSolid(GGEMSSolid const &&solid)=delete
Avoid copy by rvalue reference.
GGEMSOpenCLManager::GetDeviceBuffer
T * GetDeviceBuffer(cl::Buffer *device_ptr, GGsize const &size, GGsize const &thread_index)
Get the device pointer on host to write on it. ReleaseDeviceBuffer must be used after this method!...
Definition: GGEMSOpenCLManager.hh:480
GGEMSHistogramMode.hh
Structure storing histogram infos.
GGEMSOpenCLManager
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
Definition: GGEMSOpenCLManager.hh:54
GGEMSSolid::data_reg_type_
std::string data_reg_type_
Definition: GGEMSSolid.hh:229
T
__constant GGfloat T
Definition: GGEMSSystemOfUnits.hh:150
GGEMSSolid::kernel_option_
std::string kernel_option_
Definition: GGEMSSolid.hh:226
GGEMSSolid::InitializeKernel
virtual void InitializeKernel(void)=0
Initialize kernel for particle solid distance.
GGEMSOpenCLManager::GetInstance
static GGEMSOpenCLManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSOpenCLManager.hh:72