MCPcopy Create free account
hub / github.com/Geant4/geant4 / DefineWorldVolume

Method DefineWorldVolume

source/run/src/G4RunManagerKernel.cc:438–494  ·  view source on GitHub ↗

--------------------------------------------------------------------

Source from the content-addressed store, hash-verified

436
437// --------------------------------------------------------------------
438void G4RunManagerKernel::DefineWorldVolume(G4VPhysicalVolume* worldVol, G4bool topologyIsChanged)
439{
440 G4StateManager* stateManager = G4StateManager::GetStateManager();
441 G4ApplicationState currentState = stateManager->GetCurrentState();
442
443 if (currentState != G4State_Init) {
444 if (currentState != G4State_Idle && currentState != G4State_PreInit) {
445 G4cout << "Current application state is " << stateManager->GetStateString(currentState)
446 << G4endl;
447 G4Exception("G4RunManagerKernel::DefineWorldVolume", "DefineWorldVolumeAtIncorrectState",
448 FatalException, "Geant4 kernel is not Init state : Method ignored.");
449 return;
450 }
451
452 stateManager->SetNewState(G4State_Init);
453 }
454
455 // The world volume MUST NOT have a region defined by the user
456 if (worldVol->GetLogicalVolume()->GetRegion() != nullptr) {
457 if (worldVol->GetLogicalVolume()->GetRegion() != defaultRegion) {
458 G4ExceptionDescription ED;
459 ED << "The world volume has a user-defined region <"
460 << worldVol->GetLogicalVolume()->GetRegion()->GetName() << ">." << G4endl;
461 ED << "World would have a default region assigned by RunManagerKernel." << G4endl;
462 G4Exception("G4RunManager::DefineWorldVolume", "Run0004", FatalException, ED);
463 }
464 }
465
466 SetupDefaultRegion();
467
468 // Accept the world volume
469 currentWorld = worldVol;
470
471 // Set the default region to the world
472
473 G4LogicalVolume* worldLog = currentWorld->GetLogicalVolume();
474 worldLog->SetRegion(defaultRegion);
475 defaultRegion->AddRootLogicalVolume(worldLog);
476 if (verboseLevel > 1)
477 G4cout << worldLog->GetName() << " is registered to the default region." << G4endl;
478
479 // Set the world volume, notify the Navigator and reset its state
480 G4TransportationManager::GetTransportationManager()->SetWorldForTracking(currentWorld);
481 if (topologyIsChanged) geometryNeedsToBeClosed = true;
482
483 // Notify the VisManager as well
484 if (G4Threading::IsMasterThread()) {
485 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
486 if (pVVisManager != nullptr) pVVisManager->GeometryHasChanged();
487 }
488
489 geometryInitialized = true;
490 stateManager->SetNewState(currentState);
491 if (physicsInitialized && currentState != G4State_Idle) {
492 stateManager->SetNewState(G4State_Idle);
493 }
494}
495

Callers

nothing calls this directly

Calls 9

G4ExceptionFunction · 0.85
SetNewStateMethod · 0.80
GetRegionMethod · 0.80
SetRegionMethod · 0.80
AddRootLogicalVolumeMethod · 0.80
GeometryHasChangedMethod · 0.80
GetStateStringMethod · 0.45
GetLogicalVolumeMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected