42#ifdef G4GEOMETRY_VOXELDEBUG
88 BuildOptimisations(pOptimise, pVolume);
92 BuildOptimisations(pOptimise, verbose);
111 DeleteOptimisations(pVolume);
115 DeleteOptimisations();
140 fgInstance = &worldManager;
150void G4GeometryManager::BuildOptimisations(
G4bool allOpts,
G4bool verbose)
154 std::vector<G4SmartVoxelStat> stats;
155 if (verbose) { allTimer.
Start(); }
161 for (
size_t n=0;
n<Store->size();
n++)
163 if (verbose) timer.
Start();
177#ifdef G4GEOMETRY_VOXELDEBUG
178 G4cout <<
"**** G4GeometryManager::BuildOptimisations" <<
G4endl
179 <<
" Examining logical volume name = "
189 std::ostringstream message;
190 message <<
"VoxelHeader allocation error." <<
G4endl
191 <<
"Allocation of new VoxelHeader" <<
G4endl
192 <<
" for volume " << volume->
GetName() <<
" failed.";
193 G4Exception(
"G4GeometryManager::BuildOptimisations()",
"GeomMgt0003",
207#ifdef G4GEOMETRY_VOXELDEBUG
208 G4cout <<
"**** G4GeometryManager::BuildOptimisations" <<
G4endl
209 <<
" Skipping logical volume name = " << volume->
GetName()
226void G4GeometryManager::BuildOptimisations(
G4bool allOpts,
229 if (!pVolume) {
return; }
235 if (!tVolume) {
return BuildOptimisations(allOpts,
false); }
252 std::ostringstream message;
253 message <<
"VoxelHeader allocation error." <<
G4endl
254 <<
"Allocation of new VoxelHeader" <<
G4endl
255 <<
" for volume " << tVolume->
GetName() <<
" failed.";
256 G4Exception(
"G4GeometryManager::BuildOptimisations()",
"GeomMgt0003",
263#ifdef G4GEOMETRY_VOXELDEBUG
264 G4cout <<
"**** G4GeometryManager::BuildOptimisations" <<
G4endl
265 <<
" Skipping logical volume name = " << tVolume->
GetName()
275 BuildOptimisations(allOpts, tVolume->
GetDaughter(0));
284void G4GeometryManager::DeleteOptimisations()
288 for (
size_t n=0;
n<Store->size();
n++)
303 if (!pVolume) {
return; }
309 if (!tVolume) {
return DeleteOptimisations(); }
334 G4Exception(
"G4GeometryManager::SetMaximumExtent()",
336 "Extent can be set only BEFORE creating any geometry object!");
346G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
349 G4cout <<
"G4GeometryManager::ReportVoxelStats -- Voxel Statistics"
355 G4int i, nStat = stats.size();
358 for( i=0;i<nStat;++i ) { totalMemory += stats[i].GetMemoryUse(); }
360 G4cout <<
" Total memory consumed for geometry optimisation: "
361 << totalMemory/1024 <<
" kByte" <<
G4endl;
362 G4cout <<
" Total CPU time elapsed for geometry optimisation: "
363 << std::setprecision(2) << totalCpuTime <<
" seconds"
364 << std::setprecision(6) <<
G4endl;
371 G4int nPrint = nStat > 10 ? 10 : nStat;
376 G4cout <<
" Percent Total CPU System CPU Memory Volume\n"
377 <<
" ------- ---------- ---------- -------- ----------"
382 for(i=0;i<nPrint;++i)
384 G4double total = stats[i].GetTotalTime();
385 G4double system = stats[i].GetSysTime();
388 if (system < 0) { system = 0.0; }
389 if ((total < 0) || (totalCpuTime < perMillion))
392 { perc = total*100/totalCpuTime; }
394 G4cout << std::setprecision(2)
395 << std::setiosflags(std::ios::fixed|std::ios::right)
396 << std::setw(11) << perc
397 << std::setw(13) << total
398 << std::setw(13) << system
399 << std::setw(13) << (stats[i].GetMemoryUse()+512)/1024
400 <<
"k " << std::setiosflags(std::ios::left)
401 << stats[i].GetVolume()->GetName()
402 << std::resetiosflags(std::ios::floatfield|std::ios::adjustfield)
403 << std::setprecision(6)
414 G4cout <<
"\n Voxelisation: top memory users:" <<
G4endl;
415 G4cout <<
" Percent Memory Heads Nodes Pointers Total CPU Volume\n"
416 <<
" ------- -------- ------ ------ -------- ---------- ----------"
421 for(i=0;i<nPrint;++i)
423 G4long memory = stats[i].GetMemoryUse();
424 G4double totTime = stats[i].GetTotalTime();
425 if (totTime < 0) { totTime = 0.0; }
427 G4cout << std::setprecision(2)
428 << std::setiosflags(std::ios::fixed|std::ios::right)
430 << std::setw(11) << memory/1024 <<
"k "
431 << std::setw( 9) << stats[i].GetNumberHeads()
432 << std::setw( 9) << stats[i].GetNumberNodes()
433 << std::setw(11) << stats[i].GetNumberPointers()
434 << std::setw(13) << totTime <<
" "
435 << std::setiosflags(std::ios::left)
436 << stats[i].GetVolume()->GetName()
437 << std::resetiosflags(std::ios::floatfield|std::ios::adjustfield)
438 << std::setprecision(6)
G4DLLIMPORT std::ostream G4cout
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false, G4VPhysicalVolume *vol=0)
void OpenGeometry(G4VPhysicalVolume *vol=0)
G4bool IsGeometryClosed()
static G4GeometryManager * GetInstance()
void SetWorldMaximumExtent(G4double worldExtent)
static void SetSurfaceTolerance(G4double worldExtent)
static G4GeometryTolerance * GetInstance()
static G4LogicalVolumeStore * GetInstance()
G4int GetNoDaughters() const
void SetVoxelHeader(G4SmartVoxelHeader *pVoxel)
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4bool IsToOptimise() 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
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
const G4int kMinVoxelVolumesLevel1