MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DataElement Class Reference

#include <DataElement.h>

+ Inheritance diagram for DataElement:
+ Collaboration diagram for DataElement:

Public Member Functions

char * data (unsigned int rawIndex, unsigned int fieldIndex=0) const
 
 DataElement (Id id, const Cinfo *c, const string &name, unsigned int numData=1)
 
 DataElement (Id id, const Element *orig, unsigned int n, unsigned int startEntry)
 
bool hasFields () const
 Do not define getNode() or rawIndex() funcs, those are derived. More...
 
unsigned int numField (unsigned int rawIndex) const
 Define only in derived classes: getNode( unsigned int dataIndex ) const;. More...
 
unsigned int numLocalData () const
 Defined only in derived classes: unsigned int numData() const;. More...
 
void resize (unsigned int newNumData)
 
void resizeField (unsigned int rawIndex, unsigned int newNumField)
 
unsigned int totNumLocalField () const
 
void zombieSwap (const Cinfo *newCinfo)
 Virtual func. More...
 
 ~DataElement ()
 
- Public Member Functions inherited from Element
void addMsg (ObjId mid)
 
void addMsgAndFunc (ObjId mid, FuncId fid, BindIndex bindIndex)
 
const Cinfocinfo () const
 
void clearAllMsgs ()
 Used upon ending of MOOSE session, to rapidly clear out messages. More...
 
void clearBinding (BindIndex b)
 
virtual ElementcopyElement (Id newParent, Id newId, unsigned int n, bool toGlobal) const =0
 
void digestMessages ()
 
void dropAllMsgsFromSrc (Id src)
 
void dropMsg (ObjId mid)
 
 Element (Id id, const Cinfo *c, const string &name)
 
unsigned int findBinding (MsgFuncBinding b) const
 
ObjId findCaller (FuncId fid) const
 
unsigned int getFieldsOfOutgoingMsg (ObjId mid, vector< pair< BindIndex, FuncId > > &ret) const
 
unsigned int getInputMsgs (vector< ObjId > &caller, FuncId fid) const
 
unsigned int getInputsWithTgtIndex (vector< pair< Id, unsigned int > > &ret, const DestFinfo *finfo) const
 
const vector< MsgFuncBinding > * getMsgAndFunc (BindIndex b) const
 
unsigned int getMsgSourceAndSender (FuncId fid, vector< ObjId > &src, vector< string > &sender) const
 
unsigned int getMsgTargetAndFunctions (DataId srcDataId, const SrcFinfo *finfo, vector< ObjId > &tgt, vector< string > &func) const
 
vector< ObjIdgetMsgTargets (DataId srcDataId, const SrcFinfo *finfo) const
 
const string & getName () const
 
unsigned int getNeighbors (vector< Id > &ret, const Finfo *finfo) const
 
virtual unsigned int getNode (unsigned int dataIndex) const =0
 Returns node number of specified dataIndex. More...
 
virtual unsigned int getNumOnNode (unsigned int node) const =0
 
int getTick () const
 
bool hasMsgs (BindIndex b) const
 
Id id () const
 
void innerSetTick (unsigned int tick)
 
bool isDoomed () const
 
virtual bool isGlobal () const =0
 True if there is a copy of every dataEntry on all nodes. More...
 
virtual unsigned int localDataStart () const =0
 Returns index of first data entry on this node. More...
 
void markAsDoomed ()
 
void markRewired ()
 
const vector< MsgDigest > & msgDigest (unsigned int index)
 
const vector< ObjId > & msgIn () const
 
virtual unsigned int numData () const =0
 Returns number of data entries across all nodes. More...
 
void printMsgDigest (unsigned int srcIndex, unsigned int dataIndex) const
 
void putOffNodeTargetsInDigest (unsigned int srcNum, vector< vector< bool > > &targetNodes)
 
void putTargetsInDigest (unsigned int srcNum, const MsgFuncBinding &mfb, const FuncOrder &fo, vector< vector< bool > > &targetNodes)
 
virtual unsigned int rawIndex (unsigned int dataIndex) const =0
 
void replaceCinfo (const Cinfo *newCinfo)
 Support function for zombieSwap, replaces Cinfo. More...
 
void setName (const string &val)
 
void setTick (int t)
 
void showFields () const
 
void showMsg () const
 
virtual unsigned int startDataIndex (unsigned int nodeNum) const =0
 Returns start dataIndex on specified node. More...
 
virtual ~Element ()
 

Private Attributes

char * data_
 
unsigned int numLocalData_
 
unsigned int size_
 

Additional Inherited Members

- Static Public Member Functions inherited from Element
static void destroyElementTree (const vector< Id > &tree)
 

Detailed Description

