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

#include <FieldElement.h>

+ Inheritance diagram for FieldElement:
+ Collaboration diagram for FieldElement:

Public Member Functions

ElementcopyElement (Id newParent, Id newId, unsigned int n, bool toGlobal) const
 
char * data (unsigned int rawIndex, unsigned int fieldIndex=0) const
 
 FieldElement (Id parent, Id kid, const Cinfo *c, const string &name, const FieldElementFinfoBase *fef)
 
unsigned int getNode (unsigned int dataId) const
 Virtual: Returns location of specified dataId. More...
 
unsigned int getNumOnNode (unsigned int node) const
 Inherited virtual. More...
 
bool hasFields () const
 
bool isGlobal () const
 Virtual. Returns true if global, ie, if its parent is global. More...
 
unsigned int localDataStart () const
 Virtual: Returns index of first data entry on this node. More...
 
unsigned int numData () const
 Virtual: Returns number of data entries. More...
 
unsigned int numField (unsigned int rawIndex) const
 Virtual: Returns number of field entries for specified data. More...
 
unsigned int numLocalData () const
 Virtual: Returns number of data entries on current node. More...
 
unsigned int rawIndex (unsigned int dataId) const
 Virtual: Returns converted dataId to index on current node. More...
 
void resize (unsigned int newNumData)
 
void resizeField (unsigned int rawIndex, unsigned int newNumField)
 
unsigned int startDataIndex (unsigned int node) const
 Virtual: Returns start DataIndex on specified node. More...
 
unsigned int totNumLocalField () const
 Virtual: Returns number of field entries on current node. More...
 
void zombieSwap (const Cinfo *zCinfo)
 
 ~FieldElement ()
 
- 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

const FieldElementFinfoBasefef_
 
Id parent_
 

Additional Inherited Members

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

Detailed Description

Specialization of Element class, used to look up array fields within objects when those fields each need to have independent Element capabilies such as messaging and subfield lookup. Made automatically by Elements which have such fields.

Definition at line 18 of file FieldElement.h.

Constructor & Destructor Documentation

FieldElement::FieldElement ( Id  parent,
Id  kid,
const Cinfo c,
const string &  name,
const FieldElementFinfoBase fef 
)

Definition at line 13 of file FieldElement.cpp.

Referenced by copyElement().

17  :
18  Element( self, c, name ),
19  parent_( parent ),
20  fef_( fef )
21 {
22  ;
23 }
const FieldElementFinfoBase * fef_
Definition: FieldElement.h:119
Element(Id id, const Cinfo *c, const string &name)
Definition: Element.cpp:17
static char name[]
Definition: mfield.cpp:401

+ Here is the caller graph for this function:

FieldElement::~FieldElement ( )

Virtual func: leave the clearing of the messages to ElementBase, the data is cleared by the parent Element of this field.

Definition at line 30 of file FieldElement.cpp.

31 {
32  ;
33 }

Member Function Documentation

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

Virtual copier. Makes a copy of self.

Implements Element.

Definition at line 35 of file FieldElement.cpp.

References Element::cinfo(), fef_, FieldElement(), and Element::getName().

37 {
38  return new FieldElement( newParent, newId, cinfo(), getName(), fef_ );
39 }
const FieldElementFinfoBase * fef_
Definition: FieldElement.h:119
const Cinfo * cinfo() const
Definition: Element.cpp:66
FieldElement(Id parent, Id kid, const Cinfo *c, const string &name, const FieldElementFinfoBase *fef)
const string & getName() const
Definition: Element.cpp:56

+ Here is the call graph for this function:

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

virtual. Looks up specified field field entry. First it finds the appropriate data entry from the rawIndex. Then it looks up the field using the lookupField. Returns the data entry specified by the rawIndex, fieldIndex.

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 109 of file FieldElement.cpp.

References Element::data(), Id::element(), fef_, FieldElementFinfoBase::lookupField(), and parent_.

Referenced by numField(), and resizeField().

111 {
112  char* data = parent_.element()->data( rawIndex );
113  return fef_->lookupField( data, fieldIndex );
114 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
const FieldElementFinfoBase * fef_
Definition: FieldElement.h:119
char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const
virtual char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const =0
unsigned int rawIndex(unsigned int dataId) const
Virtual: Returns converted dataId to index on current node.
virtual char * lookupField(char *parent, unsigned int fieldIndex) const =0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Virtual: Returns location of specified dataId.

Implements Element.

Definition at line 76 of file FieldElement.cpp.

References Id::element(), Element::getNode(), and parent_.

77 {
78  return parent_.element()->getNode( dataId );
79 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual unsigned int getNode(unsigned int dataIndex) const =0
Returns node number of specified dataIndex.

+ Here is the call graph for this function:

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

Inherited virtual.

Implements Element.

Definition at line 96 of file FieldElement.cpp.

References Id::element(), Element::isGlobal(), Shell::myNode(), parent_, and totNumLocalField().

97 {
98  if ( node == Shell::myNode() || parent_.element()->isGlobal() )
99  {
100  return totNumLocalField();
101  }
102  // Here we need to refer to a postmaster function to get the
103  // number of field entries on specified node. For now, a dummy.
104  return totNumLocalField();
105 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual bool isGlobal() const =0
True if there is a copy of every dataEntry on all nodes.
static unsigned int myNode()
unsigned int totNumLocalField() const
Virtual: Returns number of field entries on current node.

+ Here is the call graph for this function:

bool FieldElement::hasFields ( ) const
inlinevirtual

Virtual: True if this is a FieldElement having an array of fields on each data entry. So true in this case.

Implements Element.

Definition at line 62 of file FieldElement.h.

62  {
63  return true;
64  }
bool FieldElement::isGlobal ( ) const
virtual

Virtual. Returns true if global, ie, if its parent is global.

Implements Element.

Definition at line 91 of file FieldElement.cpp.

References Id::element(), Element::isGlobal(), and parent_.

92 {
93  return parent_.element()->isGlobal();
94 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual bool isGlobal() const =0
True if there is a copy of every dataEntry on all nodes.

+ Here is the call graph for this function:

unsigned int FieldElement::localDataStart ( ) const
virtual

Virtual: Returns index of first data entry on this node.

Implements Element.

Definition at line 55 of file FieldElement.cpp.

References Id::element(), Element::localDataStart(), and parent_.

56 {
57  return parent_.element()->localDataStart();
58 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.

+ Here is the call graph for this function:

unsigned int FieldElement::numData ( ) const
virtual

Virtual: Returns number of data entries.

Implements Element.

Definition at line 45 of file FieldElement.cpp.

References Id::element(), Element::numData(), and parent_.

Referenced by moose_ObjId_getLength().

46 {
47  return parent_.element()->numData();
48 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int FieldElement::numField ( unsigned int  rawIndex) const
virtual

Virtual: Returns number of field entries for specified data.

Implements Element.

Definition at line 60 of file FieldElement.cpp.

References data(), Element::data(), Id::element(), fef_, FieldElementFinfoBase::getNumField(), and parent_.

Referenced by totNumLocalField().

61 {
62  const char* data = parent_.element()->data( rawIndex );
63  assert( data );
64  return fef_->getNumField( data );
65 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
const FieldElementFinfoBase * fef_
Definition: FieldElement.h:119
virtual unsigned int getNumField(const char *parent) const =0
virtual func to get size of Field array, using char* for parent
char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const
virtual char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const =0
unsigned int rawIndex(unsigned int dataId) const
Virtual: Returns converted dataId to index on current node.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int FieldElement::numLocalData ( ) const
virtual

Virtual: Returns number of data entries on current node.

Implements Element.

Definition at line 50 of file FieldElement.cpp.

References Id::element(), Element::numLocalData(), and parent_.

Referenced by totNumLocalField().

51 {
52  return parent_.element()->numLocalData();
53 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual unsigned int numLocalData() const =0
Returns number of local data entries on this node.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Virtual: Returns converted dataId to index on current node.

Implements Element.

Definition at line 86 of file FieldElement.cpp.

References Id::element(), parent_, and Element::rawIndex().

87 {
88  return parent_.element()->rawIndex( dataId );
89 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual unsigned int rawIndex(unsigned int dataIndex) const =0

+ Here is the call graph for this function:

void FieldElement::resize ( unsigned int  newNumData)
virtual

virtual Changes the number of entries in the data. Not permitted for FieldElements since they are just fields on the data.

Implements Element.

Definition at line 116 of file FieldElement.cpp.

117 {
118  assert( 0 );
119 }
void FieldElement::resizeField ( unsigned int  rawIndex,
unsigned int  newNumField 
)
virtual

virtual. Changes the number of fields on the specified data entry.

Implements Element.

Definition at line 121 of file FieldElement.cpp.

References data(), Element::data(), Id::element(), fef_, parent_, and FieldElementFinfoBase::setNumField().

123 {
124  char* data = parent_.element()->data( rawIndex );
125  fef_->setNumField( data, newNumField );
126 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
const FieldElementFinfoBase * fef_
Definition: FieldElement.h:119
virtual void setNumField(char *parent, unsigned int num) const =0
virtual func to resize Field array, using char* for parent
char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const
virtual char * data(unsigned int rawIndex, unsigned int fieldIndex=0) const =0
unsigned int rawIndex(unsigned int dataId) const
Virtual: Returns converted dataId to index on current node.

+ Here is the call graph for this function:

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

Virtual: Returns start DataIndex on specified node.

Implements Element.

Definition at line 81 of file FieldElement.cpp.

References Id::element(), parent_, and Element::startDataIndex().

82 {
83  return parent_.element()->startDataIndex( node );
84 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual unsigned int startDataIndex(unsigned int nodeNum) const =0
Returns start dataIndex on specified node.

+ Here is the call graph for this function:

unsigned int FieldElement::totNumLocalField ( ) const
virtual

Virtual: Returns number of field entries on current node.

Implements Element.

Definition at line 67 of file FieldElement.cpp.

References numField(), and numLocalData().

Referenced by getNumOnNode().

68 {
69  unsigned int ret = 0;
70  unsigned int nd = numLocalData();
71  for ( unsigned int i = 0; i < nd; ++i )
72  ret += numField( i );
73  return ret;
74 }
unsigned int numField(unsigned int rawIndex) const
Virtual: Returns number of field entries for specified data.
unsigned int numLocalData() const
Virtual: Returns number of data entries on current node.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FieldElement::zombieSwap ( const Cinfo zCinfo)
virtual

Virtual: after replacing Cinfo of parent, we need to replace Cinfo and fef here. The zCinfo is the new Cinfo for this FieldElement.

Reimplemented from Element.

Definition at line 130 of file FieldElement.cpp.

References fef_, Cinfo::findFinfo(), Element::getName(), and Element::replaceCinfo().

131 {
132  const Finfo* f = zCinfo->findFinfo( getName() );
133  assert( f );
134 
135  const FieldElementFinfoBase* zfef = dynamic_cast<
136  const FieldElementFinfoBase* >( f );
137  assert( zfef );
138  fef_ = zfef;
139  replaceCinfo( zCinfo );
140 }
const FieldElementFinfoBase * fef_
Definition: FieldElement.h:119
const string & getName() const
Definition: Element.cpp:56
void replaceCinfo(const Cinfo *newCinfo)
Support function for zombieSwap, replaces Cinfo.
Definition: Element.cpp:740
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
Definition: Finfo.h:12

+ Here is the call graph for this function:

Member Data Documentation

const FieldElementFinfoBase* FieldElement::fef_
private

Definition at line 119 of file FieldElement.h.

Referenced by copyElement(), data(), numField(), resizeField(), and zombieSwap().

Id FieldElement::parent_
private

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