OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Material.cpp
Go to the documentation of this file.
1 //
2 // Class Material
3 // Base class for representing materials
4 //
5 // Copyright (c) 2019 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // All rights reserved
7 //
8 // This file is part of OPAL.
9 //
10 // OPAL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17 //
18 #include "Physics/Material.h"
19 #include "Physics/Air.h"
20 #include "Physics/AluminaAL2O3.h"
21 #include "Physics/Aluminum.h"
22 #include "Physics/Beryllium.h"
23 #include "Physics/BoronCarbide.h"
24 #include "Physics/Copper.h"
25 #include "Physics/Gold.h"
26 #include "Physics/Graphite.h"
27 #include "Physics/GraphiteR6710.h"
28 #include "Physics/Kapton.h"
29 #include "Physics/Molybdenum.h"
30 #include "Physics/Mylar.h"
31 #include "Physics/Titanium.h"
32 #include "Physics/Water.h"
34 #include "Utilities/Util.h"
35 
36 #include <iostream>
37 
38 using namespace Physics;
39 
40 std::map<std::string, std::shared_ptr<Material> > Material::protoTable_sm;
41 
42 std::shared_ptr<Material> Material::addMaterial(const std::string& name,
43  std::shared_ptr<Material> mat_ptr) {
44  std::string nameUp = Util::toUpper(name);
45  if (protoTable_sm.find(nameUp) != protoTable_sm.end())
46  return protoTable_sm[nameUp];
47 
48  protoTable_sm.insert(std::make_pair(nameUp, mat_ptr));
49 
50  return mat_ptr;
51 }
52 
53 std::shared_ptr<Material> Material::getMaterial(const std::string& name) {
54  std::string nameUp = Util::toUpper(name);
55  return protoTable_sm[nameUp];
56 }
57 
58 namespace {
59  auto air = Material::addMaterial("Air",
60  std::shared_ptr<Material>(new Air()));
61  auto aluminaal2o3 = Material::addMaterial("AluminaAL2O3",
62  std::shared_ptr<Material>(new AluminaAL2O3()));
63  auto aluminum = Material::addMaterial("Aluminum",
64  std::shared_ptr<Material>(new Aluminum()));
65  auto beryllium = Material::addMaterial("Beryllium",
66  std::shared_ptr<Material>(new Beryllium()));
67  auto boroncarbide = Material::addMaterial("BoronCarbide",
68  std::shared_ptr<Material>(new BoronCarbide()));
69  auto copper = Material::addMaterial("Copper",
70  std::shared_ptr<Material>(new Copper()));
71  auto gold = Material::addMaterial("Gold",
72  std::shared_ptr<Material>(new Gold()));
73  auto graphite = Material::addMaterial("Graphite",
74  std::shared_ptr<Material>(new Graphite()));
75  auto graphiter6710 = Material::addMaterial("GraphiteR6710",
76  std::shared_ptr<Material>(new GraphiteR6710()));
77  auto kapton = Material::addMaterial("Kapton",
78  std::shared_ptr<Material>(new Kapton()));
79  auto molybdenum = Material::addMaterial("Molybdenum",
80  std::shared_ptr<Material>(new Molybdenum()));
81  auto mylar = Material::addMaterial("Mylar",
82  std::shared_ptr<Material>(new Mylar()));
83  auto titanium = Material::addMaterial("Titanium",
84  std::shared_ptr<Material>(new Titanium()));
85  auto water = Material::addMaterial("Water",
86  std::shared_ptr<Material>(new Water()));
87 }
const std::string name
Definition: Air.h:27
std::string toUpper(const std::string &str)
Definition: Util.cpp:132
static std::shared_ptr< Material > addMaterial(const std::string &name, std::shared_ptr< Material > mat_ptr)
Definition: Material.cpp:42
static std::map< std::string, std::shared_ptr< Material > > protoTable_sm
Definition: Material.h:69
static std::shared_ptr< Material > getMaterial(const std::string &name)
Definition: Material.cpp:53