Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GeometryWorkspace Class Reference

#include <G4GeometryWorkspace.hh>

Public Types

using pool_type = G4TWorkspacePool<G4GeometryWorkspace>
 

Public Member Functions

 G4GeometryWorkspace ()
 
 ~G4GeometryWorkspace ()=default
 
void UseWorkspace ()
 
void ReleaseWorkspace ()
 
void DestroyWorkspace ()
 
void InitialiseWorkspace ()
 

Static Public Member Functions

static pool_typeGetPool ()
 

Protected Member Functions

void InitialisePhysicalVolumes ()
 
G4bool CloneReplicaSolid (G4PVReplica *)
 

Detailed Description

Definition at line 56 of file G4GeometryWorkspace.hh.

Member Typedef Documentation

◆ pool_type

Constructor & Destructor Documentation

◆ G4GeometryWorkspace()

G4GeometryWorkspace::G4GeometryWorkspace ( )

Definition at line 50 of file G4GeometryWorkspace.cc.

51{
52 fpLogicalVolumeSIM=
54 fpPhysicalVolumeSIM=
56 fpReplicaSIM=
58 fpRegionSIM=
60
61 // Create a work area for Logical Volumes in this thread
62 // then capture its address
63 //
65
66 fLogicalVolumeOffset = fpLogicalVolumeSIM->GetOffset();
67
68 fPhysicalVolumeOffset = fpPhysicalVolumeSIM->GetOffset();
69
70 fReplicaOffset = fpReplicaSIM->GetOffset();
71
72 fRegionOffset = fpRegionSIM->GetOffset();
73}
static const G4LVManager & GetSubInstanceManager()
static const G4PVRManager & GetSubInstanceManager()
static const G4RegionManager & GetSubInstanceManager()
Definition G4Region.cc:55
static const G4PVManager & GetSubInstanceManager()

◆ ~G4GeometryWorkspace()

G4GeometryWorkspace::~G4GeometryWorkspace ( )
default

Member Function Documentation

◆ CloneReplicaSolid()

G4bool G4GeometryWorkspace::CloneReplicaSolid ( G4PVReplica * replicaPV)
protected

Definition at line 141 of file G4GeometryWorkspace.cc.

142{
143 G4LogicalVolume* logicalV = replicaPV->GetLogicalVolume();
144 G4VSolid* solid = logicalV->GetSolid();
145
146 G4AutoLock aLock(&mutex_init);
147 G4VSolid* workerSolid = solid->Clone();
148 aLock.unlock();
149
150 if( workerSolid != nullptr )
151 {
152 logicalV->InitialiseWorker(logicalV,workerSolid,nullptr);
153 }
154 else
155 {
156 // In the case that not all solids support(ed) the Clone()
157 // method, we do similar thing here to dynamically cast
158 // and then get the clone method
159 //
161 ed << "ERROR - Unable to initialise geometry for worker node." << "\n"
162 << "A solid lacks the Clone() method - or Clone() failed." << "\n"
163 << " Type of solid: " << solid->GetEntityType() << "\n"
164 << " Parameters: " << *solid;
165 G4Exception("G4GeometryWorkspace::CloneReplicaSolid()",
166 "GeomVol0003", FatalException, ed);
167 return false;
168 }
169 return true; // It Worked
170}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4VSolid * GetSolid() const
void InitialiseWorker(G4LogicalVolume *ptrMasterObject, G4VSolid *pSolid, G4VSensitiveDetector *pSDetector)
G4LogicalVolume * GetLogicalVolume() const
virtual G4VSolid * Clone() const
Definition G4VSolid.cc:391
virtual G4GeometryType GetEntityType() const =0

Referenced by InitialisePhysicalVolumes().

◆ DestroyWorkspace()

void G4GeometryWorkspace::DestroyWorkspace ( )

Definition at line 189 of file G4GeometryWorkspace.cc.

190{
192 for (auto physVol : *physVolStore)
193 {
194 G4LogicalVolume* logicalVol = physVol->GetLogicalVolume();
195 auto g4PVReplica = dynamic_cast<G4PVReplica*>(physVol);
196 if (g4PVReplica != nullptr)
197 {
198 g4PVReplica->TerminateWorker(g4PVReplica);
199 }
200 logicalVol->TerminateWorker(logicalVol);
201 }
202
203 // Threads may attempt to free memory simultaneously.
204 // Need a lock to guarantee thread safety
205 //
206 G4AutoLock aLock(&mutex_init);
207 fpLogicalVolumeSIM->FreeSlave();
208 fpPhysicalVolumeSIM->FreeSlave();
209 fpReplicaSIM->FreeSlave();
210 fpRegionSIM->FreeSlave();
211 aLock.unlock();
212}
void TerminateWorker(G4LogicalVolume *ptrMasterObject)
static G4PhysicalVolumeStore * GetInstance()

Referenced by G4WorkerThread::UpdateGeometryAndPhysicsVectorFromMaster().

◆ GetPool()

◆ InitialisePhysicalVolumes()

void G4GeometryWorkspace::InitialisePhysicalVolumes ( )
protected

Definition at line 108 of file G4GeometryWorkspace.cc.

109{
111 for (auto physVol : *physVolStore)
112 {
113 G4LogicalVolume *logicalVol = physVol->GetLogicalVolume();
114
115 // Use shadow pointer
116 //
117 G4VSolid* solid = logicalVol->GetMasterSolid();
118 auto g4PVReplica = dynamic_cast<G4PVReplica*>(physVol);
119 if (g4PVReplica == nullptr)
120 {
121 // Placement volume
122 //
123 logicalVol->InitialiseWorker(logicalVol,solid,nullptr);
124 }
125 else
126 {
127 g4PVReplica->InitialiseWorker(g4PVReplica);
128 logicalVol->InitialiseWorker(logicalVol,solid,nullptr);
129
130 // If the replica's solid (in LV) is changed during navigation,
131 // it must be thread-private
132 //
133 CloneReplicaSolid( g4PVReplica );
134 }
135 }
136}
G4bool CloneReplicaSolid(G4PVReplica *)
G4VSolid * GetMasterSolid() const

Referenced by InitialiseWorkspace().

◆ InitialiseWorkspace()

void G4GeometryWorkspace::InitialiseWorkspace ( )

Definition at line 174 of file G4GeometryWorkspace.cc.

175{
176 // Geometry related, split classes mechanism:
177 // Do *NOT* instantiate sub-instance for this thread, just copy the contents!
178 //
179 fpLogicalVolumeSIM->SlaveCopySubInstanceArray();
180 fpPhysicalVolumeSIM->SlaveCopySubInstanceArray();
181 fpReplicaSIM->SlaveCopySubInstanceArray();
182 fpRegionSIM->SlaveInitializeSubInstance();
183
185}
void SlaveInitializeSubInstance()
void SlaveCopySubInstanceArray()

Referenced by G4GeometryWorkspace(), and G4WorkerThread::UpdateGeometryAndPhysicsVectorFromMaster().

◆ ReleaseWorkspace()

void G4GeometryWorkspace::ReleaseWorkspace ( )

Definition at line 97 of file G4GeometryWorkspace.cc.

98{
99 fpLogicalVolumeSIM->UseWorkArea(nullptr);
100 fpPhysicalVolumeSIM->UseWorkArea(nullptr);
101
102 fpReplicaSIM->UseWorkArea(nullptr);
103 fpRegionSIM->UseWorkArea(nullptr);
104}
void UseWorkArea(T *newOffset)

◆ UseWorkspace()

void G4GeometryWorkspace::UseWorkspace ( )

Definition at line 78 of file G4GeometryWorkspace.cc.

79{
80 // Geometry related, split classes mechanism: instantiate sub-instance
81 // for this thread
82 //
83 fpLogicalVolumeSIM->UseWorkArea(fLogicalVolumeOffset);
84 fpPhysicalVolumeSIM->UseWorkArea(fPhysicalVolumeOffset);
85
86 fpReplicaSIM->UseWorkArea(fReplicaOffset);
87 fpRegionSIM->UseWorkArea(fRegionOffset);
88
89 // When recycling a workspace
90 // - it must be a lightweight operation, to reuse a valid work area
91 // - so it must NOT Initialise anything!
92 // Do not call InitialisePhysicalVolumes();
93}

The documentation for this class was generated from the following files: