File indexing completed on 2026-09-12 08:30:28
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
0028
0029 #include "PeriodicBoundaryPhysics.hh"
0030
0031 #include "PeriodicBoundaryProcess.hh"
0032
0033 #include "G4PhysicsConstructorFactory.hh"
0034 #include "G4ProcessManager.hh"
0035 #include "globals.hh"
0036
0037
0038 G4_DECLARE_PHYSCONSTR_FACTORY(PeriodicBoundaryPhysics);
0039
0040
0041 PeriodicBoundaryPhysics::PeriodicBoundaryPhysics(const G4String& name, G4bool per_x, G4bool per_y,
0042 G4bool per_z)
0043 : G4VPhysicsConstructor(name), fPeriodicX(per_x), fPeriodicY(per_y), fPeriodicZ(per_z)
0044 {
0045 verboseLevel = 0;
0046 }
0047
0048
0049
0050 void PeriodicBoundaryPhysics::ConstructParticle() {}
0051
0052
0053
0054 void PeriodicBoundaryPhysics::ConstructProcess()
0055 {
0056 if (verboseLevel > 0) G4cout << "Constructing cyclic boundary physics process" << G4endl;
0057
0058 auto* pbc =
0059 new PeriodicBoundaryProcess("Cyclic", fNotDefined, fPeriodicX, fPeriodicY, fPeriodicZ);
0060
0061 if (verboseLevel > 0) {
0062 pbc->SetVerboseLevel(verboseLevel);
0063 }
0064
0065 auto aParticleIterator = GetParticleIterator();
0066
0067 aParticleIterator->reset();
0068
0069 G4ProcessManager* processManager = nullptr;
0070
0071 while ((*aParticleIterator)()) {
0072 G4ParticleDefinition* particle = aParticleIterator->value();
0073
0074 G4String particleName = particle->GetParticleName();
0075
0076 processManager = particle->GetProcessManager();
0077
0078 if (!processManager) {
0079 ThrowException(particleName);
0080 return;
0081 }
0082
0083 AddDiscreteProcess(pbc, *particle, processManager);
0084 }
0085 }
0086
0087
0088
0089 void PeriodicBoundaryPhysics::ThrowException(const G4String& particleName)
0090 {
0091 std::ostringstream o;
0092 o << "Particle " << particleName << "without a Process Manager";
0093 G4Exception("G4PeriodicBoundaryPhysics::ConstructProcess()", "", FatalException, o.str().c_str());
0094 }
0095
0096
0097
0098 void PeriodicBoundaryPhysics::AddDiscreteProcess(PeriodicBoundaryProcess* periodicBoundaryProcess,
0099 G4ParticleDefinition& particle,
0100 G4ProcessManager* processManager)
0101 {
0102 if (periodicBoundaryProcess->IsApplicable(particle)) {
0103 processManager->AddDiscreteProcess(periodicBoundaryProcess);
0104 }
0105 }
0106
0107