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

#include <LocalDataElement.h>

+ Inheritance diagram for LocalDataElement:
+ Collaboration diagram for LocalDataElement:

Public Member Functions

ElementcopyElement (Id newParent, Id newId, unsigned int n, bool toGlobal) const
 
unsigned int getNode (unsigned int dataId) const
 Inherited virtual. Returns node location of specified object. More...
 
unsigned int getNumOnNode (unsigned int node) const
 Inherited virtual. More...
 
bool isGlobal () const
 Inherited virtual. Reports if this is Global, which it isn't. More...
 
 LocalDataElement (Id id, const Cinfo *c, const string &name, unsigned int numData=1)
 
 LocalDataElement (Id id, const Element *orig, unsigned int n)
 
unsigned int localDataStart () const
 Inherited virtual. Returns index of first entry on this node. More...
 
unsigned int numData () const
 Inherited virtual. Returns number of data entries over all nodes. More...
 
unsigned int rawIndex (unsigned int dataId) const
 Converts dataId to index on current node. More...
 
void resize (unsigned int newNumData)
 
unsigned int setDataSize (unsigned int numData)
 
unsigned int startDataIndex (unsigned int node) const
 Inherited virtual. Returns start DataIndex on specified node. More...
 
 ~LocalDataElement ()
 
- Public Member Functions inherited from DataElement
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 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)
 
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
 
int getTick () const
 
bool hasMsgs (BindIndex b) const
 
Id id () const
 
void innerSetTick (unsigned int tick)
 
bool isDoomed () const
 
void markAsDoomed ()
 
void markRewired ()
 
const vector< MsgDigest > & msgDigest (unsigned int index)
 
const vector< ObjId > & msgIn () const
 
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)
 
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 ~Element ()
 

Private Attributes

unsigned int localDataStart_
 
unsigned int numData_
 
unsigned int numPerNode_
 

Additional Inherited Members

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

Detailed Description

This is the class for handling the local portion of a data element that is distributed over many nodes. Does block-wise partitioning between nodes.

Definition at line 20 of file LocalDataElement.h.

Constructor & Destructor Documentation

