Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Field Class Referenceabstract

G4Field is the abstract class for any kind of field. It allows any kind of field (vector, scalar, tensor and any set of them) to be defined by implementing the inquiry function interface. A field must co-work with a corresponding Equation of Motion, to enable the integration of a particle's position, momentum and, optionally, spin. For this a field and its equation of motion must follow the same convention for the order of field components. More...

#include <G4Field.hh>

Inheritance diagram for G4Field:

Public Member Functions

 G4Field (G4bool gravityOn=false)
virtual ~G4Field ()=default
 G4Field (const G4Field &p)=default
G4Fieldoperator= (const G4Field &p)
virtual void GetFieldValue (const G4double Point[4], G4double *fieldArr) const =0
virtual G4bool DoesFieldChangeEnergy () const =0
virtual G4FieldType GetFieldType () const
G4bool IsGravityActive () const
void SetGravityActive (G4bool OnOffFlag)
virtual G4FieldClone () const

Static Public Attributes

static constexpr G4int MAX_NUMBER_OF_COMPONENTS = 24

Detailed Description

G4Field is the abstract class for any kind of field. It allows any kind of field (vector, scalar, tensor and any set of them) to be defined by implementing the inquiry function interface. A field must co-work with a corresponding Equation of Motion, to enable the integration of a particle's position, momentum and, optionally, spin. For this a field and its equation of motion must follow the same convention for the order of field components.

Definition at line 66 of file G4Field.hh.

Constructor & Destructor Documentation

◆ G4Field() [1/2]

◆ ~G4Field()

virtual G4Field::~G4Field ( )
virtualdefault

Default virtual Destructor.

◆ G4Field() [2/2]

G4Field::G4Field ( const G4Field & p)
default

Copy constructor and assignment operator.

Member Function Documentation

◆ Clone()

G4Field * G4Field::Clone ( ) const
virtual

Interface method to implement cloning, needed by multi-threading. Here issuing a fatal exception, as expecting this to be implemented concretely in derived classes.

Reimplemented in G4CachedMagneticField, G4DELPHIMagField, G4HarmonicPolMagField, G4KM_DummyField, G4LineCurrentMagField, G4QuadrupoleMagField, G4SextupoleMagField, G4TCachedMagneticField< T_Field >, G4TQuadrupoleMagField, G4TUniformMagneticField, G4UniformElectricField, G4UniformGravityField, and G4UniformMagField.

Definition at line 45 of file G4Field.cc.

46{
48 msg << "Derived class does not implement cloning,\n"
49 << "but Clone method called.\n"
50 << "Cannot continue;";
51 G4Exception("G4Field::Clone", "GeomField004", FatalException, msg );
52 return nullptr;
53}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription

Referenced by G4FieldManager::Clone().

◆ DoesFieldChangeEnergy()

virtual G4bool G4Field::DoesFieldChangeEnergy ( ) const
pure virtual

Each type/class of field should respond the field does change energy. For example:

  • an electric field should return "true"
  • a pure magnetic field should return "false"

Implemented in G4ElectricField, G4ElectroMagneticField, G4MagneticField, and G4UniformGravityField.

Referenced by G4FieldManager::G4FieldManager().

◆ GetFieldType()

virtual G4FieldType G4Field::GetFieldType ( ) const
inlinevirtual

Returns the field type-ID, "kUserFieldType". This should be overriden in derived classes.

Reimplemented in G4ElectroMagneticField, G4MagneticField, and G4UniformGravityField.

Definition at line 115 of file G4Field.hh.

115{ return kUserFieldType; }
@ kUserFieldType
User defined field type.

◆ GetFieldValue()

virtual void G4Field::GetFieldValue ( const G4double Point[4],
G4double * fieldArr ) const
pure virtual

Given the position time vector 'Point', returns the value of the field in the array 'fieldArr'. Notes: 1) The 'Point' vector has the following structure: Point[0] is x ( position, in Geant4 units ) Point[1] is y Point[2] is z Point[3] is t ( time, in Geant4 units ) 2) The convention for the components of the field array 'fieldArr' are determined by the type of field.

Parameters
[in]PointThe position time vector.
[out]fieldArrThe field array in output.

Implemented in G4CachedMagneticField, G4ElectricField, G4ElectroMagneticField, G4MagneticField, G4TCachedMagneticField< T_Field >, G4TUniformMagneticField, G4UniformElectricField, G4UniformGravityField, and G4UniformMagField.

Referenced by G4ErrorSurfaceTrajState::BuildErrorMatrix(), G4ErrorFreeTrajState::G4ErrorFreeTrajState(), G4ElectricFieldModel::GetFieldAtLocation(), G4MagneticFieldModel::GetFieldAtLocation(), G4SynchrotronRadiation::GetMeanFreePath(), G4SynchrotronRadiationInMat::GetMeanFreePath(), G4SynchrotronRadiationInMat::GetPhotonEnergy(), G4SynchrotronRadiation::PostStepDoIt(), G4SynchrotronRadiationInMat::PostStepDoIt(), G4ErrorMagFieldLimitProcess::PostStepGetPhysicalInteractionLength(), and G4ErrorFreeTrajState::PropagateError().

◆ IsGravityActive()

G4bool G4Field::IsGravityActive ( ) const
inline

Replies if the field includes gravity.

Returns
true if the field does include gravity.

Definition at line 121 of file G4Field.hh.

121{ return fGravityActive; }

Referenced by G4CoupledTransportation::AlongStepGetPhysicalInteractionLength(), and G4RepleteEofM::G4RepleteEofM().

◆ operator=()

G4Field & G4Field::operator= ( const G4Field & p)

Definition at line 38 of file G4Field.cc.

39{
40 if (&p == this) { return *this; }
41 fGravityActive= p.fGravityActive;
42 return *this;
43}

Referenced by G4ElectroMagneticField::operator=(), G4MagneticField::operator=(), and G4UniformGravityField::operator=().

◆ SetGravityActive()

void G4Field::SetGravityActive ( G4bool OnOffFlag)
inline

Sets the gravity flag.

Definition at line 127 of file G4Field.hh.

127{ fGravityActive = OnOffFlag; }

Member Data Documentation

◆ MAX_NUMBER_OF_COMPONENTS

G4int G4Field::MAX_NUMBER_OF_COMPONENTS = 24
staticconstexpr

Definition at line 138 of file G4Field.hh.


The documentation for this class was generated from the following files: