Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
+4
View File
@@ -6,6 +6,10 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-07-17 Gabriele Cosmo (geombias-V11-02-01)
- Fixed reported Coverity defect in G4WeightWindowStore, to use std::move()
for avoiding implicit copy.
## 2024-04-02 Gabriele Cosmo (geombias-V11-02-00)
- Applied trivial clang-tidy fixes to G4GeometryCell, i.e. use of default
constructor/destructor.
@@ -181,7 +181,7 @@ AddLowerWeights(const G4GeometryCell& gCell,
map[fGeneralUpperEnergyBound] = lowerWeights[i];
++i;
}
fCellToUpEnBoundLoWePairsMap[gCell] = map;
fCellToUpEnBoundLoWePairsMap[gCell] = std::move(map);
}
void G4WeightWindowStore::
+11
View File
@@ -6,6 +6,17 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-11-26 Ivana Hrivnacova (field-V11-02-06)
- Better names for the G4EquationType enum constants
## 2024-11-04 Philippe Canal (field-V11-02-05)
- Improve stability of static initialization for StepperType() and
StepperDescription() in G4DormandPrince745.
## 2024-09-10 Ivana Hrivnacova (field-V11-02-04)
- Coverity fixes:
- Use std::move, const auto& instead of auto to avoid copying
## 2024-06-20 Ivana Hrivnacova (field-V11-02-03)
- Fix in G4FieldBuilder for local fields:
apply the local fields in the order of user setting
@@ -75,8 +75,8 @@ class G4DormandPrince745 : public G4MagIntegratorStepper
G4int IntegratorOrder() const override { return 4; }
const G4String& StepperType() const { return gStepperType; }
const G4String& StepperDescription() const { return gStepperDescription; }
const G4String& StepperType() const;
const G4String& StepperDescription() const;
const field_utils::State& GetYOut() const { return fyOut; }
@@ -89,11 +89,6 @@ class G4DormandPrince745 : public G4MagIntegratorStepper
private:
static const G4String gStepperType;
static const G4String gStepperDescription;
// Name and description of this steppers
// plus details of its implementation
field_utils::State ak2, ak3, ak4, ak5, ak6, ak7, ak8, ak9;
field_utils::State fyIn, fyOut, fdydxIn;
@@ -57,20 +57,19 @@ enum G4FieldType
/// in Geant4
enum G4EquationType
{
kMagUsualEqRhs, ///< G4Mag_UsualEqRhs: the standard right-hand side for
///< equation
/// of motion.
kMagSpinEqRhs, ///< G4Mag_SpinEqRhs: the equation of motion for a particle
kEqMagnetic, ///< G4Mag_UsualEqRhs: the standard right-hand side for
///< equation of motion.
kEqMagneticWithSpin,///< G4Mag_SpinEqRhs: the equation of motion for a particle
///< with spin
/// in a pure magnetic field
kEqMagElectric, ///< G4EqMagElectricField: Equation of motion in a combined
/// electric and magnetic field
kEqEMFieldWithSpin, ///< G4EqEMFieldWithSpin: Equation of motion for a
///< in a pure magnetic field
kEqElectroMagnetic, ///< G4EqMagElectricField: Equation of motion in a combined
///< electric and magnetic field
kEqEMfieldWithSpin, ///< G4EqEMFieldWithSpin: Equation of motion for a
///< particle with spin
/// in a combined electric and magnetic field
kEqEMFieldWithEDM, ///< G4EqEMFieldWithEDM: Equation of motion in a combined
/// electric and magnetic field, with spin tracking for
/// both MDM and EDM terms
///< in a combined electric and magnetic field
kEqEMfieldWithEDM, ///< G4EqEMFieldWithEDM: Equation of motion in a combined
///< electric and magnetic field, with spin tracking for
///< both MDM and EDM terms
kUserEquation ///< User defined equation of motion
};
@@ -259,7 +258,7 @@ class G4FieldParameters
G4FieldType fField = kMagnetic;
/// Type of equation of motion of a particle in a field
G4EquationType fEquation = kMagUsualEqRhs;
G4EquationType fEquation = kEqMagnetic;
/// Type of integrator of particle's equation of motion
G4StepperType fStepper = kDormandPrince745;
@@ -55,8 +55,8 @@ class G4UIcmdWithABool;
/// - /field/fieldType fieldType \n
/// fieldType = Magnetic | ElectroMagnetic | Gravity
/// - /field/equationType eqType \n
/// eqType = MagUsualEqRhs | MagSpinEqRhs | EqMagElectric |
/// EMFieldWithSpin | EqEMFieldWithEDM
/// eqType = EqMagnetic | EqMagneticWithSpin | EqElectroMagnetic |
/// EqEMfieldWithSpin | EqEMfieldWithEDM
/// - /field/stepperType stepperType \n
/// stepperType = CashKarpRKF45 | ClassicalRK4 | ExplicitEuler | ImplicitEuler |
/// SimpleHeum | SimpleRunge | ConstRK4 | ExactHelixStepper
@@ -57,12 +57,20 @@
using namespace field_utils;
const G4String G4DormandPrince745::gStepperType =
G4String("G4DormandPrince745: 5th order");
const G4String G4DormandPrince745::gStepperDescription= G4String(
"Embedeed 5th order Runge-Kutta stepper - 7 stages, FSAL, Interpolating.");
// Name of this steppers
const G4String& G4DormandPrince745::StepperType() const
{
static G4String _stepperType("G4DormandPrince745: 5th order");
return _stepperType;
}
// Description of this steppers - plus details of its implementation
const G4String& G4DormandPrince745::StepperDescription() const
{
static G4String _stepperDescription(
"Embedeed 5th order Runge-Kutta stepper - 7 stages, FSAL, Interpolating.");
return _stepperDescription;
}
G4DormandPrince745::G4DormandPrince745(G4EquationOfMotion* equation,
G4int noIntegrationVariables)
@@ -172,7 +172,7 @@ void G4FieldBuilder::ConstructLocalFields()
for (auto [lv, field] : GetLocalFields()) {
// Volume name
auto volumeName = lv->GetName();
const auto& volumeName = lv->GetName();
// Get or create user field parameters
G4FieldParameters* fieldParameters =
@@ -326,7 +326,7 @@ void G4FieldBuilder::SetFieldType(G4FieldType fieldType)
// change default equation and stepper if other than magnetic field
if (fieldType == kElectroMagnetic) {
fFieldParameters[0]->SetEquationType(kEqMagElectric);
fFieldParameters[0]->SetEquationType(kEqElectroMagnetic);
fFieldParameters[0]->SetStepperType(kClassicalRK4);
}
}
@@ -54,7 +54,7 @@ G4FieldBuilderMessenger::G4FieldBuilderMessenger(G4FieldBuilder* fieldBuilder)
fDirectory = new G4UIdirectory(directoryName);
fDirectory->SetGuidance("Magnetic (or other type) field control commands.");
G4String commandName = directoryName;
G4String commandName = std::move(directoryName);
commandName.append("verboseLevel");
fVerboseLevelCmd = new G4UIcmdWithAnInteger(commandName, this);
fVerboseLevelCmd->SetGuidance("Set verbose level");
@@ -69,16 +69,16 @@ G4String G4FieldParameters::EquationTypeName(G4EquationType equation)
// Return the equation type as a string
switch (equation) {
case kMagUsualEqRhs:
return G4String("MagUsualEqRhs");
case kMagSpinEqRhs:
return G4String("MagSpinEqRhs");
case kEqMagElectric:
return G4String("EqMagElectric");
case kEqEMFieldWithSpin:
return G4String("EqEMFieldWithSpin");
case kEqEMFieldWithEDM:
return G4String("EqEMFieldWithEDM");
case kEqMagnetic:
return G4String("EqMagnetic");
case kEqMagneticWithSpin:
return G4String("EqMagneticWithSpin");
case kEqElectroMagnetic:
return G4String("EqElectroMagnetic");
case kEqEMfieldWithSpin:
return G4String("EqEMfieldWithSpin");
case kEqEMfieldWithEDM:
return G4String("EqEMfieldWithEDM");
case kUserEquation:
return G4String("UserDefinedEq");
}
@@ -173,17 +173,17 @@ G4EquationType G4FieldParameters::GetEquationType(const G4String& name)
{
// Return the equation type for given equation type name
if (name == EquationTypeName(kMagUsualEqRhs)) return kMagUsualEqRhs;
if (name == EquationTypeName(kMagSpinEqRhs)) return kMagSpinEqRhs;
if (name == EquationTypeName(kEqMagElectric)) return kEqMagElectric;
if (name == EquationTypeName(kEqEMFieldWithSpin)) return kEqEMFieldWithSpin;
if (name == EquationTypeName(kEqEMFieldWithEDM)) return kEqEMFieldWithEDM;
if (name == EquationTypeName(kEqMagnetic)) return kEqMagnetic;
if (name == EquationTypeName(kEqMagneticWithSpin)) return kEqMagneticWithSpin;
if (name == EquationTypeName(kEqElectroMagnetic)) return kEqElectroMagnetic;
if (name == EquationTypeName(kEqEMfieldWithSpin)) return kEqEMfieldWithSpin;
if (name == EquationTypeName(kEqEMfieldWithEDM)) return kEqEMfieldWithEDM;
if (name == EquationTypeName(kUserEquation)) return kUserEquation;
G4Exception(
"G4FieldParameters::GetEquationType:", "GeomFieldParameters0001",
FatalErrorInArgument, "Unknown equation name.");
return kMagUsualEqRhs;
return kEqMagnetic;
}
//_____________________________________________________________________________
@@ -81,7 +81,7 @@ G4FieldParametersMessenger::G4FieldParametersMessenger(
fEquationTypeCmd->SetGuidance(guidance);
fEquationTypeCmd->SetParameterName("EquationType", false);
candidates = "";
for (G4int i = kMagUsualEqRhs; i <= kEqEMFieldWithEDM; i++) {
for (G4int i = kEqMagnetic; i <= kEqEMfieldWithEDM; i++) {
G4EquationType et = (G4EquationType)i;
candidates += G4FieldParameters::EquationTypeName(et);
candidates += " ";
@@ -182,7 +182,7 @@ G4FieldParametersMessenger::G4FieldParametersMessenger(
fSetConstDistanceCmd->SetRange("ConstDistance >= 0");
fSetConstDistanceCmd->AvailableForStates(G4State_PreInit);
commandName = directoryName;
commandName = std::move(directoryName);
commandName.append("printParameters");
fPrintParametersCmd = new G4UIcmdWithoutParameter(commandName, this);
fPrintParametersCmd->SetGuidance("Prints all accuracy parameters.");
@@ -230,7 +230,7 @@ void G4FieldParametersMessenger::SetNewValue(
}
if (command == fEquationTypeCmd) {
for (G4int i = kMagUsualEqRhs; i <= kEqEMFieldWithEDM; i++) {
for (G4int i = kEqMagnetic; i <= kEqEMfieldWithEDM; i++) {
G4EquationType et = (G4EquationType)i;
if (newValues == G4FieldParameters::EquationTypeName(et)) {
fFieldParameters->SetEquationType(et);
@@ -146,7 +146,7 @@ G4EquationOfMotion* G4FieldSetup::CreateEquation(G4EquationType equation)
// magnetic fields
G4MagneticField* magField = nullptr;
if (equation == kMagUsualEqRhs || equation == kMagSpinEqRhs) {
if (equation == kEqMagnetic || equation == kEqMagneticWithSpin) {
magField = dynamic_cast<G4MagneticField*>(fG4Field);
if (magField == nullptr) {
G4Exception(
@@ -159,7 +159,7 @@ G4EquationOfMotion* G4FieldSetup::CreateEquation(G4EquationType equation)
// electromagnetic fields
G4ElectroMagneticField* elMagField = nullptr;
if (equation >= kEqMagElectric && equation <= kEqEMFieldWithEDM) {
if (equation >= kEqElectroMagnetic && equation <= kEqEMfieldWithEDM) {
elMagField = dynamic_cast<G4ElectroMagneticField*>(fG4Field);
if (elMagField == nullptr) {
G4Exception(
@@ -172,23 +172,23 @@ G4EquationOfMotion* G4FieldSetup::CreateEquation(G4EquationType equation)
// electromagnetic fields
switch (equation) {
case kMagUsualEqRhs:
case kEqMagnetic:
return new G4Mag_UsualEqRhs(magField);
break;
case kMagSpinEqRhs:
case kEqMagneticWithSpin:
return new G4Mag_SpinEqRhs(magField);
break;
case kEqMagElectric:
case kEqElectroMagnetic:
return new G4EqMagElectricField(elMagField);
break;
case kEqEMFieldWithSpin:
case kEqEMfieldWithSpin:
return new G4EqEMFieldWithSpin(elMagField);
break;
case kEqEMFieldWithEDM:
case kEqEMfieldWithEDM:
return new G4EqEMFieldWithEDM(elMagField);
break;
case kUserEquation:
@@ -57,7 +57,7 @@ G4FieldSetupMessenger::G4FieldSetupMessenger(G4FieldSetup* fieldSetup)
directoryName.append("/");
}
G4String commandName = directoryName;
G4String commandName = std::move(directoryName);
commandName.append("update");
fUpdateCmd = new G4UIcmdWithoutParameter(commandName, this);
fUpdateCmd->SetGuidance("Update field setup.");
+20 -5
View File
@@ -6,16 +6,31 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-08-26 Gabriele Cosmo (geommng-V11-02-06)
- G4GeometryManager: temporarily disable default parallel optimisation.
Fixed spelling for method OptimiseInParallel(..).
## 2024-08-07 Gabriele Cosmo (geommng-V11-02-05)
- Fixed broken condition for enabling voxels statistics report in
G4GeometryManager::UndertakeOptimisation().
- Further cleanup in G4GeometryManager for usage of static data.
Fixed spelling on data members.
- Access G4GeometryManager singleton through its GetInstance() in stores.
## 2024-08-06 Gabriele Cosmo (geommng-V11-02-04)
- In G4GeometryManager, removed unnecessary static qualifier for some methods
and ordered methods declarations in header.
## 2024-06-17 Gabriele Cosmo (geommng-V11-02-03)
- Removed G4SmartVoxelProxy source file, as now empty.
- Minor code cleanup/indentation.
## 2024-06-02 John Apostolakis (geommng-V11-02-02)
- New capability to run voxel optimisation in threads (off by default).
First version, parallelises only over volumes. The user must currently call
G4GeometryManager::RequestParallelOptimisation(optimise=true, verbose) to use
it. Set verbose=true to obtain the volumes with biggest contribution to memory
size and CPU time for voxelisation.
First version, parallelises only over volumes. The user can call
RequestParallelOptimisation(optimise, verbose) from G4GeometryManager
to turn it on/off. Set verbose=true to obtain the volumes with biggest
contribution to memory size and CPU time for voxelisation.
Added new method BuildOptimisationsParallel() to be called by
G4WorkerRunManager to initialize. Added method ReportVoxelInfo() to write out
for verification. Checked with simple and complex/large geometries.
@@ -252,7 +267,7 @@ May 16, 2018 G.Cosmo (geommng-V10-04-05)
compilation warnings on gcc-8.1.
May 11, 2018 E.Tcherniaev (geommng-V10-04-04)
- G4AffineTransform: further optimized InverseProduct(), for the case where
- G4AffineTransform: further optimised InverseProduct(), for the case where
tf2 is a pure translation.
May 7, 2018 E.Tcherniaev (geommng-V10-04-03)
@@ -54,7 +54,7 @@
// - conversion of the rotation matrix to angle & axis used to get
// a possibility to remove "friend" from the G4RotationMatrix class
// 06.05.2018 E.Tcherniaev:
// - optimized InverseProduct
// - optimised InverseProduct
// - added methods for inverse transformation: InverseTrasformPoint,
// InverseTransformAxis, InverseNetRotation, InverseNetTranslation
// --------------------------------------------------------------------
@@ -67,8 +67,8 @@ class G4GeometryManager
// present. Applies to just a specific subtree if a physical volume is
// specified.
static G4bool IsGeometryClosed();
// Return true/false according to state of optimised geoemtry.
inline G4bool IsGeometryClosed() { return fIsClosed; }
// Return true/false according to state of optimised geometry.
void SetWorldMaximumExtent(G4double worldExtent);
// Set the maximum extent of the world volume. The operation is
@@ -81,29 +81,29 @@ class G4GeometryManager
static G4GeometryManager* GetInstanceIfExist();
// Return ptr to singleton instance.
static void OptimizeInParallel(G4bool val = true);
// Request optimization using threads (if MT is enabled & used ).
void OptimiseInParallel(G4bool val = true);
// Request optimisation using threads (if MT is enabled & used ).
void UndertakeOptimisation();
// Method that contributes to (Voxel) optimisation until all work is done.
// Must be called by Worker thread initialisation - not a user callable
// method.
static void RequestParallelOptimisation(G4bool val = true,
G4bool verbose = true);
void RequestParallelOptimisation(G4bool val = true,
G4bool verbose = true);
// Detailed method for user to request parallel Optimisation
// (if verbosity is required). Calling this is enough to ask for it.
// It will be used if Geant4 is built with MT/tasks.
static void ChooseSequentialOptimisation(G4bool verbose = false);
void ChooseSequentialOptimisation(G4bool verbose = false);
// Simple way to avoid parallel optimisation.
static G4bool IsParallelOptimisationConfigured();
G4bool IsParallelOptimisationConfigured();
// Check whether parallel optimisation was requested.
static G4bool IsParallelOptimisationFinished();
G4bool IsParallelOptimisationFinished();
// Report whether parallel optimisation is done.
~G4GeometryManager();
~G4GeometryManager();
// Destructor; called by G4RunManagerKernel.
private:
@@ -129,32 +129,21 @@ class G4GeometryManager
// Methods for parallel initialization
void CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose);
// Build vector of relevant volumes.
G4LogicalVolume* ObtainVolumeToOptimize();
G4LogicalVolume* ObtainVolumeToOptimise();
static G4ThreadLocal G4GeometryManager* fgInstance;
static G4ThreadLocal G4bool fIsClosed;
static std::vector<G4LogicalVolume*> fVolumesToOptimize;
// The list of volumes which threads need to optimize.
static std::vector<G4LogicalVolume*>::iterator fLogVolumeIterator;
// Iterator used by UndertakeOptimisation().
static std::vector<G4SmartVoxelStat> fGlobVoxelStats;
// Statistics container shared by all workers
static void ConfigureParallelOptimisation(G4bool verbose);
void ConfigureParallelOptimisation(G4bool verbose);
// Prepare for parallel optimisation.
G4int ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimized);
G4int ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimised);
// Thread-safe method for worker to report it's finished its work.
// It counts the number of workers that finished, and returns count.
// It counts the number of volumes optimised; if all workers have
// reported, it results in a 'Finished' state.
static void InformOptimisationIsFinished(G4bool verbose);
void InformOptimisationIsFinished(G4bool verbose);
// Returns true if all workers are finished (or all work is done).
static void ResetListOfVolumesToOptimise();
void ResetListOfVolumesToOptimise();
// Resets (empties) the list of candidate volumes for optimisation.
// Must be called when Optimisation is finished.
@@ -164,26 +153,36 @@ class G4GeometryManager
void WaitForVoxelisationFinish(G4bool verbose = false);
// Wait until the voxelisation is all done.
private:
static G4ThreadLocal G4GeometryManager* fgInstance;
G4bool fIsClosed = false;
static std::vector<G4LogicalVolume*> fVolumesToOptimise;
// The list of volumes which threads need to optimise.
static std::vector<G4LogicalVolume*>::const_iterator fLogVolumeIterator;
// Iterator used by UndertakeOptimisation().
static std::vector<G4SmartVoxelStat> fGlobVoxelStats;
// Statistics container shared by all workers
// Flags for parallel initialization
// ---------------------------------
static G4bool fVerboseParallel;
static G4bool fParallelVoxelOptimisationRequested;
// Flag to register it was requested.
static G4bool fOptimizeInParallelConfigured;
static G4bool fOptimiseInParallelConfigured;
// Not just requested, but adopted (i.e. also in MT/tasking mode).
static G4bool fParallelVoxelOptimisationUnderway; // It has started
static G4bool fParallelVoxelOptimisationFinished; // It is done
static G4bool fUsingExistingWorkers;
// Fact: can and will use existing MT/tasks.
static G4bool fUsingExistingWorkers; // Can and will use existing MT/tasks.
// Statistics for parallel Optimisation - used in 'verbose' mode
// ------------------------------------
static G4double fSumVoxelTime;
static G4int fNumberThreadsReporting;
static unsigned int fTotalNumberVolumesOptimized;
static unsigned int fTotalNumberVolumesOptimised;
// Counters.
// For Wall Clock time in parallel mode ...
@@ -76,18 +76,17 @@ namespace // Data structures / mutexes for parallel optimisation
// ***************************************************************************
//
G4ThreadLocal G4GeometryManager* G4GeometryManager::fgInstance = nullptr;
G4ThreadLocal G4bool G4GeometryManager::fIsClosed = false;
// Static *global* class data
G4bool G4GeometryManager::fParallelVoxelOptimisationRequested = true;
// Records User choice - to use parallel voxel optimisation (or not)
G4bool G4GeometryManager::fParallelVoxelOptimisationRequested = false;
// Records User choice to use parallel voxel optimisation (or not)
G4bool G4GeometryManager::fOptimizeInParallelConfigured = false;
// Configured = requested && available (ie if MT or Threads is used)
// Value calculated during each effort to optimise
G4bool G4GeometryManager::fOptimiseInParallelConfigured = false;
// Configured = requested && available (ie if MT or Threads is used)
// Value calculated during each effort to optimise
std::vector<G4LogicalVolume*> G4GeometryManager::fVolumesToOptimize;
std::vector<G4LogicalVolume*>::iterator G4GeometryManager::fLogVolumeIterator;
std::vector<G4LogicalVolume*> G4GeometryManager::fVolumesToOptimise;
std::vector<G4LogicalVolume*>::const_iterator G4GeometryManager::fLogVolumeIterator;
std::vector<G4SmartVoxelStat> G4GeometryManager::fGlobVoxelStats;
// Container for statistics
@@ -99,7 +98,7 @@ G4bool G4GeometryManager::fParallelVoxelOptimisationFinished = false;
G4double G4GeometryManager::fSumVoxelTime = 0.0;
G4int G4GeometryManager::fNumberThreadsReporting = 0;
unsigned int G4GeometryManager::fTotalNumberVolumesOptimized = 0U;
unsigned int G4GeometryManager::fTotalNumberVolumesOptimised = 0U;
// For Wall clock
G4Timer* G4GeometryManager::fWallClockTimer = nullptr;
@@ -168,15 +167,6 @@ void G4GeometryManager::OpenGeometry(G4VPhysicalVolume* pVolume)
}
}
// ***************************************************************************
// Returns status of geometry
// ***************************************************************************
//
G4bool G4GeometryManager::IsGeometryClosed()
{
return fIsClosed;
}
// ***************************************************************************
// Returns the instance of the singleton.
// Creates it in case it's called for the first time.
@@ -209,7 +199,7 @@ G4GeometryManager* G4GeometryManager::GetInstanceIfExist()
// Simplest user method to request parallel optimisation.
// ***************************************************************************
//
void G4GeometryManager::OptimizeInParallel( G4bool val )
void G4GeometryManager::OptimiseInParallel( G4bool val )
{
RequestParallelOptimisation(val);
}
@@ -247,14 +237,14 @@ G4bool G4GeometryManager::BuildOptimisations(G4bool allOpts, G4bool verbose)
{
G4bool finishedOptimisation = false;
fOptimizeInParallelConfigured = fParallelVoxelOptimisationRequested
fOptimiseInParallelConfigured = fParallelVoxelOptimisationRequested
&& G4Threading::IsMultithreadedApplication();
static unsigned int NumCallsBuildOptimisations = 0; // WORKAROUND - TODO fix
if( fOptimizeInParallelConfigured && (NumCallsBuildOptimisations==0) )
if( fOptimiseInParallelConfigured && (NumCallsBuildOptimisations==0) )
{
PrepareParallelOptimisation(allOpts, verbose);
NumCallsBuildOptimisations++;
++NumCallsBuildOptimisations;
}
else
{
@@ -387,7 +377,7 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
G4LogicalVolumeStore* Store = G4LogicalVolumeStore::GetInstance();
if( fVolumesToOptimize.size() > 0)
if( !fVolumesToOptimise.empty() )
{
ResetListOfVolumesToOptimise();
}
@@ -402,7 +392,7 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
&& (volume->GetDaughter(0)->IsReplicated())
&& (volume->GetDaughter(0)->GetRegularStructureId()!=1) ) )
{
fVolumesToOptimize.push_back(volume);
fVolumesToOptimise.push_back(volume);
// For safety, must check (later) if there are any existing voxels and
// delete before replacement:
@@ -413,7 +403,7 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
#ifdef G4GEOMETRY_VOXELDEBUG
G4cout << "- Booking logical volume with " << volume->GetNoDaughters()
<< " daughters and name = '" << volume->GetName() << "' "
<< " -- for optimization (ie voxels will be built for it). " << G4endl;
<< " -- for optimisation (ie voxels will be built for it). " << G4endl;
#endif
}
else
@@ -428,9 +418,9 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
if(verbose)
G4cout << "** G4GeometryManager::PrepareOptimisationWork: "
<< " Number of volumes for voxelisation = "
<< fVolumesToOptimize.size() << G4endl;
<< fVolumesToOptimise.size() << G4endl;
fLogVolumeIterator = fVolumesToOptimize.begin();
fLogVolumeIterator = fVolumesToOptimise.cbegin();
}
// ***************************************************************************
@@ -439,13 +429,13 @@ G4GeometryManager::CreateListOfVolumesToOptimise(G4bool allOpts, G4bool verbose)
// Critical method for parallel optimisation - must be correct and fast.
// ***************************************************************************
//
G4LogicalVolume* G4GeometryManager::ObtainVolumeToOptimize()
G4LogicalVolume* G4GeometryManager::ObtainVolumeToOptimise()
{
G4LogicalVolume* logVolume = nullptr;
G4AutoLock lock(obtainVolumeMutex);
if( fLogVolumeIterator != fVolumesToOptimize.end() )
if( fLogVolumeIterator != fVolumesToOptimise.cend() )
{
logVolume = *fLogVolumeIterator;
++fLogVolumeIterator;
@@ -461,13 +451,13 @@ void G4GeometryManager::ResetListOfVolumesToOptimise()
{
G4AutoLock lock(obtainVolumeMutex);
std::vector<G4LogicalVolume*>().swap(fVolumesToOptimize);
std::vector<G4LogicalVolume*>().swap(fVolumesToOptimise);
// Swapping with an empty vector in order to empty it
// without calling destructors of logical volumes.
// Must not call clear: i.e. fVolumesToOptimize.clear();
// Must not call clear: i.e. fVolumesToOptimise.clear();
assert(fVolumesToOptimize.empty());
fLogVolumeIterator = fVolumesToOptimize.begin();
assert(fVolumesToOptimise.empty());
fLogVolumeIterator = fVolumesToOptimise.cbegin();
fGlobVoxelStats.clear();
// Reset also the statistics of volumes -- to avoid double recording.
@@ -508,7 +498,7 @@ void G4GeometryManager::ConfigureParallelOptimisation(G4bool verbose)
// New effort -- reset the total time -- and number of threads reporting
fSumVoxelTime = 0.0;
fNumberThreadsReporting = 0;
fTotalNumberVolumesOptimized = 0; // Number of volumes done
fTotalNumberVolumesOptimised = 0; // Number of volumes done
fWallClockStarted = false; // Will need to restart it!
}
@@ -552,9 +542,9 @@ void G4GeometryManager::UndertakeOptimisation()
}
G4Timer fetimer;
unsigned int numVolumesOptimized = 0;
unsigned int numVolumesOptimised = 0;
while( (logVolume = ObtainVolumeToOptimize()) != nullptr )
while( (logVolume = ObtainVolumeToOptimise()) != nullptr )
{
if (verbose) fetimer.Start();
@@ -568,15 +558,14 @@ void G4GeometryManager::UndertakeOptimisation()
if (head != nullptr)
{
++numVolumesOptimized;
++numVolumesOptimised;
}
else
{
G4ExceptionDescription message;
message << "VoxelHeader allocation error." << G4endl
<< "Allocation of new VoxelHeader" << G4endl
<< " for logical volume " << logVolume->GetName()
<< " failed.";
<< "for logical volume " << logVolume->GetName() << " failed.";
G4Exception("G4GeometryManager::BuildOptimisationsParallel()",
"GeomMgt0003", FatalException, message);
}
@@ -599,10 +588,10 @@ void G4GeometryManager::UndertakeOptimisation()
G4bool allDone = false;
G4int myCount= -1;
myCount = ReportWorkerIsDoneOptimising(numVolumesOptimized);
myCount = ReportWorkerIsDoneOptimising(numVolumesOptimised);
allDone = IsParallelOptimisationFinished();
if( (allDone && myCount) == G4Threading::GetNumberOfRunningWorkerThreads() )
if( allDone && (myCount == G4Threading::GetNumberOfRunningWorkerThreads()) )
{
G4int badVolumes = CheckOptimisation(); // Check all voxels are created!
if( badVolumes > 0 )
@@ -611,8 +600,8 @@ void G4GeometryManager::UndertakeOptimisation()
errmsg <<" Expected that all voxelisation work is done, "
<< "but found that voxels headers are missing in "
<< badVolumes << " volumes.";
G4Exception("G4GeometryManager::UndertakeOptimisation",
"GeomMng002",FatalException, errmsg);
G4Exception("G4GeometryManager::UndertakeOptimisation()",
"GeomMng002", FatalException, errmsg);
}
// Create report
@@ -623,15 +612,15 @@ void G4GeometryManager::UndertakeOptimisation()
std::ostream& report_stream = std::cout; // G4cout; does not work!
report_stream << G4endl
<< " G4GeometryManager::UndertakeOptimisation()"
<< " - Timing for Voxel Optimisation" << G4endl;
report_stream << " - Elapsed time (real) = " << std::setprecision(4)
<< fWallClockTimer->GetRealElapsed() << " seconds (wall clock) "
<< " , user " << fWallClockTimer->GetUserElapsed() << "seconds "
<< " , system " << fWallClockTimer->GetSystemElapsed() << " seconds."
<< G4endl;
report_stream << " - Sum voxel time (real) = " << fSumVoxelTime
<< " seconds.";
<< "G4GeometryManager::UndertakeOptimisation"
<< " -- Timing for Voxel Optimisation" << G4endl;
report_stream << " - Elapsed time (real) = " << std::setprecision(4)
<< fWallClockTimer->GetRealElapsed() << "s (wall clock)"
<< ", user " << fWallClockTimer->GetUserElapsed() << "s"
<< ", system " << fWallClockTimer->GetSystemElapsed() << "s."
<< G4endl;
report_stream << " - Sum voxel time (real) = " << fSumVoxelTime
<< "s.";
report_stream << std::setprecision(6) << G4endl << G4endl;
ReportVoxelStats( fGlobVoxelStats, fSumVoxelTime, report_stream );
@@ -667,8 +656,9 @@ void G4GeometryManager::WaitForVoxelisationFinish(G4bool verbose)
if( verbose )
{
G4AutoLock lock(outputDbgMutex);
out_stream << G4endl << "** UndertakeOptimisation done on tid= " << tid
<< " after waiting for " << trials << " trials." << G4endl;
out_stream << G4endl
<< "** UndertakeOptimisation done on tid= " << tid
<< " after waiting for " << trials << " trials." << G4endl;
out_stream.flush();
}
}
@@ -679,13 +669,10 @@ void G4GeometryManager::WaitForVoxelisationFinish(G4bool verbose)
//
G4int G4GeometryManager::CheckOptimisation()
{
unsigned int numErrors= 0;
for ( auto logical : fVolumesToOptimize ){
if( logical->GetVoxelHeader() == nullptr ){
std::cerr << "G4GeometryManager::CheckOptimisation: ERROR "
<< " logical volume " << logical->GetName() << " has Voxel Header = " << G4endl;
numErrors++;
}
unsigned int numErrors = 0;
for ( const auto& logical : fVolumesToOptimise )
{
if( logical->GetVoxelHeader() == nullptr ) { ++numErrors; }
}
return numErrors;
}
@@ -701,14 +688,14 @@ G4int G4GeometryManager::CheckOptimisation()
// ***************************************************************************
//
G4int
G4GeometryManager::ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimized)
G4GeometryManager::ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimised)
{
// Check that all are done and, if so, signal that optimisation is finished
G4int orderReporting;
G4AutoLock lock(statResultsMutex);
orderReporting = ++fNumberThreadsReporting;
fTotalNumberVolumesOptimized += numVolumesOptimized;
fTotalNumberVolumesOptimised += numVolumesOptimised;
if (fNumberThreadsReporting == G4Threading::GetNumberOfRunningWorkerThreads())
{
@@ -718,26 +705,25 @@ G4GeometryManager::ReportWorkerIsDoneOptimising(unsigned int numVolumesOptimized
return orderReporting;
}
// *****************************************************************************
// ***************************************************************************
// Inform that all work for parallel optimisation is finished.
// *****************************************************************************
// ***************************************************************************
//
void G4GeometryManager::InformOptimisationIsFinished(G4bool verbose)
{
if(verbose)
if(verbose) // G4cout does not work!
{
G4cout << "** G4GeometryManager: All voxel optimisation work is completed!"
<< G4endl;
G4cout << " Total number of volumes optimised = "
<< fTotalNumberVolumesOptimized
<< " of " << fVolumesToOptimize.size() << "expected" << G4endl;
G4cout << " Number of workers reporting = "
<< fNumberThreadsReporting
<< " of " << G4Threading::GetNumberOfRunningWorkerThreads()
<< "expected\n";
std::cout << "** G4GeometryManager: All voxel optimisation work is completed!"
<< G4endl;
std::cout << " Total number of volumes optimised = "
<< fTotalNumberVolumesOptimised
<< " of " << fVolumesToOptimise.size() << " expected\n";
std::cout << " Number of workers reporting = "
<< fNumberThreadsReporting
<< " of " << G4Threading::GetNumberOfRunningWorkerThreads()
<< " expected\n";
}
assert ( fTotalNumberVolumesOptimized == fVolumesToOptimize.size() );
assert ( fNumberThreadsReporting == G4Threading::GetNumberOfRunningWorkerThreads() );
assert ( fTotalNumberVolumesOptimised == fVolumesToOptimise.size() );
fParallelVoxelOptimisationFinished = true;
// fParallelVoxelOptimisationRequested = false; // Maintain request for next one!
@@ -876,6 +862,8 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
G4double totalCpuTime,
std::ostream &os )
{
os << "--------------------------------------------------------------------------------"
<< G4endl;
os << "G4GeometryManager::ReportVoxelStats -- Voxel Statistics"
<< G4endl << G4endl;
@@ -909,9 +897,8 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
{
os << "\n Voxelisation: top CPU users:" << G4endl;
os << " Percent Total CPU System CPU Memory Volume\n"
<< " ------- ---------- ---------- -------- ----------"
<< G4endl;
// 12345678901.234567890123.234567890123.234567890123k .
<< " ------- ---------- ---------- -------- ----------"
<< G4endl;
}
for(i=0; i<nPrint; ++i)
@@ -952,9 +939,8 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
{
os << "\n Voxelisation: top memory users:" << G4endl;
os << " Percent Memory Heads Nodes Pointers Total CPU Volume\n"
<< " ------- -------- ------ ------ -------- ---------- ----------"
<< G4endl;
// 12345678901.2345678901k .23456789.23456789.2345678901.234567890123. .
<< " ------- -------- ------ ------ -------- ---------- ----------"
<< G4endl;
}
for(i=0; i<nPrint; ++i)
@@ -964,32 +950,34 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
if (totTime < 0) { totTime = 0.0; }
os << std::setprecision(2)
<< std::setiosflags(std::ios::fixed|std::ios::right)
<< std::setw(11) << G4double(memory*100)/G4double(totalMemory)
<< std::setw(11) << memory/1024 << "k "
<< std::setw( 9) << stats[i].GetNumberHeads()
<< std::setw( 9) << stats[i].GetNumberNodes()
<< std::setw(11) << stats[i].GetNumberPointers()
<< std::setw(13) << totTime << " "
<< std::setiosflags(std::ios::left)
<< stats[i].GetVolume()->GetName()
<< std::resetiosflags(std::ios::floatfield|std::ios::adjustfield)
<< std::setprecision(6)
<< G4endl;
<< std::setiosflags(std::ios::fixed|std::ios::right)
<< std::setw(11) << G4double(memory*100)/G4double(totalMemory)
<< std::setw(11) << memory/1024 << "k "
<< std::setw( 9) << stats[i].GetNumberHeads()
<< std::setw( 9) << stats[i].GetNumberNodes()
<< std::setw(11) << stats[i].GetNumberPointers()
<< std::setw(13) << totTime << " "
<< std::setiosflags(std::ios::left)
<< stats[i].GetVolume()->GetName()
<< std::resetiosflags(std::ios::floatfield|std::ios::adjustfield)
<< std::setprecision(6)
<< G4endl;
}
os << "--------------------------------------------------------------------------------"
<< G4endl << G4endl;
}
// ***************************************************************************
// Check whether parallel optimisation was requested --static (class) method.
// Check whether parallel optimisation was requested -- static (class) data.
// ***************************************************************************
//
G4bool G4GeometryManager::IsParallelOptimisationConfigured()
{
return fOptimizeInParallelConfigured;
return fOptimiseInParallelConfigured;
}
// ***************************************************************************
// Report whether parallel optimisation is done -- static (class) method.
// Report whether parallel optimisation is done -- static (class) data.
// ***************************************************************************
//
G4bool G4GeometryManager::IsParallelOptimisationFinished()
@@ -76,7 +76,7 @@ void G4LogicalVolumeStore::Clean()
{
// Do nothing if geometry is closed
//
if (G4GeometryManager::IsGeometryClosed())
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
{
G4cout << "WARNING - Attempt to delete the logical volume store"
<< " while geometry closed !" << G4endl;
@@ -77,7 +77,7 @@ void G4PhysicalVolumeStore::Clean()
{
// Do nothing if geometry is closed
//
if (G4GeometryManager::IsGeometryClosed())
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
{
G4cout << "WARNING - Attempt to delete the physical volume store"
<< " while geometry closed !" << G4endl;
@@ -79,7 +79,7 @@ void G4RegionStore::Clean()
{
// Do nothing if geometry is closed
//
if (G4GeometryManager::IsGeometryClosed())
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
{
G4cout << "WARNING - Attempt to delete the region store"
<< " while geometry closed !" << G4endl;
@@ -75,7 +75,7 @@ void G4SolidStore::Clean()
{
// Do nothing if geometry is closed
//
if (G4GeometryManager::IsGeometryClosed())
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
{
G4cout << "WARNING - Attempt to delete the solid store"
<< " while geometry closed !" << G4endl;
+5
View File
@@ -6,6 +6,11 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-11-22 Gabriele Cosmo (geomnav-V11-02-03)
- In G4MultiLevelLocator::EstimateIntersectionPoint(), moved repeated assertion
on invalid intersection within G4DEBUG_FIELD, to avoid excess of warning
printouts in rare cases of failed convergence, as reported by CMS.
## 2024-05-15 Ivana Hrivnacova (geomnav-V11-02-02)
- Let G4TransportationManager notify G4FieldManager about the global
field via newly added G4FieldManager::SetGlobalFieldManager().
@@ -281,7 +281,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
G4LocatorChangeLogger::ReportEndChanges(G4cerr, endChangeA, endChangeB);
}
}
#endif
if( !validIntersectP )
{
G4ExceptionDescription errmsg;
@@ -294,7 +294,8 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
G4Exception("G4MultiLevelLocator::EstimateIntersectionPoint", "GeomNav0004",
JustWarning, errmsg);
}
#endif
// F = a point on true AB path close to point E
// (the closest if possible)
//
+5
View File
@@ -6,6 +6,11 @@ It must **not** be used as a substitute for writing good git commit messages!
------------------------------------------------------------------------------
## 2024-07-26 Evgueni Tcherniaev (geom-bool-V11-02-03)
- G4MultiUnion::GetCubicVolume(): used EstimateCubicVolume().
- G4BooleanSolid::SetCubVolStatistics(), G4BooleanSolid::SetCubVolEpsilon():
added check for G4MultiUnion to avoid memory corruption.
## 2024-06-04 Evgueni Tcherniaev (geom-bool-V11-02-02)
- G4BooleanSolid::SetCubVolStatistics(st), G4BooleanSolid::SetCubVolEpsilon(ep):
propagate parameter to all constituents.
@@ -239,7 +239,10 @@ void G4BooleanSolid::SetCubVolStatistics(G4int st)
ptr = ((G4ScaledSolid*)ptr)->GetUnscaledSolid();
continue;
}
((G4BooleanSolid*)ptr)->SetCubVolStatistics(st);
if (type != "G4MultiUnion") // G4MultiUnion doesn't have SetCubVolStatistics()
{
((G4BooleanSolid*)ptr)->SetCubVolStatistics(st);
}
break;
}
}
@@ -266,7 +269,10 @@ void G4BooleanSolid::SetCubVolStatistics(G4int st)
ptr = ((G4ScaledSolid*)ptr)->GetUnscaledSolid();
continue;
}
((G4BooleanSolid*)ptr)->SetCubVolStatistics(st);
if (type != "G4MultiUnion") // G4MultiUnion doesn't have SetCubVolStatistics()
{
((G4BooleanSolid*)ptr)->SetCubVolStatistics(st);
}
break;
}
}
@@ -303,7 +309,10 @@ void G4BooleanSolid::SetCubVolEpsilon(G4double ep)
ptr = ((G4ScaledSolid*)ptr)->GetUnscaledSolid();
continue;
}
((G4BooleanSolid*)ptr)->SetCubVolEpsilon(ep);
if (type != "G4MultiUnion") // G4MultiUnion doesn't have SetCubVolEpsilon()
{
((G4BooleanSolid*)ptr)->SetCubVolEpsilon(ep);
}
break;
}
}
@@ -330,7 +339,10 @@ void G4BooleanSolid::SetCubVolEpsilon(G4double ep)
ptr = ((G4ScaledSolid*)ptr)->GetUnscaledSolid();
continue;
}
((G4BooleanSolid*)ptr)->SetCubVolEpsilon(ep);
if (type != "G4MultiUnion") // G4MultiUnion doesn't have SetCubVolEpsilon()
{
((G4BooleanSolid*)ptr)->SetCubVolEpsilon(ep);
}
break;
}
}
@@ -124,28 +124,9 @@ G4MultiUnion& G4MultiUnion::operator = (const G4MultiUnion& rhs)
//______________________________________________________________________________
G4double G4MultiUnion::GetCubicVolume()
{
// Computes the cubic volume of the "G4MultiUnion" structure using
// random points
if (fCubicVolume == 0.0)
{
G4ThreeVector extentMin, extentMax, d, p, point;
G4int inside = 0, generated;
BoundingLimits(extentMin, extentMax);
d = (extentMax - extentMin) / 2.;
p = (extentMax + extentMin) / 2.;
G4ThreeVector left = p - d;
G4ThreeVector length = d * 2;
for (generated = 0; generated < 10000; ++generated)
{
G4ThreeVector rvec(G4UniformRand(), G4UniformRand(), G4UniformRand());
point = left + G4ThreeVector(length.x()*rvec.x(),
length.y()*rvec.y(),
length.z()*rvec.z());
if (Inside(point) != EInside::kOutside) ++inside;
}
G4double vbox = (2 * d.x()) * (2 * d.y()) * (2 * d.z());
fCubicVolume = inside * vbox / generated;
fCubicVolume = EstimateCubicVolume(1000000, 0.001);
}
return fCubicVolume;
}
+14
View File
@@ -6,6 +6,20 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-10-01 Evgueni Tcherniaev (geom-specific-V11-02-08)
- G4GenericTrap: Fixed minor defect reported by Coverity
## 2024-07-18 Alvaro Tolosa-Delgado (geom-specific-V11-02-07)
- Remove internal state of G4TwistedTubs and G4VTwistedFaceted.
## 2024-07-10 Evgueni Tcherniaev (geom-specific-V11-02-06)
- G4ExtrudedSolid: Fixed defects reported by Coverity
## 2024-07-08 Gabriele Cosmo (geom-specific-V11-02-05)
- Fixed reported Coverity defect; in G4Voxelizer, use std::move instead of
plain vector copy in methods BuildReduceVoxels(..), BuildReduceVoxels2(..),
BuildBoundaries() and CreateMiniVoxels(..).
## 2024-05-29 Evgueni Tcherniaev (geom-specific-V11-02-04)
- Added new methods GetNumOfConstituents() and IsFaceted().
@@ -226,109 +226,6 @@ class G4TwistedTubs : public G4VSolid
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr; // polyhedron for vis
class LastState // last Inside result
{
public:
LastState()
{
p.set(kInfinity,kInfinity,kInfinity);
inside = kOutside;
}
~LastState()= default;
LastState(const LastState& r) = default;
LastState& operator=(const LastState& r)
{
if (this == &r) { return *this; }
p = r.p; inside = r.inside;
return *this;
}
public:
G4ThreeVector p;
EInside inside;
};
class LastVector // last SurfaceNormal result
{
public:
LastVector()
{
p.set(kInfinity,kInfinity,kInfinity);
vec.set(kInfinity,kInfinity,kInfinity);
surface = new G4VTwistSurface*[1];
}
~LastVector()
{
delete [] surface;
}
LastVector(const LastVector& r) : p(r.p), vec(r.vec)
{
surface = new G4VTwistSurface*[1];
surface[0] = r.surface[0];
}
LastVector& operator=(const LastVector& r)
{
if (&r == this) { return *this; }
p = r.p; vec = r.vec;
delete [] surface; surface = new G4VTwistSurface*[1];
surface[0] = r.surface[0];
return *this;
}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4VTwistSurface **surface;
};
class LastValue // last G4double value
{
public:
LastValue()
{
p.set(kInfinity,kInfinity,kInfinity);
value = DBL_MAX;
}
~LastValue()= default;
LastValue(const LastValue& r) = default;
LastValue& operator=(const LastValue& r)
{
if (this == &r) { return *this; }
p = r.p; value = r.value;
return *this;
}
public:
G4ThreeVector p;
G4double value;
};
class LastValueWithDoubleVector // last G4double value
{
public:
LastValueWithDoubleVector()
{
p.set(kInfinity,kInfinity,kInfinity);
vec.set(kInfinity,kInfinity,kInfinity);
value = DBL_MAX;
}
~LastValueWithDoubleVector()= default;
LastValueWithDoubleVector(const LastValueWithDoubleVector& r) = default;
LastValueWithDoubleVector& operator=(const LastValueWithDoubleVector& r)
{
if (this == &r) { return *this; }
p = r.p; vec = r.vec; value = r.value;
return *this;
}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4double value;
};
LastState fLastInside;
LastVector fLastNormal;
LastValue fLastDistanceToIn;
LastValue fLastDistanceToOut;
LastValueWithDoubleVector fLastDistanceToInWithV;
LastValueWithDoubleVector fLastDistanceToOutWithV;
};
//=====================================================================
@@ -190,110 +190,6 @@ class G4VTwistedFaceted: public G4VSolid
G4VTwistSurface* fSide180 ; // Twisted Side at phi = 180 deg
G4VTwistSurface* fSide270 ; // Twisted Side at phi = 270 deg
private:
class LastState // last Inside result
{
public:
LastState()
{
p.set(kInfinity,kInfinity,kInfinity); inside = kOutside;
}
~LastState()= default;
LastState(const LastState& r) = default;
LastState& operator=(const LastState& r)
{
if (this == &r) { return *this; }
p = r.p; inside = r.inside;
return *this;
}
public:
G4ThreeVector p;
EInside inside;
};
class LastVector // last SurfaceNormal result
{
public:
LastVector()
{
p.set(kInfinity,kInfinity,kInfinity);
vec.set(kInfinity,kInfinity,kInfinity);
surface = new G4VTwistSurface*[1];
}
~LastVector()
{
delete [] surface;
}
LastVector(const LastVector& r) : p(r.p), vec(r.vec)
{
surface = new G4VTwistSurface*[1];
surface[0] = r.surface[0];
}
LastVector& operator=(const LastVector& r)
{
if (&r == this) { return *this; }
p = r.p; vec = r.vec;
delete [] surface; surface = new G4VTwistSurface*[1];
surface[0] = r.surface[0];
return *this;
}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4VTwistSurface **surface;
};
class LastValue // last G4double value
{
public:
LastValue()
{
p.set(kInfinity,kInfinity,kInfinity);
value = DBL_MAX;
}
~LastValue()= default;
LastValue(const LastValue& r) = default;
LastValue& operator=(const LastValue& r)
{
if (this == &r) { return *this; }
p = r.p; value = r.value;
return *this;
}
public:
G4ThreeVector p;
G4double value;
};
class LastValueWithDoubleVector // last G4double value
{
public:
LastValueWithDoubleVector()
{
p.set(kInfinity,kInfinity,kInfinity);
vec.set(kInfinity,kInfinity,kInfinity);
value = DBL_MAX;
}
~LastValueWithDoubleVector()= default;
LastValueWithDoubleVector(const LastValueWithDoubleVector& r) = default;
LastValueWithDoubleVector& operator=(const LastValueWithDoubleVector& r)
{
if (this == &r) { return *this; }
p = r.p; vec = r.vec; value = r.value;
return *this;
}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4double value;
};
LastState fLastInside;
LastVector fLastNormal;
LastValue fLastDistanceToIn;
LastValue fLastDistanceToOut;
LastValueWithDoubleVector fLastDistanceToInWithV;
LastValueWithDoubleVector fLastDistanceToOutWithV;
};
//=====================================================================
@@ -733,7 +733,7 @@ G4bool G4ExtrudedSolid::AddGeneralPolygonFacets()
triangle[0] = c1->second;
triangle[1] = c2->second;
triangle[2] = c3->second;
fTriangles.push_back(triangle);
fTriangles.push_back(std::move(triangle));
// remove the ear point from verticesToBeDone
//
@@ -772,7 +772,7 @@ G4bool G4ExtrudedSolid::MakeFacets()
triangle[0] = 0;
triangle[1] = 1;
triangle[2] = 2;
fTriangles.push_back(triangle);
fTriangles.push_back(std::move(triangle));
}
else if ( fNv == 4 )
@@ -793,13 +793,13 @@ G4bool G4ExtrudedSolid::MakeFacets()
triangle1[0] = 0;
triangle1[1] = 1;
triangle1[2] = 2;
fTriangles.push_back(triangle1);
fTriangles.push_back(std::move(triangle1));
std::vector<G4int> triangle2(3);
triangle2[0] = 0;
triangle2[1] = 2;
triangle2[2] = 3;
fTriangles.push_back(triangle2);
fTriangles.push_back(std::move(triangle2));
}
else
{
@@ -798,7 +798,7 @@ G4double G4GenericTrap::DistanceToOut(const G4ThreeVector& p,
if (iface < 0)
{
*validNorm = true;
n->set(0., 0., G4double(iface + 3)); // little trick: (-4+3)=-1, (-2+3)=+1
n->set(0, 0, iface + 3); // little trick: (-4+3)=-1, (-2+3)=+1
}
else
{
@@ -56,6 +56,7 @@ namespace
G4Mutex polyhedronMutex = G4MUTEX_INITIALIZER;
}
//=====================================================================
//* constructors ------------------------------------------------------
@@ -223,12 +224,7 @@ G4TwistedTubs::G4TwistedTubs(const G4TwistedTubs& rhs)
fTanOuterStereo2(rhs.fTanOuterStereo2),
fLowerEndcap(nullptr), fUpperEndcap(nullptr), fLatterTwisted(nullptr), fFormerTwisted(nullptr),
fInnerHype(nullptr), fOuterHype(nullptr),
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
fLastInside(rhs.fLastInside), fLastNormal(rhs.fLastNormal),
fLastDistanceToIn(rhs.fLastDistanceToIn),
fLastDistanceToOut(rhs.fLastDistanceToOut),
fLastDistanceToInWithV(rhs.fLastDistanceToInWithV),
fLastDistanceToOutWithV(rhs.fLastDistanceToOutWithV)
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea)
{
for (auto i=0; i<2; ++i)
{
@@ -268,11 +264,6 @@ G4TwistedTubs& G4TwistedTubs::operator = (const G4TwistedTubs& rhs)
fLowerEndcap= fUpperEndcap= fLatterTwisted= fFormerTwisted= nullptr;
fInnerHype= fOuterHype= nullptr;
fCubicVolume= rhs.fCubicVolume; fSurfaceArea= rhs.fSurfaceArea;
fLastInside= rhs.fLastInside; fLastNormal= rhs.fLastNormal;
fLastDistanceToIn= rhs.fLastDistanceToIn;
fLastDistanceToOut= rhs.fLastDistanceToOut;
fLastDistanceToInWithV= rhs.fLastDistanceToInWithV;
fLastDistanceToOutWithV= rhs.fLastDistanceToOutWithV;
for (auto i=0; i<2; ++i)
{
@@ -381,44 +372,32 @@ EInside G4TwistedTubs::Inside(const G4ThreeVector& p) const
// G4Timer timer(timerid, "G4TwistedTubs", "Inside");
// timer.Start();
G4ThreeVector *tmpp;
EInside *tmpinside;
if (fLastInside.p == p)
{
return fLastInside.inside;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastInside.p));
tmpinside = const_cast<EInside*>(&(fLastInside.inside));
tmpp->set(p.x(), p.y(), p.z());
}
EInside outerhypearea = ((G4TwistTubsHypeSide *)fOuterHype)->Inside(p);
G4double innerhyperho = ((G4TwistTubsHypeSide *)fInnerHype)->GetRhoAtPZ(p);
G4double distanceToOut = p.getRho() - innerhyperho; // +ve: inside
EInside tmpinside;
if ((outerhypearea == kOutside) || (distanceToOut < -halftol))
{
*tmpinside = kOutside;
tmpinside = kOutside;
}
else if (outerhypearea == kSurface)
{
*tmpinside = kSurface;
tmpinside = kSurface;
}
else
{
if (distanceToOut <= halftol)
{
*tmpinside = kSurface;
tmpinside = kSurface;
}
else
{
*tmpinside = kInside;
tmpinside = kInside;
}
}
return fLastInside.inside;
return tmpinside;
}
//=====================================================================
@@ -433,14 +412,6 @@ G4ThreeVector G4TwistedTubs::SurfaceNormal(const G4ThreeVector& p) const
// Which of the three or four surfaces are we closest to?
//
if (fLastNormal.p == p)
{
return fLastNormal.vec;
}
auto tmpp = const_cast<G4ThreeVector*>(&(fLastNormal.p));
auto tmpnormal = const_cast<G4ThreeVector*>(&(fLastNormal.vec));
auto tmpsurface = const_cast<G4VTwistSurface**>(fLastNormal.surface);
tmpp->set(p.x(), p.y(), p.z());
G4double distance = kInfinity;
@@ -466,10 +437,7 @@ G4ThreeVector G4TwistedTubs::SurfaceNormal(const G4ThreeVector& p) const
}
}
tmpsurface[0] = surfaces[besti];
*tmpnormal = tmpsurface[0]->GetNormal(bestxx, true);
return fLastNormal.vec;
return surfaces[besti]->GetNormal(bestxx, true);
}
//=====================================================================
@@ -485,26 +453,6 @@ G4double G4TwistedTubs::DistanceToIn (const G4ThreeVector& p,
// The function returns kInfinity if no intersection or
// just grazing within tolerance.
//
// checking last value
//
G4ThreeVector* tmpp;
G4ThreeVector* tmpv;
G4double* tmpdist;
if ((fLastDistanceToInWithV.p == p) && (fLastDistanceToInWithV.vec == v))
{
return fLastDistanceToIn.value;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToInWithV.p));
tmpv = const_cast<G4ThreeVector*>(&(fLastDistanceToInWithV.vec));
tmpdist = const_cast<G4double*>(&(fLastDistanceToInWithV.value));
tmpp->set(p.x(), p.y(), p.z());
tmpv->set(v.x(), v.y(), v.z());
}
//
// Calculate DistanceToIn(p,v)
//
@@ -524,8 +472,7 @@ G4double G4TwistedTubs::DistanceToIn (const G4ThreeVector& p,
G4ThreeVector normal = SurfaceNormal(p);
if (normal*v < 0)
{
*tmpdist = 0.;
return fLastDistanceToInWithV.value;
return 0;
}
}
}
@@ -557,9 +504,7 @@ G4double G4TwistedTubs::DistanceToIn (const G4ThreeVector& p,
bestxx = xx;
}
}
*tmpdist = distance;
return fLastDistanceToInWithV.value;
return distance;
}
//=====================================================================
@@ -570,23 +515,6 @@ G4double G4TwistedTubs::DistanceToIn (const G4ThreeVector& p) const
// DistanceToIn(p):
// Calculate distance to surface of shape from `outside',
// allowing for tolerance
//
// checking last value
//
G4ThreeVector* tmpp;
G4double* tmpdist;
if (fLastDistanceToIn.p == p)
{
return fLastDistanceToIn.value;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToIn.p));
tmpdist = const_cast<G4double*>(&(fLastDistanceToIn.value));
tmpp->set(p.x(), p.y(), p.z());
}
//
// Calculate DistanceToIn(p)
@@ -600,8 +528,7 @@ G4double G4TwistedTubs::DistanceToIn (const G4ThreeVector& p) const
{}
case (kSurface) :
{
*tmpdist = 0.;
return fLastDistanceToIn.value;
return 0;
}
case (kOutside) :
{
@@ -628,8 +555,7 @@ G4double G4TwistedTubs::DistanceToIn (const G4ThreeVector& p) const
bestxx = xx;
}
}
*tmpdist = distance;
return fLastDistanceToIn.value;
return distance;
}
default :
{
@@ -656,32 +582,11 @@ G4double G4TwistedTubs::DistanceToOut( const G4ThreeVector& p,
// The function returns kInfinity if no intersection or
// just grazing within tolerance.
//
// checking last value
//
G4ThreeVector* tmpp;
G4ThreeVector* tmpv;
G4double* tmpdist;
if ((fLastDistanceToOutWithV.p == p) && (fLastDistanceToOutWithV.vec == v) )
{
return fLastDistanceToOutWithV.value;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToOutWithV.p));
tmpv = const_cast<G4ThreeVector*>(&(fLastDistanceToOutWithV.vec));
tmpdist = const_cast<G4double*>(&(fLastDistanceToOutWithV.value));
tmpp->set(p.x(), p.y(), p.z());
tmpv->set(v.x(), v.y(), v.z());
}
//
// Calculate DistanceToOut(p,v)
//
EInside currentside = Inside(p);
if (currentside == kOutside)
{
}
@@ -693,16 +598,14 @@ G4double G4TwistedTubs::DistanceToOut( const G4ThreeVector& p,
// If the particle is exiting from the volume, return 0.
//
G4ThreeVector normal = SurfaceNormal(p);
G4VTwistSurface *blockedsurface = fLastNormal.surface[0];
if (normal*v > 0)
{
if (calcNorm)
{
*norm = (blockedsurface->GetNormal(p, true));
*validNorm = blockedsurface->IsValidNorm();
*norm = normal;
*validNorm = true;
}
*tmpdist = 0.;
return fLastDistanceToOutWithV.value;
return 0;
}
}
}
@@ -746,9 +649,7 @@ G4double G4TwistedTubs::DistanceToOut( const G4ThreeVector& p,
}
}
*tmpdist = distance;
return fLastDistanceToOutWithV.value;
return distance;
}
@@ -761,23 +662,6 @@ G4double G4TwistedTubs::DistanceToOut( const G4ThreeVector& p ) const
// Calculate distance to surface of shape from `inside',
// allowing for tolerance
//
// checking last value
//
G4ThreeVector* tmpp;
G4double* tmpdist;
if (fLastDistanceToOut.p == p)
{
return fLastDistanceToOut.value;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToOut.p));
tmpdist = const_cast<G4double*>(&(fLastDistanceToOut.value));
tmpp->set(p.x(), p.y(), p.z());
}
//
// Calculate DistanceToOut(p)
//
@@ -791,8 +675,7 @@ G4double G4TwistedTubs::DistanceToOut( const G4ThreeVector& p ) const
}
case (kSurface) :
{
*tmpdist = 0.;
return fLastDistanceToOut.value;
return 0;
}
case (kInside) :
{
@@ -819,9 +702,7 @@ G4double G4TwistedTubs::DistanceToOut( const G4ThreeVector& p ) const
bestxx = xx;
}
}
*tmpdist = distance;
return fLastDistanceToOut.value;
return distance;
}
default :
{
@@ -54,6 +54,7 @@ namespace
G4Mutex polyhedronMutex = G4MUTEX_INITIALIZER;
}
//=====================================================================
//* constructors ------------------------------------------------------
@@ -222,12 +223,7 @@ G4VTwistedFaceted::G4VTwistedFaceted(const G4VTwistedFaceted& rhs)
fDx3(rhs.fDx3), fDx4(rhs.fDx4), fDz(rhs.fDz), fDx(rhs.fDx), fDy(rhs.fDy),
fAlph(rhs.fAlph), fTAlph(rhs.fTAlph), fdeltaX(rhs.fdeltaX),
fdeltaY(rhs.fdeltaY), fPhiTwist(rhs.fPhiTwist), fLowerEndcap(nullptr),
fUpperEndcap(nullptr), fSide0(nullptr), fSide90(nullptr), fSide180(nullptr), fSide270(nullptr),
fLastInside(rhs.fLastInside), fLastNormal(rhs.fLastNormal),
fLastDistanceToIn(rhs.fLastDistanceToIn),
fLastDistanceToOut(rhs.fLastDistanceToOut),
fLastDistanceToInWithV(rhs.fLastDistanceToInWithV),
fLastDistanceToOutWithV(rhs.fLastDistanceToOutWithV)
fUpperEndcap(nullptr), fSide0(nullptr), fSide90(nullptr), fSide180(nullptr), fSide270(nullptr)
{
CreateSurfaces();
}
@@ -257,11 +253,6 @@ G4VTwistedFaceted& G4VTwistedFaceted::operator = (const G4VTwistedFaceted& rhs)
fCubicVolume= rhs.fCubicVolume; fSurfaceArea= rhs.fSurfaceArea;
fRebuildPolyhedron = false;
delete fpPolyhedron; fpPolyhedron = nullptr;
fLastInside= rhs.fLastInside; fLastNormal= rhs.fLastNormal;
fLastDistanceToIn= rhs.fLastDistanceToIn;
fLastDistanceToOut= rhs.fLastDistanceToOut;
fLastDistanceToInWithV= rhs.fLastDistanceToInWithV;
fLastDistanceToOutWithV= rhs.fLastDistanceToOutWithV;
CreateSurfaces();
@@ -347,20 +338,7 @@ G4VTwistedFaceted::CalculateExtent( const EAxis pAxis,
EInside G4VTwistedFaceted::Inside(const G4ThreeVector& p) const
{
G4ThreeVector *tmpp;
EInside *tmpin;
if (fLastInside.p == p)
{
return fLastInside.inside;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastInside.p));
tmpin = const_cast<EInside*>(&(fLastInside.inside));
tmpp->set(p.x(), p.y(), p.z());
}
*tmpin = kOutside ;
EInside tmpin = kOutside ;
G4double phi = p.z()/(2*fDz) * fPhiTwist ; // rotate the point to z=0
G4double cphi = std::cos(-phi) ;
@@ -414,13 +392,13 @@ EInside G4VTwistedFaceted::Inside(const G4ThreeVector& p) const
if ( posy <= yMax - kCarTolerance*0.5
&& posy >= yMin + kCarTolerance*0.5 )
{
if (std::fabs(posz) <= fDz - kCarTolerance*0.5 ) *tmpin = kInside ;
else if (std::fabs(posz) <= fDz + kCarTolerance*0.5 ) *tmpin = kSurface ;
if (std::fabs(posz) <= fDz - kCarTolerance*0.5 ) tmpin = kInside ;
else if (std::fabs(posz) <= fDz + kCarTolerance*0.5 ) tmpin = kSurface ;
}
else if ( posy <= yMax + kCarTolerance*0.5
&& posy >= yMin - kCarTolerance*0.5 )
{
if (std::fabs(posz) <= fDz + kCarTolerance*0.5 ) *tmpin = kSurface ;
if (std::fabs(posz) <= fDz + kCarTolerance*0.5 ) tmpin = kSurface ;
}
}
else if ( posx <= xMax + kCarTolerance*0.5
@@ -429,15 +407,15 @@ EInside G4VTwistedFaceted::Inside(const G4ThreeVector& p) const
if ( posy <= yMax + kCarTolerance*0.5
&& posy >= yMin - kCarTolerance*0.5 )
{
if (std::fabs(posz) <= fDz + kCarTolerance*0.5) *tmpin = kSurface ;
if (std::fabs(posz) <= fDz + kCarTolerance*0.5) tmpin = kSurface ;
}
}
#ifdef G4TWISTDEBUG
G4cout << "inside = " << fLastInside.inside << G4endl ;
G4cout << "inside = " << tmpin << G4endl ;
#endif
return fLastInside.inside;
return tmpin;
}
@@ -454,15 +432,6 @@ G4ThreeVector G4VTwistedFaceted::SurfaceNormal(const G4ThreeVector& p) const
// Which of the three or four surfaces are we closest to?
//
if (fLastNormal.p == p)
{
return fLastNormal.vec;
}
auto tmpp = const_cast<G4ThreeVector*>(&(fLastNormal.p));
auto tmpnormal = const_cast<G4ThreeVector*>(&(fLastNormal.vec));
auto tmpsurface = const_cast<G4VTwistSurface**>(fLastNormal.surface);
tmpp->set(p.x(), p.y(), p.z());
G4double distance = kInfinity;
@@ -490,10 +459,7 @@ G4ThreeVector G4VTwistedFaceted::SurfaceNormal(const G4ThreeVector& p) const
}
}
tmpsurface[0] = surfaces[besti];
*tmpnormal = tmpsurface[0]->GetNormal(bestxx, true);
return fLastNormal.vec;
return surfaces[besti]->GetNormal(bestxx, true);
}
@@ -510,26 +476,6 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p,
// The function returns kInfinity if no intersection or
// just grazing within tolerance.
//
// checking last value
//
G4ThreeVector* tmpp;
G4ThreeVector* tmpv;
G4double* tmpdist;
if (fLastDistanceToInWithV.p == p && fLastDistanceToInWithV.vec == v)
{
return fLastDistanceToIn.value;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToInWithV.p));
tmpv = const_cast<G4ThreeVector*>(&(fLastDistanceToInWithV.vec));
tmpdist = const_cast<G4double*>(&(fLastDistanceToInWithV.value));
tmpp->set(p.x(), p.y(), p.z());
tmpv->set(v.x(), v.y(), v.z());
}
//
// Calculate DistanceToIn(p,v)
//
@@ -547,8 +493,7 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p,
G4ThreeVector normal = SurfaceNormal(p);
if (normal*v < 0)
{
*tmpdist = 0.;
return fLastDistanceToInWithV.value;
return 0;
}
}
@@ -574,7 +519,7 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p,
for (const auto & surface : surfaces)
{
#ifdef G4TWISTDEBUG
G4cout << G4endl << "surface " << i << ": " << G4endl << G4endl ;
G4cout << G4endl << "surface " << &surface - &*surfaces << ": " << G4endl << G4endl ;
#endif
G4double tmpdistance = surface->DistanceToIn(p, v, xx);
#ifdef G4TWISTDEBUG
@@ -592,9 +537,8 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p,
G4cout << "best distance = " << distance << G4endl ;
#endif
*tmpdist = distance;
// timer.Stop();
return fLastDistanceToInWithV.value;
return distance;
}
@@ -608,23 +552,6 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p) const
// allowing for tolerance
//
//
// checking last value
//
G4ThreeVector* tmpp;
G4double* tmpdist;
if (fLastDistanceToIn.p == p)
{
return fLastDistanceToIn.value;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToIn.p));
tmpdist = const_cast<G4double*>(&(fLastDistanceToIn.value));
tmpp->set(p.x(), p.y(), p.z());
}
//
// Calculate DistanceToIn(p)
//
@@ -639,8 +566,7 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p) const
case (kSurface) :
{
*tmpdist = 0.;
return fLastDistanceToIn.value;
return 0;
}
case (kOutside) :
@@ -671,8 +597,7 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p) const
bestxx = xx;
}
}
*tmpdist = distance;
return fLastDistanceToIn.value;
return distance;
}
default:
@@ -702,26 +627,6 @@ G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p,
// The function returns kInfinity if no intersection or
// just grazing within tolerance.
//
// checking last value
//
G4ThreeVector* tmpp;
G4ThreeVector* tmpv;
G4double* tmpdist;
if (fLastDistanceToOutWithV.p == p && fLastDistanceToOutWithV.vec == v )
{
return fLastDistanceToOutWithV.value;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToOutWithV.p));
tmpv = const_cast<G4ThreeVector*>(&(fLastDistanceToOutWithV.vec));
tmpdist = const_cast<G4double*>(&(fLastDistanceToOutWithV.value));
tmpp->set(p.x(), p.y(), p.z());
tmpv->set(v.x(), v.y(), v.z());
}
//
// Calculate DistanceToOut(p,v)
//
@@ -737,17 +642,15 @@ G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p,
// if the particle is exiting from the volume, return 0
//
G4ThreeVector normal = SurfaceNormal(p);
G4VTwistSurface *blockedsurface = fLastNormal.surface[0];
if (normal*v > 0)
{
if (calcNorm)
{
*norm = (blockedsurface->GetNormal(p, true));
*validNorm = blockedsurface->IsValidNorm();
*norm = normal;
*validNorm = true;
}
*tmpdist = 0.;
// timer.Stop();
return fLastDistanceToOutWithV.value;
return 0;
}
}
@@ -789,8 +692,7 @@ G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p,
}
}
*tmpdist = distance;
return fLastDistanceToOutWithV.value;
return distance;
}
@@ -802,24 +704,6 @@ G4double G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p ) const
// DistanceToOut(p):
// Calculate distance to surface of shape from `inside',
// allowing for tolerance
//
// checking last value
//
G4ThreeVector* tmpp;
G4double* tmpdist;
if (fLastDistanceToOut.p == p)
{
return fLastDistanceToOut.value;
}
else
{
tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToOut.p));
tmpdist = const_cast<G4double*>(&(fLastDistanceToOut.value));
tmpp->set(p.x(), p.y(), p.z());
}
//
// Calculate DistanceToOut(p)
@@ -848,8 +732,7 @@ G4double G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p ) const
}
case (kSurface) :
{
*tmpdist = 0.;
retval = fLastDistanceToOut.value;
retval = 0;
break;
}
@@ -881,9 +764,7 @@ G4double G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p ) const
bestxx = xx;
}
}
*tmpdist = distance;
retval = fLastDistanceToOut.value;
retval = distance;
break;
}
@@ -306,7 +306,7 @@ void G4Voxelizer::BuildBoundaries()
reduced.push_back(boundary[i]);
}
}
boundary = reduced;
boundary = std::move(reduced);
}
}
}
@@ -591,7 +591,7 @@ void G4Voxelizer::BuildReduceVoxels(std::vector<G4double> boundaries[],
skip = mergings[i];
}
}
boundaries[k] = reducedBoundary;
boundaries[k] = std::move(reducedBoundary);
}
/*
G4int count = 0;
@@ -695,7 +695,7 @@ void G4Voxelizer::BuildReduceVoxels2(std::vector<G4double> boundaries[],
}
}
reducedBoundary[destination-1] = boundary[max];
boundaries[k] = reducedBoundary;
boundaries[k] = std::move(reducedBoundary);
}
}
@@ -746,7 +746,7 @@ void G4Voxelizer::CreateMiniVoxels(std::vector<G4double> boundaries[],
}
fVoxelBoxes.push_back(box);
std::vector<G4int>(candidates).swap(candidates);
fVoxelBoxesCandidates.push_back(candidates);
fVoxelBoxesCandidates.push_back(std::move(candidates));
}
}
}
+8
View File
@@ -6,6 +6,14 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-09-10 Ivana Hrivnacova (geomvol-V11-02-04)
- Coverity fix in G4ReflectionFactory:
Do not pass the same G4VisAttributes object to the reflected LV
## 2024-08-07 Gabriele Cosmo (geomvol-V11-02-03)
- Access G4GeometryManager singleton through its GetInstance() in
G4AssemblyStore.
## 2024-04-02 Gabriele Cosmo (geomvol-V11-02-02)
- Applied trivial clang-tidy fixes to G4AssemblyStore, i.e. removed
unnecessary 'if' check for null pointer in Clean() method.
@@ -70,7 +70,7 @@ void G4AssemblyStore::Clean()
{
// Do nothing if geometry is closed
//
if (G4GeometryManager::IsGeometryClosed())
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
{
G4cout << "WARNING - Attempt to delete the assembly store"
<< " while geometry closed !" << G4endl;
@@ -424,7 +424,10 @@ G4LogicalVolume* G4ReflectionFactory::CreateReflectedLV(G4LogicalVolume* LV)
LV->GetFieldManager(),
LV->GetSensitiveDetector(),
LV->GetUserLimits());
refLV->SetVisAttributes(LV->GetVisAttributes()); // vis-attributes
if (LV->GetVisAttributes() != nullptr) {
refLV->SetVisAttributes(*LV->GetVisAttributes()); // vis-attributes
}
refLV->SetBiasWeight(LV->GetBiasWeight()); // biasing weight
if (LV->IsRegion())
{