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

#include <Element.h>

+ Inheritance diagram for Element:
+ Collaboration diagram for Element:

Public Member Functions

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
 
virtual char * data (unsigned int rawIndex, unsigned int fieldIndex=0) 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
 
virtual bool hasFields () const =0
 
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...
 
virtual unsigned int numField (unsigned int rawIndex) const =0
 Returns number of field entries for specified data. More...
 
virtual unsigned int numLocalData () const =0
 Returns number of local data entries on this node. 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...
 
virtual void resize (unsigned int newNumData)=0
 
virtual void resizeField (unsigned int rawIndex, unsigned int newNumField)=0
 
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 unsigned int totNumLocalField () const =0
 
virtual void zombieSwap (const Cinfo *zCinfo)
 virtual func, this base version must be called by all derived classes More...
 
virtual ~Element ()
 

Static Public Member Functions

static void destroyElementTree (const vector< Id > &tree)
 

Private Member Functions

unsigned int getInputs (vector< Id > &ret, const DestFinfo *finfo) const
 
unsigned int getOutputs (vector< Id > &ret, const SrcFinfo *finfo) const
 

Private Attributes

const Cinfocinfo_
 Stores the unique identifier for Element. More...
 
Id id_
 Name of the Element. More...
 
bool isDoomed_
 True if the element is marked for destruction. More...
 
bool isRewired_
 True if messages have been changed and need to digestMessages. More...
 
vector< ObjIdm_
 
vector< vector< MsgFuncBinding > > msgBinding_
 
vector< vector< MsgDigest > > msgDigest_
 
string name_
 
int tick_
 Returns tick on which element is scheduled. -1 for disabled. More...
 

Detailed Description

Base class for all object lookups. Provides the MOOSE interface so that it handles messaging, class info, and basic fields. Does not do data.

Definition at line 20 of file Element.h.

Constructor & Destructor Documentation

Element::Element ( Id  id,
const Cinfo c,
const string &  name 
)

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.

Definition at line 17 of file Element.cpp.

18  : name_( name ),
19  id_( id ),
20  cinfo_( c ),
21  msgBinding_( c->numBindIndex() ),
22  msgDigest_( c->numBindIndex() ),
23  tick_( -1 ),
24  isRewired_( false ),
25  isDoomed_( false )
26 {
27  id.bindIdToElement( this );
28 }
bool isRewired_
True if messages have been changed and need to digestMessages.
Definition: Element.h:443
Id id_
Name of the Element.
Definition: Element.h:401
string name_
Definition: Element.h:399
const Cinfo * cinfo_
Stores the unique identifier for Element.
Definition: Element.h:406
vector< vector< MsgDigest > > msgDigest_
Definition: Element.h:437
static char name[]
Definition: mfield.cpp:401
unsigned int numBindIndex() const
Definition: Cinfo.cpp:265
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423
int tick_
Returns tick on which element is scheduled. -1 for disabled.
Definition: Element.h:440
bool isDoomed_
True if the element is marked for destruction.
Definition: Element.h:446
Element::~Element ( )
virtual

Destructor

Definition at line 31 of file Element.cpp.

References Msg::deleteMsg(), id_, m_, markAsDoomed(), msgBinding_, and Id::zeroOut().

32 {
33  // A flag that the Element is doomed, used to avoid lookups
34  // when deleting Msgs.
35  id_.zeroOut();
36  markAsDoomed();
37  for ( vector< vector< MsgFuncBinding > >::iterator
38  i = msgBinding_.begin(); i != msgBinding_.end(); ++i )
39  {
40  for ( vector< MsgFuncBinding >::iterator
41  j = i->begin(); j != i->end(); ++j )
42  {
43  // This call internally protects against double deletion.
44  Msg::deleteMsg( j->mid );
45  }
46  }
47 
48  for ( vector< ObjId >::iterator i = m_.begin(); i != m_.end(); ++i )
49  Msg::deleteMsg( *i );
50 }
void markAsDoomed()
Definition: Element.cpp:696
void zeroOut() const
Definition: Id.cpp:191
Id id_
Name of the Element.
Definition: Element.h:401
static void deleteMsg(ObjId mid)
Definition: Msg.cpp:52
vector< ObjId > m_
Definition: Element.h:412
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the call graph for this function:

Member Function Documentation

void Element::addMsg ( ObjId  mid)

Pushes the Msg mid onto the list. The position on the list does not matter.

Definition at line 79 of file Element.cpp.

References m_, and markRewired().

Referenced by Msg::Msg().

80 {
81  while ( m_.size() > 0 )
82  {
83  if ( m_.back().bad() )
84  m_.pop_back();
85  else
86  break;
87  }
88  m_.push_back( m );
89  markRewired();
90 }
void markRewired()
Definition: Element.cpp:706
vector< ObjId > m_
Definition: Element.h:412

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Element::addMsgAndFunc ( ObjId  mid,
FuncId  fid,
BindIndex  bindIndex 
)

Pushes back the specified Msg and Func pair into the properly indexed place on the msgBinding_ vector.

Definition at line 128 of file Element.cpp.

References markRewired(), and msgBinding_.

Referenced by SrcFinfo::addMsg(), OneToAllMsg::copy(), OneToOneDataIndexMsg::copy(), OneToOneMsg::copy(), SingleMsg::copy(), DiagonalMsg::copy(), SparseMsg::copy(), testMsgField(), and testSendMsg().

129 {
130  if ( msgBinding_.size() < bindIndex + 1U )
131  msgBinding_.resize( bindIndex + 1 );
132  msgBinding_[ bindIndex ].push_back( MsgFuncBinding( mid, fid ) );
133  markRewired();
134 }
void markRewired()
Definition: Element.cpp:706
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Cinfo * Element::cinfo ( ) const

Gets the class information for this Element

Definition at line 66 of file Element.cpp.

References cinfo_.

Referenced by ReadCell::addCaConc(), ReadCell::addCanonicalChannel(), addClockMsg(), ReadCell::addSpikeGen(), Stoich::allocateModelObject(), assignParam(), Dsolve::buildMeshJunctions(), Dsolve::buildNeuroMeshJunctions(), Dsolve::calcJunction(), SetGet::checkSet(), PostMaster::clearPendingRecv(), convertConcToNumRateUsingMesh(), FieldElement::copyElement(), DataElement::DataElement(), HSolve::deepSearchForCompartment(), HSolve::deleteIncomingMessages(), Neutral::destroy(), Shell::doAddMsg(), doClassSpecificMessaging(), Shell::doLoadModel(), fillSegIndex(), fillSegments(), VoxelPoolsBase::filterCrossRateTerms(), findAllConnectedCompartments(), findFuncMsgSrc(), Neutral::getClass(), getCompt(), Neutral::getDestFields(), Msg::getDestFieldsOnE1(), Msg::getDestFieldsOnE2(), Neutral::getMsgDestFunctions(), Neutral::getMsgDests(), getMsgSourceAndSender(), getMsgTargetAndFunctions(), Neutral::getNeighbors(), Neutral::getOutgoingMsgs(), Stoich::getProxyPools(), getReactantVols(), Neutral::getSourceFields(), Msg::getSrcFieldsOnE1(), Msg::getSrcFieldsOnE2(), Neutral::getValueFields(), Shell::innerAddMsg(), innerCopyElements(), Neutral::isA(), isOffSolverReac(), isPartOfDend(), ReadKkit::loadTab(), localGet(), Stoich::locateOffSolverReacs(), Eref::msgDigest(), GetOpFunc1< T, L, A >::op(), GetEpFunc1< T, L, A >::op(), ReadCspace::printMol(), putFuncsInOrder(), putOffNodeTargetsInDigest(), ReadCell::read(), DataElement::resize(), Gsolve::setCompartment(), ZombiePoolInterface::setCompartment(), Stoich::setCompartment(), Ksolve::setDsolve(), Gsolve::setDsolve(), Stoich::setDsolve(), Stoich::setKsolve(), Gsolve::setN(), Gsolve::setNinit(), HSolve::setSeed(), ZombieFunction::setSolver(), ZombieReac::setSolver(), ZombieMMenz::setSolver(), ZombieEnz::setSolver(), Neuron::setSpineAndPsdMesh(), Gsolve::setStoich(), SteadyState::setStoich(), Ksolve::setStoich(), Dsolve::setStoich(), EndoMesh::setSurround(), setTick(), ReadKkit::setupSlaveMsg(), SetGet::strGet(), SetGet::strSet(), HSolveUtils::targets(), Stoich::unZombifyModel(), Stoich::unZombifyPools(), Pool::vGetIsBuffered(), ZombiePool::vSetSolver(), ZombieCaConc::vSetSolver(), ZombieHHChannel::vSetSolver(), ZombieCompartment::vSetSolver(), DataElement::zombieSwap(), ZombieFunction::zombify(), CplxEnzBase::zombify(), ReacBase::zombify(), EnzBase::zombify(), CaConcBase::zombify(), PoolBase::zombify(), HHChannelBase::zombify(), moose::CompartmentBase::zombify(), Stoich::zombifyModel(), and DataElement::~DataElement().

