OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
DumpFields Class Reference

#include <DumpFields.h>

Inheritance diagram for DumpFields:
Inheritance graph
[legend]
Collaboration diagram for DumpFields:
Collaboration graph
[legend]

Public Types

enum  {
  FILE_NAME , X_START , DX , X_STEPS ,
  Y_START , DY , Y_STEPS , Z_START ,
  DZ , Z_STEPS , SIZE
}
 The common attributes of DumpFields. More...
 

Public Member Functions

 DumpFields ()
 
 DumpFields (const std::string &name, DumpFields *parent)
 
virtual ~DumpFields ()
 
virtual DumpFieldsclone (const std::string &name)
 
virtual void execute ()
 
void print (std::ostream &os) const
 
- Public Member Functions inherited from Action
virtual ~Action ()
 
virtual bool canReplaceBy (Object *object)
 Test if replacement is allowed. More...
 
virtual const std::string getCategory () const
 Return the object category as a string. More...
 
virtual bool shouldTrace () const
 Trace flag. More...
 
virtual bool shouldUpdate () const
 Update flag. More...
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
void copyAttributes (const Object &)
 Copy attributes from another object. More...
 
virtual AttributefindAttribute (const std::string &name)
 Find an attribute by name. More...
 
virtual const AttributefindAttribute (const std::string &name) const
 Find an attribute by name. More...
 
virtual ObjectmakeTemplate (const std::string &, TokenStream &, Statement &)
 Macro handler function. More...
 
virtual ObjectmakeInstance (const std::string &name, Statement &, const Parser *)
 Macro handler function. More...
 
virtual void parse (Statement &)
 Parse the object. More...
 
virtual void parseShortcut (Statement &, bool eval=true)
 Parser for single-attribute commands. More...
 
virtual void printValue (std::ostream &) const
 
virtual void printHelp (std::ostream &) const
 Print help. More...
 
virtual void replace (Object *oldObject, Object *newObject)
 Replace references. More...
 
virtual void update ()
 Update this object. More...
 
bool isBuiltin () const
 True, if [b]this[/b] is a built-in object. More...
 
virtual bool isShared () const
 Shared flag. More...
 
virtual void setShared (bool)
 Set/reset shared flag. More...
 
void setDirty (bool)
 Set/reset the [b]modified[/b] flag. More...
 
bool isDirty () const
 True, if the [b]modified[/b] flag is set. More...
 
void setFlag (bool)
 Flag/unflag this object, e. g. to control output of objects for. More...
 
bool isFlagged () const
 True, if [b]this[/b] is flagged by setFlag(true). More...
 
const ObjectgetBaseObject () const
 Return the object's base type object. More...
 
const std::string & getOpalName () const
 Return object name. More...
 
ObjectgetParent () const
 Return parent pointer. More...
 
bool isTreeMember (const Object *subTree) const
 Test for tree membership. More...
 
void setOpalName (const std::string &name)
 Set object name. More...
 
void setParent (Object *)
 Set parent object. More...
 
void clear ()
 Clear the occurrence counter. More...
 
int increment ()
 Increment and return the occurrence counter. More...
 
int occurrenceCount ()
 Return the occurrence counter. More...
 
void registerReference (Invalidator *a)
 Register a reference to this object. More...
 
void unregisterReference (Invalidator *a)
 Unegister a reference to this object. More...
 
void registerOwnership (const AttributeHandler::OwnerType &itsClass) const
 
- Public Member Functions inherited from RCObject
int addReference () const
 Increment reference count. More...
 
int removeReference () const
 Decrement the reference count. More...
 
bool isShared () const
 Test for sharing. More...
 

Static Public Member Functions

static void writeFields (Component *field)
 

Private Member Functions

virtual void writeFieldThis (Component *field)
 
virtual void buildGrid ()
 
 DumpFields (const DumpFields &dump)
 
DumpFieldsoperator= (const DumpFields &dump)
 

Static Private Member Functions

static void checkInt (double value, std::string name, double tolerance=1e-9)
 

Private Attributes

interpolation::ThreeDGridgrid_m = NULL
 
std::string filename_m
 

Static Private Attributes

static std::unordered_set< DumpFields * > dumpsSet_m
 

Additional Inherited Members

- Public Attributes inherited from Object
std::vector< AttributeitsAttr
 The object attributes. More...
 
- Protected Member Functions inherited from Action
 Action (int size, const char *name, const char *help)
 Constructor for exemplars. More...
 
 Action (const std::string &name, Action *parent)
 Constructor for cloning. More...
 
- Protected Member Functions inherited from Object
 Object (int size, const char *name, const char *help)
 Constructor for exemplars. More...
 
 Object (const std::string &name, Object *parent)
 Constructor for clones. More...
 
- Protected Member Functions inherited from RCObject
 RCObject ()
 Default constructor. More...
 
 RCObject (const RCObject &)
 Copy constructor. More...
 
virtual ~RCObject ()=0
 
RCObjectoperator= (const RCObject &right)
 
- Protected Attributes inherited from Object
bool builtin
 Built-in flag. More...
 
bool modified
 Dirty flag. More...
 
bool flagged
 Object flag. More...
 

Detailed Description

DumpFields dumps the static magnetic field of a Ring in a user-defined grid

The idea is to print out the field map across a grid in space for debugging purposes. The problem is to manage the DumpFields object through three phases of program execution; initial construction, parsing and then actual field map writing (where we need to somehow let DumpFields know what the field maps are). So for each DumpFields object created, we store in a set. When the execute() method is called, DumpFields builds a grid using the parsed information.

When the ParallelCyclotronTracker is about to start tracking, it calls writeFields method which loops over the static set of DumpFields and writes each one. It is not the cleanest implementation, but I can't see a better way.

The DumpFields themselves operate by iterating over a ThreeDGrid object and looking up the field/writing it out on each grid point.

In order to dump time dependent fields, for example RF, see the DumpEMFields action.

Definition at line 54 of file DumpFields.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

The common attributes of DumpFields.

Enumerator
FILE_NAME 
X_START 
DX 
X_STEPS 
Y_START 
DY 
Y_STEPS 
Z_START 
DZ 
Z_STEPS 
SIZE 

Definition at line 58 of file DumpFields.h.

Constructor & Destructor Documentation

◆ DumpFields() [1/3]

DumpFields::DumpFields ( )

Constructor

Definition at line 35 of file DumpFields.cpp.

References DX, DY, DZ, FILE_NAME, Object::itsAttr, Attributes::makeReal(), Attributes::makeString(), Object::registerOwnership(), AttributeHandler::STATEMENT, X_START, X_STEPS, Y_START, Y_STEPS, Z_START, and Z_STEPS.

Referenced by clone().

Here is the call graph for this function:

◆ DumpFields() [2/3]

DumpFields::DumpFields ( const std::string &  name,
DumpFields parent 
)

Constructor

Definition at line 74 of file DumpFields.cpp.

◆ ~DumpFields()

DumpFields::~DumpFields ( )
virtual

Destructor deletes grid_m and if in the dumps set, take it out

Definition at line 78 of file DumpFields.cpp.

References dumpsSet_m, and grid_m.

◆ DumpFields() [3/3]

DumpFields::DumpFields ( const DumpFields dump)
private

Member Function Documentation

◆ buildGrid()

void DumpFields::buildGrid ( )
privatevirtual

Definition at line 104 of file DumpFields.cpp.

References checkInt(), DX, DY, DZ, FILE_NAME, filename_m, Attributes::getReal(), Attributes::getString(), grid_m, Object::itsAttr, X_START, X_STEPS, Y_START, Y_STEPS, Z_START, and Z_STEPS.

Referenced by execute().

Here is the call graph for this function:

◆ checkInt()

void DumpFields::checkInt ( double  value,
std::string  name,
double  tolerance = 1e-9 
)
staticprivate

Definition at line 136 of file DumpFields.cpp.

References abs(), floor(), name, and real().

Referenced by buildGrid().

Here is the call graph for this function:

◆ clone()

DumpFields * DumpFields::clone ( const std::string &  name)
virtual

Make a clone (overloadable copy-constructor).

Parameters
namenot used If this is in the dumpsSet_m, so will the clone. Not sure how the itsAttr stuff works, so this may not get properly copied?

Implements Object.

Definition at line 83 of file DumpFields.cpp.

References interpolation::ThreeDGrid::clone(), DumpFields(), dumpsSet_m, filename_m, grid_m, and name.

Referenced by execute().

Here is the call graph for this function:

◆ execute()

void DumpFields::execute ( )
virtual

Builds the grid but does not write the field map

Builds a grid of points in x-y-z space using the ThreeDGrid algorithm. Checks that X_STEPS, Y_STEPS, Z_STEPS are integers or throws OpalException.

Reimplemented from Object.

Definition at line 95 of file DumpFields.cpp.

References buildGrid(), clone(), and dumpsSet_m.

Here is the call graph for this function:

◆ operator=()

DumpFields& DumpFields::operator= ( const DumpFields dump)
private

◆ print()

void DumpFields::print ( std::ostream &  os) const
virtual

Print the attributes of DumpFields to standard out

Reimplemented from Object.

Definition at line 204 of file DumpFields.cpp.

References DX, DY, DZ, endl(), filename_m, Attributes::getReal(), Object::itsAttr, X_START, X_STEPS, Y_START, Y_STEPS, Z_START, and Z_STEPS.

Referenced by operator<<().

Here is the call graph for this function:

◆ writeFields()

void DumpFields::writeFields ( Component field)
static

Write the fields for all defined DumpFields objects

Parameters
fieldborrowed reference to the Component object that holds the field map; caller owns the memory. Iterates over the DumpFields in the dumpsSet_m and calls writeFieldThis on each DumpFields. This writes each field map in turn. Format is: <number of rows> <column 1> <units> <column 2> <units> <column 3> <units> <column 4> <units> <column 5> <units> <column 6> <units> 0 <field map data>

Definition at line 129 of file DumpFields.cpp.

References dumpsSet_m.

Referenced by ParallelCyclotronTracker::execute().

◆ writeFieldThis()

void DumpFields::writeFieldThis ( Component field)
privatevirtual

Member Data Documentation

◆ dumpsSet_m

std::unordered_set< DumpFields * > DumpFields::dumpsSet_m
staticprivate

Definition at line 125 of file DumpFields.h.

Referenced by clone(), execute(), writeFields(), and ~DumpFields().

◆ filename_m

std::string DumpFields::filename_m
private

Definition at line 123 of file DumpFields.h.

Referenced by buildGrid(), clone(), print(), and writeFieldThis().

◆ grid_m

interpolation::ThreeDGrid* DumpFields::grid_m = NULL
private

Definition at line 121 of file DumpFields.h.

Referenced by buildGrid(), clone(), writeFieldThis(), and ~DumpFields().


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