GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSSolid.cc
Go to the documentation of this file.
1 // ************************************************************************
2 // * This file is part of GGEMS. *
3 // * *
4 // * GGEMS is free software: you can redistribute it and/or modify *
5 // * it under the terms of the GNU General Public License as published by *
6 // * the Free Software Foundation, either version 3 of the License, or *
7 // * (at your option) any later version. *
8 // * *
9 // * GGEMS is distributed in the hope that it will be useful, *
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 // * GNU General Public License for more details. *
13 // * *
14 // * You should have received a copy of the GNU General Public License *
15 // * along with GGEMS. If not, see <https://www.gnu.org/licenses/>. *
16 // * *
17 // ************************************************************************
18 
38 
42 
44 : kernel_option_("")
45 {
46  GGcout("GGEMSSolid", "GGEMSSolid", 3) << "GGEMSSolid creating..." << GGendl;
47 
48  // Allocation of geometry transformation
50  data_reg_type_ = "";
51 
54 
55  solid_data_ = new cl::Buffer*[number_activated_devices_];
56  label_data_ = new cl::Buffer*[number_activated_devices_];
57  for (GGsize i = 0; i < number_activated_devices_; ++i) label_data_[i] = nullptr;
58 
59  // Storing a kernel for each device
63 
64  is_scatter_ = false;
65 
66  GGcout("GGEMSSolid", "GGEMSSolid", 3) << "GGEMSSolid created!!!" << GGendl;
67 }
68 
72 
74 {
75  GGcout("GGEMSSolid", "~GGEMSSolid", 3) << "GGEMSSolid erasing..." << GGendl;
76 
80  }
81 
83  delete[] kernel_project_to_solid_;
84  kernel_project_to_solid_ = nullptr;
85  }
86 
90  }
91 
94  geometry_transformation_ = nullptr;
95  }
96 
98 
99  if (label_data_) {
100  for (GGsize i = 0; i < number_activated_devices_; ++i) {
101  GGEMSVoxelizedSolidData* solid_data_device = opencl_manager.GetDeviceBuffer<GGEMSVoxelizedSolidData>(solid_data_[i], sizeof(GGEMSVoxelizedSolidData), i);
102  GGsize number_of_voxels = static_cast<GGsize>(solid_data_device->number_of_voxels_);
103  opencl_manager.ReleaseDeviceBuffer(solid_data_[i], solid_data_device, i);
104  opencl_manager.Deallocate(label_data_[i], number_of_voxels*sizeof(GGuchar), i);
105  }
106  delete[] label_data_;
107  label_data_ = nullptr;
108  }
109 
110  if (solid_data_) {
111  for (GGsize i = 0; i < number_activated_devices_; ++i) {
112  opencl_manager.Deallocate(solid_data_[i], sizeof(GGEMSSolidBoxData), i);
113  }
114  delete[] solid_data_;
115  solid_data_ = nullptr;
116  }
117 
118  GGcout("GGEMSSolid", "~GGEMSSolid", 3) << "GGEMSSolid erased!!!" << GGendl;
119 }
120 
124 
126 {
127  kernel_option_ += " -DGGEMS_TRACKING";
128 }
129 
133 
134 void GGEMSSolid::SetRotation(GGfloat3 const& rotation_xyz)
135 {
136  geometry_transformation_->SetRotation(rotation_xyz);
137 }
138 
142 
143 void GGEMSSolid::SetPosition(GGfloat3 const& position_xyz)
144 {
146 }
GGEMSSolid::label_data_
cl::Buffer ** label_data_
Definition: GGEMSSolid.hh:216
GGEMSVoxelizedSolidData_t::number_of_voxels_
GGint number_of_voxels_
Definition: GGEMSVoxelizedSolidData.hh:46
GGEMSGeometryTransformation
This class handles everything about geometry transformation.
Definition: GGEMSGeometryTransformation.hh:42
GGEMSVoxelizedSolidData_t
Structure storing the stack of data for voxelized solid.
Definition: GGEMSVoxelizedSolidData.hh:41
GGEMSVoxelizedSolidData
struct GGEMSVoxelizedSolidData_t GGEMSVoxelizedSolidData
GGEMSOpenCLManager::GetNumberOfActivatedDevice
GGsize GetNumberOfActivatedDevice(void) const
get the number of activated devices
Definition: GGEMSOpenCLManager.hh:167
GGEMSSolid::GGEMSSolid
GGEMSSolid(void)
GGEMSSolid constructor.
Definition: GGEMSSolid.cc:43
GGEMSSolid::solid_data_
cl::Buffer ** solid_data_
Definition: GGEMSSolid.hh:215
GGEMSCrossSections.hh
GGEMS class handling the cross sections tables.
GGEMSGeometryTransformation::SetTranslation
void SetTranslation(GGfloat const &tx, GGfloat const &ty, GGfloat const &tz)
Set the translation in X, Y and Z.
Definition: GGEMSGeometryTransformation.cc:143
GGEMSSolid::kernel_project_to_solid_
cl::Kernel ** kernel_project_to_solid_
Definition: GGEMSSolid.hh:224
GGEMSSolid::~GGEMSSolid
virtual ~GGEMSSolid(void)
GGEMSSolid destructor.
Definition: GGEMSSolid.cc:73
GGEMSOpenCLManager::Deallocate
void Deallocate(cl::Buffer *buffer, GGsize size, GGsize const &thread_index, std::string const &class_name="Undefined")
Deallocation of OpenCL memory.
Definition: GGEMSOpenCLManager.cc:981
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
GGEMSVoxelizedSolidData.hh
Structure storing the stack of data for voxelized and analytical solid.
GGEMSSolid::kernel_track_through_solid_
cl::Kernel ** kernel_track_through_solid_
Definition: GGEMSSolid.hh:225
GGsize
#define GGsize
Definition: GGEMSTypes.hh:252
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::EnableTracking
void EnableTracking(void)
Enabling tracking infos during simulation.
Definition: GGEMSSolid.cc:125
GGEMSSolidBoxData_t
Structure storing the stack of data for solid box.
Definition: GGEMSSolidBoxData.hh:41
GGEMSGeometryTransformation::SetRotation
void SetRotation(GGfloat const &rx, GGfloat const &ry, GGfloat const &rz)
Set the Rotation in X, Y and Z around global axis.
Definition: GGEMSGeometryTransformation.hh:103
GGfloat3
#define GGfloat3
Definition: GGEMSTypes.hh:275
GGEMSSolid.hh
GGEMS class for solid. This class store geometry about phantom or detector.
GGEMSSolid::SetPosition
void SetPosition(GGfloat3 const &position_xyz)
set a position for solid
Definition: GGEMSSolid.cc:143
GGcout
GGEMSStream GGcout
Definition: GGEMSPrint.cc:34
GGEMSSolid::number_activated_devices_
GGsize number_activated_devices_
Definition: GGEMSSolid.hh:217
GGEMSSourceManager.hh
GGEMS class handling the source(s)
GGEMSSolid::is_scatter_
bool is_scatter_
Definition: GGEMSSolid.hh:231
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
GGendl
#define GGendl
overload C++ std::endl
Definition: GGEMSPrint.hh:60
GGEMSSolidBoxData.hh
Structure storing the data for solid box.
GGEMSOpenCLManager
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
Definition: GGEMSOpenCLManager.hh:54
GGuchar
#define GGuchar
Definition: GGEMSTypes.hh:203
GGEMSSolid::data_reg_type_
std::string data_reg_type_
Definition: GGEMSSolid.hh:229
GGEMSPseudoRandomGenerator.hh
Class managing the random number in GGEMS.
GGEMSGeometryTransformation.hh
Class managing the geometry transformation.
GGEMSSolid::SetRotation
void SetRotation(GGfloat3 const &rotation_xyz)
set a rotation for solid
Definition: GGEMSSolid.hh:108
GGEMSSolid::kernel_option_
std::string kernel_option_
Definition: GGEMSSolid.hh:226
GGEMSOpenCLManager::GetInstance
static GGEMSOpenCLManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSOpenCLManager.hh:72