EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EGS_DynamicGeometry Class Reference

A dynamic geometry. More...

#include <egs_dynamic_geometry.h>

Inheritance diagram for EGS_DynamicGeometry:
EGS_BaseGeometry

Classes

struct  EGS_ControlPoint
 Structure to store control point information for dynamic geometry. More...
 

Public Member Functions

 EGS_DynamicGeometry (EGS_BaseGeometry *G, EGS_Input *dyninp, const string &Name="")
 Construct a dynamic geometry using G as the geometry and cpts as the control points. More...
 
 ~EGS_DynamicGeometry ()
 
void setTransformation (EGS_AffineTransform t)
 Sets the current state transform of the geometry. This is called when checking location. Same as gtransformed. More...
 
int computeIntersections (int ireg, int n, const EGS_Vector &x, const EGS_Vector &u, EGS_GeometryIntersections *isections)
 Computes intersections of a particle with the dynamic geometry. More...
 
bool isRealRegion (int ireg) const
 Checks if a region is real. More...
 
bool isInside (const EGS_Vector &x)
 Checks if a point is inside the dynamic geometry. More...
 
int isWhere (const EGS_Vector &x)
 Checks the location of a point. More...
 
int inside (const EGS_Vector &x)
 Alias for isWhere method. More...
 
int medium (int ireg) const
 Returns the medium index of a region. More...
 
EGS_Float howfarToOutside (int ireg, const EGS_Vector &x, const EGS_Vector &u)
 Computes the distance to the outside of the dynamic geometry. More...
 
int howfar (int ireg, const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int *newmed=0, EGS_Vector *normal=0)
 Computes the distance to the nearest boundary. More...
 
EGS_Float hownear (int ireg, const EGS_Vector &x)
 Computes the distance to the nearest boundary. More...
 
int getMaxStep () const
 Returns the maximum step allowed for the dynamic geometry. More...
 
bool hasBooleanProperty (int ireg, EGS_BPType prop) const
 Checks if the dynamic geometry has a specific boolean property in a region. More...
 
void setBooleanProperty (EGS_BPType prop)
 Sets a boolean property for the dynamic geometry. More...
 
void addBooleanProperty (int bit)
 Adds a boolean property for the dynamic geometry. More...
 
void setBooleanProperty (EGS_BPType prop, int start, int end, int step=1)
 Sets a boolean property for a range of regions in the dynamic geometry. More...
 
void addBooleanProperty (int bit, int start, int end, int step=1)
 Adds a boolean property for a range of regions in the dynamic geometry. More...
 
const string & getType () const
 Returns the type of the dynamic geometry. More...
 
EGS_Float getRelativeRho (int ireg) const
 Gets the relative density of a region in the dynamic geometry. More...
 
void setRelativeRho (int start, int end, EGS_Float rho)
 Sets the relative density for a range of regions in the dynamic geometry. More...
 
void setRelativeRho (EGS_Input *)
 This is just a placeholder function.
 
EGS_Float getBScaling (int ireg) const
 Gets the magnetic field scaling factor for a region in the dynamic geometry. More...
 
void setBScaling (int start, int end, EGS_Float bf)
 Sets the magnetic field scaling factor for a range of regions in the dynamic geometry. More...
 
void setBScaling (EGS_Input *)
 This is just a placeholder function.
 
int getGlobalRegionOffset (const string geomName)
 Pass along getGlobalRegionOffset calls to the original geometry. More...
 
void getLabelRegions (const string &str, vector< int > &regs, bool sanitize=true)
 Retrieves regions labeled with a given string. More...
 
void getNextGeom (EGS_RandomGenerator *rndm)
 Updates the next particle state for geometries. It is tasked with determining the next state of the dynamic geometry. More...
 
void updatePosition (EGS_Float time)
 Updates the position of the dynamic geometry to the specified time. More...
 
void containsDynamic (bool &hasdynamic)
 Determines whether the simulation geometry contains a dynamic geometry. More...
 
bool hasRhoScaling () override
 
void finishInitialization () override
 
- Public Member Functions inherited from EGS_BaseGeometry
 EGS_BaseGeometry (const string &Name)
 Construct a geometry named Name. More...
 
