Import Geant4 10.3.0.beta source tree
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GeometryTolerance.cc 92328 2015-08-28 07:44:26Z gcosmo $
|
||||
// $Id: G4GeometryTolerance.cc 96427 2016-04-14 09:37:29Z gcosmo $
|
||||
//
|
||||
// class G4GeometryTolerance
|
||||
//
|
||||
@@ -36,25 +36,25 @@
|
||||
|
||||
#include "G4GeometryTolerance.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4AutoDelete.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// Static class data
|
||||
// Static class instance
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4GeometryTolerance* G4GeometryTolerance::fpInstance = 0;
|
||||
G4bool G4GeometryTolerance::fInitialised = false;
|
||||
G4double G4GeometryTolerance::fCarTolerance = 1E-9*mm;
|
||||
G4double G4GeometryTolerance::fAngTolerance = 1E-9*rad;
|
||||
G4double G4GeometryTolerance::fRadTolerance = 1E-9*mm;
|
||||
G4ThreadLocal G4GeometryTolerance* G4GeometryTolerance::fpInstance = 0;
|
||||
|
||||
// ***************************************************************************
|
||||
// Constructor.
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4GeometryTolerance::G4GeometryTolerance()
|
||||
G4GeometryTolerance::G4GeometryTolerance() : fInitialised(false)
|
||||
{
|
||||
fCarTolerance = 1E-9*mm;
|
||||
fAngTolerance = 1E-9*rad;
|
||||
fRadTolerance = 1E-9*mm;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -63,7 +63,6 @@ G4GeometryTolerance::G4GeometryTolerance()
|
||||
//
|
||||
G4GeometryTolerance::~G4GeometryTolerance()
|
||||
{
|
||||
delete fpInstance; fpInstance = 0;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -76,6 +75,7 @@ G4GeometryTolerance* G4GeometryTolerance::GetInstance()
|
||||
if (fpInstance == 0)
|
||||
{
|
||||
fpInstance = new G4GeometryTolerance;
|
||||
G4AutoDelete::Register(fpInstance);
|
||||
}
|
||||
return fpInstance;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
/*
|
||||
* G4MTBarrier.cc
|
||||
*
|
||||
* Created on: Feb 10, 2016
|
||||
* Author: adotti
|
||||
*/
|
||||
|
||||
#include "G4MTBarrier.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
G4MTBarrier::G4MTBarrier(unsigned int numThreads ) :
|
||||
m_numActiveThreads(numThreads),
|
||||
m_counter(0),
|
||||
m_mutex(G4MUTEX_INITIALIZER),
|
||||
m_counterChanged(G4CONDITION_INITIALIZER),
|
||||
m_continue(G4CONDITION_INITIALIZER)
|
||||
{
|
||||
#if defined(WIN32)
|
||||
InitializeCriticalSection( &cs1 );
|
||||
InitializeCriticalSection( &cs2 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void G4MTBarrier::ThisWorkerReady() {
|
||||
//Step-1: Worker acquires lock on shared resource (the counter)
|
||||
#ifndef WIN32
|
||||
G4AutoLock lock(&m_mutex);
|
||||
#else
|
||||
EnterCriticalSection( &cs1 );
|
||||
#endif
|
||||
//Step-2: Worker increases counter
|
||||
++m_counter;
|
||||
//Step-3: Worker broadcasts that the counter has changed
|
||||
G4CONDITIONBROADCAST(&m_counterChanged);
|
||||
//Step-4: Worker waits on condition to continue
|
||||
#ifndef WIN32
|
||||
G4CONDITIONWAIT(&m_continue,&m_mutex);
|
||||
#else
|
||||
# ifdef G4MULTITHREADED
|
||||
G4CONDITIONWAIT(&m_continue,&cs1);
|
||||
# endif
|
||||
LeaveCriticalSection(&cs1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void G4MTBarrier::Wait() {
|
||||
while (true)
|
||||
{
|
||||
//Step-2: Acquires lock on shared resource (the counter)
|
||||
#ifndef WIN32
|
||||
G4AutoLock lock(&m_mutex);
|
||||
#else
|
||||
EnterCriticalSection(&cs2);
|
||||
#endif
|
||||
//If the counter equals active threads, all threads are ready, exit the loop
|
||||
if ( m_counter == m_numActiveThreads ) { break; }
|
||||
//Step-3: Not all workers are ready, wait for the number to change
|
||||
//before repeating the check
|
||||
#ifdef WIN32
|
||||
# ifdef G4MULTITHREADED
|
||||
G4CONDITIONWAIT(&m_counterChanged,&cs2);
|
||||
# endif
|
||||
LeaveCriticalSection(&cs2);
|
||||
#else
|
||||
G4CONDITIONWAIT(&m_counterChanged,&m_mutex);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void G4MTBarrier::ReleaseBarrier() {
|
||||
//Step-4: re-aquire lock and re-set shared resource for future re-use
|
||||
G4AutoLock lock(&m_mutex);
|
||||
m_counter = 0;
|
||||
G4CONDITIONBROADCAST(&m_continue);
|
||||
}
|
||||
|
||||
void G4MTBarrier::WaitForReadyWorkers() {
|
||||
//Step-1: Master enters a loop to wait all workers to be ready
|
||||
Wait();
|
||||
//Done, all workers are ready, broadcast a continue signal
|
||||
ReleaseBarrier();
|
||||
}
|
||||
|
||||
void G4MTBarrier::ResetCounter() {
|
||||
G4AutoLock l(&m_mutex);
|
||||
m_counter = 0;
|
||||
}
|
||||
|
||||
unsigned int G4MTBarrier::GetCounter() {
|
||||
G4AutoLock l(&m_mutex);
|
||||
const unsigned int result = m_counter;
|
||||
return result;
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UnitsTable.cc 94074 2015-11-05 14:56:40Z gcosmo $
|
||||
// $Id: G4UnitsTable.cc 96706 2016-05-02 09:31:38Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//
|
||||
@@ -149,9 +149,9 @@ G4double G4UnitDefinition::GetValueOf(const G4String& str)
|
||||
}
|
||||
}
|
||||
std::ostringstream message;
|
||||
message << "The unit '" << str << "' does not exist in the Units Table.";
|
||||
message << "The unit '" << str << "' does not exist in the Units Table!";
|
||||
G4Exception("G4UnitDefinition::GetValueOf()", "InvalidUnit",
|
||||
JustWarning, message, "Returning Value = 0.");
|
||||
FatalException, message);
|
||||
return 0.;
|
||||
}
|
||||
|
||||
@@ -171,9 +171,9 @@ G4String G4UnitDefinition::GetCategory(const G4String& str)
|
||||
}
|
||||
}
|
||||
std::ostringstream message;
|
||||
message << "The unit '" << str << "' does not exist in the Units Table.";
|
||||
message << "The unit '" << str << "' does not exist in the Units Table!";
|
||||
G4Exception("G4UnitDefinition::GetCategory()", "InvalidUnit",
|
||||
JustWarning, message, "Returning Value = 0.");
|
||||
FatalException, message);
|
||||
name = "None";
|
||||
return name;
|
||||
}
|
||||
@@ -237,7 +237,7 @@ void G4UnitDefinition::BuildUnitsTable()
|
||||
//Time
|
||||
new G4UnitDefinition( "second","s" ,"Time",second);
|
||||
new G4UnitDefinition("millisecond","ms" ,"Time",millisecond);
|
||||
new G4UnitDefinition("microsecond","mus" ,"Time",microsecond);
|
||||
new G4UnitDefinition("microsecond","us" ,"Time",microsecond);
|
||||
new G4UnitDefinition( "nanosecond","ns" ,"Time",nanosecond);
|
||||
new G4UnitDefinition( "picosecond","ps" ,"Time",picosecond);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user