Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GeometryManager.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4GeometryManager
27//
28// Class description:
29//
30// A class responsible for high level geometrical functions, and for
31// high level objects in the geometry subdomain.
32// The class is a 'singleton', with access via the static method
33// G4GeometryManager::GetInstance().
34
35// Author: Paul Kent (CERN), 26.07.1995 - Initial version
36// John Apostolakis (CERN), 12.06.2024 - Added parallel optimisation
37// --------------------------------------------------------------------
38#ifndef G4GEOMETRYMANAGER_HH
39#define G4GEOMETRYMANAGER_HH
40
41#include <vector>
42
43#include "G4Types.hh"
44#include "G4SmartVoxelStat.hh"
45#include "G4ios.hh"
46
48class G4Timer;
50
51/**
52 * @brief G4GeometryManager is a singleton class responsible for high level
53 * geometrical functions, and for high level objects in the geometry subdomain.
54 */
55
56class G4GeometryManager
57{
58 public:
59
60 /**
61 * Destructor; called by G4RunManagerKernel.
62 */
64
65 /**
66 * Returns a pointer to the singleton instance of the class, creating
67 * it if not existing.
68 */
69 static G4GeometryManager* GetInstance();
70
71 /**
72 * Simply returns a pointer to the singleton instance.
73 */
74 static G4GeometryManager* GetInstanceIfExist();
75
76 /**
77 * Closes ('locks') the geometry: performs sanity and 'completion' checks
78 * and optionally [default=yes] builds the optimisation structure.
79 * Applies to just a specific subtree if a physical volume is specified.
80 * @param[in] pOptimise Flag to enabling/disabling optimisation structure.
81 * @param[in] verbose Flag for verbosity.
82 * @param[in] vol Optional pointer to a physical volume (subtree) for
83 * optimisation.
84 * @returns true if process succeeds.
85 */
86 G4bool CloseGeometry(G4bool pOptimise = true,
87 G4bool verbose = false,
88 G4VPhysicalVolume* vol = nullptr);
89
90 /**
91 * Opens ('unlocks') the geometry and removes the optimisation structure if
92 * present. Applies to just a specific subtree if a physical volume is
93 * specified.
94 * @param[in] vol Optional pointer to a physical volume (subtree) for
95 * optimisation.
96 */
97 void OpenGeometry(G4VPhysicalVolume* vol = nullptr);
98
99 /**
100 * Returns true/false according to the state of the optimised geometry.
101 */
103
104 /**
105 * Sets the maximum extent of the world volume.
106 * The operation is allowed only if NO solids have been created already.
107 */
108 void SetWorldMaximumExtent(G4double worldExtent);
109
110 // Methods to choose or undertake Parallel Optimisation
111 // ----------------------------------------------------
112
113 /**
114 * Requests optimisation using threads (if MT is enabled & used ).
115 */
116 void OptimiseInParallel(G4bool val = true);
117
118 /**
119 * Method that contributes to (voxel) optimisation until all work is done.
120 * To be called by a worker thread initialisation - not by the user.
121 */
123
124 /**
125 * Detailed method for user to request parallel optimisation (if verbosity
126 * is required). Calling this method is enough to ask for it.
127 * It will be used if Geant4 is built with MT/tasks.
128 * Parallelism will be used if Geant4 is built with MT/tasks.
129 */
130 void RequestParallelOptimisation(G4bool val = true, G4bool verbose = true);
131
132 /**
133 * Checks whether parallel optimisation was requested and configured.
134 */
136
137 /**
138 * Reports whether parallel optimisation was completed.
139 */
141
142 private:
143
144 /**
145 * Private Constructor. Set the geometry to be open.
146 */
147 G4GeometryManager();
148
149 // Create the voxel optimisation information. Return whether work is completed
150 // (In case of parallel optimisation, it will be done later by the workers)
151
152 /**
153 * Optimises all volumes or just multi-volumes (parameterisations, etc. ).
154 */
155 G4bool BuildOptimisations(G4bool allOpt, G4bool verbose = false);
156
157 /**
158 * Optimises one volume or subtree only.
159 */
160 G4bool BuildOptimisations(G4bool allOpt, G4VPhysicalVolume* vol);
161
162 /**
163 * Builds the optimisation structure in sequential mode.
164 */
165 void BuildOptimisationsSequential(G4bool allOpts, G4bool verbose = true);
166
167 /**
168 * Methods to delete the optimisation structure.
169 */
170 void DeleteOptimisations();
171 void DeleteOptimisations(G4VPhysicalVolume* vol);
172
173 private:
174
175 /** The static instance. */
176 static G4ThreadLocal G4GeometryManager* fgInstance;
177
178 /** Pointer to the voxelisation helper. */
179 static G4VoxelisationHelper* fParallelVoxeliser;
180
181 G4bool fIsClosed = false;
182
183 // Flags for parallel initialization
184 // ---------------------------------
185 static G4bool fParallelVoxelOptimisationRequested;
186
187 /** Not just requested, but adopted (i.e. also in MT/tasking mode). */
188 static G4bool fOptimiseInParallelConfigured;
189};
190
191#endif
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
static G4GeometryManager * GetInstance()
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=nullptr)
void SetWorldMaximumExtent(G4double worldExtent)
void OptimiseInParallel(G4bool val=true)
void RequestParallelOptimisation(G4bool val=true, G4bool verbose=true)
G4bool IsParallelOptimisationConfigured()
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)
static G4GeometryManager * GetInstanceIfExist()
G4bool IsParallelOptimisationFinished()
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VoxelisationHelper is a helper class to undertake voxelisation in parallel, aiding and off-loading ...
#define G4ThreadLocal
Definition tls.hh:77