virtual ~EGS_BaseGeometry ()
 Destructor. More...
 
bool isConvex () const
 Is the geometry convex? More...
 
virtual EGS_Float getVolume (int ireg)
 Calculates the volume of region ireg. More...
 
virtual EGS_Float getBound (int idir, int ind)
 Returns region boundaries in direction determined by idir. More...
 
virtual int getNRegDir (int idir)
 
int regions () const
 Returns the number of local regions in this geometry. More...
 
void setMedium (const string &Name)
 Set all regions to a medium with name Name. More...
 
void setMedium (int start, int end, const string &Name, int delta=1)
 Set every delta'th region between start and end to the medium named Name. More...
 
void setMedium (int imed)
 Set all regions to a medium with index imed. More...
 
void setMedium (int istart, int iend, int imed, int delta=1)
 Set every delta'th region between start and end (inclusive) to imed. More...
 
void setMedia (EGS_Input *inp)
 Set the media in the geometry from the input pointed to by inp. More...
 
EGS_Float getMediumRho (int ind) const
 
virtual void setApplication (EGS_Application *app)
 
bool hasBScaling () const
 Does this geometry object have a B field scaling feature?
 
const string & getName () const
 Get the name of this geometry. More...
 
void setDebug (bool deb)
 Turn debugging on. More...
 
void setName (EGS_Input *inp)
 Set the name of the geometry from the input inp. More...
 
void setBoundaryTolerance (EGS_Input *inp)
 Set the value of the boundary tolerance from the input inp. More...
 
void setBoundaryTolerance (EGS_Float tol)
 Set the value of the boundary tolerance from argument.
 
virtual void printInfo () const
 Print information about this geometry. More...
 
int ref ()
 Increase the reference count to this geometry. More...
 
int deref ()
 Decrease the reference count to this geometry. More...
 
EGS_Float getBoundaryTolerance ()
 Get the value of the boundary tolerance.
 
virtual void getNumberRegions (const string &str, vector< int > &regs)
 Get a list of all the regions labeled with a number.
 
virtual const string & getLabelName (const int i)
 Get the name of the i-th explicit label in the geometry.
 
virtual int getLabelCount ()
 Get the number of explicit labels in the geometry.
 
int setLabels (EGS_Input *input)
 Set the labels from an input block.
 
int setLabels (const string &inp)
 Set the labels from an input string.
 
bool validateRegions (const std::vector< int > &regions)
 Validate that all region numbers are within valid bounds. More...
 

Protected Member Functions

void setMedia (EGS_Input *inp, int, const int *)
 Don't define media in the transformed geometry definition. More...
 
int getCoordGeom (EGS_Float rand, EGS_ControlPoint &gipt)
 Extract coordinates for the next dynamic geometry position. More...
 
void buildDynamicGeometry (EGS_BaseGeometry *g, EGS_Input *dyninp)
 Builds the dynamic geometry using input specifications. More...
 

Protected Attributes

EGS_BaseGeometryg
 The geometry undergoing dynamic motion.
 
string type
 The geometry type.
 
EGS_AffineTransform T
 Affine transformation representing the current state.
 
vector< EGS_ControlPointcpts
 Control points for dynamic motion.
 
int ncpts
 Number of control points.
 
EGS_Float ptime
 Time index corresponding to the particle.
 
- Protected Attributes inherited from EGS_BaseGeometry
int nreg
 Number of local regions in this geometry. More...
 
string name
 Name of this geometry. More...
 
short * region_media
 Array of media indeces. More...
 
int med
 Medium index. More...
 
bool has_rho_scaling
 Does this geometry have relative mass density scvaling?
 
EGS_Float * rhor
 Array with relative mass densities.
 
bool has_B_scaling
 Does this geometry has B field scaling factor?
 
bool has_Ref_rho
 
EGS_Float * bfactor
 Array with B field scaling factors.
 
EGS_Float rhoRef
 Reference density for B field scaling.
 
int nref
 Number of references to this geometry. More...
 
bool debug
 Debugging flag. More...
 
bool is_convex
 Is this geometry convex? More...
 
EGS_BPType bproperty
 A bit mask of boolean properties for the entire geometry. More...
 
EGS_BPType * bp_array
 An array of boolean properties on a region by region basis. More...
 
EGS_Float boundaryTolerance
 Boundary tolerance for geometries that need it.
 
EGS_Float halfBoundaryTolerance
 
vector< EGS_Labellabels
 Labels. More...
 
EGS_Applicationapp
 The application this object belongs to.
 

Additional Inherited Members

- Static Public Member Functions inherited from EGS_BaseGeometry
static int findRegion (EGS_Float xp, int np, const EGS_Float *p)
 Find the bin to which xp belongs, given np bin edges p. More...
 
static int nMedia ()
 Get the number of media registered so far by all geometries. More...
 
static const char * getMediumName (int ind)
 Get the name of medium with index ind. More...
 
static int addMedium (const string &medname)
 Add a medium or get the index of an existing medium. More...
 
static int getMediumIndex (const string &medname)
 Get the index of a medium named medname. More...
 
static EGS_BaseGeometrycreateGeometry (EGS_Input *)
 Create a geometry (or geometries) from a given input. More...
 
static EGS_BaseGeometrycreateSingleGeometry (EGS_Input *inp)
 Create a single geometry from the input inp. More...
 
static void clearGeometries ()
 Clears (deletes) all geometries in the currently active geometry list. More...
 
static EGS_BaseGeometrygetGeometry (const string &Name)
 Get a pointer to the geometry named Name. More...
 
static EGS_BaseGeometry ** getGeometries ()
 
static int getNGeometries ()
 
static string getUniqueName ()
 Get a unique geometry name. More...
 
static void describeGeometries ()
 Describes all existing geometries. More...
 
static void setActiveGeometryList (int list)
 Set the currently active geometry list.
 
static int getLastError ()
 
static void resetErrorFlag ()
 
- Static Protected Attributes inherited from EGS_BaseGeometry
static int error_flag = 0
 Set to non-zero status if a geometry problem is encountered.
 

Detailed Description

A dynamic geometry.

A dynamic geometry provides the functionality to model motion of geometries during the simulation. This is automatically synchronized with the motion of sources and shapes. To do this, the geometry applies transformations to a previously defined geometry. By sampling a time index, continuous motion is modelled by interpolating between user-defined control points.

A dynamic geometry is defined using

:start geometry:
    name        = ...
    library     = egs_dynamic_geometry
    base geometry = name of a predefined geometry that we want to add motion to :start motion: # units of cm and degrees
        control point = timeIndex(1) xtrans(1) ytrans(1) ztrans(1) xrot(1) yrot(1) zrot(1)
        control point = timeIndex(2) xtrans(2) ytrans(2) ztrans(2) xrot(2) yrot(2) zrot(2)
        .
        .
        .
        control point = timeIndex(N) xtrans(N) ytrans(N) ztrans(N) xrot(N) yrot(N) zrot(N)
    :stop motion:
:stop geometry:

Control points must be defined such that timeIndex(i+1)>=timeIndex(i), where timeIndex(i) is the value of time index for control point i. The timeIndex(i) are automatically normalized by timeIndex(N), where N is the number of control points.

A translation from the starting position of the geometry is applied according to xtrans, ytrans and ztrans. A rotation follows the same rotation technique as in EGS_AffineTransform, using the rotation input parameter for 2 or 3 values. Angles are in degrees and translations in cm.

Continuous, dynamic motion between control points is simulated by choosing a random number, R, on (0,1] and, for timeIndex(i)<R<=timeIndex(i+1), setting the translation or rotation parameter P by interpolation: P=P(i)+[P(i+1)-P(i)]/[timeIndex(i+1)-timeIndex(i)]*[R-timeIndex(i)]

It is generally expected that the user provide timeIndex(1)=0.0. However, the geometry can function with timeIndex(1)>0.0, in the case where a user desires to eliminate particles associated with a range of timeIndex values, but there will be a lot of warning messages.

Definition at line 110 of file egs_dynamic_geometry.h.

Constructor & Destructor Documentation

◆ EGS_DynamicGeometry()

