OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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"
21#include "Physics/Aluminum.h"
22#include "Physics/Beryllium.h"
24#include "Physics/Copper.h"
25#include "Physics/Gold.h"
26#include "Physics/Graphite.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"
33#include "Utilities/Util.h"
34
35#include <iostream>
36
37using namespace Physics;
38
39std::map<std::string, std::shared_ptr<Material> > Material::protoTable_sm;
40
41std::shared_ptr<Material> Material::addMaterial(
42 const std::string& name, std::shared_ptr<Material> mat_ptr) {
43 std::string nameUp = Util::toUpper(name);
44 if (protoTable_sm.find(nameUp) != protoTable_sm.end()) return protoTable_sm[nameUp];
45
46 protoTable_sm.insert(std::make_pair(nameUp, mat_ptr));
47
48 return mat_ptr;
49}
50
51std::shared_ptr<Material> Material::getMaterial(const std::string& name) {
52 std::string nameUp = Util::toUpper(name);
53 return protoTable_sm[nameUp];
54}
55
56namespace {
57 auto air = Material::addMaterial("Air", std::shared_ptr<Material>(new Air()));
58 auto aluminaal2o3 =
59 Material::addMaterial("AluminaAL2O3", std::shared_ptr<Material>(new AluminaAL2O3()));
60 auto aluminum = Material::addMaterial("Aluminum", std::shared_ptr<Material>(new Aluminum()));
61 auto beryllium = Material::addMaterial("Beryllium", std::shared_ptr<Material>(new Beryllium()));
62 auto boroncarbide =
63 Material::addMaterial("BoronCarbide", std::shared_ptr<Material>(new BoronCarbide()));
64 auto copper = Material::addMaterial("Copper", std::shared_ptr<Material>(new Copper()));
65 auto gold = Material::addMaterial("Gold", std::shared_ptr<Material>(new Gold()));
66 auto graphite = Material::addMaterial("Graphite", std::shared_ptr<Material>(new Graphite()));
67 auto graphiter6710 =
68 Material::addMaterial("GraphiteR6710", std::shared_ptr<Material>(new GraphiteR6710()));
69 auto kapton = Material::addMaterial("Kapton", std::shared_ptr<Material>(new Kapton()));
70 auto molybdenum =
71 Material::addMaterial("Molybdenum", std::shared_ptr<Material>(new Molybdenum()));
72 auto mylar = Material::addMaterial("Mylar", std::shared_ptr<Material>(new Mylar()));
73 auto titanium = Material::addMaterial("Titanium", std::shared_ptr<Material>(new Titanium()));
74 auto water = Material::addMaterial("Water", std::shared_ptr<Material>(new Water()));
75} // namespace
static std::shared_ptr< Material > addMaterial(const std::string &name, std::shared_ptr< Material > mat_ptr)
Definition Material.cpp:41
static std::map< std::string, std::shared_ptr< Material > > protoTable_sm
Definition Material.h:54
static std::shared_ptr< Material > getMaterial(const std::string &name)
Definition Material.cpp:51
Definition Air.h:27
std::string toUpper(const std::string &str)
Definition Util.cpp:141