This is the base class for managing the data in the MOOSE interface. Elaborates on base class for how it handles destruction. Subclasses of this handle special node decomposition. This does basic data management with raw indices.

Definition at line 21 of file DataElement.h.

Constructor & Destructor Documentation

DataElement::DataElement ( Id  id,
const Cinfo c,
const string &  name,
unsigned int  numData = 1 
)

This is the main constructor, used by Shell::innerCreate which makes most Elements. Also used to create base Elements to init the simulator in main.cpp. Id is the Id of the new Element Cinfo is the class name is its name numData is the number of data entries, defaults to a singleton. The isGlobal flag specifies whether the created objects should be replicated on all nodes, or partitioned without replication.

DataElement::DataElement ( Id  id,
const Element orig,
unsigned int  n,
unsigned int  startEntry 
)

This constructor copies over the original n times. It is used for doing all copies, in Shell::innerCopyElements.

Definition at line 35 of file DataElement.cpp.

References Element::cinfo(), DinfoBase::copyData(), Element::data(), data_, Cinfo::dinfo(), Element::numData(), numLocalData_, size_, and DinfoBase::sizeIncrement().

37  :
38  Element( id, orig->cinfo(), orig->getName() )
39 {
40  numLocalData_ = n;
41  size_ = cinfo()->dinfo()->sizeIncrement();
42  data_ = cinfo()->dinfo()->copyData( orig->data( 0 ), orig->numData(),
43  numLocalData_, startEntry );
44  // cinfo_->postCreationFunc( id, this );
45 }
char * data_
Definition: DataElement.h:136
unsigned int size_
Definition: DataElement.h:148
virtual char * copyData(const char *orig, unsigned int origEntries, unsigned int copyEntries, unsigned int startEntry) const =0
const DinfoBase * dinfo() const
Definition: Cinfo.cpp:275
virtual unsigned int sizeIncrement() const =0
const Cinfo * cinfo() const
Definition: Element.cpp:66
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
unsigned int numLocalData_
Definition: DataElement.h:141
Element(Id id, const Cinfo *c, const string &name)
Definition: Element.cpp:17
virtual char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const =0
const string & getName() const
Definition: Element.cpp:56

+ Here is the call graph for this function:

DataElement::~DataElement ( )

Virtual Destructor

Definition at line 48 of file DataElement.cpp.

References Element::cinfo(), data_, DinfoBase::destroyData(), and Cinfo::dinfo().

49 {
50  // cout << "deleting element " << getName() << endl;
51  cinfo()->dinfo()->destroyData( data_ );
52  data_ = 0;
53  // The base class destroys the messages.
54 }
char * data_
Definition: DataElement.h:136
virtual void destroyData(char *d) const =0
const DinfoBase * dinfo() const
Definition: Cinfo.cpp:275
const Cinfo * cinfo() const
Definition: Element.cpp:66

+ Here is the call graph for this function:

Member Function Documentation

char * DataElement::data ( unsigned int  rawIndex,
unsigned int  fieldIndex = 0 
) const
virtual

Inherited virtual. Looks up specified field data entry. On regular objects just returns the data entry specified by the rawIndex. On FieldElements like synapses, does a second lookup on the field index. Note that the index is NOT a DataIndex: it is instead the raw index of the data on the current node. Index is also NOT the character offset, but the index to the data array in whatever type the data may be.

The DataIndex has to be filtered through the nodeMap to find a) if the entry is here, and b) what its raw index is.

Returns 0 if either index is out of range.

Implements Element.

Definition at line 82 of file DataElement.cpp.

References data_, numLocalData_, and size_.

83 {
84  assert( rawIndex < numLocalData_ );
85  // return data_ + ( rawIndex * cinfo()->dinfo()->size() );
86  return data_ + rawIndex * size_;
87 }
char * data_
Definition: DataElement.h:136
unsigned int size_
Definition: DataElement.h:148
unsigned int numLocalData_
Definition: DataElement.h:141
virtual unsigned int rawIndex(unsigned int dataIndex) const =0
bool DataElement::hasFields ( ) const
inlinevirtual

Do not define getNode() or rawIndex() funcs, those are derived.

Inherited virtual True if this is a FieldElement having an array of fields on each data entry. Clearly not true for the base Element.

Implements Element.

Definition at line 81 of file DataElement.h.

81  {
82  return false;
83  }
unsigned int DataElement::numField ( unsigned int  rawIndex) const
virtual

Define only in derived classes: getNode( unsigned int dataIndex ) const;.

Inherited virtual. Returns number of field entries for specified data

Implements Element.

Definition at line 67 of file DataElement.cpp.

68 {
69  return 1;
70 }
unsigned int DataElement::numLocalData ( ) const
virtual

Defined only in derived classes: unsigned int numData() const;.

copyElement function is defined only in derived classes.Inherited virtual. Returns number of data entries on this node

Implements Element.

Definition at line 61 of file DataElement.cpp.

References numLocalData_.

Referenced by LocalDataElement::getNode(), GlobalDataElement::getNumOnNode(), and GlobalDataElement::numData().

62 {
63  return numLocalData_;
64 }
unsigned int numLocalData_
Definition: DataElement.h:141

+ Here is the caller graph for this function:

void DataElement::resize ( unsigned int  newNumLocalData)
virtual

Inherited virtual. Changes the total number of data entries on Element in entire simulation. Not permitted for FieldElements since they are just fields on the data.

virtual func, overridden. Here we resize the local data. This function would be called by derived classes to do their own data management as per node decomposition.

Implements Element.

Reimplemented in LocalDataElement.

Definition at line 95 of file DataElement.cpp.

References Element::cinfo(), DinfoBase::copyData(), data_, DinfoBase::destroyData(), Cinfo::dinfo(), and numLocalData_.

Referenced by LocalDataElement::resize().

96 {
97  numLocalData_ = newNumLocalData;
98  char* temp = data_;
99  data_ = cinfo()->dinfo()->copyData(
100  temp, numLocalData_, newNumLocalData, 0 );
101  cinfo()->dinfo()->destroyData( temp );
102  numLocalData_ = newNumLocalData;
103 }
char * data_
Definition: DataElement.h:136
virtual void destroyData(char *d) const =0
virtual char * copyData(const char *orig, unsigned int origEntries, unsigned int copyEntries, unsigned int startEntry) const =0
const DinfoBase * dinfo() const
Definition: Cinfo.cpp:275
const Cinfo * cinfo() const
Definition: Element.cpp:66
unsigned int numLocalData_
Definition: DataElement.h:141

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void DataElement::resizeField ( unsigned int  rawIndex,
unsigned int  newNumField 
)
inlinevirtual

Inherited virtual. Changes the number of fields on the specified data entry. Doesn't do anything for the regular Element.

Implements Element.

Definition at line 121 of file DataElement.h.

123  {;}
unsigned int DataElement::totNumLocalField ( ) const
virtual

Inherited virtual: Returns number of field entries on current node, same as numLocalData().

Implements Element.

Definition at line 73 of file DataElement.cpp.

References numLocalData_.

74 {
75  return numLocalData_;
76 }
unsigned int numLocalData_
Definition: DataElement.h:141
void DataElement::zombieSwap ( const Cinfo newCinfo)
virtual

Virtual func.

Reimplemented from Element.

Definition at line 109 of file DataElement.cpp.

References DinfoBase::allocData(), Element::cinfo(), data_, DinfoBase::destroyData(), Cinfo::dinfo(), numLocalData_, Element::replaceCinfo(), size_, DinfoBase::sizeIncrement(), and Element::zombieSwap().

110 {
111  cinfo()->dinfo()->destroyData( data_ );
112  data_ = zCinfo->dinfo()->allocData( numLocalData_ );
113  replaceCinfo( zCinfo );
114  size_ = zCinfo->dinfo()->sizeIncrement();
115  Element::zombieSwap( zCinfo ); // Handles clock tick reassignment.
116 }
char * data_
Definition: DataElement.h:136
virtual void zombieSwap(const Cinfo *zCinfo)
virtual func, this base version must be called by all derived classes
Definition: Element.cpp:159
virtual void destroyData(char *d) const =0
unsigned int size_
Definition: DataElement.h:148
const DinfoBase * dinfo() const
Definition: Cinfo.cpp:275
const Cinfo * cinfo() const
Definition: Element.cpp:66
unsigned int numLocalData_
Definition: DataElement.h:141
void replaceCinfo(const Cinfo *newCinfo)
Support function for zombieSwap, replaces Cinfo.
Definition: Element.cpp:740

+ Here is the call graph for this function:

Member Data Documentation

char* DataElement::data_
private

This points to an array holding the data for the Element.

Definition at line 136 of file DataElement.h.

Referenced by data(), DataElement(), resize(), zombieSwap(), and ~DataElement().

unsigned int DataElement::numLocalData_
private

This is the number of data entries on the current node.

Definition at line 141 of file DataElement.h.

Referenced by data(), DataElement(), numLocalData(), resize(), totNumLocalField(), and zombieSwap().

unsigned int DataElement::size_
private

This is the size of the data. Can get from cinfo()->dinfo(), but this is called so often than it makes a measurable difference.

Definition at line 148 of file DataElement.h.

Referenced by data(), DataElement(), and zombieSwap().


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