63 #define DEBUG_MEM_STEPPING
64 #define DEBUG_MEM_DETAILED_STEPPING
69 using namespace G4MemStat;
77 #define RED "\033[0;31m"
78 #define LIGHT_RED "\33[1;31m"
79 #define GREEN "\033[32;40m"
80 #define GREEN_ON_BLUE "\033[1;32;44m"
81 #define RESET_COLOR "\033[0m"
86 #define GREEN_ON_BLUE ""
87 #define RESET_COLOR ""
97 return std::numeric_limits<T>::has_infinity
98 && value == std::numeric_limits<T>::infinity();
104 if(fgScheduler == 0) fgScheduler =
new G4Scheduler();
115 G4cout <<
"G4Scheduler received G4State_Quit" <<
G4endl;
325 <<
"You are asking to use user defined steps but you did not give any.";
326 G4Exception(
"G4Scheduler::FindUserPreDefinedTimeStep",
329 exceptionDescription);
383 G4cout <<
"*** G4Scheduler starts processing " <<
G4endl;
385 G4cout <<
"___________________________________________"
386 "___________________________" <<
G4endl;
411 G4bool trackFound =
false;
437 G4cout <<
"G4Scheduler: process time= "<< localtimer <<
G4endl;
461 G4cout <<
"*** G4Scheduler ends at time : "
463 G4cout <<
"___________________________________" <<
G4endl;
467 G4cout <<
"*** G4Scheduler did not start because no "
468 "track was found to be processed"<<
G4endl;
469 G4cout <<
"___________________________________" <<
G4endl;
525 double nextWatchedTime = -1;
541 if(nextWatchedTime >
fEndTime && carryOn)
564 G4cout <<
"G4Scheduler has reached a stage: it might be"
565 " a transition or the end"
568 G4bool normalStop =
false;
572 G4cout <<
"== G4Scheduler: I stop because I reached the stop time : "
578 G4cout <<
"G4Scheduler: I stop because the current main list of tracks "
585 G4cout <<
"G4Scheduler: I stop because I reached the maximum allowed "
592 G4cout <<
"G4Scheduler: It might be that I stop because "
593 "I have been told so. You may check "
594 "member fContinue and usage of the method G4Scheduler::Stop()."
608 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
609 MemStat mem_first, mem_second, mem_diff;
612 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
626 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
628 mem_diff = mem_second-mem_first;
629 G4cout <<
"\t || MEM || After step " <<
fNbSteps <<
", diff is : "
636 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
638 mem_diff = mem_second-mem_first;
639 G4cout <<
"\t || MEM || After stepping, diff is : " << mem_diff <<
G4endl;
644 G4cout <<
"*** G4Scheduler has finished processing a track list at time : "
678 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
679 MemStat mem_first, mem_second, mem_diff;
682 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
697 <<
" the chosen user time step is : "
717 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
719 mem_diff = mem_second-mem_first;
720 G4cout <<
"|| MEM || After computing TS, diff is : " << mem_diff <<
G4endl;
737 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
751 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
753 mem_diff = mem_second-mem_first;
754 G4cout <<
"|| MEM || After IL, diff is : " << mem_diff <<
G4endl;
763 G4cout <<
"*** The minimum time returned by the processes is : "
771 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
809 exceptionDescription <<
"Too many zero time steps were detected. ";
810 exceptionDescription <<
"The simulation is probably stuck. ";
812 <<
"The maximum number of zero time steps is currently : "
814 exceptionDescription <<
".";
817 "SchedulerNullTimeSteps",
819 exceptionDescription);
835 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
837 mem_diff = mem_second-mem_first;
838 G4cout <<
"|| MEM || After LeadingTracks and UserPreTimeStepAction: "
842 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
865 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
867 mem_diff = mem_second-mem_first;
868 G4cout <<
"|| MEM || After DoIT, diff is : " << mem_diff <<
G4endl;
871 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
893 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
895 mem_diff = mem_second-mem_first;
896 G4cout <<
"|| MEM || After computing reactions + UserPostTimeStepAction, "
897 "diff is : " << mem_diff <<
G4endl;
911 std::stringstream finalOutput;
913 finalOutput <<
"*** End of step N°" <<
fNbSteps
917 <<
"\t " << interactionType
924 finalOutput <<
"It has also reached the user time limit" <<
G4endl;
926 finalOutput <<
"_______________________________________________________________"
930 G4cout << finalOutput.str();
947 map<double, double>::const_iterator it_fpUserTimeSteps_i =
fpUserTimeSteps
949 map<double, double>::const_iterator it_fpUserTimeSteps_low =
fpUserTimeSteps
965 it_fpUserTimeSteps_i--;
973 it_fpUserTimeSteps_i = it_fpUserTimeSteps_low;
974 map<double, double>::const_iterator tmp_it = it_fpUserTimeSteps_low;
985 else if (it_fpUserTimeSteps_i == it_fpUserTimeSteps_low)
994 if(it_fpUserTimeSteps_i !=
fpUserTimeSteps->begin()) it_fpUserTimeSteps_i--;
999 it_fpUserTimeSteps_i = it_fpUserTimeSteps_low;
1002 return it_fpUserTimeSteps_i->second;
1013 exceptionDescription
1014 <<
"You are asking to use user defined steps but you did not give any.";
1015 G4Exception(
"G4Scheduler::FindUserPreDefinedTimeStep",
1018 exceptionDescription);
1021 map<double, double>::iterator fpUserTimeSteps_i =
1038 fpUserTimeSteps_i--;
1045 fpUserTimeSteps_i = fpUserTimeSteps_low;
1047 else if(fpUserTimeSteps_i == fpUserTimeSteps_low)
1050 fpUserTimeSteps_i--;
1054 fpUserTimeSteps_i = fpUserTimeSteps_low;
1067 exceptionDescription
1068 <<
"End tracking is called while G4Scheduler is still running."
1074 exceptionDescription);
1084 for (; it != end; ++it)
1096 for (; it != end; ++it)
1152 interactionType =
"eInteractionWithMedium";
1155 interactionType =
"eCollisionBetweenTracks";
1158 interactionType =
"eCollisionBetweenTracks";
static G4ITReactionSet * Instance()
G4ITReactionSet * fReactionSet
double GetLimitingTimeStep() const
static G4ThreadLocal G4Scheduler * fgScheduler
void DoIt(double timeStep)
std::ostringstream G4ExceptionDescription
bool DelayListsNOTEmpty()
void GetCollisionType(G4String &interactionType)
virtual void StartProcessing()
G4UserTimeStepAction * fpUserTimeStepAction
double GetNextWatchedTime() const
virtual void DefineTracks()
bool fUsePreDefinedTimeSteps
virtual size_t GetNTracks()
static constexpr double microsecond
void EndTrackingWOKill(G4Track *)
std::set< double > fWatchedTimes
G4ITModelProcessor * fpModelProcessor
int fMaxNZeroTimeStepsAllowed
virtual void EndProcessing()
virtual void UserPostTimeStepAction()
void ComputeTrackReaction(G4ITStepStatus fITStepStatus, G4double fGlobalTime, G4double currentTimeStep, G4double previousTimeStep, G4bool reachedUserTimeLimit, G4double fTimeTolerance, G4UserTimeStepAction *fpUserTimeStepAction, G4int fVerbose)
void SetInteractivity(G4ITTrackingInteractivity *)
G4ITStepProcessor * fpStepProcessor
virtual void RegisterModel(G4VITStepModel *, double)
bool fReachedUserTimeLimit
void ResetLeadingTracks()
static G4ITTypeManager * Instance()
void SetTrackingManager(G4ITTrackingManager *trackMan)
G4ITStepStatus fITStepStatus
bool SecondaryListsNOTEmpty()
virtual size_t GetNTracks()
bool GetComputeTimeStep()
static void DeleteInstance()
void MergeSecondariesWithMainList()
G4SchedulerMessenger * fpMessenger
const XML_Char int const XML_Char * value
void ForceReinitialization()
void RegisterModel(G4VITStepModel *aModel, const G4double globalTime)
void PrepareLeadingTracks()
virtual void Initialize()
double fDefaultMinTimeStep
std::map< double, double > * fpUserTimeSteps
G4ITTrackingInteractivity * fpTrackingInteractivity
G4TrackList * GetMainList(Key)
double fUserUpperTimeLimit
static void DeleteInstance()
G4double ComputeInteractionLength(double previousTimeStep)
G4TrackManyList * GetSecondariesList()
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4double CalculateMinTimeStep(G4double currentGlobalTime, G4double definedMinTimeStep)
double fDefinedMinTimeStep
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
bool MergeNextTimeToMainList(double &time)
virtual G4bool Notify(G4ApplicationState requestedState)
G4Scheduler & operator=(const G4Scheduler &)
virtual void UserPreTimeStepAction()
G4GLOB_DLL std::ostream G4cout
G4ITTrackingManager * fpTrackingManager
void SetInteractivity(G4ITTrackingInteractivity *)
void FindUserPreDefinedTimeStep()
G4ITModelHandler * fpModelHandler
void SetTrackingManager(G4ITTrackingManager *trackingManager)
static constexpr double picosecond
const XML_Char XML_Content * model
virtual void Initialize()
static G4Scheduler * Instance()
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4ITTrackHolder & fTrackContainer
void SetModelHandler(G4ITModelHandler *)
G4bool fUseDefaultTimeSteps