Geant4 11.1.1
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 ()
 
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()
Definition: G4PVReplica.cc:343
static const G4RegionManager & GetSubInstanceManager()
Definition: G4Region.cc:55
static const G4PVManager & GetSubInstanceManager()

◆ ~G4GeometryWorkspace()

G4GeometryWorkspace::~G4GeometryWorkspace ( )

Definition at line 77 of file G4GeometryWorkspace.cc.

78{
79}

Member Function Documentation

◆ CloneReplicaSolid()

G4bool G4GeometryWorkspace::CloneReplicaSolid ( G4PVReplica replicaPV)
protected

Definition at line 148 of file G4GeometryWorkspace.cc.

149{
150 G4LogicalVolume* logicalV = replicaPV->GetLogicalVolume();
151 G4VSolid* solid = logicalV->GetSolid();
152
153 G4AutoLock aLock(&mutex_init);
154 G4VSolid* workerSolid = solid->Clone();
155 aLock.unlock();
156
157 if( workerSolid != nullptr )
158 {
159 logicalV->InitialiseWorker(logicalV,workerSolid,nullptr);
160 }
161 else
162 {
163 // In the case that not all solids support(ed) the Clone()
164 // method, we do similar thing here to dynamically cast
165 // and then get the clone method
166 //
168 ed << "ERROR - Unable to initialise geometry for worker node." << "\n"
169 << "A solid lacks the Clone() method - or Clone() failed." << "\n"
170 << " Type of solid: " << solid->GetEntityType() << "\n"
171 << " Parameters: " << *solid;
172 G4Exception("G4GeometryWorkspace::CloneReplicaSolid()",
173 "GeomVol0003", FatalException, ed);
174 return false;
175 }
176 return true; // It Worked
177}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
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 196 of file G4GeometryWorkspace.cc.

197{
199 for (std::size_t ip=0; ip<physVolStore->size(); ++ip)
200 {
201 G4VPhysicalVolume* physVol = (*physVolStore)[ip];
202 G4LogicalVolume* logicalVol = physVol->GetLogicalVolume();
203 G4PVReplica* g4PVReplica = dynamic_cast<G4PVReplica*>(physVol);
204 if (g4PVReplica != nullptr)
205 {
206 g4PVReplica->TerminateWorker(g4PVReplica);
207 }
208 logicalVol->TerminateWorker(logicalVol);
209 }
210
211 // Threads may attempt to free memory simultaneously.
212 // Need a lock to guarantee thread safety
213 //
214 G4AutoLock aLock(&mutex_init);
215 fpLogicalVolumeSIM->FreeSlave();
216 fpPhysicalVolumeSIM->FreeSlave();
217 fpReplicaSIM->FreeSlave();
218 fpRegionSIM->FreeSlave();
219 aLock.unlock();
220}
void TerminateWorker(G4LogicalVolume *ptrMasterObject)
void TerminateWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:400
static G4PhysicalVolumeStore * GetInstance()

Referenced by G4WorkerThread::UpdateGeometryAndPhysicsVectorFromMaster().

◆ GetPool()

◆ InitialisePhysicalVolumes()

void G4GeometryWorkspace::InitialisePhysicalVolumes ( )
protected

Definition at line 114 of file G4GeometryWorkspace.cc.

115{
117 for (std::size_t ip=0; ip<physVolStore->size(); ++ip)
118 {
119 G4VPhysicalVolume* physVol = (*physVolStore)[ip];
120 G4LogicalVolume *logicalVol = physVol->GetLogicalVolume();
121
122 // Use shadow pointer
123 //
124 G4VSolid* solid = logicalVol->GetMasterSolid();
125 G4PVReplica* g4PVReplica = dynamic_cast<G4PVReplica*>(physVol);
126 if (g4PVReplica == nullptr)
127 {
128 // Placement volume
129 //
130 logicalVol->InitialiseWorker(logicalVol,solid,nullptr);
131 }
132 else
133 {
134 g4PVReplica->InitialiseWorker(g4PVReplica);
135 logicalVol->InitialiseWorker(logicalVol,solid,nullptr);
136
137 // If the replica's solid (in LV) is changed during navigation,
138 // it must be thread-private
139 //
140 CloneReplicaSolid( g4PVReplica );
141 }
142 }
143}
G4bool CloneReplicaSolid(G4PVReplica *)
G4VSolid * GetMasterSolid() const
void InitialiseWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:355

Referenced by InitialiseWorkspace().

◆ InitialiseWorkspace()

void G4GeometryWorkspace::InitialiseWorkspace ( )

Definition at line 181 of file G4GeometryWorkspace.cc.

182{
183 // Geometry related, split classes mechanism:
184 // Do *NOT* instantiate sub-instance for this thread, just copy the contents!
185 //
186 fpLogicalVolumeSIM->SlaveCopySubInstanceArray();
187 fpPhysicalVolumeSIM->SlaveCopySubInstanceArray();
188 fpReplicaSIM->SlaveCopySubInstanceArray();
189 fpRegionSIM->SlaveInitializeSubInstance();
190
192}
void SlaveInitializeSubInstance()
void SlaveCopySubInstanceArray()

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

◆ ReleaseWorkspace()

void G4GeometryWorkspace::ReleaseWorkspace ( )

Definition at line 103 of file G4GeometryWorkspace.cc.

104{
105 fpLogicalVolumeSIM->UseWorkArea(nullptr);
106 fpPhysicalVolumeSIM->UseWorkArea(nullptr);
107
108 fpReplicaSIM->UseWorkArea(nullptr);
109 fpRegionSIM->UseWorkArea(nullptr);
110}
void UseWorkArea(T *newOffset)

◆ UseWorkspace()

void G4GeometryWorkspace::UseWorkspace ( )

Definition at line 84 of file G4GeometryWorkspace.cc.

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

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