67 {
68  return cinfo_;
69 }
const Cinfo * cinfo_
Stores the unique identifier for Element.
Definition: Element.h:406
void Element::clearAllMsgs ( )

Used upon ending of MOOSE session, to rapidly clear out messages.

Used upon ending of MOOSE session, to rapidly clear out messages, secure in the knowledge that the data structures will be destroyed separately.

Definition at line 150 of file Element.cpp.

References m_, markAsDoomed(), msgBinding_, and msgDigest_.

151 {
152  markAsDoomed();
153  m_.clear();
154  msgBinding_.clear();
155  msgDigest_.clear();
156 }
void markAsDoomed()
Definition: Element.cpp:696
vector< ObjId > m_
Definition: Element.h:412
vector< vector< MsgDigest > > msgDigest_
Definition: Element.h:437
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the call graph for this function:

void Element::clearBinding ( BindIndex  b)

Clears out all Msgs on specified BindIndex. Used in Shell::set

Definition at line 136 of file Element.cpp.

References Msg::deleteMsg(), markRewired(), and msgBinding_.

137 {
138  assert( b < msgBinding_.size() );
139  vector< MsgFuncBinding > temp = msgBinding_[ b ];
140  msgBinding_[ b ].resize( 0 );
141  for( vector< MsgFuncBinding >::iterator i = temp.begin();
142  i != temp.end(); ++i )
143  {
144  Msg::deleteMsg( i->mid );
145  }
146  markRewired();
147 }
void markRewired()
Definition: Element.cpp:706
static void deleteMsg(ObjId mid)
Definition: Msg.cpp:52
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the call graph for this function:

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

Copier

Implemented in GlobalDataElement, MsgElement, LocalDataElement, and FieldElement.

Referenced by innerCopyElements().

+ Here is the caller graph for this function:

virtual char* Element::data ( unsigned int  rawIndex,
unsigned int  fieldIndex = 0 
) const
pure 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.

Implemented in MsgElement, DataElement, and FieldElement.

Referenced by buildFinfoElement(), Eref::data(), FieldElement::data(), DataElement::DataElement(), main(), Cinfo::makeCinfoElements(), FieldElement::numField(), FieldElement::resizeField(), testArith(), testCreateMsg(), testFibonacci(), testGet(), testSendMsg(), testSetGetSynapse(), and testSetGetVec().

+ Here is the caller graph for this function:

void Element::destroyElementTree ( const vector< Id > &  tree)
static

Destroys all Elements in tree, being efficient about not trying to traverse through clearing messages to doomed Elements. Assumes tree includes all child elements. Typically the Neutral::destroy function builds up this tree and then calls this function.

Definition at line 676 of file Element.cpp.

References Id::destroy().

Referenced by Neutral::destroy().

677 {
678  for( vector< Id >::const_iterator i = tree.begin();
679  i != tree.end(); i++ )
680  i->element()->markAsDoomed(); // Indicate that Element is doomed
681  bool killShell = false;
682 
683  // Do not destroy the shell till the very end.
684  for( vector< Id >::const_iterator i = tree.begin();
685  i != tree.end(); i++ )
686  {
687  if ( *i == Id() )
688  killShell = true;
689  else
690  i->destroy();
691  }
692  if ( killShell )
693  Id().destroy();
694 }
void destroy() const
Definition: Id.cpp:176
Definition: Id.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Element::digestMessages ( )

Rebuild digested message array; traverse all messages to do so

Definition at line 569 of file Element.cpp.

References findNumDigest(), msgBinding_, msgDigest_, name_, numData(), Shell::numNodes(), putFuncsInOrder(), putOffNodeTargetsInDigest(), and putTargetsInDigest().

Referenced by msgDigest().

570 {
571  bool report = 0; // for debugging
572  msgDigest_.clear();
573  msgDigest_.resize( msgBinding_.size() * numData() );
574  vector< bool > temp( Shell::numNodes(), false );
575  vector< vector< bool > > targetNodes( numData(), temp );
576  // targetNodes[srcDataId][node]. The idea is that if any dataEntry has
577  // a target off-node, it should flag the entry here so that it can
578  // send the message request to the proxy on that node.
579  for ( unsigned int i = 0; i < msgBinding_.size(); ++i )
580  {
581  // Go through and identify functions with the same ptr.
582  vector< FuncOrder > fo = putFuncsInOrder( this, msgBinding_[i] );
583  for ( vector< FuncOrder >::const_iterator
584  k = fo.begin(); k != fo.end(); ++k )
585  {
586  const MsgFuncBinding& mfb = msgBinding_[i][ k->index() ];
587  putTargetsInDigest( i, mfb, *k, targetNodes );
588  }
589  if ( Shell::numNodes() > 1 )
590  {
591  if ( report )
592  {
593  unsigned int numPre = findNumDigest( msgDigest_,
594  msgBinding_.size(), numData(), i );
595  putOffNodeTargetsInDigest( i, targetNodes );
596  unsigned int numPost = findNumDigest( msgDigest_,
597  msgBinding_.size(), numData(), i );
598  cout << "\nfor Element " << name_;
599  cout << ", Func: " << i << ", numFunc = " << fo.size() <<
600  ", numPre= " << numPre <<
601  ", numPost= " << numPost << endl;
602  for ( unsigned int j = 0; j < numData(); ++j )
603  {
604  cout << endl << j << " ";
605  for ( unsigned int node = 0; node < Shell::numNodes(); ++node)
606  {
607  cout << (int)targetNodes[j][node];
608  }
609  }
610  cout << endl;
611  }
612  else
613  {
614  putOffNodeTargetsInDigest( i, targetNodes );
615  }
616  }
617  }
618 }
void putOffNodeTargetsInDigest(unsigned int srcNum, vector< vector< bool > > &targetNodes)
Definition: Element.cpp:517
vector< FuncOrder > putFuncsInOrder(const Element *elm, const vector< MsgFuncBinding > &vec)
Definition: Element.cpp:392
string name_
Definition: Element.h:399
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
vector< vector< MsgDigest > > msgDigest_
Definition: Element.h:437
void putTargetsInDigest(unsigned int srcNum, const MsgFuncBinding &mfb, const FuncOrder &fo, vector< vector< bool > > &targetNodes)
Definition: Element.cpp:466
static unsigned int numNodes()
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423
unsigned int findNumDigest(const vector< vector< MsgDigest > > &md, unsigned int totFunc, unsigned int numData, unsigned int funcNum)
Definition: Element.cpp:558

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Element::dropAllMsgsFromSrc ( Id  src)

Drop all messages arriving from src onto current Element, regardless of which field they come from.

Definition at line 197 of file Element.cpp.

References Msg::deleteMsg(), Msg::e1(), Msg::e2(), Id::element(), Msg::getMsg(), and m_.

Referenced by setTick().

198 {
199  static Id clockId( 1 );
200  const Element* clock = clockId.element();
201  vector< ObjId > msgs;
202  for ( vector< ObjId >::const_iterator i = m_.begin();
203  i != m_.end(); ++i )
204  {
205  const Msg* m = Msg::getMsg( *i );
206  const Element* src;
207  if ( m->e1() == this )
208  {
209  src = m->e2();
210  }
211  else
212  {
213  src = m->e1();
214  }
215  if ( src == clock )
216  {
217  msgs.push_back( *i );
218  }
219  }
220  sort( msgs.begin(), msgs.end() );
221  // C++ detritus.
222  msgs.erase( unique( msgs.begin(), msgs.end() ), msgs.end() );
223  for( vector< ObjId >::iterator
224  i = msgs.begin(); i != msgs.end(); ++i )
225  Msg::deleteMsg( *i );
226 }
Element * e2() const
Definition: Msg.h:68
static void deleteMsg(ObjId mid)
Definition: Msg.cpp:52
vector< ObjId > m_
Definition: Element.h:412
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
Definition: Id.h:17
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Element::dropMsg ( ObjId  mid)

Removes the specified msg from the list.

Called from ~Msg. This requires the usual scan through all msgs, and could get inefficient.

Definition at line 113 of file Element.cpp.

References isDoomed(), m_, markRewired(), and msgBinding_.

Referenced by Msg::~Msg().

114 {
115  if ( isDoomed() ) // This is a flag that the Element is doomed.
116  return;
117  // Here we have the spectacularly ugly C++ erase-remove idiot.
118  m_.erase( remove( m_.begin(), m_.end(), mid ), m_.end() );
119 
120  for ( vector< vector< MsgFuncBinding > >::iterator i = msgBinding_.begin(); i != msgBinding_.end(); ++i )
121  {
122  matchMid match( mid );
123  i->erase( remove_if( i->begin(), i->end(), match ), i->end() );
124  }
125  markRewired();
126 }
void markRewired()
Definition: Element.cpp:706
vector< ObjId > m_
Definition: Element.h:412
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423
bool isDoomed() const
Definition: Element.cpp:701

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int Element::findBinding ( MsgFuncBinding  b) const

Returns the binding index of the specified entry. Returns ~0 on failure.

Definition at line 374 of file Element.cpp.

References msgBinding_.

Referenced by findCaller(), getInputMsgs(), and getMsgSourceAndSender().

375 {
376  for ( unsigned int i = 0; i < msgBinding_.size(); ++i )
377  {
378  const vector< MsgFuncBinding >& mb = msgBinding_[i];
379  vector< MsgFuncBinding>::const_iterator bi =
380  find( mb.begin(), mb.end(), b );
381  if ( bi != mb.end() )
382  return i;
383  }
384  return ~0;
385 }
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the caller graph for this function:

ObjId Element::findCaller ( FuncId  fid) const

Returns the first Msg that calls the specified Fid, on current Element. Returns 0 on failure.

Definition at line 350 of file Element.cpp.

References BADINDEX, Msg::e1(), Msg::e2(), findBinding(), Msg::getMsg(), and m_.

Referenced by HSolve::deleteIncomingMessages(), Shell::innerMove(), Neutral::isDescendant(), Neutral::parent(), Neutral::path(), and testAssortedMsg().

351 {
352  for ( vector< ObjId >::const_iterator i = m_.begin();
353  i != m_.end(); ++i )
354  {
355  const Msg* m = Msg::getMsg( *i );
356  const Element* src;
357  if ( m->e1() == this )
358  {
359  src = m->e2();
360  }
361  else
362  {
363  src = m->e1();
364  }
365  unsigned int ret = src->findBinding( MsgFuncBinding( *i, fid ) );
366  if ( ret != ~0U )
367  {
368  return *i;
369  }
370  }
371  return ObjId( 0, BADINDEX );
372 }
Element * e2() const
Definition: Msg.h:68
Definition: ObjId.h:20
vector< ObjId > m_
Definition: Element.h:412
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
const unsigned int BADINDEX
Used by ObjId and Eref.
Definition: consts.cpp:25
unsigned int findBinding(MsgFuncBinding b) const
Definition: Element.cpp:374

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int Element::getFieldsOfOutgoingMsg ( ObjId  mid,
vector< pair< BindIndex, FuncId > > &  ret 
) const

Fills in vector, each entry of which identifies the src and dest fields respectively. Src field is local and identified by BindIndex Dest field is a FuncId on the remote Element.

Definition at line 1009 of file Element.cpp.

References msgBinding_.

Referenced by Msg::getDestFieldsOnE1(), Msg::getDestFieldsOnE2(), Msg::getSrcFieldsOnE1(), Msg::getSrcFieldsOnE2(), and testMsgSrcDestFields().

1011 {
1012  ret.resize( 0 );
1013  for ( unsigned int i = 0; i < msgBinding_.size(); ++i )
1014  {
1015  const vector< MsgFuncBinding >& mb = msgBinding_[i];
1016  for ( vector< MsgFuncBinding >::const_iterator j = mb.begin();
1017  j != mb.end(); ++j )
1018  {
1019  if ( j->mid == mid )
1020  {
1021  ret.push_back( pair< BindIndex, FuncId >( i, j->fid ));
1022  }
1023  }
1024  }
1025  return ret.size();
1026 }
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the caller graph for this function:

unsigned int Element::getInputMsgs ( vector< ObjId > &  caller,
FuncId  fid 
) const

More general function. Fills up vector of ObjIds that call the specified Fid on current Element. Returns # found

Definition at line 984 of file Element.cpp.

References Msg::e1(), Msg::e2(), findBinding(), Msg::getMsg(), and m_.

Referenced by getInputs(), getInputsWithTgtIndex(), and insertSharedMsgs().

986 {
987  for ( vector< ObjId >::const_iterator i = m_.begin();
988  i != m_.end(); ++i )
989  {
990  const Msg* m = Msg::getMsg( *i );
991  const Element* src;
992  if ( m->e1() == this )
993  {
994  src = m->e2();
995  }
996  else
997  {
998  src = m->e1();
999  }
1000  unsigned int ret = src->findBinding( MsgFuncBinding( *i, fid ) );
1001  if ( ret != ~0U )
1002  {
1003  caller.push_back( *i );
1004  }
1005  }
1006  return caller.size();
1007 }
Element * e2() const
Definition: Msg.h:68
vector< ObjId > m_
Definition: Element.h:412
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
unsigned int findBinding(MsgFuncBinding b) const
Definition: Element.cpp:374

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int Element::getInputs ( vector< Id > &  ret,
const DestFinfo finfo 
) const
private

Fills in vector of Ids sending messeges to this DestFinfo on this Element. Returns # found

Definition at line 887 of file Element.cpp.

References Msg::e1(), Msg::e2(), DestFinfo::getFid(), getInputMsgs(), Msg::getMsg(), and id().

Referenced by getNeighbors().

889 {
890  assert( finfo ); // would like to check that finfo is on src.
891  unsigned int oldSize = ret.size();
892 
893  FuncId fid = finfo->getFid();
894  vector< ObjId > caller;
895  getInputMsgs( caller, fid );
896  for ( vector< ObjId >::iterator i = caller.begin();
897  i != caller.end(); ++i )
898  {
899  const Msg* m = Msg::getMsg( *i );
900  assert( m );
901 
902  Id id = m->e1()->id();
903  if ( m->e1() == this )
904  id = m->e2()->id();
905  ret.push_back( id );
906  }
907  return ret.size() - oldSize;
908 }
Element * e2() const
Definition: Msg.h:68
Id id() const
Definition: Element.cpp:71
FuncId getFid() const
Definition: DestFinfo.cpp:45
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
unsigned int getInputMsgs(vector< ObjId > &caller, FuncId fid) const
Definition: Element.cpp:984
Definition: Id.h:17
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
unsigned int FuncId
Definition: header.h:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int Element::getInputsWithTgtIndex ( vector< pair< Id, unsigned int > > &  ret,
const DestFinfo finfo 
) const

Returns vectors of sources of messages to a field or data element. To go with each entry, also return the field or data index of target.

Returns vectors of sources of messages to a field or data element. To go with each entry, also return the field or data index of target. Needed to track which inputs go to with field index of current element. So if A–>x0, B–>x1, and C–>x2, it will return A, B, C, no matter in which order the messages were created. If there are multiple messages to x0, it will return the first.

Definition at line 918 of file Element.cpp.

References Eref::dataIndex(), Msg::e1(), Msg::e2(), Eref::fieldIndex(), Msg::firstTgt(), DestFinfo::getFid(), getInputMsgs(), Msg::getMsg(), hasFields(), and id().

920 {
921  assert( finfo ); // would like to check that finfo is on src.
922  ret.clear();
923 
924  FuncId fid = finfo->getFid();
925  vector< ObjId > caller;
926  getInputMsgs( caller, fid );
927  for ( vector< ObjId >::iterator i = caller.begin();
928  i != caller.end(); ++i )
929  {
930  const Msg* m = Msg::getMsg( *i );
931  assert( m );
932 
933  if ( m->e1() == this )
934  {
935  Eref tgt = m->firstTgt( Eref( m->e2(), 0 ) );
936  unsigned int idx = this->hasFields() ? tgt.fieldIndex(): tgt.dataIndex();
937  ret.push_back( pair< Id, unsigned int >( m->e2()->id(), idx ) );
938  }
939  else if ( m->e2() == this )
940  {
941  Eref tgt = m->firstTgt( Eref( m->e1(), 0 ) );
942  unsigned int idx = this->hasFields() ? tgt.fieldIndex(): tgt.dataIndex();
943  ret.push_back( pair< Id, unsigned int >( m->e1()->id(), idx ) );
944  }
945  }
946  return ret.size();
947 }
Element * e2() const
Definition: Msg.h:68
virtual Eref firstTgt(const Eref &src) const =0
unsigned int dataIndex() const
Definition: Eref.h:50
unsigned int fieldIndex() const
Definition: Eref.h:61
Id id() const
Definition: Element.cpp:71
FuncId getFid() const
Definition: DestFinfo.cpp:45
virtual bool hasFields() const =0
Definition: Eref.h:26
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
unsigned int getInputMsgs(vector< ObjId > &caller, FuncId fid) const
Definition: Element.cpp:984
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
unsigned int FuncId
Definition: header.h:42

+ Here is the call graph for this function:

const vector< MsgFuncBinding > * Element::getMsgAndFunc ( BindIndex  b) const

gets the Msg/Func binding information for specified bindIndex. This is a vector. Returns 0 on failure.

Definition at line 300 of file Element.cpp.

References msgBinding_.

Referenced by Neutral::child(), Neutral::children(), convertConcToNumRateUsingVol(), getMsgTargetAndFunctions(), EnzBase::getNumPrd(), ReacBase::getNumPrd(), EnzBase::getNumSub(), ReacBase::getNumSub(), Neutral::getOutgoingMsgs(), getOutputs(), getReactantVols(), and innerCopyMsgs().

301 {
302  if ( b < msgBinding_.size() )
303  return &( msgBinding_[ b ] );
304  return 0;
305 }
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the caller graph for this function:

unsigned int Element::getMsgSourceAndSender ( FuncId  fid,
vector< ObjId > &  src,
vector< string > &  sender 
) const

Fills in matching vectors of destination ObjIds and the destination function, for the specified source Finfo and dataId on this Element. Used in Neutral::msgDests and Neutral::msgDestFunctions. Returns number of dests found.

Definition at line 828 of file Element.cpp.

References cinfo(), Msg::e1(), Msg::e2(), findBinding(), Msg::getMsg(), id(), m_, and Cinfo::srcFinfoName().

Referenced by testMsgSrcDestFields().

831 {
832  for ( vector< ObjId >::const_iterator i = m_.begin();
833  i != m_.end(); ++i )
834  {
835  const Msg* m = Msg::getMsg( *i );
836  const Element* src;
837  if ( m->e1() == this )
838  {
839  src = m->e2();
840  }
841  else
842  {
843  src = m->e1();
844  }
845  unsigned int ret = src->findBinding( MsgFuncBinding( *i, fid ) );
846  if ( ret != ~0U )
847  {
848  // problem here, to get dataId
849  srcObj.push_back( ObjId( src->id(), 0 ) );
850  sender.push_back( src->cinfo()->srcFinfoName( ret ) );
851  }
852  }
853  return srcObj.size();
854 }
Element * e2() const
Definition: Msg.h:68
Definition: ObjId.h:20
Id id() const
Definition: Element.cpp:71
vector< ObjId > m_
Definition: Element.h:412
const Cinfo * cinfo() const
Definition: Element.cpp:66
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
const string & srcFinfoName(BindIndex bid) const
Definition: Cinfo.cpp:552
unsigned int findBinding(MsgFuncBinding b) const
Definition: Element.cpp:374

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int Element::getMsgTargetAndFunctions ( DataId  srcDataId,
const SrcFinfo finfo,
vector< ObjId > &  tgt,
vector< string > &  func 
) const

Fills in matching vectors of destination ObjIds and the destination function, for the specified source Finfo and dataId on this Element. Used in Neutral::msgDests and Neutral::msgDestFunctions. Returns number of dests found.

Definition at line 772 of file Element.cpp.

References cinfo(), Cinfo::destFinfoName(), Msg::e1(), Msg::e2(), SrcFinfo::getBindIndex(), Msg::getMsg(), getMsgAndFunc(), name, numData(), Msg::sources(), and Msg::targets().

Referenced by Stoich::allocateModelObject(), Neutral::getMsgDestFunctions(), Neutral::getMsgDests(), and testMsgSrcDestFields().

777 {
778  assert( finfo ); // would like to check that finfo is on this.
779  assert( srcDataId < this->numData() );
780 
781  tgt.resize( 0 );
782  func.resize( 0 );
783 
784  const vector< MsgFuncBinding >* msgVec =
785  getMsgAndFunc( finfo->getBindIndex() );
786  for ( unsigned int i = 0; i < msgVec->size(); ++i )
787  {
788  const Msg* m = Msg::getMsg( (*msgVec)[i].mid );
789  assert( m );
790  FuncId fid = (*msgVec)[i].fid;
791  if ( m->e1() == this ) // regular direction message.
792  {
793  string name = m->e2()->cinfo()->destFinfoName( fid );
794  vector< vector< Eref > > t;
795  m->targets( t );
796  assert( t.size() == this->numData() );
797  vector< Eref >& row = t[srcDataId];
798  for ( vector< Eref >::const_iterator
799  e = row.begin(); e != row.end(); ++e )
800  {
801  tgt.push_back( e->objId() );
802  func.push_back( name );
803  }
804  }
805  else if ( m->e2() == this )
806  {
807  string name = m->e1()->cinfo()->destFinfoName( fid );
808  vector< vector< Eref > > t;
809  m->sources( t );
810  assert( t.size() == this->numData() );
811  vector< Eref >& row = t[srcDataId];
812  for ( vector< Eref >::const_iterator
813  e = row.begin(); e != row.end(); ++e )
814  {
815  tgt.push_back( e->objId() );
816  func.push_back( name );
817  }
818  }
819  else
820  {
821  assert( 0 );
822  }
823  }
824  return tgt.size();
825 }
Element * e2() const
Definition: Msg.h:68
BindIndex getBindIndex() const
Definition: SrcFinfo.cpp:28
virtual void sources(vector< vector< Eref > > &v) const =0
virtual void targets(vector< vector< Eref > > &v) const =0
const string & destFinfoName(FuncId fid) const
Definition: Cinfo.cpp:569
const vector< MsgFuncBinding > * getMsgAndFunc(BindIndex b) const
Definition: Element.cpp:300
const Cinfo * cinfo() const
Definition: Element.cpp:66
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
static char name[]
Definition: mfield.cpp:401
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
unsigned int FuncId
Definition: header.h:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

vector< ObjId > Element::getMsgTargets ( DataId  srcDataId,
const SrcFinfo finfo 
) const

Enumerates msg targets. Will get confused if some are across nodes.

Definition at line 856 of file Element.cpp.

References ALLDATA, SrcFinfo::getBindIndex(), Eref::msgDigest(), and numData().

Referenced by Adaptor::reinit(), and ChemCompt::setEntireVolume().

858 {
859  assert( finfo ); // would like to check that finfo is on this.
860  assert( srcDataId < this->numData() );
861 
862  vector< ObjId > ret;
863  Eref er( const_cast< Element* >( this ), srcDataId );
864 
865  const vector< MsgDigest >&md = er.msgDigest( finfo->getBindIndex() );
866  for ( vector< MsgDigest >::const_iterator
867  i = md.begin(); i != md.end(); ++i )
868  {
869  for ( vector< Eref >::const_iterator
870  j = i->targets.begin(); j != i->targets.end(); ++j )
871  {
872  if ( j->dataIndex() == ALLDATA )
873  {
874  for ( unsigned int k = 0;
875  k < j->element()->numData(); ++k )
876  ret.push_back( ObjId( j->id(), k ) );
877  }
878  else
879  {
880  ret.push_back( j->objId() );
881  }
882  }
883  }
884  return ret;
885 }
BindIndex getBindIndex() const
Definition: SrcFinfo.cpp:28
Definition: ObjId.h:20
const unsigned int ALLDATA
Used by ObjId and Eref.
Definition: consts.cpp:22
Definition: Eref.h:26
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 Element::getNeighbors ( vector< Id > &  ret,
const Finfo finfo 
) const

Fills in vector of Ids connected to this Finfo on this Element. Returns # found

Definition at line 949 of file Element.cpp.

References SharedFinfo::dest(), getInputs(), getOutputs(), and SharedFinfo::src().

Referenced by ReadCell::buildCompartment(), findAllConnectedCompartments(), findFuncMsgSrc(), findMeshOfEnz(), findParentComptOfReac(), Neutral::getNeighbors(), isOffSolverReac(), moose::VClamp::reinit(), ZombieReac::setSolver(), ZombieMMenz::setSolver(), ZombieEnz::setSolver(), HSolveUtils::targets(), testShellAddMsg(), and testTwoReacGetNeighbors().

951 {
952  ret.resize( 0 );
953  if ( !finfo )
954  return 0;
955 
956  const SrcFinfo* srcF = dynamic_cast< const SrcFinfo* >( finfo );
957  const DestFinfo* destF = dynamic_cast< const DestFinfo* >( finfo );
958  const SharedFinfo* sharedF = dynamic_cast< const SharedFinfo* >( finfo );
959  assert( srcF || destF || sharedF );
960 
961 
962  if ( srcF )
963  return getOutputs( ret, srcF );
964  else if ( destF )
965  return getInputs( ret, destF );
966  else if ( ! sharedF->src().empty() )
967  return getOutputs( ret, sharedF->src().front() );
968  else if ( ! sharedF->dest().empty() )
969  {
970  Finfo* subFinfo = sharedF->dest().front();
971  const DestFinfo* subDestFinfo =
972  dynamic_cast< const DestFinfo* >( subFinfo );
973  assert( subDestFinfo );
974  return getInputs( ret, subDestFinfo );
975  }
976  else
977  {
978  assert( 0 );
979  }
980  return 0;
981 }
unsigned int getOutputs(vector< Id > &ret, const SrcFinfo *finfo) const
Definition: Element.cpp:749
const vector< Finfo * > & dest() const
const vector< SrcFinfo * > & src() const
unsigned int getInputs(vector< Id > &ret, const DestFinfo *finfo) const
Definition: Element.cpp:887
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual unsigned int Element::getNode ( unsigned int  dataIndex) const
pure virtual

Returns node number of specified dataIndex.

Implemented in MsgElement, GlobalDataElement, LocalDataElement, and FieldElement.

Referenced by HopFunc1< A >::dataOpVec(), FieldElement::getNode(), Eref::getNode(), and Eref::isDataHere().

+ Here is the caller graph for this function:

virtual unsigned int Element::getNumOnNode ( unsigned int  node) const
pure virtual

Returns number of data (or, if relevant, field) entries on specified node.

Implemented in MsgElement, GlobalDataElement, LocalDataElement, and FieldElement.

Referenced by HopFunc1< A >::dataOpVec(), and HopFunc2< A1, A2 >::opVec().

+ Here is the caller graph for this function:

unsigned int Element::getOutputs ( vector< Id > &  ret,
const SrcFinfo finfo 
) const
private

Fills in vector of Ids receiving messages from this SrcFinfo. Returns # found

Definition at line 749 of file Element.cpp.

References Msg::e1(), Msg::e2(), SrcFinfo::getBindIndex(), Msg::getMsg(), getMsgAndFunc(), and id().

Referenced by getNeighbors().

751 {
752  assert( finfo ); // would like to check that finfo is on this.
753  unsigned int oldSize = ret.size();
754 
755  const vector< MsgFuncBinding >* msgVec =
756  getMsgAndFunc( finfo->getBindIndex() );
757  if ( !msgVec )
758  return 0;
759  for ( unsigned int i = 0; i < msgVec->size(); ++i )
760  {
761  const Msg* m = Msg::getMsg( (*msgVec)[i].mid );
762  assert( m );
763  Id id = m->e2()->id();
764  if ( m->e2() == this )
765  id = m->e1()->id();
766  ret.push_back( id );
767  }
768 
769  return ret.size() - oldSize;
770 }
Element * e2() const
Definition: Msg.h:68
BindIndex getBindIndex() const
Definition: SrcFinfo.cpp:28
Id id() const
Definition: Element.cpp:71
const vector< MsgFuncBinding > * getMsgAndFunc(BindIndex b) const
Definition: Element.cpp:300
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
Definition: Id.h:17
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int Element::getTick ( ) const

Returns Clock tick used by object. -1 means none. -2 means none for now because I am a zombie, but if I should be unzombified please put me back on my default clock tick.

Definition at line 186 of file Element.cpp.

References tick_.

Referenced by Streamer::addTable(), Neutral::getDt(), Neutral::getTick(), Table::reinit(), Streamer::reinit(), and Stoich::unZombifyModel().

187 {
188  return tick_;
189 }
int tick_
Returns tick on which element is scheduled. -1 for disabled.
Definition: Element.h:440

+ Here is the caller graph for this function:

virtual bool Element::hasFields ( ) const
pure virtual

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

Implemented in MsgElement, DataElement, and FieldElement.

Referenced by Neutral::child(), Shell::doFind(), OneToOneMsg::firstTgt(), getInputsWithTgtIndex(), innerGetVec(), moose_ObjId_getLength(), GetHopFunc< A >::opGetVec(), HopFunc1< A >::opVec(), OpFunc1Base< ProcPtr >::opVecBuffer(), Neutral::path(), OneToOneMsg::sources(), and OneToOneMsg::targets().

+ Here is the caller graph for this function:

bool Element::hasMsgs ( BindIndex  b) const

Returns true if there are one or more Msgs on the specified BindIndex

Definition at line 307 of file Element.cpp.

References msgBinding_.

Referenced by Clock::buildTicks(), and NeuroMesh::transmitSpineInfo().

308 {
309  return ( b < msgBinding_.size() && msgBinding_[b].size() > 0 );
310 }
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the caller graph for this function:

Id Element::id ( ) const
void Element::innerSetTick ( unsigned int  tick)

Direct assignment of tick field, without doing any of the message manipulation

Definition at line 191 of file Element.cpp.

References tick_.

192 {
193  if ( tick < 32 )
194  tick_ = tick;
195 }
int tick_
Returns tick on which element is scheduled. -1 for disabled.
Definition: Element.h:440
bool Element::isDoomed ( ) const

Definition at line 701 of file Element.cpp.

References isDoomed_.

Referenced by dropMsg(), and Stoich::unZombifyPools().

702 {
703  return isDoomed_;
704 }
bool isDoomed_
True if the element is marked for destruction.
Definition: Element.h:446

+ Here is the caller graph for this function:

virtual bool Element::isGlobal ( ) const
pure virtual

True if there is a copy of every dataEntry on all nodes.

Implemented in MsgElement, GlobalDataElement, LocalDataElement, and FieldElement.

Referenced by HopFunc1< A >::dataOpVec(), PostMaster::dispatchSetBuf(), filterOffNodeTargets(), FieldElement::getNumOnNode(), FieldElement::isGlobal(), GetHopFunc< A >::opGetVec(), HopFunc1< A >::opVec(), HopFunc2< A1, A2 >::opVec(), putTargetsInDigest(), PostMaster::remoteFieldGetVec(), PostMaster::remoteGet(), PostMaster::remoteGetVec(), and testCopyFieldElement().

+ Here is the caller graph for this function:

void Element::markAsDoomed ( )

Set flag to state that Element is due for destruction. Useful to avoid following messages that will soon be gone.

Definition at line 696 of file Element.cpp.

References isDoomed_.

Referenced by clearAllMsgs(), and ~Element().

697 {
698  isDoomed_ = true;
699 }
bool isDoomed_
True if the element is marked for destruction.
Definition: Element.h:446

+ Here is the caller graph for this function:

void Element::markRewired ( )

Set flag to state that the messages on this Element have changed, and need to be re-digested.

Definition at line 706 of file Element.cpp.

References isRewired_.

Referenced by addMsg(), addMsgAndFunc(), clearBinding(), dropMsg(), SparseMsg::randomConnect(), OneToAllMsg::setI1(), SingleMsg::setI1(), SingleMsg::setI2(), DiagonalMsg::setStride(), SingleMsg::setTargetField(), SparseMsg::transpose(), and SparseMsg::updateAfterFill().

707 {
708  isRewired_ = true;
709 }
bool isRewired_
True if messages have been changed and need to digestMessages.
Definition: Element.h:443

+ Here is the caller graph for this function:

const vector< MsgDigest > & Element::msgDigest ( unsigned int  index)

Raw lookup into MsgDigest vector. One for each MsgSrc X ObjEntry. If the messages have been rewired, this call triggers the re-parsing of all messages before returning the digested msgs.

Definition at line 289 of file Element.cpp.

References digestMessages(), isRewired_, and msgDigest_.

Referenced by Eref::msgDigest(), and testSendMsg().

290 {
291  if ( isRewired_ )
292  {
293  digestMessages();
294  isRewired_ = false;
295  }
296  assert( index < msgDigest_.size() );
297  return msgDigest_[ index ];
298 }
bool isRewired_
True if messages have been changed and need to digestMessages.
Definition: Element.h:443
void digestMessages()
Definition: Element.cpp:569
vector< vector< MsgDigest > > msgDigest_
Definition: Element.h:437

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const vector< ObjId > & Element::msgIn ( ) const

Returns all incoming Msgs.

Definition at line 387 of file Element.cpp.

References m_.

Referenced by Neutral::getIncomingMsgs().

388 {
389  return m_;
390 }
vector< ObjId > m_
Definition: Element.h:412

+ Here is the caller graph for this function:

virtual unsigned int Element::numField ( unsigned int  rawIndex) const
pure virtual

Returns number of field entries for specified data.

Implemented in MsgElement, DataElement, and FieldElement.

Referenced by GetHopFunc< A >::getLocalFieldVec(), Neutral::getNumField(), innerGetVec(), HopFunc1< A >::localFieldOpVec(), HopFunc1< A >::localOpVec(), HopFunc2< A1, A2 >::opVec(), OpFunc1Base< ProcPtr >::opVecBuffer(), OpFunc2Base< A1, A2 >::opVecBuffer(), OneToOneMsg::sources(), OneToOneMsg::targets(), testCopyFieldElement(), and testSyncSynapseSize().

+ Here is the caller graph for this function:

void Element::printMsgDigest ( unsigned int  srcIndex,
unsigned int  dataIndex 
) const

Utility function for debugging

Definition at line 711 of file Element.cpp.

References msgBinding_, msgDigest_, and numData().

712 {
713  unsigned int numSrcMsgs = msgBinding_.size();
714  unsigned int start = 0;
715  unsigned int end = numData();
716  if ( dataId < numData() )
717  {
718  start = dataId;
719  end = dataId + 1;
720  }
721  for (unsigned int i = start; i < end; ++i )
722  {
723  cout << i << ": ";
724  const vector< MsgDigest> & md =
725  msgDigest_[numSrcMsgs * i + srcIndex];
726  for ( unsigned int j = 0; j < md.size(); ++j )
727  {
728  cout << j << ": ";
729  for ( unsigned int k = 0; k < md[j].targets.size(); ++k )
730  {
731  cout << " " <<
732  md[j].targets[k].dataIndex() << "," <<
733  md[j].targets[k].fieldIndex();
734  }
735  }
736  cout << endl;
737  }
738 }
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
vector< vector< MsgDigest > > msgDigest_
Definition: Element.h:437
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the call graph for this function:

void Element::putOffNodeTargetsInDigest ( unsigned int  srcNum,
vector< vector< bool > > &  targetNodes 
)

Inner function that adds off-node targets to the MsgDigest

Definition at line 517 of file Element.cpp.

References cinfo(), Msg::e1(), Msg::e2(), MsgFuncBinding::fid, Msg::getMsg(), Cinfo::getOpFunc(), OpFunc::makeHopFunc(), MsgFuncBinding::mid, msgBinding_, msgDigest_, numData(), and Shell::numNodes().

Referenced by digestMessages().

520 {
521  if ( msgBinding_[ srcNum ].size() == 0 )
522  return;
523  const MsgFuncBinding& mfb = msgBinding_[ srcNum ][0];
524  const Msg* msg = Msg::getMsg( mfb.mid );
525  const OpFunc* func;
526  if ( msg->e1() == this )
527  {
528  func = msg->e2()->cinfo()->getOpFunc( mfb.fid );
529  }
530  else
531  {
532  func = msg->e1()->cinfo()->getOpFunc( mfb.fid );
533  }
534  assert( func );
535  // How do I eventually destroy these?
536  const OpFunc* hop = func->makeHopFunc( srcNum );
537  for ( unsigned int i = 0; i < numData(); ++i )
538  {
539  vector< Eref > tgts;
540  for ( unsigned int j = 0; j < Shell::numNodes(); ++j )
541  {
542  if ( targetNodes[i][j] )
543  tgts.push_back( Eref( this, i, j ) );
544  // This is a hack. I encode the target node # in the FieldIndex
545  // and the originating Eref in the remainder of the Eref.
546  // The HopFunc has to extract both these things to push into
547  // the correct SendBuffer.
548  }
549  if ( tgts.size() > 0 )
550  {
551  vector< MsgDigest >& md =
552  msgDigest_[ msgBinding_.size() * i + srcNum ];
553  md.push_back( MsgDigest( hop, tgts ) );
554  }
555  }
556 }
Element * e2() const
Definition: Msg.h:68
const OpFunc * getOpFunc(FuncId fid) const
Definition: Cinfo.cpp:240
virtual const OpFunc * makeHopFunc(HopIndex hopIndex) const =0
Definition: Eref.h:26
const Cinfo * cinfo() const
Definition: Element.cpp:66
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
Definition: Msg.h:18
vector< vector< MsgDigest > > msgDigest_
Definition: Element.h:437
Element * e1() const
Definition: Msg.h:61
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
static unsigned int numNodes()
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Element::putTargetsInDigest ( unsigned int  srcNum,
const MsgFuncBinding mfb,
const FuncOrder fo,
vector< vector< bool > > &  targetNodes 
)

Inner function that adds targets to a single function in the MsgDigest

Definition at line 466 of file Element.cpp.

References Msg::e1(), Msg::e2(), filterOffNodeTargets(), FuncOrder::func(), Msg::getMsg(), isGlobal(), localDataStart(), MsgFuncBinding::mid, msgBinding_, msgDigest_, Shell::myNode(), numLocalData(), Shell::numNodes(), Msg::sources(), and Msg::targets().

Referenced by digestMessages().

471 {
472  const Msg* msg = Msg::getMsg( mfb.mid );
473  vector< vector < Eref > > erefs;
474  if ( msg->e1() == this )
475  msg->targets( erefs );
476  else if ( msg->e2() == this )
477  msg->sources( erefs );
478  else
479  assert( 0 );
480 
481  if ( Shell::numNodes() > 1 )
483  localDataStart(),
485  isGlobal(), Shell::myNode(),
486  erefs, targetNodes );
487 
488  for ( unsigned int j = 0; j < erefs.size(); ++j )
489  {
490  vector< MsgDigest >& md =
491  msgDigest_[ msgBinding_.size() * j + srcNum ];
492  // k->func(); erefs[ j ];
493  if ( md.size() == 0 || md.back().func != fo.func() )
494  {
495  md.push_back( MsgDigest( fo.func(), erefs[j] ) );
496  /*
497  if ( md.back().targets.size() > 0 )
498  cout << "putTargetsInDigest: " << md.back().targets[0] <<
499  ", eref = " << erefs[j][0] << endl;
500  else
501  cout << "putTargetsInDigest: empty\n";
502  */
503  }
504  else
505  {
506  md.back().targets.insert( md.back().targets.end(),
507  erefs[ j ].begin(),
508  erefs[ j ].end() );
509  }
510  }
511 }
Element * e2() const
Definition: Msg.h:68
virtual void sources(vector< vector< Eref > > &v) const =0
virtual void targets(vector< vector< Eref > > &v) const =0
virtual bool isGlobal() const =0
True if there is a copy of every dataEntry on all nodes.
const OpFunc * func() const
Definition: FuncOrder.h:21
Definition: Msg.h:18
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.
virtual unsigned int numLocalData() const =0
Returns number of local data entries on this node.
vector< vector< MsgDigest > > msgDigest_
Definition: Element.h:437
Element * e1() const
Definition: Msg.h:61
static unsigned int myNode()
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
static unsigned int numNodes()
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423
void filterOffNodeTargets(unsigned int start, unsigned int end, bool isSrcGlobal, unsigned int myNode, vector< vector< Eref > > &erefs, vector< vector< bool > > &targetNodes)
Definition: Element.cpp:429

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual unsigned int Element::rawIndex ( unsigned int  dataIndex) const
pure virtual

Converts dataIndex to index on current node. No error check.

Implemented in MsgElement, GlobalDataElement, LocalDataElement, and FieldElement.

Referenced by Eref::data(), Neutral::getNumField(), FieldElement::rawIndex(), and Neutral::setNumField().

+ Here is the caller graph for this function:

void Element::replaceCinfo ( const Cinfo newCinfo)

Support function for zombieSwap, replaces Cinfo.

Definition at line 740 of file Element.cpp.

References cinfo_.

Referenced by Pool::vSetIsBuffered(), FieldElement::zombieSwap(), DataElement::zombieSwap(), and MsgElement::zombieSwap().

741 {
742  cinfo_ = newCinfo;
743  // Stuff to be done for data is handled by derived classes in ZombeSwap.
744 }
const Cinfo * cinfo_
Stores the unique identifier for Element.
Definition: Element.h:406

+ Here is the caller graph for this function:

virtual void Element::resize ( unsigned int  newNumData)
pure virtual

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

Implemented in MsgElement, DataElement, FieldElement, and LocalDataElement.

Referenced by LookupField< L, A >::getVec(), Neutral::setNumData(), and Stoich::zombifyModel().

+ Here is the caller graph for this function:

virtual void Element::resizeField ( unsigned int  rawIndex,
unsigned int  newNumField 
)
pure virtual

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

Implemented in MsgElement, DataElement, and FieldElement.

Referenced by SparseMsg::randomConnect(), Neutral::setNumField(), and SparseMsg::updateAfterFill().

+ Here is the caller graph for this function:

void Element::setName ( const string &  val)

Changes name of Element

Definition at line 61 of file Element.cpp.

References name_.

Referenced by Neutral::setName(), testGet(), and testStrGet().

62 {
63  name_ = val;
64 }
string name_
Definition: Element.h:399

+ Here is the caller graph for this function:

void Element::setTick ( int  t)

Assigns clock tick to be used by object. -1 means none. This function does substantial message manipulation to set up the message from the Clock object to the current object to define the Tick. Furthermore, if the object has both init and proc methods, it will set them both up, with the init method on 't-1' and the proc method on 't'

Definition at line 251 of file Element.cpp.

References addClockMsg(), cinfo(), cinfo_, dropAllMsgsFromSrc(), Cinfo::findFinfo(), Cinfo::name(), and tick_.

Referenced by innerCopyElements(), Shell::innerCreate(), Stoich::installAndUnschedFunc(), Stoich::installAndUnschedFuncRate(), Stoich::installAndUnschedFuncReac(), Streamer::reinit(), Neutral::setTick(), Stoich::unZombifyModel(), and zombieSwap().

252 {
253  Id clockId( 1 );
254  if ( t == tick_ )
255  return;
256  if ( tick_ >= 0 ) // Drop all messages coming here from clock.
257  {
258  dropAllMsgsFromSrc( clockId );
259  }
260  tick_ = t;
261  if ( t < 0 || t > 31 ) // Only 32 ticks available.
262  {
263  // Don't need to add new ticks.
264  return;
265  }
266  const Finfo* f2 = cinfo()->findFinfo( "init" );
267  if ( f2 && dynamic_cast< const SharedFinfo* >( f2 ) )
268  {
269  // Must build init msg too. This comes on the previous tick.
270  assert( t > 0 );
271  addClockMsg( t-1, id(), f2 );
272  }
273  f2 = cinfo()->findFinfo( "proc" );
274  if ( f2 )
275  {
276  addClockMsg( t, id(), f2 );
277  }
278  else
279  {
280  cout << "Element::setTick:Warning: Attempt to assign a tick to a '"
281  << cinfo_->name() << "'.\nThis does not support process actions.\n";
282  tick_ = -1;
283  }
284 }
const std::string & name() const
Definition: Cinfo.cpp:260
const Cinfo * cinfo() const
Definition: Element.cpp:66
const Cinfo * cinfo_
Stores the unique identifier for Element.
Definition: Element.h:406
void dropAllMsgsFromSrc(Id src)
Definition: Element.cpp:197
Definition: Id.h:17
static bool addClockMsg(unsigned int tick, Id tgt, const Finfo *f2)
Definition: Element.cpp:228
int tick_
Returns tick on which element is scheduled. -1 for disabled.
Definition: Element.h:440
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Element::showFields ( ) const

Utility function for printing out all fields and their values

Definition at line 623 of file Element.cpp.

References cinfo_, Id::eref(), Cinfo::finfoMap(), id(), and name.

624 {
625  vector< const SrcFinfo* > srcVec;
626  vector< const DestFinfo* > destVec;
627  vector< const SharedFinfo* > sharedVec;
628  vector< const Finfo* > valueVec; // ValueFinfos are what is left.
629  for ( map< string, Finfo* >::const_iterator i =
630  cinfo_->finfoMap().begin();
631  i != cinfo_->finfoMap().end(); ++i )
632  {
633  const SrcFinfo* sf = dynamic_cast< const SrcFinfo* >( i->second);
634  const DestFinfo* df = dynamic_cast< const DestFinfo* >( i->second);
635  const SharedFinfo* shf = dynamic_cast< const SharedFinfo* >( i->second);
636  if ( sf )
637  srcVec.push_back( sf );
638  else if ( df )
639  destVec.push_back( df );
640  else if ( shf )
641  sharedVec.push_back( shf );
642  else
643  valueVec.push_back( i->second );
644  }
645 
646  cout << "Showing SrcFinfos: \n";
647  for ( unsigned int i = 0; i < srcVec.size(); ++i )
648  cout << i << ": " << srcVec[i]->name() << " Bind=" << srcVec[i]->getBindIndex() << endl;
649  cout << "Showing " << destVec.size() << " DestFinfos: \n";
650  /*
651  for ( unsigned int i = 0; i < destVec.size(); ++i )
652  cout << i << ": " << destVec[i]->name() << " FuncId=" << destVec[i]->getFid() << endl;
653  */
654  cout << "Showing SharedFinfos: \n";
655  for ( unsigned int i = 0; i < sharedVec.size(); ++i )
656  {
657  cout << i << ": " << sharedVec[i]->name() << " Src=[ ";
658  for ( unsigned int j = 0; j < sharedVec[i]->src().size(); ++j )
659  cout << " " << sharedVec[i]->src()[j]->name();
660  cout << " ] Dest=[ ";
661  for ( unsigned int j = 0; j < sharedVec[i]->dest().size(); ++j )
662  cout << " " << sharedVec[i]->dest()[j]->name();
663  cout << " ]\n";
664  }
665  cout << "Listing ValueFinfos: \n";
666  Eref er = this->id().eref();
667  string val;
668  for ( unsigned int i = 0; i < valueVec.size(); ++i )
669  {
670  valueVec[i]->strGet( er, valueVec[i]->name(), val );
671  cout << i << ": " << valueVec[i]->name() << " " <<
672  val << endl;
673  }
674 }
const map< string, Finfo * > & finfoMap() const
Definition: Cinfo.cpp:270
Eref eref() const
Definition: Id.cpp:125
Id id() const
Definition: Element.cpp:71
Definition: Eref.h:26
const Cinfo * cinfo_
Stores the unique identifier for Element.
Definition: Element.h:406
static char name[]
Definition: mfield.cpp:401

+ Here is the call graph for this function:

void Element::showMsg ( ) const

Utility function for traversing and displaying all messages

Definition at line 313 of file Element.cpp.

References cinfo_, Msg::e1(), Msg::e2(), Cinfo::finfoMap(), SrcFinfo::getBindIndex(), Msg::getMsg(), getName(), m_, msgBinding_, Finfo::name(), and name_.

314 {
315  cout << "Outgoing: \n";
316  for ( map< string, Finfo* >::const_iterator i =
317  cinfo_->finfoMap().begin();
318  i != cinfo_->finfoMap().end(); ++i )
319  {
320  const SrcFinfo* sf = dynamic_cast< const SrcFinfo* >( i->second );
321  if ( sf && msgBinding_.size() > sf->getBindIndex() )
322  {
323  const vector< MsgFuncBinding >& mb = msgBinding_[ sf->getBindIndex()];
324  unsigned int numTgt = mb.size();
325  if ( numTgt > 0 )
326  {
327  for ( unsigned int j = 0; j < numTgt; ++j )
328  {
329  cout << sf->name() << " bindId=" << sf->getBindIndex() << ": ";
330  cout << j << ": MessageId=" << mb[j].mid <<
331  ", FuncId=" << mb[j].fid <<
332  ", " << Msg::getMsg( mb[j].mid )->e1()->getName() <<
333  " -> " <<
334  Msg::getMsg( mb[j].mid )->e2()->getName() << endl;
335  }
336  }
337  }
338  }
339  cout << "Dest and Src: \n";
340  for ( unsigned int i = 0; i < m_.size(); ++i )
341  {
342  const Msg* m = Msg::getMsg( m_[i] );
343  cout << i << ": MessageId= " << m_[i] <<
344  ", e1= " << m->e1()->name_ <<
345  ", e2= " << m->e2()->name_ << endl;
346  }
347 }
Element * e2() const
Definition: Msg.h:68
BindIndex getBindIndex() const
Definition: SrcFinfo.cpp:28
const map< string, Finfo * > & finfoMap() const
Definition: Cinfo.cpp:270
const string & name() const
Definition: Finfo.cpp:80
vector< ObjId > m_
Definition: Element.h:412
string name_
Definition: Element.h:399
Definition: Msg.h:18
const Cinfo * cinfo_
Stores the unique identifier for Element.
Definition: Element.h:406
Element * e1() const
Definition: Msg.h:61
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
vector< vector< MsgFuncBinding > > msgBinding_
Definition: Element.h:423
const string & getName() const
Definition: Element.cpp:56

+ Here is the call graph for this function:

virtual unsigned int Element::startDataIndex ( unsigned int  nodeNum) const
pure virtual

Returns start dataIndex on specified node.

Implemented in MsgElement, GlobalDataElement, LocalDataElement, and FieldElement.

Referenced by HopFunc1< A >::dataOpVec(), and FieldElement::startDataIndex().

+ Here is the caller graph for this function:

virtual unsigned int Element::totNumLocalField ( ) const
pure virtual

Returns number of field entries on local node. If this is not a FieldElement, returns numLocalData, assuming 1 field per data.

Implemented in MsgElement, DataElement, and FieldElement.

void Element::zombieSwap ( const Cinfo zCinfo)
virtual

virtual func, this base version must be called by all derived classes

zombieSwap: replaces the Cinfo and data of the zombie. Allocates a new data block using zCinfo, that matches the number of entries of the old data block. Deletes old data. The base version calls the Clock object to assign a suitable default clock.

Reimplemented in MsgElement, DataElement, and FieldElement.

Definition at line 159 of file Element.cpp.

References Clock::lookupDefaultTick(), Cinfo::name(), setTick(), and tick_.

Referenced by ReadKkit::buildSumTotal(), ReadKkit::setupSlaveMsg(), DataElement::zombieSwap(), MsgElement::zombieSwap(), ZombieFunction::zombify(), ReacBase::zombify(), CplxEnzBase::zombify(), EnzBase::zombify(), CaConcBase::zombify(), PoolBase::zombify(), HHChannelBase::zombify(), and moose::CompartmentBase::zombify().

160 {
161  // cout << name_ << ", cname=" << c->name() << ", t0 = " << this->tick_ << ", t1 = " << Clock::lookupDefaultTick( c->name() ) << endl;
162  if ( tick_ == -1 ) // Object is already disabled, let it be.
163  {
164  return;
165  }
166  bool zombieInName = ( c->name().substr(0, 6) == "Zombie" );
167  if ( tick_ == -2 && !zombieInName ) // Object was a zombie and wants to come home.
168  {
169  int t = Clock::lookupDefaultTick( c->name() );
170  setTick( t );
171  }
172  else if ( tick_ >= 0 ) // disable clock, with option to return
173  {
174  if ( zombieInName )
175  {
176  setTick( -2 );
177  }
178  else
179  {
180  int t = Clock::lookupDefaultTick( c->name() );
181  setTick( t );
182  }
183  }
184 }
static unsigned int lookupDefaultTick(const string &className)
Definition: Clock.cpp:1035
void setTick(int t)
Definition: Element.cpp:251
int tick_
Returns tick on which element is scheduled. -1 for disabled.
Definition: Element.h:440

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

const Cinfo* Element::cinfo_
private

Stores the unique identifier for Element.

Class information

Definition at line 406 of file Element.h.

Referenced by cinfo(), replaceCinfo(), setTick(), showFields(), and showMsg().

Id Element::id_
private

Name of the Element.

Definition at line 401 of file Element.h.

Referenced by id(), and ~Element().

bool Element::isDoomed_
private

True if the element is marked for destruction.

Definition at line 446 of file Element.h.

Referenced by isDoomed(), and markAsDoomed().

bool Element::isRewired_
private

True if messages have been changed and need to digestMessages.

Definition at line 443 of file Element.h.

Referenced by markRewired(), and msgDigest().

vector< ObjId > Element::m_
private

Message vector. This is the low-level messaging information. Contains info about incoming as well as outgoing Msgs.

Definition at line 412 of file Element.h.

Referenced by addMsg(), clearAllMsgs(), dropAllMsgsFromSrc(), dropMsg(), findCaller(), getInputMsgs(), getMsgSourceAndSender(), msgIn(), showMsg(), and ~Element().

vector< vector < MsgFuncBinding > > Element::msgBinding_
private

Binds an outgoing message to its function. Each index (BindIndex) gives a vector of MsgFuncBindings, which are just pairs of ObjId, FuncId. SrcFinfo keeps track of the BindIndex to look things up. Note that a single BindIndex may refer to multiple Msg/Func pairs. This means that a single MsgSrc may dispatch data through multiple msgs using a single 'send' call.

Definition at line 423 of file Element.h.

Referenced by addMsgAndFunc(), clearAllMsgs(), clearBinding(), digestMessages(), dropMsg(), findBinding(), getFieldsOfOutgoingMsg(), getMsgAndFunc(), hasMsgs(), printMsgDigest(), putOffNodeTargetsInDigest(), putTargetsInDigest(), showMsg(), and ~Element().

vector< vector < MsgDigest > > Element::msgDigest_
private

Digested vector of message traversal sets. Each set has a Func and element to lead off, followed by a list of target indices and fields. The indexing is like this: msgDigest_[ numSrcMsgs * dataIndex + srcMsgIndex ][ func# ] So we look up a vector of MsgDigests, each with a unique func, based on both the dataIndex and the message number. This is designed so that if we expand the number of data entries we don't have to redo the ordering.

Definition at line 437 of file Element.h.

Referenced by clearAllMsgs(), digestMessages(), msgDigest(), printMsgDigest(), putOffNodeTargetsInDigest(), and putTargetsInDigest().

string Element::name_
private

Definition at line 399 of file Element.h.

Referenced by digestMessages(), getName(), setName(), and showMsg().

int Element::tick_
private

Returns tick on which element is scheduled. -1 for disabled.

Definition at line 440 of file Element.h.

Referenced by getTick(), innerSetTick(), setTick(), and zombieSwap().


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