Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4LPhysicsFreeVector.cc 74256 2013-10-02 14:24:02Z gcosmo $
// $Id: G4LPhysicsFreeVector.cc 98864 2016-08-15 11:53:26Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -41,52 +41,22 @@
// --------------------------------------------------------------------
#include "G4LPhysicsFreeVector.hh"
#include "G4SystemOfUnits.hh"
#include "G4ios.hh"
// --------------------------------------------------------------------
G4LPhysicsFreeVector::G4LPhysicsFreeVector()
: G4PhysicsVector()
{
type = T_G4LPhysicsFreeVector;
}
: G4PhysicsFreeVector()
{}
// --------------------------------------------------------------------
G4LPhysicsFreeVector::G4LPhysicsFreeVector(size_t nbin,
G4double binmin,
G4double binmax)
: G4PhysicsVector()
{
type = T_G4LPhysicsFreeVector;
edgeMin = binmin;
edgeMax = binmax;
numberOfNodes = nbin;
binVector.reserve(numberOfNodes);
dataVector.reserve(numberOfNodes);
for (size_t i=0; i<numberOfNodes; i++)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
}
}
G4LPhysicsFreeVector::G4LPhysicsFreeVector(size_t length, G4double, G4double)
: G4PhysicsFreeVector(length)
{}
// --------------------------------------------------------------------
G4LPhysicsFreeVector::~G4LPhysicsFreeVector()
{
}
// --------------------------------------------------------------------
void G4LPhysicsFreeVector::DumpValues()
{
for (size_t i = 0; i < numberOfNodes; i++)
{
G4cout << binVector[i] << " " << dataVector[i]/millibarn << G4endl;
}
}
{}
// --------------------------------------------------------------------
@@ -270,7 +270,7 @@ G4Physics2DVector::PutVectors(const std::vector<G4double>& vecX,
// --------------------------------------------------------------
void G4Physics2DVector::Store(std::ofstream& out)
void G4Physics2DVector::Store(std::ofstream& out) const
{
// binning
G4int prec = out.precision();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsFreeVector.cc 93409 2015-10-21 13:26:27Z gcosmo $
// $Id: G4PhysicsFreeVector.cc 98864 2016-08-15 11:53:26Z gcosmo $
//
//
//--------------------------------------------------------------------
@@ -45,18 +45,17 @@
#include "G4PhysicsFreeVector.hh"
G4PhysicsFreeVector::G4PhysicsFreeVector()
: G4PhysicsVector()
{
type = T_G4PhysicsFreeVector;
}
G4PhysicsFreeVector::G4PhysicsFreeVector(size_t theNbin)
G4PhysicsFreeVector::G4PhysicsFreeVector(size_t length)
: G4PhysicsVector()
{
type = T_G4PhysicsFreeVector;
numberOfNodes = theNbin;
numberOfNodes = length;
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
@@ -70,6 +69,7 @@ G4PhysicsFreeVector::G4PhysicsFreeVector(size_t theNbin)
G4PhysicsFreeVector::G4PhysicsFreeVector(const G4DataVector& theBinVector,
const G4DataVector& theDataVector)
: G4PhysicsVector()
{
type = T_G4PhysicsFreeVector;
numberOfNodes = theBinVector.size();
@@ -79,32 +79,16 @@ G4PhysicsFreeVector::G4PhysicsFreeVector(const G4DataVector& theBinVector,
for (size_t i=0; i<numberOfNodes; ++i)
{
binVector.push_back(theBinVector[i]);
dataVector.push_back(theDataVector[i]);
binVector.push_back(theBinVector[i]);
dataVector.push_back(theDataVector[i]);
}
if(numberOfNodes > 0)
{
edgeMin = binVector[0];
edgeMax = binVector[numberOfNodes-1];
}
edgeMin = binVector[0];
edgeMax = binVector[numberOfNodes-1];
}
G4PhysicsFreeVector::~G4PhysicsFreeVector()
{
}
{}
void G4PhysicsFreeVector::PutValue( size_t theBinNumber,
G4double theBinValue,
G4double theDataValue )
{
binVector[theBinNumber] = theBinValue;
dataVector[theBinNumber] = theDataValue;
if( theBinNumber == numberOfNodes-1 )
{
edgeMax = binVector[numberOfNodes-1];
}
if( theBinNumber == 0 )
{
edgeMin = binVector[0];
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLinearVector.cc 93409 2015-10-21 13:26:27Z gcosmo $
// $Id: G4PhysicsLinearVector.cc 98864 2016-08-15 11:53:26Z gcosmo $
//
//
//--------------------------------------------------------------------
@@ -46,29 +46,13 @@ G4PhysicsLinearVector::G4PhysicsLinearVector()
type = T_G4PhysicsLinearVector;
}
G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin)
: G4PhysicsVector()
{
type = T_G4PhysicsLinearVector;
numberOfNodes = theNbin + 1;
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
for (size_t i=0; i<numberOfNodes; ++i)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
}
}
G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin,
G4double theEmax, size_t theNbin)
: G4PhysicsVector()
{
type = T_G4PhysicsLinearVector;
dBin = (theEmax-theEmin)/theNbin;
dBin = (theEmax-theEmin)/(G4double)theNbin;
baseBin = theEmin/dBin;
numberOfNodes = theNbin + 1;
@@ -91,16 +75,16 @@ G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin,
}
G4PhysicsLinearVector::~G4PhysicsLinearVector(){}
G4PhysicsLinearVector::~G4PhysicsLinearVector()
{}
G4bool G4PhysicsLinearVector::Retrieve(std::ifstream& fIn, G4bool ascii)
{
G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
if (success)
{
G4double theEmin = binVector[0];
dBin = binVector[1]-theEmin;
baseBin = theEmin/dBin;
dBin = binVector[1]-edgeMin;
baseBin = edgeMin/dBin;
}
return success;
}
@@ -108,8 +92,7 @@ G4bool G4PhysicsLinearVector::Retrieve(std::ifstream& fIn, G4bool ascii)
void G4PhysicsLinearVector::ScaleVector(G4double factorE, G4double factorV)
{
G4PhysicsVector::ScaleVector(factorE, factorV);
G4double theEmin = binVector[0];
dBin = binVector[1]-theEmin;
baseBin = theEmin/dBin;
dBin = binVector[1]-edgeMin;
baseBin = edgeMin/dBin;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsLogVector.cc 93409 2015-10-21 13:26:27Z gcosmo $
// $Id: G4PhysicsLogVector.cc 98864 2016-08-15 11:53:26Z gcosmo $
//
//
// --------------------------------------------------------------
@@ -54,29 +54,13 @@ G4PhysicsLogVector::G4PhysicsLogVector()
type = T_G4PhysicsLogVector;
}
G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin)
: G4PhysicsVector()
{
type = T_G4PhysicsLogVector;
numberOfNodes = theNbin + 1;
dataVector.reserve(numberOfNodes);
binVector.reserve(numberOfNodes);
for (size_t i=0; i<numberOfNodes; ++i)
{
binVector.push_back(0.0);
dataVector.push_back(0.0);
}
}
G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin,
G4double theEmax, size_t theNbin)
: G4PhysicsVector()
{
type = T_G4PhysicsLogVector;
dBin = G4Log(theEmax/theEmin)/theNbin;
dBin = G4Log(theEmax/theEmin)/(G4double)theNbin;
baseBin = G4Log(theEmin)/dBin;
numberOfNodes = theNbin + 1;
@@ -99,17 +83,15 @@ G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin,
}
G4PhysicsLogVector::~G4PhysicsLogVector()
{
}
{}
G4bool G4PhysicsLogVector::Retrieve(std::ifstream& fIn, G4bool ascii)
{
G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
if (success)
{
G4double theEmin = binVector[0];
dBin = G4Log(binVector[1]/theEmin);
baseBin = G4Log(theEmin)/dBin;
dBin = G4Log(binVector[1]/edgeMin);
baseBin = G4Log(edgeMin)/dBin;
}
return success;
}
@@ -117,7 +99,6 @@ G4bool G4PhysicsLogVector::Retrieve(std::ifstream& fIn, G4bool ascii)
void G4PhysicsLogVector::ScaleVector(G4double factorE, G4double factorV)
{
G4PhysicsVector::ScaleVector(factorE, factorV);
G4double theEmin = binVector[0];
dBin = G4Log(binVector[1]/theEmin);
baseBin = G4Log(theEmin)/dBin;
dBin = G4Log(binVector[1]/edgeMin);
baseBin = G4Log(edgeMin)/dBin;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsOrderedFreeVector.cc 93409 2015-10-21 13:26:27Z gcosmo $
// $Id: G4PhysicsOrderedFreeVector.cc 98864 2016-08-15 11:53:26Z gcosmo $
//
////////////////////////////////////////////////////////////////////////
// PhysicsOrderedFreeVector Class Implementation
@@ -51,42 +51,30 @@
#include "G4PhysicsOrderedFreeVector.hh"
/////////////////////////
// Class Implementation
/////////////////////////
/////////////////
// Constructors
/////////////////
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector()
: G4PhysicsVector()
{
type = T_G4PhysicsOrderedFreeVector;
}
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector(G4double *Energies,
G4double *Values,
size_t VectorLength)
: G4PhysicsVector()
{
type = T_G4PhysicsOrderedFreeVector;
type = T_G4PhysicsOrderedFreeVector;
for (size_t i = 0 ; i < VectorLength ; ++i)
{
InsertValues(Energies[i], Values[i]);
}
dataVector.reserve(VectorLength);
binVector.reserve(VectorLength);
for (size_t i = 0 ; i < VectorLength ; ++i)
{
InsertValues(Energies[i], Values[i]);
}
}
G4PhysicsOrderedFreeVector::G4PhysicsOrderedFreeVector()
: G4PhysicsVector()
{
type = T_G4PhysicsOrderedFreeVector;
}
////////////////
// Destructors
////////////////
G4PhysicsOrderedFreeVector::~G4PhysicsOrderedFreeVector() {}
////////////
// Methods
////////////
G4PhysicsOrderedFreeVector::~G4PhysicsOrderedFreeVector()
{}
void G4PhysicsOrderedFreeVector::InsertValues(G4double energy, G4double value)
{
@@ -137,11 +125,3 @@ G4double G4PhysicsOrderedFreeVector::LinearInterpolationOfEnergy(G4double aValue
}
return res;
}
void G4PhysicsOrderedFreeVector::DumpValues()
{
for (size_t i = 0; i < numberOfNodes; i++)
{
G4cout << binVector[i] << "\t" << dataVector[i] << G4endl;
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsTable.cc 67970 2013-03-13 10:10:06Z gcosmo $
// $Id: G4PhysicsTable.cc 98864 2016-08-15 11:53:26Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -60,6 +60,7 @@ G4PhysicsTable::G4PhysicsTable(size_t cap)
vecFlag.reserve(cap);
}
/*
G4PhysicsTable::G4PhysicsTable(const G4PhysicsTable& right)
: G4PhysCollection()
{
@@ -81,7 +82,7 @@ G4PhysicsTable& G4PhysicsTable::operator=(const G4PhysicsTable& right)
}
return *this;
}
*/
G4PhysicsTable::~G4PhysicsTable()
{
G4PhysCollection::clear();
@@ -212,7 +213,7 @@ G4bool G4PhysicsTable::RetrievePhysicsTable(const G4String& fileName,
fIn >> vType;
}
G4PhysicsVector* pVec = CreatePhysicsVector(vType);
if (pVec==0)
if (pVec==nullptr)
{
#ifdef G4VERBOSE
G4cerr << "G4PhysicsTable::RetrievePhysicsTable():";
@@ -282,7 +283,7 @@ void G4PhysicsTable::ResetFlagArray()
G4PhysicsVector* G4PhysicsTable::CreatePhysicsVector(G4int type)
{
G4PhysicsVector* pVector=0;
G4PhysicsVector* pVector = nullptr;
switch (type)
{
case T_G4PhysicsLinearVector:
@@ -294,7 +295,7 @@ G4PhysicsVector* G4PhysicsTable::CreatePhysicsVector(G4int type)
break;
case T_G4PhysicsLnVector:
pVector = new G4PhysicsLnVector();
pVector = new G4PhysicsLogVector();
break;
case T_G4PhysicsFreeVector:
@@ -306,7 +307,7 @@ G4PhysicsVector* G4PhysicsTable::CreatePhysicsVector(G4int type)
break;
case T_G4LPhysicsFreeVector:
pVector = new G4LPhysicsFreeVector();
pVector = new G4PhysicsFreeVector();
break;
default:
+32 -20
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.cc 93409 2015-10-21 13:26:27Z gcosmo $
// $Id: G4PhysicsVector.cc 98864 2016-08-15 11:53:26Z gcosmo $
//
//
// --------------------------------------------------------------
@@ -58,20 +58,18 @@
// --------------------------------------------------------------
G4PhysicsVector::G4PhysicsVector(G4bool)
G4PhysicsVector::G4PhysicsVector(G4bool val)
: type(T_G4PhysicsVector),
edgeMin(0.), edgeMax(0.), numberOfNodes(0),
useSpline(false),
useSpline(val),
dBin(0.), baseBin(0.),
verboseLevel(0)
{
}
{}
// --------------------------------------------------------------
G4PhysicsVector::~G4PhysicsVector()
{
}
G4PhysicsVector::~G4PhysicsVector()
{}
// --------------------------------------------------------------
@@ -157,7 +155,7 @@ G4double G4PhysicsVector::GetLowEdgeEnergy(size_t binNumber) const
// --------------------------------------------------------------
G4bool G4PhysicsVector::Store(std::ofstream& fOut, G4bool ascii)
G4bool G4PhysicsVector::Store(std::ofstream& fOut, G4bool ascii) const
{
// Ascii mode
if (ascii)
@@ -205,15 +203,7 @@ G4bool G4PhysicsVector::Retrieve(std::ifstream& fIn, G4bool ascii)
// contents
G4int siz=0;
fIn >> siz;
if (fIn.fail()) { return false; }
if (siz<=0)
{
#ifdef G4VERBOSE
G4cerr << "G4PhysicsVector::Retrieve():";
G4cerr << " Invalid vector size: " << siz << G4endl;
#endif
return false;
}
if (fIn.fail() || siz<=0) { return false; }
binVector.reserve(siz);
dataVector.reserve(siz);
@@ -273,6 +263,16 @@ G4bool G4PhysicsVector::Retrieve(std::ifstream& fIn, G4bool ascii)
// --------------------------------------------------------------
void G4PhysicsVector::DumpValues(G4double unitE, G4double unitV) const
{
for (size_t i = 0; i < numberOfNodes; ++i)
{
G4cout << binVector[i]/unitE << " " << dataVector[i]/unitV << G4endl;
}
}
// --------------------------------------------------------------------
void
G4PhysicsVector::ScaleVector(G4double factorE, G4double factorV)
{
@@ -284,8 +284,8 @@ G4PhysicsVector::ScaleVector(G4double factorE, G4double factorV)
}
secDerivative.clear();
edgeMin *= factorE;
edgeMax *= factorE;
edgeMin = binVector[0];
edgeMax = binVector[n-1];
}
// --------------------------------------------------------------
@@ -529,3 +529,15 @@ G4double G4PhysicsVector::FindLinearEnergy(G4double rand) const
}
//---------------------------------------------------------------
void G4PhysicsVector::PrintPutValueError(size_t index)
{
G4ExceptionDescription ed;
ed << "Vector type " << type << " length= " << numberOfNodes
<< " an attempt to put data at index= " << index;
G4Exception("G4PhysicsVector::PutValue()","gl0005",FatalException,
ed,"Memory overwritten");
}
//---------------------------------------------------------------
@@ -49,6 +49,8 @@
#if defined(G4MULTITHREADED)
#include <atomic>
namespace
{
G4ThreadLocal G4int G4ThreadID = G4Threading::MASTER_ID;
@@ -58,7 +60,13 @@ namespace
G4Pid_t G4Threading::G4GetPidId()
{ // In multithreaded mode return Thread ID
#if defined(__MACH__)
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
uint64_t tid64;
pthread_threadid_np(NULL, &tid64);
return (pid_t)tid64;
#else
return syscall(SYS_thread_selfid);
#endif
#elif defined(WIN32)
return GetCurrentThreadId();
#else
@@ -111,6 +119,14 @@ G4bool G4Threading::G4SetPinAffinity(G4int, G4Thread&)
void G4Threading::SetMultithreadedApplication(G4bool value ) { isMTAppType = value; }
G4bool G4Threading::IsMultithreadedApplication() { return isMTAppType; }
namespace
{
std::atomic_int numActThreads(0);
}
int G4Threading::WorkerThreadLeavesPool() { return numActThreads--; }
int G4Threading::WorkerThreadJoinsPool() { return numActThreads++;}
G4int G4Threading::GetNumberOfRunningWorkerThreads() { return numActThreads.load(); }
#else // Sequential mode
G4int fake_mutex_lock_unlock( G4Mutex* ) { return 0; }
@@ -134,4 +150,8 @@ G4bool G4Threading::G4SetPinAffinity(G4int,G4Thread&) { return true;}
void G4Threading::SetMultithreadedApplication(G4bool) {}
G4bool G4Threading::IsMultithreadedApplication() { return false; }
int G4Threading::WorkerThreadLeavesPool() { return 0; }
int G4Threading::WorkerThreadJoinsPool() { return 0; }
G4int G4Threading::GetNumberOfRunningWorkerThreads() { return 0; }
#endif
+130 -21
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UnitsTable.cc 96706 2016-05-02 09:31:38Z gcosmo $
// $Id: G4UnitsTable.cc 99523 2016-09-26 10:25:48Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//
@@ -51,17 +51,47 @@
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4Threading.hh"
G4ThreadLocal G4UnitsTable *G4UnitDefinition::pUnitsTable = 0;
G4ThreadLocal G4UnitsTable* G4UnitDefinition::pUnitsTable = 0;
G4ThreadLocal G4bool G4UnitDefinition::unitsTableDestroyed = false;
#ifdef G4MULTITHREADED
G4UnitsTable* G4UnitDefinition::pUnitsTableShadow = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4UnitsTable::G4UnitsTable() {;}
G4UnitsTable::~G4UnitsTable()
{
G4UnitsTable::iterator itr = begin();
for(;itr!=end();itr++)
{ delete *itr; }
clear();
}
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4UnitDefinition::G4UnitDefinition(const G4String& name,
const G4String& symbol,
const G4String& category, G4double value)
: Name(name),SymbolName(symbol),Value(value)
: Name(name),SymbolName(symbol),Value(value)
{
if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
if (!pUnitsTable)
{
if(unitsTableDestroyed)
{
G4Exception("G4UnitDefinition::G4UnitDefinition","UnitsTable0000",
FatalException,"G4UnitsTable had already deleted.");
}
pUnitsTable = new G4UnitsTable;
#ifdef G4MULTITHREADED
if(G4Threading::IsMasterThread())
{ pUnitsTableShadow = pUnitsTable; }
#endif
}
// Does the Category objet already exist ?
//
@@ -85,9 +115,7 @@ G4UnitDefinition::G4UnitDefinition(const G4String& name,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4UnitDefinition::~G4UnitDefinition()
{
if (!pUnitsTable) { delete pUnitsTable; pUnitsTable = 0; }
}
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -130,22 +158,42 @@ G4UnitsTable& G4UnitDefinition::GetUnitsTable()
{
if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
if(pUnitsTable->size()==0) { BuildUnitsTable(); }
#ifdef G4MULTITHREADED
if(G4Threading::IsMasterThread() && !pUnitsTableShadow)
{ pUnitsTableShadow = pUnitsTable; }
#endif
return *pUnitsTable;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4UnitDefinition::IsUnitDefined(const G4String& str)
{
G4String name, symbol;
for (size_t i=0;i<(GetUnitsTable()).size();++i)
{
G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
for (size_t j=0;j<units.size();++j)
{
name=units[j]->GetName(); symbol=units[j]->GetSymbol();
if(str==name||str==symbol) { return true; }
}
}
return false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4UnitDefinition::GetValueOf(const G4String& str)
{
G4String name,symbol;
for (size_t i=0;i<(GetUnitsTable()).size();i++)
G4String name, symbol;
for (size_t i=0;i<(GetUnitsTable()).size();++i)
{
G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
for (size_t j=0;j<units.size();j++)
for (size_t j=0;j<units.size();++j)
{
name=units[j]->GetName(); symbol=units[j]->GetSymbol();
if(str==name||str==symbol)
{ return units[j]->GetValue(); }
if(str==name||str==symbol) { return units[j]->GetValue(); }
}
}
std::ostringstream message;
@@ -159,15 +207,14 @@ G4double G4UnitDefinition::GetValueOf(const G4String& str)
G4String G4UnitDefinition::GetCategory(const G4String& str)
{
G4String name,symbol;
for (size_t i=0;i<(GetUnitsTable()).size();i++)
G4String name, symbol;
for (size_t i=0;i<(GetUnitsTable()).size();++i)
{
G4UnitsContainer& units = (*pUnitsTable)[i]->GetUnitsList();
for (size_t j=0;j<units.size();j++)
for (size_t j=0;j<units.size();++j)
{
name=units[j]->GetName(); symbol=units[j]->GetSymbol();
if(str==name||str==symbol)
{ return (*pUnitsTable)[i]->GetName(); }
if(str==name||str==symbol) { return (*pUnitsTable)[i]->GetName(); }
}
}
std::ostringstream message;
@@ -296,7 +343,7 @@ void G4UnitDefinition::BuildUnitsTable()
new G4UnitDefinition("newton","N","Force",newton);
//Pressure
new G4UnitDefinition( "pascal","Pa" ,"Pressure",pascal);
new G4UnitDefinition( "pascal","Pa" ,"Pressure",hep_pascal);
new G4UnitDefinition( "bar","bar","Pressure",bar);
new G4UnitDefinition("atmosphere","atm","Pressure",atmosphere);
@@ -312,8 +359,10 @@ void G4UnitDefinition::BuildUnitsTable()
new G4UnitDefinition("megavolt","MV","Electric potential",megavolt);
//Electric field
new G4UnitDefinition( "volt/m","V/m","Electric field",volt/m);
new G4UnitDefinition( "volt/m","V/m" ,"Electric field",volt/m);
new G4UnitDefinition("kilovolt/m","kV/m","Electric field",kilovolt/m);
new G4UnitDefinition("megavolt/m","MV/m","Electric field",megavolt/m);
//Magnetic flux
new G4UnitDefinition("weber","Wb","Magnetic flux",weber);
@@ -353,12 +402,19 @@ void G4UnitDefinition::PrintUnitsTable()
void G4UnitDefinition::ClearUnitsTable()
{
if (!pUnitsTable) { pUnitsTable = new G4UnitsTable; }
#ifdef G4MULTITHREADED
delete pUnitsTable;
pUnitsTable = nullptr;
if(G4Threading::IsMasterThread())
{ pUnitsTableShadow = nullptr; }
#else
for (size_t i=0;i<pUnitsTable->size();i++)
{
delete (*pUnitsTable)[i];
}
pUnitsTable->clear();
#endif
unitsTableDestroyed = true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -534,3 +590,56 @@ std::ostream& operator<<(std::ostream& flux, G4BestUnit a)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifdef G4MULTITHREADED
void G4UnitsTable::Synchronize()
{
G4UnitsTable* orig = &(G4UnitDefinition::GetUnitsTableShadow());
if(this==orig) return;
G4UnitsTable::iterator utItr = orig->begin();
for(;utItr!=orig->end();utItr++)
{
G4UnitsCategory* category = *utItr;
G4String catName = category->GetName();
G4UnitsContainer* units = &(category->GetUnitsList());
G4UnitsContainer::iterator ucItr = units->begin();
for(;ucItr!=units->end();ucItr++)
{
G4UnitDefinition* unit = *ucItr;
if(!Contains(unit,catName))
{
new G4UnitDefinition(unit->GetName(),unit->GetSymbol(),
catName,unit->GetValue());
}
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4UnitsTable::Contains(const G4UnitDefinition* unit,
const G4String& categoryName)
{
G4UnitsTable::iterator utItr = begin();
for(;utItr!=end();utItr++)
{
G4UnitsCategory* category = *utItr;
G4String catName = category->GetName();
if(catName!=categoryName) continue;
G4UnitsContainer* units = &(category->GetUnitsList());
G4UnitsContainer::iterator ucItr = units->begin();
for(;ucItr!=units->end();ucItr++)
{
if((*ucItr)->GetName()==unit->GetName() &&
(*ucItr)->GetSymbol()==unit->GetSymbol())
{ return true; }
}
}
return false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif