BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Attributes | Friends
BDSArray4D Class Reference

4D array and base class for 3,2 & 1D arrays. More...

#include <BDSArray4D.hh>

Inheritance diagram for BDSArray4D:
Inheritance graph
Collaboration diagram for BDSArray4D:
Collaboration graph

Public Member Functions

 BDSArray4D ()=delete
 
 BDSArray4D (G4int nXIn, G4int nYIn, G4int nZIn, G4int nTIn)
 
virtual BDSFieldValueoperator() (G4int x, G4int y=0, G4int z=0, G4int t=0)
 Setter & (technically, a non-const) accessor.
 
const BDSFieldValueoperator() (BDSFourVector< G4int > &pos)
 Convenience accessor to operator().
 
virtual const BDSFieldValueGetConst (G4int x, G4int y=0, G4int z=0, G4int t=0) const
 
virtual const BDSFieldValueoperator() (G4int x, G4int y=0, G4int z=0, G4int t=0) const
 Convenience shortcut to GetConst().
 
const BDSFieldValueoperator() (const BDSFourVector< G4int > &pos) const
 Convenience accessor to operator().
 
virtual G4bool Outside (G4int x, G4int y, G4int z, G4int t) const
 Return whether the indices are valid and lie within the array boundaries or not.
 
virtual void OutsideWarn (G4int x, G4int y, G4int z, G4int t) const
 Use Outside() but warn and exit if the coordinates requested are outside the array.
 
virtual std::ostream & Print (std::ostream &out) const
 
G4int NX () const
 Access the number of elements in a given dimension.
 
G4int NY () const
 Access the number of elements in a given dimension.
 
G4int NZ () const
 Access the number of elements in a given dimension.
 
G4int NT () const
 Access the number of elements in a given dimension.
 
BDSFourVector< G4int > NXYZT () const
 Access the number of elements in a given dimension.
 

Protected Attributes

BDSFieldValue defaultValue
 Need to store a default value so it can be return by reference.
 
const G4int nX
 Dimension.
 
const G4int nY
 Dimension.
 
const G4int nZ
 Dimension.
 
const G4int nT
 Dimension.
 

Private Attributes

std::vector< BDSFieldValuedata
 A 1D array representing all the data.
 

Friends

std::ostream & operator<< (std::ostream &out, BDSArray4D const &a)
 Output stream.
 

Detailed Description

4D array and base class for 3,2 & 1D arrays.

Data represents T,Z,Y,X dimensions. The data is stored as a (1D) vector and stored in that order. This means that adjacent X values are stored next to each other. Storing the data as a 1D vector improves performance for random access (through behind the scenes caching) and significantly improves performance for copying.

Data can be accessed by index only in the array. Testing of indices is provided.

The () operator is used for accessing and setting as the [] operator can only ever accept one parameter by design. https://isocpp.org/wiki/faq/operator-overloading#matrix-subscript-op

The size cannot be changed after construction.

Author
Laurie Nevay

Definition at line 50 of file BDSArray4D.hh.

Constructor & Destructor Documentation

◆ BDSArray4D() [1/2]

BDSArray4D::BDSArray4D ( )
delete

No default constructor as the array is not adjustable after construction and therefore the size must be known at construction time.

◆ BDSArray4D() [2/2]

BDSArray4D::BDSArray4D ( G4int  nXIn,
G4int  nYIn,
G4int  nZIn,
G4int  nTIn 
)

At construction the size of the array must be known as this implementation does not allow the size to be changed afterwards.

Definition at line 31 of file BDSArray4D.cc.

◆ ~BDSArray4D()

virtual BDSArray4D::~BDSArray4D ( )
inlinevirtual

Definition at line 59 of file BDSArray4D.hh.

Member Function Documentation

◆ GetConst()

const BDSFieldValue & BDSArray4D::GetConst ( G4int  x,
G4int  y = 0,
G4int  z = 0,
G4int  t = 0 
) const
virtual

Accessor only as returns const reference to data. By being named this can be used explicitly to ensure const access - recommended main main interface.

Reimplemented in BDSArray2DCoordsRDipole, and BDSArray2DCoordsRQuad.

Definition at line 46 of file BDSArray4D.cc.

References data, defaultValue, nX, nY, nZ, and Outside().

Referenced by BDSArray1DCoords::ExtractNearest(), BDSArray1DCoordsTransformed::ExtractNearest(), BDSArray2DCoords::ExtractNearest(), BDSArray2DCoordsTransformed::ExtractNearest(), BDSArray3DCoords::ExtractNearest(), BDSArray3DCoordsTransformed::ExtractNearest(), BDSArray4DCoords::ExtractNearest(), BDSArray4DCoordsTransformed::ExtractNearest(), BDSArray1DCoords::ExtractSection2(), BDSArray1DCoordsTransformed::ExtractSection2(), BDSArray2DCoords::ExtractSection2x2(), BDSArray2DCoordsTransformed::ExtractSection2x2(), BDSArray3DCoords::ExtractSection2x2x2(), BDSArray3DCoordsTransformed::ExtractSection2x2x2(), BDSArray4DCoords::ExtractSection2x2x2x2(), BDSArray4DCoordsTransformed::ExtractSection2x2x2x2(), BDSArray1DCoords::ExtractSection4(), BDSArray1DCoordsTransformed::ExtractSection4(), BDSArray2DCoords::ExtractSection4x4(), BDSArray2DCoordsTransformed::ExtractSection4x4(), BDSArray3DCoords::ExtractSection4x4x4(), BDSArray3DCoordsTransformed::ExtractSection4x4x4(), BDSArray4DCoords::ExtractSection4x4x4x4(), BDSArray4DCoordsTransformed::ExtractSection4x4x4x4(), BDSArray2DCoordsRDipole::GetConst(), BDSArray2DCoordsRQuad::GetConst(), operator()(), and Print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NT()