EGS_DynamicGeometry::EGS_DynamicGeometry ( EGS_BaseGeometry G,
EGS_Input dyninp,
const string &  Name = "" 
)

Construct a dynamic geometry using G as the geometry and cpts as the control points.

Parameters
GPointer to the base geometry to be transformed dynamically.
dyninpInput containing dynamic geometry specifications.
NameName of the dynamic geometry.

Definition at line 131 of file egs_dynamic_geometry.h.

References buildDynamicGeometry(), egsWarning, epsilon, and EGS_BaseGeometry::getType().

◆ ~EGS_DynamicGeometry()

EGS_DynamicGeometry::~EGS_DynamicGeometry ( )

Destructor.

Definition at line 164 of file egs_dynamic_geometry.h.

Member Function Documentation

◆ setTransformation()

void EGS_DynamicGeometry::setTransformation ( EGS_AffineTransform  t)

Sets the current state transform of the geometry. This is called when checking location. Same as gtransformed.

Parameters
tAffine transformation to set.

Definition at line 175 of file egs_dynamic_geometry.h.

◆ computeIntersections()

int EGS_DynamicGeometry::computeIntersections ( int  ireg,
int  n,
const EGS_Vector x,
const EGS_Vector u,
EGS_GeometryIntersections isections 
)
virtual

Computes intersections of a particle with the dynamic geometry.

Parameters
iregRegion index.
nNumber of particles.
xParticle position.
uParticle direction.
isectionsGeometry intersections.
Returns
Number of intersections.

Reimplemented from EGS_BaseGeometry.

Definition at line 341 of file egs_dynamic_geometry.cpp.

◆ isRealRegion()

bool EGS_DynamicGeometry::isRealRegion ( int  ireg) const
virtual

Checks if a region is real.

Parameters
iregRegion index.
Returns
True if the region is real, false otherwise.

Reimplemented from EGS_BaseGeometry.

Definition at line 349 of file egs_dynamic_geometry.cpp.

◆ isInside()

bool EGS_DynamicGeometry::isInside ( const EGS_Vector x)
virtual

Checks if a point is inside the dynamic geometry.

Parameters
xPoint to check.
Returns
True if the point is inside, false otherwise.

Implements EGS_BaseGeometry.

Definition at line 353 of file egs_dynamic_geometry.cpp.

◆ isWhere()

int EGS_DynamicGeometry::isWhere ( const EGS_Vector x)
virtual

Checks the location of a point.

Parameters
xPoint to check.
Returns
Index of the region containing the point.

Implements EGS_BaseGeometry.

Definition at line 359 of file egs_dynamic_geometry.cpp.

◆ inside()

int EGS_DynamicGeometry::inside ( const EGS_Vector x)
virtual

Alias for isWhere method.

Parameters
xPoint to check.
Returns
Index of the region containing the point.

Implements EGS_BaseGeometry.

Definition at line 365 of file egs_dynamic_geometry.cpp.

◆ medium()

int EGS_DynamicGeometry::medium ( int  ireg) const
virtual

Returns the medium index of a region.

Parameters
iregRegion index.
Returns
Medium index.

Reimplemented from EGS_BaseGeometry.

Definition at line 369 of file egs_dynamic_geometry.cpp.

◆ howfarToOutside()

EGS_Float EGS_DynamicGeometry::howfarToOutside ( int  ireg,
const EGS_Vector x,
const EGS_Vector u 
)
virtual

Computes the distance to the outside of the dynamic geometry.

Parameters
iregRegion index.
xParticle position.
uParticle direction.
Returns
Distance to the outside.

Reimplemented from EGS_BaseGeometry.

Definition at line 373 of file egs_dynamic_geometry.cpp.

References g, EGS_AffineTransform::inverseTransform(), EGS_BaseGeometry::isWhere(), and T.

◆ howfar()

int EGS_DynamicGeometry::howfar ( int  ireg,
const EGS_Vector x,
const EGS_Vector u,
EGS_Float &  t,
int *  newmed = 0,
EGS_Vector normal = 0 
)
virtual

Computes the distance to the nearest boundary.

Parameters
iregRegion index.
xParticle position.
uParticle direction.
tOutput: distance to the nearest boundary.
newmedOutput: new medium index after crossing the boundary.
normalOutput: normal vector at the intersection point.
Returns
Index of the new region.

