Geant4-11
Namespaces | Data Structures | Functions
G4INCL::NuclearPotential Namespace Reference

Namespaces

namespace  anonymous_namespace{G4INCLINuclearPotential.cc}
 

Data Structures

class  INuclearPotential
 
class  NuclearPotentialConstant
 
class  NuclearPotentialEnergyIsospin
 
class  NuclearPotentialEnergyIsospinSmooth
 
class  NuclearPotentialIsospin
 

Functions

void clearCache ()
 Clear the INuclearPotential cache. More...
 
INuclearPotential const * createPotential (const PotentialType type, const G4int theA, const G4int theZ, const G4bool pionPotential)
 Create an INuclearPotential object. More...
 

Function Documentation

◆ clearCache()

void G4INCL::NuclearPotential::clearCache ( )

Clear the INuclearPotential cache.

Definition at line 102 of file G4INCLINuclearPotential.cc.

102 {
104 for(std::map<long,INuclearPotential const *>::const_iterator i = nuclearPotentialCache->begin(), e=nuclearPotentialCache->end(); i!=e; ++i)
105 delete i->second;
106 nuclearPotentialCache->clear();
109 }
110 }
G4ThreadLocal std::map< long, INuclearPotential const * > * nuclearPotentialCache

References G4INCL::NuclearPotential::anonymous_namespace{G4INCLINuclearPotential.cc}::nuclearPotentialCache.

Referenced by G4INCL::INCL::~INCL().

◆ createPotential()

INuclearPotential const * G4INCL::NuclearPotential::createPotential ( const PotentialType  type,
const G4int  theA,
const G4int  theZ,
const G4bool  pionPotential 
)

Create an INuclearPotential object.

This is the method that should be used to instantiate objects derived from INuclearPotential. It uses a caching mechanism to minimise thrashing and speed up the code.

Parameters
typethe type of the potential to be created
theAmass number of the nucleus
theZcharge number of the nucleus
pionPotentialwhether pions should also feel the potential
Returns
a pointer to the nuclear potential

Definition at line 70 of file G4INCLINuclearPotential.cc.

70 {
72 nuclearPotentialCache = new std::map<long,INuclearPotential const *>;
73
74 const long nuclideID = (pionPotential ? 1 : -1) * (1000*theZ + theA + 1000000*type); // MCNP-style nuclide IDs
75 const std::map<long,INuclearPotential const *>::const_iterator mapEntry = nuclearPotentialCache->find(nuclideID);
76 if(mapEntry == nuclearPotentialCache->end()) {
77 INuclearPotential const *thePotential = NULL;
78 switch(type) {
80 thePotential = new NuclearPotentialEnergyIsospinSmooth(theA, theZ, pionPotential);
81 break;
83 thePotential = new NuclearPotentialEnergyIsospin(theA, theZ, pionPotential);
84 break;
86 thePotential = new NuclearPotentialIsospin(theA, theZ, pionPotential);
87 break;
89 thePotential = new NuclearPotentialConstant(theA, theZ, pionPotential);
90 break;
91 default:
92 INCL_FATAL("Unrecognized potential type at Nucleus creation." << '\n');
93 break;
94 }
95 (*nuclearPotentialCache)[nuclideID] = thePotential;
96 return thePotential;
97 } else {
98 return mapEntry->second;
99 }
100 }
#define INCL_FATAL(x)
@ IsospinEnergySmoothPotential
@ IsospinEnergyPotential

References G4INCL::ConstantPotential, INCL_FATAL, G4INCL::IsospinEnergyPotential, G4INCL::IsospinEnergySmoothPotential, G4INCL::IsospinPotential, and G4INCL::NuclearPotential::anonymous_namespace{G4INCLINuclearPotential.cc}::nuclearPotentialCache.

Referenced by G4INCL::Nucleus::Nucleus().