File indexing completed on 2025-02-23 09:22:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #include "PeriodicBoundaryPhysics.hh"
0028
0029 #include "PeriodicBoundaryProcess.hh"
0030
0031 #include "G4PhysicsConstructorFactory.hh"
0032 #include "G4ProcessManager.hh"
0033 #include "globals.hh"
0034
0035
0036 G4_DECLARE_PHYSCONSTR_FACTORY(PeriodicBoundaryPhysics);
0037
0038
0039 PeriodicBoundaryPhysics::PeriodicBoundaryPhysics(const G4String& name, G4bool per_x, G4bool per_y,
0040 G4bool per_z)
0041 : G4VPhysicsConstructor(name), fPeriodicX(per_x), fPeriodicY(per_y), fPeriodicZ(per_z)
0042 {
0043 verboseLevel = 0;
0044 }
0045
0046
0047
0048 void PeriodicBoundaryPhysics::ConstructParticle() {}
0049
0050
0051
0052 void PeriodicBoundaryPhysics::ConstructProcess()
0053 {
0054 if (verboseLevel > 0) G4cout << "Constructing cyclic boundary physics process" << G4endl;
0055
0056 auto* pbc =
0057 new PeriodicBoundaryProcess("Cyclic", fNotDefined, fPeriodicX, fPeriodicY, fPeriodicZ);
0058
0059 if (verboseLevel > 0) {
0060 pbc->SetVerboseLevel(verboseLevel);
0061 }
0062
0063 auto aParticleIterator = GetParticleIterator();
0064
0065 aParticleIterator->reset();
0066
0067 G4ProcessManager* processManager = nullptr;
0068
0069 while ((*aParticleIterator)()) {
0070 G4ParticleDefinition* particle = aParticleIterator->value();
0071
0072 G4String particleName = particle->GetParticleName();
0073
0074 processManager = particle->GetProcessManager();
0075
0076 if (!processManager) {
0077 ThrowException(particleName);
0078 return;
0079 }
0080
0081 AddDiscreteProcess(pbc, *particle, processManager);
0082 }
0083 }
0084
0085
0086
0087 void PeriodicBoundaryPhysics::ThrowException(const G4String& particleName)
0088 {
0089 std::ostringstream o;
0090 o << "Particle " << particleName << "without a Process Manager";
0091 G4Exception("G4PeriodicBoundaryPhysics::ConstructProcess()", "", FatalException, o.str().c_str());
0092 }
0093
0094
0095
0096 void PeriodicBoundaryPhysics::AddDiscreteProcess(PeriodicBoundaryProcess* periodicBoundaryProcess,
0097 G4ParticleDefinition& particle,
0098 G4ProcessManager* processManager)
0099 {
0100 if (periodicBoundaryProcess->IsApplicable(particle)) {
0101 processManager->AddDiscreteProcess(periodicBoundaryProcess);
0102 }
0103 }
0104
0105