Implements EGS_BaseGeometry.

Definition at line 378 of file egs_dynamic_geometry.cpp.

◆ hownear()

EGS_Float EGS_DynamicGeometry::hownear ( int  ireg,
const EGS_Vector x 
)
virtual

Computes the distance to the nearest boundary.

Parameters
iregRegion index.
xParticle position.
Returns
Distance to the nearest boundary.

Implements EGS_BaseGeometry.

Definition at line 390 of file egs_dynamic_geometry.cpp.

◆ getMaxStep()

int EGS_DynamicGeometry::getMaxStep ( ) const
virtual

Returns the maximum step allowed for the dynamic geometry.

Returns
Maximum allowed step.

Reimplemented from EGS_BaseGeometry.

Definition at line 396 of file egs_dynamic_geometry.cpp.

◆ hasBooleanProperty()

bool EGS_DynamicGeometry::hasBooleanProperty ( int  ireg,
EGS_BPType  prop 
) const
virtual

Checks if the dynamic geometry has a specific boolean property in a region.

Parameters
iregRegion index.
propBoolean property type.
Returns
True if the region has the specified property, false otherwise.

Reimplemented from EGS_BaseGeometry.

Definition at line 400 of file egs_dynamic_geometry.cpp.

◆ setBooleanProperty() [1/2]

void EGS_DynamicGeometry::setBooleanProperty ( EGS_BPType  prop)
virtual

Sets a boolean property for the dynamic geometry.

Parameters
propBoolean property type.

Reimplemented from EGS_BaseGeometry.

Definition at line 404 of file egs_dynamic_geometry.cpp.

References EGS_AffineTransform::inverseTransform(), and T.

◆ addBooleanProperty() [1/2]

void EGS_DynamicGeometry::addBooleanProperty ( int  bit)
virtual

Adds a boolean property for the dynamic geometry.

Parameters
bitBit index of the property to add.

Reimplemented from EGS_BaseGeometry.

Definition at line 408 of file egs_dynamic_geometry.cpp.

◆ setBooleanProperty() [2/2]

void EGS_DynamicGeometry::setBooleanProperty ( EGS_BPType  prop,
int  start,
int  end,
int  step = 1 
)
virtual

Sets a boolean property for a range of regions in the dynamic geometry.

Parameters
propBoolean property type.
startStart index of the range.
endEnd index of the range.
stepStep size for the range.

Reimplemented from EGS_BaseGeometry.

Definition at line 412 of file egs_dynamic_geometry.cpp.

◆ addBooleanProperty() [2/2]

void EGS_DynamicGeometry::addBooleanProperty ( int  bit,
int  start,
int  end,
int  step = 1 
)
virtual

Adds a boolean property for a range of regions in the dynamic geometry.

Parameters
bitBit index of the property to add.
startStart index of the range.
endEnd index of the range.
stepStep size for the range.

Reimplemented from EGS_BaseGeometry.

Definition at line 416 of file egs_dynamic_geometry.cpp.

◆ getType()

const string & EGS_DynamicGeometry::getType ( ) const
virtual

Returns the type of the dynamic geometry.

Returns
Type of the dynamic geometry.

Implements EGS_BaseGeometry.

Definition at line 420 of file egs_dynamic_geometry.cpp.

◆ getRelativeRho()

EGS_Float EGS_DynamicGeometry::getRelativeRho ( int  ireg) const
virtual

Gets the relative density of a region in the dynamic geometry.

Parameters
iregRegion index.
Returns
Relative density of the region.

Reimplemented from EGS_BaseGeometry.

Definition at line 424 of file egs_dynamic_geometry.cpp.

◆ setRelativeRho()

void EGS_DynamicGeometry::setRelativeRho ( int  start,
int  end,
EGS_Float  rho 
)
virtual

Sets the relative density for a range of regions in the dynamic geometry.

Parameters
startStart index of the range.
endEnd index of the range.
rhoRelative density to set.

Reimplemented from EGS_BaseGeometry.

Definition at line 53 of file egs_dynamic_geometry.cpp.

