BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSTunnelFactory.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSDebug.hh"
20#include "BDSGeometryComponent.hh"
21#include "BDSTunnelFactory.hh"
22#include "BDSTunnelFactoryBase.hh"
23#include "BDSTunnelFactoryCircular.hh"
24#include "BDSTunnelFactoryElliptical.hh"
25#include "BDSTunnelFactoryRectangular.hh"
26#include "BDSTunnelFactoryRectAboveGround.hh"
27#include "BDSTunnelFactorySquare.hh"
28#include "BDSTunnelSection.hh"
29#include "BDSTunnelType.hh"
30
31#include "globals.hh" // geant4 globals / types
32
34
36{
37 if (!instance)
38 {instance = new BDSTunnelFactory();}
39 return instance;
40}
41
43{
49}
50
51BDSTunnelFactory::~BDSTunnelFactory()
52{
53 delete circular;
54 delete elliptical;
55 delete rectangular;
56 delete square;
57 delete rectaboveground;
58 instance = nullptr;
59}
60
62{
63 switch (tunnelType.underlying())
64 {
65 case BDSTunnelType::circular:
66 {return circular; break;}
67 case BDSTunnelType::elliptical:
68 {return elliptical; break;}
69 case BDSTunnelType::rectangular:
70 {return rectangular; break;}
71 case BDSTunnelType::square:
72 {return square; break;}
73 case BDSTunnelType::rectaboveground:
74 {return rectaboveground; break;}
75 default:
76 {
77#ifdef BDSDEBUG
78 G4cout << __METHOD_NAME__ << "unknown tunnel type \"" << tunnelType
79 << "\" - using circular tunnel factory by default" << G4endl;
80#endif
81 return circular;
82 break;
83 }
84 }
85}
86
88 G4String name,
89 G4double length,
90 G4double tunnelThickness,
91 G4double tunnelSoilThickness,
92 G4Material* tunnelMaterial,
93 G4Material* tunnelSoilMaterial,
94 G4bool tunnelFloor,
95 G4double tunnelFloorOffset,
96 G4double tunnel1,
97 G4double tunnel2,
98 G4bool visible)
99{
100 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
101 return factory->CreateTunnelSection(name, length, tunnelThickness,
102 tunnelSoilThickness, tunnelMaterial,
103 tunnelSoilMaterial, tunnelFloor,
104 tunnelFloorOffset, tunnel1, tunnel2, visible);
105}
106
108 G4String name,
109 G4double length,
110 G4double angleIn,
111 G4double tunnelThickness,
112 G4double tunnelSoilThickness,
113 G4Material* tunnelMaterial,
114 G4Material* tunnelSoilMaterial,
115 G4bool tunnelFloor,
116 G4double tunnelFloorOffset,
117 G4double tunnel1,
118 G4double tunnel2,
119 G4bool visible)
120{
121 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
122 return factory->CreateTunnelSectionAngledIn(name, length, angleIn, tunnelThickness,
123 tunnelSoilThickness, tunnelMaterial,
124 tunnelSoilMaterial, tunnelFloor,
125 tunnelFloorOffset, tunnel1, tunnel2, visible);
126}
127
129 G4String name,
130 G4double length,
131 G4double angleOut,
132 G4double tunnelThickness,
133 G4double tunnelSoilThickness,
134 G4Material* tunnelMaterial,
135 G4Material* tunnelSoilMaterial,
136 G4bool tunnelFloor,
137 G4double tunnelFloorOffset,
138 G4double tunnel1,
139 G4double tunnel2,
140 G4bool visible)
141{
142 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
143 return factory->CreateTunnelSectionAngledOut(name, length, angleOut, tunnelThickness,
144 tunnelSoilThickness, tunnelMaterial,
145 tunnelSoilMaterial, tunnelFloor,
146 tunnelFloorOffset, tunnel1, tunnel2, visible);
147}
148
150 G4String name,
151 G4double length,
152 G4double angleIn,
153 G4double angleOut,
154 G4double tunnelThickness,
155 G4double tunnelSoilThickness,
156 G4Material* tunnelMaterial,
157 G4Material* tunnelSoilMaterial,
158 G4bool tunnelFloor,
159 G4double tunnelFloorOffset,
160 G4double tunnel1,
161 G4double tunnel2,
162 G4bool visible)
163{
164 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
165 return factory->CreateTunnelSectionAngledInOut(name, length, angleIn, angleOut,
166 tunnelThickness, tunnelSoilThickness, tunnelMaterial,
167 tunnelSoilMaterial, tunnelFloor,
168 tunnelFloorOffset, tunnel1, tunnel2, visible);
169}
170
172 G4String name,
173 G4double length,
174 G4ThreeVector inputFace,
175 G4ThreeVector outputFace,
176 G4double tunnelThickness,
177 G4double tunnelSoilThickness,
178 G4Material* tunnelMaterial,
179 G4Material* tunnelSoilMaterial,
180 G4bool tunnelFloor,
181 G4double tunnelFloorOffset,
182 G4double tunnel1,
183 G4double tunnel2,
184 G4bool visible)
185{
186 BDSTunnelFactoryBase* factory = GetAppropriateFactory(tunnelType);
187 return factory->CreateTunnelSectionAngled(name, length, inputFace, outputFace,
188 tunnelThickness, tunnelSoilThickness, tunnelMaterial,
189 tunnelSoilMaterial, tunnelFloor,
190 tunnelFloorOffset, tunnel1, tunnel2, visible);
191}
Abstract base class for tunnel factory classes.
virtual BDSTunnelSection * CreateTunnelSectionAngledInOut(G4String name, G4double length, G4double angleIn, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)
virtual BDSTunnelSection * CreateTunnelSectionAngled(G4String name, G4double length, G4ThreeVector inputFaceIn, G4ThreeVector outputFaceIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)=0
Create a tunnel section with an angled input and output face. Pure virtual.
virtual BDSTunnelSection * CreateTunnelSectionAngledIn(G4String name, G4double length, G4double angleIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)
virtual BDSTunnelSection * CreateTunnelSectionAngledOut(G4String name, G4double length, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)
virtual BDSTunnelSection * CreateTunnelSection(G4String name, G4double length, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)=0
Create a tunnel section with flat input and output faces. Pure virtual.
Factory for circular tunnel segments. Builds floor, tunnel and soil.
Factory for elliptical tunnel segments. Builds floor, tunnel and soil.
Factory for rectangular tunnel segments above ground.
Factory for rectangular tunnel segments. Builds floor, tunnel and soil.
Factory for square tunnel segments. Builds floor, tunnel and soil.
A singleton class that provides an interface to all tunnel factories.
static BDSTunnelFactory * instance
Singleton instance.
BDSTunnelSection * CreateTunnelSectionAngledIn(BDSTunnelType tunnelType, G4String name, G4double length, G4double angleIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
BDSTunnelSection * CreateTunnelSectionAngled(BDSTunnelType tunnelType, G4String name, G4double length, G4ThreeVector inputFaceIn, G4ThreeVector outputFaceIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
BDSTunnelFactory()
Private constructor as a singleton.
BDSTunnelFactoryBase * rectangular
Factory instance.
BDSTunnelFactoryBase * GetAppropriateFactory(BDSTunnelType tunnelType)
Accessor method to dispatch to appropriate derived factory.
BDSTunnelSection * CreateTunnelSectionAngledOut(BDSTunnelType tunnelType, G4String name, G4double length, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
BDSTunnelFactoryBase * circular
Factory instance.
BDSTunnelFactoryBase * square
Factory instance.
BDSTunnelSection * CreateTunnelSection(BDSTunnelType tunnelType, G4String name, G4double length, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
Create a tunnel section with straight input and output face.
static BDSTunnelFactory * Instance()
singleton pattern
BDSTunnelFactoryBase * elliptical
Factory instance.
BDSTunnelSection * CreateTunnelSectionAngledInOut(BDSTunnelType tunnelType, G4String name, G4double length, G4double angleIn, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible=true)
Create a tunnel section with an angled input and output face.
BDSTunnelFactoryBase * rectaboveground
Factory instance.
Class that represents a section of tunnel.
type underlying() const
return underlying value (can be used in switch statement)