37#ifdef G4GEOMETRY_VOXELDEBUG
83 if (pVolume !=
nullptr)
106 if (pVolume !=
nullptr)
159 std::vector<G4SmartVoxelStat> stats;
160 if (verbose) { allTimer.
Start(); }
166 for (
size_t n=0;
n<Store->size(); ++
n)
168 if (verbose) timer.
Start();
182#ifdef G4GEOMETRY_VOXELDEBUG
183 G4cout <<
"**** G4GeometryManager::BuildOptimisations" <<
G4endl
184 <<
" Examining logical volume name = "
194 std::ostringstream message;
195 message <<
"VoxelHeader allocation error." <<
G4endl
196 <<
"Allocation of new VoxelHeader" <<
G4endl
197 <<
" for volume " << volume->
GetName() <<
" failed.";
198 G4Exception(
"G4GeometryManager::BuildOptimisations()",
"GeomMgt0003",
212#ifdef G4GEOMETRY_VOXELDEBUG
213 G4cout <<
"**** G4GeometryManager::BuildOptimisations" <<
G4endl
214 <<
" Skipping logical volume name = " << volume->
GetName()
234 if (pVolume ==
nullptr) {
return; }
257 std::ostringstream message;
258 message <<
"VoxelHeader allocation error." <<
G4endl
259 <<
"Allocation of new VoxelHeader" <<
G4endl
260 <<
" for volume " << tVolume->
GetName() <<
" failed.";
261 G4Exception(
"G4GeometryManager::BuildOptimisations()",
"GeomMgt0003",
268#ifdef G4GEOMETRY_VOXELDEBUG
269 G4cout <<
"**** G4GeometryManager::BuildOptimisations" <<
G4endl
270 <<
" Skipping logical volume name = " << tVolume->
GetName()
293 for (
size_t n=0;
n<Store->size(); ++
n)
308 if (!pVolume) {
return; }
339 G4Exception(
"G4GeometryManager::SetMaximumExtent()",
341 "Extent can be set only BEFORE creating any geometry object!");
354 G4cout <<
"G4GeometryManager::ReportVoxelStats -- Voxel Statistics"
360 G4int i, nStat = stats.size();
363 for( i=0; i<nStat; ++i ) { totalMemory += stats[i].GetMemoryUse(); }
365 G4cout <<
" Total memory consumed for geometry optimisation: "
366 << totalMemory/1024 <<
" kByte" <<
G4endl;
367 G4cout <<
" Total CPU time elapsed for geometry optimisation: "
368 << std::setprecision(2) << totalCpuTime <<
" seconds"
369 << std::setprecision(6) <<
G4endl;
374 std::sort( stats.begin(), stats.end(),
377 return a.GetTotalTime() > b.GetTotalTime();
380 G4int nPrint = nStat > 10 ? 10 : nStat;
385 G4cout <<
" Percent Total CPU System CPU Memory Volume\n"
386 <<
" ------- ---------- ---------- -------- ----------"
391 for(i=0; i<nPrint; ++i)
394 G4double system = stats[i].GetSysTime();
397 if (system < 0) { system = 0.0; }
401 { perc =
total*100/totalCpuTime; }
403 G4cout << std::setprecision(2)
404 << std::setiosflags(std::ios::fixed|std::ios::right)
405 << std::setw(11) << perc
406 << std::setw(13) <<
total
407 << std::setw(13) << system
408 << std::setw(13) << (stats[i].GetMemoryUse()+512)/1024
409 <<
"k " << std::setiosflags(std::ios::left)
410 << stats[i].GetVolume()->GetName()
411 << std::resetiosflags(std::ios::floatfield|std::ios::adjustfield)
412 << std::setprecision(6)
419 std::sort( stats.begin(), stats.end(),
422 return a.GetMemoryUse() > b.GetMemoryUse();
427 G4cout <<
"\n Voxelisation: top memory users:" <<
G4endl;
428 G4cout <<
" Percent Memory Heads Nodes Pointers Total CPU Volume\n"
429 <<
" ------- -------- ------ ------ -------- ---------- ----------"
434 for(i=0; i<nPrint; ++i)
436 G4long memory = stats[i].GetMemoryUse();
437 G4double totTime = stats[i].GetTotalTime();
438 if (totTime < 0) { totTime = 0.0; }
440 G4cout << std::setprecision(2)
441 << std::setiosflags(std::ios::fixed|std::ios::right)
443 << std::setw(11) << memory/1024 <<
"k "
444 << std::setw( 9) << stats[i].GetNumberHeads()
445 << std::setw( 9) << stats[i].GetNumberNodes()
446 << std::setw(11) << stats[i].GetNumberPointers()
447 << std::setw(13) << totTime <<
" "
448 << std::setiosflags(std::ios::left)
449 << stats[i].GetVolume()->GetName()
450 << std::resetiosflags(std::ios::floatfield|std::ios::adjustfield)
451 << std::setprecision(6)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static constexpr double perMillion
G4GLOB_DLL std::ostream G4cout
G4GeometryManager()=default
static void ReportVoxelStats(std::vector< G4SmartVoxelStat > &stats, G4double totalCpuTime)
void DeleteOptimisations()
static G4bool IsGeometryClosed()
static G4ThreadLocal G4GeometryManager * fgInstance
static G4GeometryManager * GetInstance()
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=nullptr)
void SetWorldMaximumExtent(G4double worldExtent)
void BuildOptimisations(G4bool allOpt, G4bool verbose=false)
static G4ThreadLocal G4bool fIsClosed
void OpenGeometry(G4VPhysicalVolume *vol=nullptr)
static G4GeometryManager * GetInstanceIfExist()
void SetSurfaceTolerance(G4double worldExtent)
static G4GeometryTolerance * GetInstance()
static G4LogicalVolumeStore * GetInstance()
void SetVoxelHeader(G4SmartVoxelHeader *pVoxel)
size_t GetNoDaughters() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4bool IsToOptimise() const
const G4String & GetName() const
G4SmartVoxelHeader * GetVoxelHeader() const
static G4SolidStore * GetInstance()
G4double GetSystemElapsed() const
G4double GetUserElapsed() const
G4LogicalVolume * GetMotherLogical() const
virtual G4bool IsReplicated() const =0
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetRegularStructureId() const =0
G4double total(Particle const *const p1, Particle const *const p2)
const G4int kMinVoxelVolumesLevel1