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

A stack of geometries. More...

#include <egs_stack_geometry.h>

Inheritance diagram for EGS_StackGeometry:
EGS_BaseGeometry

Public Member Functions

 EGS_StackGeometry (const vector< EGS_BaseGeometry * > &geoms, const string &Name="")
 Construct a geometry stack from the vector of geometries geom.
 
bool isRealRegion (int ireg) const
 
bool isInside (const EGS_Vector &x)
 
int isWhere (const EGS_Vector &x)
 
int inside (const EGS_Vector &x)
 
int medium (int ireg) const
 
int howfar (int ireg, const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int *newmed=0, EGS_Vector *normal=0)
 
EGS_Float hownear (int ireg, const EGS_Vector &x)
 
bool hasBooleanProperty (int ireg, EGS_BPType prop) const
 
void setBooleanProperty (EGS_BPType)
 
void addBooleanProperty (int)
 
void setBooleanProperty (EGS_BPType, int, int, int step=1)
 
void addBooleanProperty (int, int, int, int step=1)
 
const string & getType () const
 
void printInfo () const
 
EGS_Float getRelativeRho (int ireg) const
 
void setRelativeRho (int start, int end, EGS_Float rho)
 
void setRelativeRho (EGS_Input *)
 
EGS_Float getBScaling (int ireg) const
 
void setBScaling (int start, int end, EGS_Float bf)
 
void setBScaling (EGS_Input *)
 
virtual void getLabelRegions (const string &str, vector< int > &regs)
 
- 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 howfarToOutside (int ireg, const EGS_Vector &x, const EGS_Vector &u)
 
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...
 
virtual int getMaxStep () const
 Returns the maximum number of steps through the geometry. More...
 
virtual int computeIntersections (int ireg, int n, const EGS_Vector &x, const EGS_Vector &u, EGS_GeometryIntersections *isections)
 Calculates intersection distances to region boundaries. 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...
 
bool hasRhoScaling () const
 Does this geometry object have a mass density scaling feature? 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.
 
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.
 

Protected Member Functions

void setMedia (EGS_Input *, int, const int *)
 

Protected Attributes

int ng
 
int nmax
 
EGS_BaseGeometry ** g
 
vector< labelstack_labels
 
- 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? More...
 
EGS_Float * rhor
 Array with relative mass densities. More...
 
bool has_B_scaling
 Does this geometry has B field scaling factor? More...
 
bool has_Ref_rho
 
EGS_Float * bfactor
 Array with B field scaling factors. More...
 
EGS_Float rhoRef
 Reference density for B field scaling. More...
 
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< labellabels
 Labels. More...
 
EGS_Applicationapp
 The application this object belongs to.
 

Static Protected Attributes

static string type = "EGS_StackGeometry"
 
- Static Protected Attributes inherited from EGS_BaseGeometry
static int error_flag = 0
 Set to non-zero status if a geometry problem is encountered.
 

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. More...
 
static int getLastError ()
 
static void resetErrorFlag ()
 

Detailed Description

A stack of geometries.

A stack of geometries is conceptually similar to a geometry union except that additional restrictions are made, which permit a more efficient implementation of the various geometry methods:

Due to these limitations, a geometry stack is less general and therefore presumably less useful than a geometry union. However, if the geometry under consideration is such that it can be represented as a stack of geometries, the simulation may be substantially more efficient compared to a union, particularly when there are many geometries in the stack. A typical example of a geometry stack is the geometry package of the BEAMnrc code, which is built from "component modules" (corresponding to the geometry objects in this implementation), put together one after the other. The EGS_StackGeometry class is of course much more versatile than the BEAMnrc geometry as it permits to have an arbitrary number of geometries of arbitrary type, dynamically determined at run time from the user input, instead of a fixed set of component modules determined when the BEAMnrc accelerator is built and compiled.

A geometry stack is defined in the input file using the following keys:

library = egs_gstack
geometries = list of names of previously defined geometries
tolerance = small floating number

The tolerance key defines a small floating point number $boundaryTolerance$. Each time a particle exits a geometry, its position is moved by $boundaryTolerance$ along its direction of motion. This is needed to avoid numericall roundoff problems that may result in the particle not having entered the next geometry in the stack and therefore being discarded.

The $tolerance$ key duplicates the functionality of the $boundary tolerance$ key for backwards compatibility.

A simple example:

:start geometry definition:

    :start geometry:
        library = egs_cones
        type = EGS_ConeStack
        name = my_conestack
        axis = 0 0 2.6 0 0 -1
        :start layer:
            thickness = 0.05
            top radii = 0.
            bottom radii = 0.0858
            media = water
        :stop layer:
        :start layer:
            thickness = 0.1
            top radii = 0. 0.0858
            bottom radii = 0.3125 0.35
            media = air water
        :stop layer:
        :start layer:
            thickness = 0.2
            bottom radii = 0.3125 0.35
            media = air water
        :stop layer:
        :start layer:
            thickness = 2
            top radii = 0.050 0.3125 0.35
            bottom radii = 0.050 0.3125 0.35
            media = water air water
        :stop layer:
    :stop geometry:

    :start geometry:
        name        = my_box
        library     = egs_box
        box size    = 3 3 .5
        :start media input:
            media = water
        :stop media input:
    :stop geometry:

    :start geometry:
        name            = my_stack
        library         = egs_gstack
        geometries      = my_conestack my_box
        tolerance       = 1e-4
    :stop geometry:

    simulation geometry = my_stack

:stop geometry definition:
egs_gstack.png
A simple example with clipping plane 1,0,0,0

Definition at line 173 of file egs_stack_geometry.h.


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