LocalDataElement::LocalDataElement ( 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.

Referenced by copyElement().

+ Here is the caller graph for this function:

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

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

Definition at line 28 of file LocalDataElement.cpp.

30  :
31  DataElement( id, orig, setDataSize( n ),
32  ( 1 + (n - 1 ) / Shell::numNodes() ) * Shell::myNode() )
33 {;}
unsigned int setDataSize(unsigned int numData)
static unsigned int myNode()
static unsigned int numNodes()
DataElement(Id id, const Cinfo *c, const string &name, unsigned int numData=1)
LocalDataElement::~LocalDataElement ( )

Virtual Destructor

Definition at line 36 of file LocalDataElement.cpp.

37 {;}

Member Function Documentation

Element * LocalDataElement::copyElement ( Id  newParent,
Id  newId,
unsigned int  n,
bool  toGlobal 
) const
virtual

Virtual copier. Makes a copy of self.

Implements Element.

Definition at line 41 of file LocalDataElement.cpp.

References LocalDataElement().

43 {
44  if ( toGlobal ) {
45  cout << "Don't know yet how to copy LocalDataElement to global\n";
46  assert( 0 );
47  return 0;
48  } else {
49  return new LocalDataElement( newId, this, n );
50  }
51 }
LocalDataElement(Id id, const Cinfo *c, const string &name, unsigned int numData=1)

+ Here is the call graph for this function:

unsigned int LocalDataElement::getNode ( unsigned int  dataId) const
virtual

Inherited virtual. Returns node location of specified object.

Implements Element.

Definition at line 72 of file LocalDataElement.cpp.

References ALLDATA, Shell::myNode(), DataElement::numLocalData(), and numPerNode_.

72  {
73  // Assume numData = 95. DataId = 0-9: 0, DataId=80-89:8, DataId >= 90:9
74  if ( dataId == ALLDATA ) {
75  if ( numLocalData() > 0 ) {
76  return Shell::myNode();
77  } else {
78  return 0; // Sure to have some data on node 0.
79  }
80  }
81  return dataId / numPerNode_;
82 }
const unsigned int ALLDATA
Used by ObjId and Eref.
Definition: consts.cpp:22
unsigned int numPerNode_
static unsigned int myNode()
unsigned int numLocalData() const
Defined only in derived classes: unsigned int numData() const;.
Definition: DataElement.cpp:61

+ Here is the call graph for this function:

unsigned int LocalDataElement::getNumOnNode ( unsigned int  node) const
virtual

Inherited virtual.

Implements Element.

Definition at line 121 of file LocalDataElement.cpp.

References numData(), numData_, and numPerNode_.

122 {
123  unsigned int lastUsedNode = numData_ / numPerNode_;
124  if ( lastUsedNode > node )
125  return numPerNode_;
126  if ( lastUsedNode == node )
127  return numData() - node * numPerNode_;
128  return 0;
129 }
unsigned int numData_
unsigned int numData() const
Inherited virtual. Returns number of data entries over all nodes.
unsigned int numPerNode_

+ Here is the call graph for this function:

bool LocalDataElement::isGlobal ( ) const
inlinevirtual

Inherited virtual. Reports if this is Global, which it isn't.

Implements Element.

Definition at line 73 of file LocalDataElement.h.

73  {
74  return false;
75  }
unsigned int LocalDataElement::localDataStart ( ) const
virtual

Inherited virtual. Returns index of first entry on this node.

Implements Element.

Definition at line 64 of file LocalDataElement.cpp.

References localDataStart_.

65 {
66  // return numPerNode_ * Shell::myNode();
67  return localDataStart_;
68 }
unsigned int localDataStart_
unsigned int LocalDataElement::numData ( ) const
virtual

Inherited virtual. Returns number of data entries over all nodes.

Implements Element.

Definition at line 59 of file LocalDataElement.cpp.

References numData_.

Referenced by getNumOnNode(), and setDataSize().

60 {
61  return numData_;
62 }
unsigned int numData_

+ Here is the caller graph for this function:

unsigned int LocalDataElement::rawIndex ( unsigned int  dataId) const
virtual

Converts dataId to index on current node.

Implements Element.

Definition at line 93 of file LocalDataElement.cpp.

References numPerNode_.

93  {
94  return dataId % numPerNode_;
95 }
unsigned int numPerNode_
void LocalDataElement::resize ( unsigned int  newNumData)
virtual

the data() function is inherited from DataElement and used as is. 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.

Reimplemented from DataElement.

Definition at line 116 of file LocalDataElement.cpp.

References DataElement::resize(), and setDataSize().

117 {
118  DataElement::resize( setDataSize( newNumData ) );
119 }
void resize(unsigned int newNumData)
Definition: DataElement.cpp:95
unsigned int setDataSize(unsigned int numData)

+ Here is the call graph for this function:

unsigned int LocalDataElement::setDataSize ( unsigned int  numData)

Definition at line 101 of file LocalDataElement.cpp.

References localDataStart_, Shell::myNode(), numData(), numData_, Shell::numNodes(), and numPerNode_.

Referenced by resize().

102 {
103  numData_ = numData;
104  numPerNode_ = 1 + (numData_ -1 ) / Shell::numNodes();
106 
107  unsigned int lastUsedNode = numData / numPerNode_;
108  if ( lastUsedNode > Shell::myNode() )
109  return numPerNode_;
110  if ( lastUsedNode == Shell::myNode() )
111  return numData - Shell::myNode() * numPerNode_;
112  return 0;
113 }
unsigned int numData_
unsigned int numData() const
Inherited virtual. Returns number of data entries over all nodes.
unsigned int numPerNode_
static unsigned int myNode()
unsigned int localDataStart_
static unsigned int numNodes()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int LocalDataElement::startDataIndex ( unsigned int  node) const
virtual

Inherited virtual. Returns start DataIndex on specified node.

Inherited virtual. Returns start DataId on specified node.

Implements Element.

Definition at line 85 of file LocalDataElement.cpp.

References numData_, and numPerNode_.

86 {
87  if ( numPerNode_ * node < numData_ )
88  return numPerNode_ * node;
89  else
90  return numData_; // error.
91 }
unsigned int numData_
unsigned int numPerNode_

Member Data Documentation

unsigned int LocalDataElement::localDataStart_
private

Precomputed value for start index of data on this node.

Definition at line 121 of file LocalDataElement.h.

Referenced by localDataStart(), and setDataSize().

unsigned int LocalDataElement::numData_
private

This is the total number of data entries on this Element, in the entire simulation. Note that these entries do not have to be on this node, some may be farmed out to other nodes.

Definition at line 109 of file LocalDataElement.h.

Referenced by getNumOnNode(), numData(), setDataSize(), and startDataIndex().

unsigned int LocalDataElement::numPerNode_
private

This is the number of data entries per node, except for possibly the last node if they don't divide evenly. Useful for intermediate calculations.

Definition at line 116 of file LocalDataElement.h.

Referenced by getNode(), getNumOnNode(), rawIndex(), setDataSize(), and startDataIndex().


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