GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSMaterials.hh
Go to the documentation of this file.
1 #ifndef GUARD_GGEMS_MATERIALS_GGEMSMATERIALS_HH
2 #define GUARD_GGEMS_MATERIALS_GGEMSMATERIALS_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 #ifdef _MSC_VER
35 #pragma warning(disable: 4251) // Deleting warning exporting STL members!!!
36 #endif
37 
41 
42 class GGEMSRangeCuts;
43 
48 class GGEMS_EXPORT GGEMSMaterials
49 {
50  public:
54  GGEMSMaterials(void);
55 
59  ~GGEMSMaterials(void);
60 
66  GGEMSMaterials(GGEMSMaterials const& materials) = delete;
67 
73  GGEMSMaterials& operator=(GGEMSMaterials const& materials) = delete;
74 
80  GGEMSMaterials(GGEMSMaterials const&& materials) = delete;
81 
87  GGEMSMaterials& operator=(GGEMSMaterials const&& materials) = delete;
88 
94  void AddMaterial(std::string const& material_name);
95 
103  GGfloat GetDensity(std::string const& material_name, GGsize const& thread_index = 0) const;
104 
112  GGfloat GetAtomicNumberDensity(std::string const& material_name, GGsize const& thread_index = 0) const;
113 
124  GGfloat GetEnergyCut(std::string const& material_name, std::string const& particle_type, GGfloat const& distance, std::string const& unit, GGsize const& thread_index = 0);
125 
132  inline std::string GetMaterialName(GGsize i) const {return materials_.at(i);}
133 
140  inline ptrdiff_t GetMaterialIndex(std::string const& material_name) const
141  {
142  std::vector<std::string>::const_iterator iter_mat = std::find(materials_.begin(), materials_.end(), material_name);
143  if (iter_mat == materials_.end()) {
144  std::ostringstream oss(std::ostringstream::out);
145  oss << "Material '" << material_name << "' not found!!!" << std::endl;
146  GGEMSMisc::ThrowException("GGEMSMaterials", "GetMaterialIndex", oss.str());
147  }
148  return std::distance(materials_.begin(), iter_mat);
149  }
150 
156  inline GGsize GetNumberOfMaterials(void) const {return materials_.size();}
157 
164  inline cl::Buffer* GetMaterialTables(GGsize const& thread_index) const {return material_tables_[thread_index];}
165 
171  inline GGEMSRangeCuts* GetRangeCuts(void) const {return range_cuts_;}
172 
180  void SetDistanceCut(std::string const& particle_name, GGfloat const& value, std::string const& unit);
181 
186  void PrintInfos(void) const;
187 
192  void Initialize(void);
193 
198  void Clean(void);
199 
200  private:
205  void BuildMaterialTables(void);
206 
207  private:
208  std::vector<std::string> materials_;
209  cl::Buffer** material_tables_;
212 };
213 
219 extern "C" GGEMS_EXPORT GGEMSMaterials* create_ggems_materials(void);
220 
227 extern "C" GGEMS_EXPORT void add_material_ggems_materials(GGEMSMaterials* materials, char const* material_name);
228 
234 extern "C" GGEMS_EXPORT void initialize_ggems_materials(GGEMSMaterials* materials);
235 
241 extern "C" GGEMS_EXPORT void print_material_properties_ggems_materials(GGEMSMaterials* materials);
242 
250 extern "C" GGEMS_EXPORT GGfloat get_density_ggems_materials(GGEMSMaterials* materials, char const* material_name);
251 
262 extern "C" GGEMS_EXPORT GGfloat get_energy_cut_ggems_materials(GGEMSMaterials* materials, char const* material_name, char const* particle_type, GGfloat const distance, char const* unit);
263 
271 extern "C" GGEMS_EXPORT GGfloat get_atomic_number_density_ggems_materials(GGEMSMaterials* materials, char const* material_name);
272 
278 extern "C" GGEMS_EXPORT void clean_ggems_materials(GGEMSMaterials* materials);
279 
280 #endif // End of GUARD_GGEMS_PHYSICS_GGEMSMATERIALS_HH
get_atomic_number_density_ggems_materials
GGfloat get_atomic_number_density_ggems_materials(GGEMSMaterials *materials, char const *material_name)
Get the density of material in g.cm-3.
Definition: GGEMSMaterials.cc:460
GGEMSMaterials::range_cuts_
GGEMSRangeCuts * range_cuts_
Definition: GGEMSMaterials.hh:211
GGEMSMaterials::GetMaterialIndex
ptrdiff_t GetMaterialIndex(std::string const &material_name) const
get the index of the material
Definition: GGEMSMaterials.hh:140
initialize_ggems_materials
void initialize_ggems_materials(GGEMSMaterials *materials)
Intialize the tables for the materials.
Definition: GGEMSMaterials.cc:424
GGEMSRangeCuts
GGEMS class storing and converting the cut in energy cut.
Definition: GGEMSRangeCuts.hh:50
GGEMSMaterials::GGEMSMaterials
GGEMSMaterials(GGEMSMaterials const &&materials)=delete
Avoid copy by rvalue reference.
GGEMSMaterials::GetMaterialTables
cl::Buffer * GetMaterialTables(GGsize const &thread_index) const
get the pointer on material tables on OpenCL device
Definition: GGEMSMaterials.hh:164
GGEMSMaterials
GGEMS class handling material(s) for a specific navigator.
Definition: GGEMSMaterials.hh:49
GGEMSMaterials::GetRangeCuts
GGEMSRangeCuts * GetRangeCuts(void) const
get the pointer on range cuts
Definition: GGEMSMaterials.hh:171
GGsize
#define GGsize
Definition: GGEMSTypes.hh:252
GGEMSMaterials::GGEMSMaterials
GGEMSMaterials(GGEMSMaterials const &materials)=delete
Avoid copy by reference.
add_material_ggems_materials
void add_material_ggems_materials(GGEMSMaterials *materials, char const *material_name)
Add a material.
Definition: GGEMSMaterials.cc:415
GGEMSMaterials::GetMaterialName
std::string GetMaterialName(GGsize i) const
get the name of the material at position i
Definition: GGEMSMaterials.hh:132
GGEMSMaterials::GetNumberOfMaterials
GGsize GetNumberOfMaterials(void) const
Get the number of materials in the phantom.
Definition: GGEMSMaterials.hh:156
GGEMSMaterialTables.hh
Structure storing the material tables on OpenCL device.
GGEMSMaterials::materials_
std::vector< std::string > materials_
Definition: GGEMSMaterials.hh:208
GGEMSOpenCLManager.hh
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
get_energy_cut_ggems_materials
GGfloat get_energy_cut_ggems_materials(GGEMSMaterials *materials, char const *material_name, char const *particle_type, GGfloat const distance, char const *unit)
Get the energy cut of material in keV.
Definition: GGEMSMaterials.cc:451
clean_ggems_materials
void clean_ggems_materials(GGEMSMaterials *materials)
clean all declared materials on OpenCL device
Definition: GGEMSMaterials.cc:469
create_ggems_materials
GGEMSMaterials * create_ggems_materials(void)
Get the GGEMSMaterials pointer for python user.
Definition: GGEMSMaterials.cc:406
print_material_properties_ggems_materials
void print_material_properties_ggems_materials(GGEMSMaterials *materials)
Print tables.
Definition: GGEMSMaterials.cc:433
get_density_ggems_materials
GGfloat get_density_ggems_materials(GGEMSMaterials *materials, char const *material_name)
Get the density of material in g.cm-3.
Definition: GGEMSMaterials.cc:442
GGEMSMaterials::material_tables_
cl::Buffer ** material_tables_
Definition: GGEMSMaterials.hh:209
GGEMSMaterials::operator=
GGEMSMaterials & operator=(GGEMSMaterials const &materials)=delete
Avoid assignement by reference.
GGEMSMaterials::operator=
GGEMSMaterials & operator=(GGEMSMaterials const &&materials)=delete
Avoid copy by rvalue reference.
GGEMSMaterials::number_activated_devices_
GGsize number_activated_devices_
Definition: GGEMSMaterials.hh:210
GGEMSMaterialsDatabaseManager.hh
GGEMS singleton class managing the material database.
GGEMSMisc::ThrowException
void ThrowException(std::string const &class_name, std::string const &method_name, std::string const &message)
Throw a C++ exception.
Definition: GGEMSTools.cc:61
GGfloat
#define GGfloat
Definition: GGEMSTypes.hh:273