◆ getBScaling()

EGS_Float EGS_DynamicGeometry::getBScaling ( int  ireg) const
virtual

Gets the magnetic field scaling factor for a region in the dynamic geometry.

Parameters
iregRegion index.
Returns
Magnetic field scaling factor.

Reimplemented from EGS_BaseGeometry.

Definition at line 428 of file egs_dynamic_geometry.cpp.

◆ setBScaling()

void EGS_DynamicGeometry::setBScaling ( int  start,
int  end,
EGS_Float  bf 
)
virtual

Sets the magnetic field scaling factor for a range of regions in the dynamic geometry.

Parameters
startStart index of the range.
endEnd index of the range.
bfMagnetic field scaling factor to set.

Reimplemented from EGS_BaseGeometry.

Definition at line 63 of file egs_dynamic_geometry.cpp.

◆ getGlobalRegionOffset()

int EGS_DynamicGeometry::getGlobalRegionOffset ( const string  geomName)
virtual

Pass along getGlobalRegionOffset calls to the original geometry.

Parameters
geomNameThe name of the geometry being queried.

Reimplemented from EGS_BaseGeometry.

Definition at line 150 of file egs_dynamic_geometry.cpp.

References EGS_BaseGeometry::setName().

◆ getLabelRegions()

void EGS_DynamicGeometry::getLabelRegions ( const string &  str,
vector< int > &  regs,
bool  sanitize = true 
)
virtual

Retrieves regions labeled with a given string.

Parameters
strLabel to search for.
regsOutput: List of region indices with the specified label.

Reimplemented from EGS_BaseGeometry.

Definition at line 154 of file egs_dynamic_geometry.cpp.

◆ getNextGeom()

void EGS_DynamicGeometry::getNextGeom ( EGS_RandomGenerator rndm)
virtual

Updates the next particle state for geometries. It is tasked with determining the next state of the dynamic geometry.

Parameters
rndmRandom number generator.

Reimplemented from EGS_BaseGeometry.

Definition at line 432 of file egs_dynamic_geometry.cpp.

◆ updatePosition()

void EGS_DynamicGeometry::updatePosition ( EGS_Float  time)
virtual

Updates the position of the dynamic geometry to the specified time.

Parameters
timeTime index to update to.

Reimplemented from EGS_BaseGeometry.

Definition at line 466 of file egs_dynamic_geometry.cpp.

◆ containsDynamic()

void EGS_DynamicGeometry::containsDynamic ( bool &  hasdynamic)
virtual

Determines whether the simulation geometry contains a dynamic geometry.

Parameters
hasdynamicOutput: True if the simulation contains a dynamic geometry, false otherwise.

Reimplemented from EGS_BaseGeometry.

Definition at line 485 of file egs_dynamic_geometry.cpp.

◆ setMedia()

void EGS_DynamicGeometry::setMedia ( EGS_Input inp,
int  ,
const int *   
)
protectedvirtual

Don't define media in the transformed geometry definition.

This function is re-implemented to warn the user not to define media in the definition of a transformed geometry. Instead, media should be defined when specifying the geometry to be transformed.

Reimplemented from EGS_BaseGeometry.

Definition at line 48 of file egs_dynamic_geometry.cpp.

References egsWarning.

◆ getCoordGeom()

int EGS_DynamicGeometry::getCoordGeom ( EGS_Float  rand,
EGS_ControlPoint gipt 
)
protected

Extract coordinates for the next dynamic geometry position.

Parameters
randRandom number for time sampling.
giptEGS_ControlPoint structure to store the coordinates.
Returns
0 if successful, otherwise 1.

Definition at line 271 of file egs_dynamic_geometry.cpp.

References egsFatal.

◆ buildDynamicGeometry()

void EGS_DynamicGeometry::buildDynamicGeometry ( EGS_BaseGeometry g,
EGS_Input dyninp 
)
protected

Builds the dynamic geometry using input specifications.

Parameters
gPointer to the base geometry to be transformed dynamically.
dyninpInput containing dynamic geometry specifications.

Definition at line 162 of file egs_dynamic_geometry.cpp.

Referenced by EGS_DynamicGeometry().


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