G4int BDSArray4D::NT ( ) const
inline

Access the number of elements in a given dimension.

Definition at line 65 of file BDSArray4D.hh.

References nT.

Referenced by NXYZT().

Here is the caller graph for this function:

◆ NX()

G4int BDSArray4D::NX ( ) const
inline

Access the number of elements in a given dimension.

Definition at line 62 of file BDSArray4D.hh.

References nX.

Referenced by NXYZT().

Here is the caller graph for this function:

◆ NXYZT()

BDSFourVector< G4int > BDSArray4D::NXYZT ( ) const
inline

Access the number of elements in a given dimension.

Definition at line 66 of file BDSArray4D.hh.

References NT(), NX(), NY(), and NZ().

Here is the call graph for this function:

◆ NY()

G4int BDSArray4D::NY ( ) const
inline

Access the number of elements in a given dimension.

Definition at line 63 of file BDSArray4D.hh.

References nY.

Referenced by NXYZT().

Here is the caller graph for this function:

◆ NZ()

G4int BDSArray4D::NZ ( ) const
inline

Access the number of elements in a given dimension.

Definition at line 64 of file BDSArray4D.hh.

References nZ.

Referenced by NXYZT().

Here is the caller graph for this function:

◆ operator()() [1/4]

const BDSFieldValue & BDSArray4D::operator() ( BDSFourVector< G4int > &  pos)
inline

Convenience accessor to operator().

Definition at line 76 of file BDSArray4D.hh.

References operator()(), BDSFourVector< Type >::t(), BDSFourVector< Type >::x(), BDSFourVector< Type >::y(), and BDSFourVector< Type >::z().

Here is the call graph for this function:

◆ operator()() [2/4]

const BDSFieldValue & BDSArray4D::operator() ( const BDSFourVector< G4int > &  pos) const
inline

Convenience accessor to operator().

Definition at line 94 of file BDSArray4D.hh.

References operator()(), BDSFourVector< Type >::t(), BDSFourVector< Type >::x(), BDSFourVector< Type >::y(), and BDSFourVector< Type >::z().

Here is the call graph for this function:

◆ operator()() [3/4]

BDSFieldValue & BDSArray4D::operator() ( G4int  x,
G4int  y = 0,
G4int  z = 0,
G4int  t = 0 
)
virtual

Setter & (technically, a non-const) accessor.

Definition at line 37 of file BDSArray4D.cc.

References data, nX, nY, nZ, and OutsideWarn().

Referenced by operator()().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator()() [4/4]

const BDSFieldValue & BDSArray4D::operator() ( G4int  x,
G4int  y = 0,
G4int  z = 0,
G4int  t = 0 
) const
virtual

Convenience shortcut to GetConst().

Definition at line 56 of file BDSArray4D.cc.

References GetConst().

Here is the call graph for this function:

◆ Outside()

G4bool BDSArray4D::Outside ( G4int  x,
G4int  y,
G4int  z,
G4int  t 
) const
virtual

Return whether the indices are valid and lie within the array boundaries or not.

Reimplemented in BDSArray2DCoordsRDipole, and BDSArray2DCoordsRQuad.

Definition at line 64 of file BDSArray4D.cc.

References nT, nX, nY, and nZ.

Referenced by GetConst(), and OutsideWarn().

Here is the caller graph for this function:

◆ OutsideWarn()

void BDSArray4D::OutsideWarn ( G4int  x,
G4int  y,
G4int  z,
G4int  t 
) const
virtual

Use Outside() but warn and exit if the coordinates requested are outside the array.

Definition at line 76 of file BDSArray4D.cc.

References Outside().

Referenced by operator()().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Print()

std::ostream & BDSArray4D::Print ( std::ostream &  out) const
virtual

Virtual function is more flexible than plain operator<< for ostreaming as the derived function may use the base class part of the print out first or in a different way. The operator<< for ostream uses this function.

Reimplemented in BDSArray1DCoordsTransformed, BDSArray2DCoordsRDipole, BDSArray2DCoordsRQuad, BDSArray2DCoordsTransformed, BDSArray3DCoordsTransformed, BDSArray4DCoords, and BDSArray4DCoordsTransformed.

Definition at line 91 of file BDSArray4D.cc.

References GetConst(), nT, nX, nY, and nZ.

Referenced by BDSArray1DCoordsTransformed::Print(), BDSArray2DCoordsRDipole::Print(), BDSArray2DCoordsRQuad::Print(), BDSArray2DCoordsTransformed::Print(), BDSArray3DCoordsTransformed::Print(), and BDSArray4DCoords::Print().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
BDSArray4D const &  a 
)
friend

Output stream.

Definition at line 112 of file BDSArray4D.cc.

Field Documentation

◆ data

std::vector<BDSFieldValue> BDSArray4D::data
private

A 1D array representing all the data.

Definition at line 131 of file BDSArray4D.hh.

Referenced by GetConst(), and operator()().

◆ defaultValue

BDSFieldValue BDSArray4D::defaultValue
protected

Need to store a default value so it can be return by reference.

Definition at line 127 of file BDSArray4D.hh.

Referenced by BDSArray2DCoordsRDipole::GetConst(), BDSArray2DCoordsRQuad::GetConst(), and GetConst().

◆ nT

const G4int BDSArray4D::nT
protected

◆ nX

const G4int BDSArray4D::nX
protected

◆ nY

const G4int BDSArray4D::nY
protected

◆ nZ

const G4int BDSArray4D::nZ
protected

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