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

#include <Shell.h>

+ Collaboration diagram for Shell:

Public Member Functions

void addClockMsgs (const vector< ObjId > &list, const string &field, unsigned int tick, unsigned int msgIndex)
 
void destroy (const Eref &e, ObjId oid)
 
ObjId doAddMsg (const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
 
Id doCopy (Id orig, ObjId newParent, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
 Returns the Id of the root of the copied tree upon success. More...
 
Id doCreate (string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
 
bool doDelete (ObjId oid)
 
ObjId doFind (const string &path) const
 
Id doLoadModel (const string &fname, const string &modelpath, const string &solverClass="")
 Returns the Id of the loaded model. More...
 
void doMove (Id orig, ObjId newParent)
 
void doNonBlockingStart (double runtime)
 
void doQuit ()
 
void doReacDiffMesh (Id baseCompartment)
 
void doReinit ()
 
void doSaveModel (Id model, const string &fileName, bool qflag=0) const
 
void doSetClock (unsigned int tickNum, double dt)
 
void doSetParserIdleFlag (bool isParserIdle)
 
void doStart (double runtime, bool notify=false)
 
void doStop ()
 
void doSyncDataHandler (Id tgt)
 
void doTerminate ()
 
void doUseClock (string path, string field, unsigned int tick)
 
string doVersion ()
 
void error (const string &text)
 
void expectVector (bool flag)
 
ObjId getCwe () const
 
const ProcInfogetProcInfo (unsigned int index) const
 
void handleAck (unsigned int ackNode, unsigned int status)
 
void handleAddMsg (const Eref &e, string msgType, ObjId src, string srcField, ObjId dest, string destField, unsigned int msgIndex)
 
void handleCopy (const Eref &e, vector< ObjId > args, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
 
void handleCreate (const Eref &e, string type, ObjId parent, Id newElm, string name, NodeBalance nb, unsigned int parentMsgIndex)
 
void handleMove (const Eref &e, Id orig, ObjId newParent)
 
void handleQuit ()
 This function is NOT called when simulation ends normally. More...
 
void handleSync (const Eref &e, Id elm, FuncId fid)
 
void handleUseClock (const Eref &e, string path, string field, unsigned int tick, unsigned int msgIndex)
 
void initAck ()
 
const MsginnerAddMsg (string msgType, ObjId src, string srcField, ObjId dest, string destField, unsigned int msgIndex)
 
bool innerCopy (const vector< ObjId > &args, const string &newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
 Does actual work of copying. Returns true on success. More...
 
void innerCreate (string type, ObjId parent, Id newElm, string name, const NodeBalance &nb, unsigned int parentMsgIndex)
 
bool innerMove (Id orig, ObjId newParent)
 
bool innerUseClock (string path, string field, unsigned int tick, unsigned int msgIndex)
 
bool isAckPending () const
 
bool isRunning () const
 
void setCwe (ObjId cwe)
 
void setShellElement (Element *shelle)
 
 Shell ()
 
void start (double runTime)
 
void waitForAck ()
 
void warning (const string &text)
 
 ~Shell ()
 

Static Public Member Functions

static bool adopt (ObjId parent, Id child, unsigned int msgIndex)
 
static bool adopt (Id parent, Id child, unsigned int msgIndex)
 Adaptor for above function. Also static function. More...
 
static bool chopPath (const string &path, vector< string > &ret, vector< unsigned int > &index)
 
static bool chopString (const string &path, vector< string > &ret, char separator= '/')
 
static void cleanSimulation ()
 Clean-up MOOSE before shutting down. This function is called whenever keyboard interrupt terminates the simulation. More...
 
static void clearRestructuringQ ()
 
static void dropClockMsgs (const vector< ObjId > &list, const string &field)
 
static bool inBlockingParserCall ()
 
static const CinfoinitCinfo ()
 
static bool isNameValid (const string &name)
 
static bool isParserIdle ()
 
static bool isSingleThreaded ()
 
static bool keepLooping ()
 
static void launchParser ()
 
static void launchThreads ()
 
static void loadBalance ()
 
static unsigned int myNode ()
 
static unsigned int numCores ()
 
static unsigned int numNodes ()
 
static unsigned int numProcessThreads ()
 
static const ProcInfoprocInfo ()
 Static func for returning the ProcInfo of the shell. More...
 
static unsigned int reduceInt (unsigned int val)
 
static void setHardware (unsigned int numCores, unsigned int numNodes, unsigned int myNode)
 

Static Public Attributes

static const unsigned int ErrorStatus = ~1
 
static const unsigned int OkStatus = ~0
 

Private Attributes

ObjId cwe_
 Current working Element. More...
 
vector< double * > getBuf_
 
bool gettingVector_
 
unsigned int numGetVecReturns_
 
Elementshelle_
 

Static Private Attributes

static vector< unsigned int > acked_
 
static bool doReinit_
 
static bool isBlockedOnParser_ = 0
 
static bool isParserIdle_
 
static bool keepLooping_ = 1
 
static unsigned int myNode_
 
static unsigned int numAcks_ = 0
 
static unsigned int numCores_
 
static unsigned int numNodes_
 
static unsigned int numProcessThreads_
 
static ProcInfo p_
 
static double runtime_
 
static vector< ProcInfothreadProcs_
 

Detailed Description

Definition at line 43 of file Shell.h.

Constructor & Destructor Documentation

Shell::Shell ( )

Definition at line 152 of file Shell.cpp.

References getBuf_.

153  :
154  gettingVector_( 0 ),
155  numGetVecReturns_( 0 ),
156  cwe_( ObjId() )
157 {
158  getBuf_.resize( 1, 0 );
159 }
Definition: ObjId.h:20
ObjId cwe_
Current working Element.
Definition: Shell.h:639
vector< double * > getBuf_
Definition: Shell.h:558
bool gettingVector_
Definition: Shell.h:564
unsigned int numGetVecReturns_
Definition: Shell.h:570
Shell::~Shell ( )

Definition at line 161 of file Shell.cpp.

162 {
163  ;
164 }

Member Function Documentation

void Shell::addClockMsgs ( const vector< ObjId > &  list,
const string &  field,
unsigned int  tick,
unsigned int  msgIndex 
)

Utility function to set up messages to schedule a list of Ids using the specified field and tick

Definition at line 924 of file Shell.cpp.

References dropClockMsgs(), and innerAddMsg().

Referenced by innerUseClock().

927 {
928  if ( !Id( 1 ).element() )
929  return;
930  ObjId clockId( 1 );
931  dropClockMsgs( list, field ); // Forbid duplicate PROCESS actions.
932  for ( vector< ObjId >::const_iterator i = list.begin();
933  i != list.end(); ++i )
934  {
935  if ( i->element() )
936  {
937  stringstream ss;
938  ss << "proc" << tick;
939  const Msg* m = innerAddMsg( "OneToAll",
940  clockId, ss.str(),
941  *i, field, msgIndex++ );
942  if ( m )
943  i->element()->innerSetTick( tick );
944  }
945  }
946 }
const Msg * innerAddMsg(string msgType, ObjId src, string srcField, ObjId dest, string destField, unsigned int msgIndex)
Definition: Shell.cpp:759
Definition: ObjId.h:20
Definition: Msg.h:18
static void dropClockMsgs(const vector< ObjId > &list, const string &field)
Definition: Shell.cpp:886
Definition: Id.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Shell::adopt ( ObjId  parent,
Id  child,
unsigned int  msgIndex 
)
static

Static utility function. Attaches child element to parent element. Must only be called from functions executing in parallel on all nodes, as it does a local message addition MsgIndex is needed to be sure that the same msg identifies parent-child connection on all nodes.

Definition at line 654 of file Shell.cpp.

References Finfo::addMsg(), ObjId::element(), Id::element(), ObjId::eref(), Cinfo::findFinfo(), Element::getName(), Neutral::initCinfo(), and Msg::mid().

Referenced by adopt(), buildFinfoElement(), init(), Msg::initMsgManagers(), innerCopyElements(), innerCreate(), Cinfo::makeCinfoElements(), testSetGetExtField(), and testStrSet().

655 {
656  static const Finfo* pf = Neutral::initCinfo()->findFinfo( "parentMsg" );
657  // static const DestFinfo* pf2 = dynamic_cast< const DestFinfo* >( pf );
658  // static const FuncId pafid = pf2->getFid();
659  static const Finfo* f1 = Neutral::initCinfo()->findFinfo( "childOut" );
660 
661  assert( !( child.element() == 0 ) );
662  assert( !( child == Id() ) );
663  assert( !( parent.element() == 0 ) );
664 
665  Msg* m = new OneToAllMsg( parent.eref(), child.element(), msgIndex );
666  assert( m );
667 
668  // cout << myNode_ << ", Shell::adopt: mid = " << m->mid() << ", pa =" << parent << "." << parent()->getName() << ", kid=" << child << "." << child()->getName() << "\n";
669 
670  if ( !f1->addMsg( pf, m->mid(), parent.element() ) )
671  {
672  cout << "move: Error: unable to add parent->child msg from " <<
673  parent.element()->getName() << " to " <<
674  child.element()->getName() << "\n";
675  return 0;
676  }
677  return 1;
678 }
ObjId mid() const
Definition: Msg.h:106
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual bool addMsg(const Finfo *target, ObjId mid, Element *src) const
Definition: Finfo.h:92
Definition: Msg.h:18
Element * element() const
Definition: ObjId.cpp:124
Eref eref() const
Definition: ObjId.cpp:66
Definition: Id.h:17
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
const string & getName() const
Definition: Element.cpp:56
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:

bool Shell::adopt ( Id  parent,
Id  child,
unsigned int  msgIndex 
)
static

Adaptor for above function. Also static function.

Definition at line 681 of file Shell.cpp.

References adopt().

682 {
683  return adopt( ObjId( parent ), child, msgIndex );
684 }
Definition: ObjId.h:20
static bool adopt(ObjId parent, Id child, unsigned int msgIndex)
Definition: Shell.cpp:654

+ Here is the call graph for this function:

bool Shell::chopPath ( const string &  path,
vector< string > &  ret,
vector< unsigned int > &  index 
)
static

Chop up the path into a vector of Element names, and also fills out a matching vector of indices. If at any level of the path there are no indices or the index is zero, the index entry * remains empty. Otherwise the entry contains a vector with index values for this level of the path. The zeroth position of this index vector is the slowest varying, i.e., most significant. Returns true if it starts at '/'.

Example: /foo/bar[10]/zod[3][4][5] would return: ret: {"foo", "bar", "zod" } index: { {}, {10}, {3,4,5} }

static func.

Example: /foo/bar[10]/zod[3] would return: ret: {"foo", "bar", "zod" } index: { 0, 10, 3 }

Definition at line 512 of file Shell.cpp.

References chopString(), and extractIndex().

Referenced by doFind(), and testChopPath().

514 {
515  bool isAbsolute = chopString( path, ret, '/' );
516  if ( isAbsolute )
517  {
518  index.clear();
519  }
520  else
521  {
522  index.clear();
523  }
524  for ( unsigned int i = 0; i < ret.size(); ++i )
525  {
526  index.push_back( 0 );
527  if ( ret[i] == "." )
528  continue;
529  if ( ret[i] == ".." )
530  {
531  continue;
532  }
533  if ( !extractIndex( ret[i], index[i] ) )
534  {
535  cout << "Error: Shell::chopPath: Failed to parse indices in path '" <<
536  path << "'\n";
537  ret.resize( 0 );
538  index.resize( 0 );
539  return isAbsolute;
540  }
541  size_t pos = ret[i].find_first_of( '[' );
542  if ( ret[i].find_first_of( '[' ) != string::npos )
543  ret[i] = ret[i].substr( 0, pos );
544  }
545 
546  return isAbsolute;
547 }
static bool chopString(const string &path, vector< string > &ret, char separator= '/')
Definition: Shell.cpp:459
bool extractIndex(const string &s, unsigned int &index)
Definition: Shell.cpp:423
static char path[]
Definition: mfield.cpp:403

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Shell::chopString ( const string &  path,
vector< string > &  ret,
char  separator = '/' 
)
static

Chops up the names in the string into the vector of strings, using the specified separator. Returns true if it is an absolute path, that is, starts with the separator.

Static func to subdivide a string at the specified separator.

Definition at line 459 of file Shell.cpp.

References path.

Referenced by chopPath(), findBraceContent(), innerFind(), matchBeforeBrace(), simpleWildcardFind(), and testChopString().

461 {
462  // /foo/bar/zod
463  // foo/bar/zod
464  // ./foo/bar/zod
465  // ../foo/bar/zod
466  // .
467  // /
468  // ..
469  ret.resize( 0 );
470  if ( path.length() == 0 )
471  return 1; // Treat it as an absolute path
472 
473  bool isAbsolute = 0;
474  string temp = path;
475  if ( path[0] == separator )
476  {
477  isAbsolute = 1;
478  if ( path.length() == 1 )
479  return 1;
480  temp = temp.substr( 1 );
481  }
482 
483  string::size_type pos = temp.find_first_of( separator );
484  ret.push_back( temp.substr( 0, pos ) );
485  while ( pos != string::npos )
486  {
487  temp = temp.substr( pos + 1 );
488  if ( temp.length() == 0 )
489  break;
490  pos = temp.find_first_of( separator );
491  ret.push_back( temp.substr( 0, pos ) );
492  }
493  return isAbsolute;
494 }
static char path[]
Definition: mfield.cpp:403

+ Here is the caller graph for this function:

void Shell::cleanSimulation ( )
static

Clean-up MOOSE before shutting down. This function is called whenever keyboard interrupt terminates the simulation.

Cleans up all Elements except /root itself, /clock, /classes, and /Msgs. In due course will also do suitable reinitialization of tick and other values.

Definition at line 1015 of file Shell.cpp.

References Neutral::children(), Eref::data(), moose::debug, doDelete(), Id::eref(), moose::info, and LOG.

Referenced by handle_keyboard_interrupts().

1016 {
1017  Eref sheller = Id().eref();
1018  Shell* s = reinterpret_cast< Shell* >( sheller.data() );
1019  vector< Id > kids;
1020  Neutral::children( sheller, kids );
1021  for ( vector< Id >::iterator i = kids.begin(); i != kids.end(); ++i )
1022  {
1023  if ( i->value() > 4 ) /* These are created by users */
1024  {
1025  LOG( moose::debug
1026  , "Shell::cleanSimulation: deleted cruft at " <<
1027  i->value() << ": " << i->path());
1028  s->doDelete( *i );
1029  }
1030  }
1031  LOG( moose::info, "Cleaned up!");
1032 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
static void children(const Eref &e, vector< Id > &ret)
Definition: Neutral.cpp:342
Definition: Eref.h:26
bool doDelete(ObjId oid)
Definition: Shell.cpp:259
Definition: Id.h:17
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void Shell::clearRestructuringQ ( )
static

Works through internal queue of operations that modify the structure of the simulation. These operations have to be carefully separated from any other functions or messaging, so this happens while all other threads are blocked.

void Shell::destroy ( const Eref e,
ObjId  oid 
)

Definition at line 722 of file Shell.cpp.

References cwe_, Eref::data(), Neutral::destroy(), ObjId::eref(), and ObjId::id.

Referenced by initCinfo().

723 {
724  Neutral *n = reinterpret_cast< Neutral* >( e.data() );
725  assert( n );
726  // cout << myNode_ << ": Shell::destroy done for element id: " << eid << ", name = " << eid.element()->getName() << endl;
727  n->destroy( oid.eref(), 0 );
728  if ( cwe_.id == oid.id )
729  cwe_ = ObjId();
730 }
char * data() const
Definition: Eref.cpp:41
Id id
Definition: ObjId.h:98
Definition: ObjId.h:20
ObjId cwe_
Current working Element.
Definition: Shell.h:639
void destroy(const Eref &e, int stage)
Definition: Neutral.cpp:605
Eref eref() const
Definition: ObjId.cpp:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjId Shell::doAddMsg ( const string &  msgType,
ObjId  src,
const string &  srcField,
ObjId  dest,
const string &  destField 
)

Sets up a Message of specified type. Later need to consider doing this through MsgSpecs only. Here the 'args' vector handles whatever arguments we may need to pass to the specified msgType.

Definition at line 269 of file Shell.cpp.

References BADINDEX, Finfo::checkTarget(), Element::cinfo(), ObjId::dataIndex, Id::element(), Cinfo::findFinfo(), Cinfo::finfoMap(), Element::getName(), ObjId::id, innerAddMsg(), Msg::mid(), myNode_, and SetGet6< A1, A2, A3, A4, A5, A6 >::set().

Referenced by ReadCell::addCanonicalChannel(), ReadKkit::addmsg(), ReadCell::addSpikeGen(), addSpine(), benchmarkMsg(), ReadSwc::build(), ReadCell::buildCompartment(), ReadKkit::buildEnz(), ReadKkit::buildSumTotal(), doClassSpecificMessaging(), ReadCspace::expandEnzyme(), ReadCspace::expandReaction(), ReadKkit::innerAddMsg(), makeCompt(), ReadCspace::makePlots(), makeReacTest(), Stoich::setElist(), testAssortedMsg(), testCalcJunction(), testClock(), testCopyMsgOps(), testGetMsg(), testGetMsgs(), testMMenzProcess(), testMpiFibonacci(), testMsgElementListing(), testPoolVolumeScaling(), testReacVolumeScaling(), testShellAddMsg(), testStats(), and testTwoReacGetNeighbors().

272 {
273 
274  if ( !src.id.element() )
275  {
276  cout << myNode_ << ": Error: Shell::doAddMsg: src not found" << endl;
277  return ObjId();
278  }
279  if ( !dest.id.element() )
280  {
281  cout << myNode_ << ": Error: Shell::doAddMsg: dest not found" << endl;
282  return ObjId(0, BADINDEX );
283  }
284  const Finfo* f1 = src.id.element()->cinfo()->findFinfo( srcField );
285  if ( !f1 )
286  {
287  cout << myNode_ << ": Shell::doAddMsg: Error: Failed to find field " << srcField <<
288  " on src: " << src.id.element()->getName() << endl;
289  return ObjId(0, BADINDEX );
290  }
291  const Finfo* f2 = dest.id.element()->cinfo()->findFinfo( destField );
292  if ( !f2 )
293  {
294  cout << myNode_ << ": Shell::doAddMsg: Error: Failed to find field " << destField <<
295  " on dest: " << dest.id.element()->getName() << endl;
296  cout << "Available fields are : " << endl
297  << moose::mapToString<string, Finfo*>(dest.id.element()->cinfo()->finfoMap());
298 
299  return ObjId( 0, BADINDEX );
300  }
301  if ( ! f1->checkTarget( f2 ) )
302  {
303  cout << myNode_ << ": Shell::doAddMsg: Error: Src/Dest Msg type mismatch: " << srcField << "/" << destField << endl;
304  return ObjId( 0, BADINDEX );
305  }
306 
307  const Msg* m = innerAddMsg( msgType, src, srcField, dest, destField, 0 );
308 
310  ObjId(), // Apply command to Shell
311  "addMsg", // Function to call.
312  msgType,
313  src,
314  srcField,
315  dest,
316  destField,
317  m->mid().dataIndex
318  );
319 
320  return m->mid();
321 
322  // const Msg* m = innerAddMsg( msgType, src, srcField, dest, destField );
323  // return m->mid();
324  // return Msg::lastMsg()->mid();
325 }
ObjId mid() const
Definition: Msg.h:106
static unsigned int myNode_
Definition: Shell.h:606
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
const Msg * innerAddMsg(string msgType, ObjId src, string srcField, ObjId dest, string destField, unsigned int msgIndex)
Definition: Shell.cpp:759
Id id
Definition: ObjId.h:98
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6)
Definition: SetGet.h:818
Definition: ObjId.h:20
const map< string, Finfo * > & finfoMap() const
Definition: Cinfo.cpp:270
virtual bool checkTarget(const Finfo *target) const
Definition: Finfo.h:81
const Cinfo * cinfo() const
Definition: Element.cpp:66
Definition: Msg.h:18
const string & getName() const
Definition: Element.cpp:56
const unsigned int BADINDEX
Used by ObjId and Eref.
Definition: consts.cpp:25
const Finfo * findFinfo(const string &name) const
Definition: Cinfo.cpp:224
unsigned int dataIndex
Definition: ObjId.h:99
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Id Shell::doCopy ( Id  orig,
ObjId  newParent,
string  newName,
unsigned int  n,
bool  toGlobal,
bool  copyExtMsgs 
)

Returns the Id of the root of the copied tree upon success.

Copies orig Element to newParent. n specifies how many copies are made. copyExtMsgs specifies whether to also copy messages from orig to objects outside the copy tree. Usually we don't do this.

Definition at line 16 of file ShellCopy.cpp.

References Neutral::child(), ObjId::eref(), Neutral::isDescendant(), isNameValid(), Id::nextId(), ObjId::path(), Id::path(), and shelle_.

Referenced by ReadCell::addChannel(), addSpine(), ReadCell::buildCompartment(), buildFromProto(), testCopy(), testCopyFieldElement(), testCopyMsgOps(), and testGetMsg().

18 {
19  if ( newName.length() > 0 && !isNameValid( newName ) ) {
20  cout << "Error: Shell::doCopy: Illegal name for copy.\n";
21  return Id();
22  }
23 
24  if ( Neutral::isDescendant( newParent, orig ) ) {
25  cout << "Error: Shell::doCopy: Cannot copy object to descendant in tree\n";
26  return Id();
27  }
28  if ( n < 1 ) {
29  cout << "Warning: Shell::doCopy( " << orig.path() << " to " <<
30  newParent.path() << " ) : numCopies must be > 0, using 1 \n";
31  return Id();
32  }
33  if ( Neutral::child( newParent.eref(), newName ) != Id() ) {
34  cout << "Error: Shell::doCopy: Cannot copy object '" << newName <<
35  "' onto '" << newParent.path() <<
36  "' since object with same name already present.\n";
37  return Id();
38  }
39 
40  Eref sheller( shelle_, 0 );
41  Id newElm = Id::nextId();
42  vector< ObjId > args;
43  args.push_back( orig );
44  args.push_back( newParent );
45  args.push_back( newElm );
46  SetGet5< vector < ObjId >, string, unsigned int, bool, bool >::set(
47  ObjId(), "copy",
48  args, newName, n, toGlobal, copyExtMsg );
49  /*
50  if ( innerCopy( args, newName, n, toGlobal, copyExtMsg ) )
51  return newElm;
52  else
53  return Id();
54  */
55  return newElm;
56 }
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
static Id child(const Eref &e, const string &name)
Definition: Neutral.cpp:665
Definition: ObjId.h:20
static Id nextId()
Definition: Id.cpp:132
static bool isDescendant(Id me, Id ancestor)
Definition: Neutral.cpp:647
string path() const
Definition: ObjId.cpp:119
Definition: Eref.h:26
Eref eref() const
Definition: ObjId.cpp:66
Definition: Id.h:17
Element * shelle_
Definition: Shell.h:551
static bool isNameValid(const string &name)
Definition: Shell.cpp:499

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Id Shell::doCreate ( string  type,
ObjId  parent,
string  name,
unsigned int  numData,
NodePolicy  nodePolicy = MooseBlockBalance,
unsigned int  preferredNode = 1 
)

Create an Element. Returns its id. type: Specifies classname of Objects in Element. parent: Id of parent element name: Name to be used for identifying Element. numData: Size of array.

This is the version used by the parser. Acts as a blocking, serial-like interface to a potentially multithread, multinode call. Returns the new Id index upon success, otherwise returns Id(). The data of the new Element is not necessarily allocated at this point, that can be deferred till the global Instantiate or Reset calls. Idea is that the model should be fully defined before load balancing.

Definition at line 181 of file Shell.cpp.

References Cinfo::banCreation(), Neutral::child(), ObjId::element(), ObjId::eref(), Cinfo::find(), isNameValid(), name, Id::nextId(), OneToAllMsg::numMsg(), ObjId::path(), SetGet6< A1, A2, A3, A4, A5, A6 >::set(), moose::showWarn(), and warning().

Referenced by ReadKkit::assignPoolCompartments(), benchmarkMsg(), ReadKkit::buildChan(), ReadCell::buildCompartment(), ReadKkit::buildEnz(), ReadKkit::buildGraph(), ReadKkit::buildGroup(), ReadKkit::buildInfo(), ReadKkit::buildPlot(), ReadKkit::buildPool(), ReadKkit::buildReac(), ReadKkit::buildStim(), ReadKkit::buildSumTotal(), ReadKkit::buildTable(), doLoadModel(), ReadCspace::expandEnzyme(), ReadCspace::expandReaction(), makeCompt(), ReadCspace::makeMolecule(), ReadCspace::makePlots(), makeReacTest(), makeStandardElements(), ReadCell::read(), ReadKkit::read(), ReadCell::startGraftCell(), test_to_py(), testAssortedMsg(), testBuildStoich(), testCalcJunction(), testCellDiffn(), testChildren(), testClockMessaging(), testCopy(), testCopyFieldElement(), testCopyMsgOps(), testCylDiffn(), testCylDiffnWithStoich(), testDescendant(), testFilterOffNodeTargets(), testFindModelParent(), testGetMsg(), testGetMsgs(), testInterNodeOps(), testMMenz(), testMMenzProcess(), testMove(), testMpiFibonacci(), testMsgElementListing(), testObjIdToAndFromPath(), testPoolVolumeScaling(), testReacVolumeScaling(), testReMesh(), testRunGsolve(), testRunKsolve(), testShellAddMsg(), testShellParserCreateDelete(), testShellParserStart(), testShellSetGet(), testSmallCellDiffn(), testStats(), testSyncSynapseSize(), testTable(), testTaperingCylDiffn(), testTreeTraversal(), testTwoReacGetNeighbors(), testVolScaling(), and testWildcard().

185 {
186 
187  const Cinfo* c = Cinfo::find( type );
188  if ( !isNameValid( name ) )
189  {
190  stringstream ss;
191  ss << "Shell::doCreate: bad character in name'" << name <<
192  "'. No Element created";
193  warning( ss.str() );
194  return Id();
195  }
196 
197  if ( c )
198  {
199  if ( c->banCreation() )
200  {
201  stringstream ss;
202  ss << "Shell::doCreate: Cannot create an object of class '" <<
203  type << "' because it is an abstract base class or a FieldElement.\n";
204  warning( ss.str() );
205  return Id();
206  }
207  Element* pa = parent.element();
208  if ( !pa )
209  {
210  stringstream ss;
211  ss << "Shell::doCreate: Parent Element'" << parent << "' not found. No Element created";
212  warning( ss.str() );
213  return Id();
214  }
215 
216  // TODO: This should be an error in future.
217  // This logic of handling already existing path is now handled in
218  // melements.cpp . Calling this section should become an error in
219  // future.
220  if ( Neutral::child( parent.eref(), name ) != Id() )
221  {
222  stringstream ss;
223  ss << "Object with same path already present : " << parent.path()
224  << "/" << name;
225  moose::showWarn( ss.str() );
226  return Id();
227  }
228  // Get the new Id ahead of time and pass to all nodes.
229  Id ret = Id::nextId();
230  NodeBalance nb( numData, nodePolicy, preferredNode );
231  // Get the parent MsgIndex ahead of time and pass to all nodes.
232  unsigned int parentMsgIndex = OneToAllMsg::numMsg();
233 
235  ObjId(), // Apply command to Shell
236  "create", // Function to call.
237  type, // class of new object
238  parent, // Parent
239  ret, // id of new object
240  name, // name of new object
241  nb, // Node balance configuration
242  parentMsgIndex // Message index of child-parent msg.
243  );
244 
245  // innerCreate( type, parent, ret, name, numData, isGlobal );
246 
247  return ret;
248  }
249  else
250  {
251  stringstream ss;
252  ss << "Shell::doCreate: Class '" << type << "' not known. No Element created";
253  warning( ss.str() );
254  }
255 
256  return Id();
257 }
void warning(const string &text)
Definition: Shell.cpp:1001
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6)
Definition: SetGet.h:818
static const Cinfo * find(const std::string &name)
Definition: Cinfo.cpp:200
static Id child(const Eref &e, const string &name)
Definition: Neutral.cpp:665
Definition: ObjId.h:20
static Id nextId()
Definition: Id.cpp:132
bool banCreation() const
Definition: Cinfo.cpp:232
Element * element() const
Definition: ObjId.cpp:124
static char name[]
Definition: mfield.cpp:401
Definition: Id.h:17
void showWarn(string msg)
Definition: Cinfo.h:18
static unsigned int numMsg()
Assign the first DataId.
static bool isNameValid(const string &name)
Definition: Shell.cpp:499

+ Here is the call graph for this function:

bool Shell::doDelete ( ObjId  oid)

Delete specified Element and all its children and all Msgs connected to it. This also works for Msgs, which are also identified by an ObjId. Unlike regular objects, only the one Msg entry specified by the DataIndex part of the ObjId argument is deleted.

Definition at line 259 of file Shell.cpp.

References SetGet1< A >::set().

Referenced by addSpine(), benchmarkMsg(), cleanSimulation(), test_to_py(), testAssortedMsg(), testBuildStoich(), testCalcJunction(), testCellDiffn(), testChildren(), testClockMessaging(), testCopy(), testCopyFieldElement(), testCopyMsgOps(), testCylDiffn(), testCylDiffnWithStoich(), testDescendant(), testFilterOffNodeTargets(), testFindModelParent(), testGetMsg(), testGetMsgs(), testInterNodeOps(), testMMenz(), testMMenzProcess(), testMove(), testMsgElementListing(), testObjIdToAndFromPath(), testPoolVolumeScaling(), testReacVolumeScaling(), testReadKkit(), ReadCspace::testReadModel(), testReMesh(), testRunGsolve(), testRunKsolve(), testSetupReac(), testShellAddMsg(), testShellParserCreateDelete(), testShellSetGet(), testSmallCellDiffn(), testStats(), testSyncSynapseSize(), testTable(), testTaperingCylDiffn(), testTreeTraversal(), testTwoReacGetNeighbors(), testVolScaling(), and testWildcard().

260 {
261  SetGet1< ObjId >::set( ObjId(), "delete", oid );
262  /*
263  Neutral n;
264  n.destroy( i.eref(), 0 );
265  */
266  return true;
267 }
Definition: ObjId.h:20
static bool set(const ObjId &dest, const string &field, A arg)
Definition: SetGet.h:153

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjId Shell::doFind ( const string &  path) const

Looks up the Id specified by the given path. May include relative references and the internal cwe (current working Element) on the shell

Definition at line 549 of file Shell.cpp.

References BADINDEX, Neutral::child(), chopPath(), cwe_, ObjId::dataIndex, ObjId::element(), ObjId::eref(), ObjId::fieldIndex, Element::hasFields(), Element::numData(), and Neutral::parent().

Referenced by ReadKkit::buildChan(), ReadKkit::buildEnz(), ReadKkit::buildGraph(), ReadKkit::buildGroup(), ReadKkit::buildPlot(), ReadKkit::buildPool(), ReadKkit::buildReac(), ReadKkit::buildStim(), ReadKkit::buildTable(), Id::Id(), and testTreeTraversal().

550 {
551  if ( path == "/" || path == "/root" )
552  return ObjId();
553 
554  ObjId curr;
555  vector< string > names;
556  vector< unsigned int > indices;
557  bool isAbsolute = chopPath( path, names, indices );
558  assert( names.size() == indices.size() );
559 
560  if ( !isAbsolute )
561  curr = cwe_;
562 
563  for ( unsigned int i = 0; i < names.size(); ++i )
564  {
565  if ( names[i] == "." )
566  {
567  }
568  else if ( names[i] == ".." )
569  {
570  curr = Neutral::parent( curr.eref() );
571  }
572  else
573  {
574  ObjId pa = curr;
575  curr = Neutral::child( curr.eref(), names[i] );
576  if ( curr == ObjId() ) // Neutral::child returned Id(), ie, bad.
577  return ObjId( 0, BADINDEX );
578  if ( curr.element()->hasFields() )
579  {
580  curr.dataIndex = pa.dataIndex;
581  curr.fieldIndex = indices[i];
582  }
583  else
584  {
585  curr.dataIndex = indices[i];
586  if ( curr.element()->numData() <= curr.dataIndex )
587  return ObjId( 0, BADINDEX );
588  }
589  }
590  }
591 
592  assert( curr.element() );
593  if ( curr.element()->numData() <= curr.dataIndex )
594  return ObjId( 0, BADINDEX );
595  if ( curr.fieldIndex > 0 && !curr.element()->hasFields() )
596  return ObjId( 0, BADINDEX );
597 
598  return curr;
599 }
static ObjId parent(const Eref &e)
Definition: Neutral.cpp:701
unsigned int fieldIndex
Definition: ObjId.h:100
static Id child(const Eref &e, const string &name)
Definition: Neutral.cpp:665
Definition: ObjId.h:20
ObjId cwe_
Current working Element.
Definition: Shell.h:639
virtual bool hasFields() const =0
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
Element * element() const
Definition: ObjId.cpp:124
static bool chopPath(const string &path, vector< string > &ret, vector< unsigned int > &index)
Definition: Shell.cpp:512
Eref eref() const
Definition: ObjId.cpp:66
const unsigned int BADINDEX
Used by ObjId and Eref.
Definition: consts.cpp:25
static char path[]
Definition: mfield.cpp:403
unsigned int dataIndex
Definition: ObjId.h:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Id Shell::doLoadModel ( const string &  fname,
const string &  modelpath,
const string &  solverClass = "" 
)

Returns the Id of the loaded model.

Loads in a model to a specified path. Tries to figure out model type from fname or contents of file. Currently knows about kkit, cspace. Soon to learn .p, SBML, NeuroML. Later to learn NineML

Definition at line 132 of file LoadModels.cpp.

References ReadSwc::build(), Element::cinfo(), CSPACE, cwe_, doCreate(), DOTP, Id::element(), moose::failed, findModelParent(), findModelType(), moose::info, Cinfo::isA(), KKIT, LOG, ReadCspace::makePlots(), ReadCell::read(), ReadKkit::read(), ReadCspace::readModelString(), SWC, and UNKNOWN.

133 {
134  ifstream fin( fileName.c_str() );
135  if ( !fin )
136  {
137  LOG( moose::failed, "Shell::doLoadModel: could not open file " << fileName );
138  return Id();
139  }
140 
141  string modelName;
142  Id parentId;
143 
144  if ( !( findModelParent ( cwe_, modelPath, parentId, modelName ) ) )
145  return Id();
146 
147  string line;
148  switch ( findModelType( fileName, fin, line ) )
149  {
150  case DOTP:
151  {
152  ReadCell rc;
153  return rc.read( fileName, modelName, parentId );
154  return Id();
155  }
156  case SWC:
157  {
158  LOG( moose::info, "In doLoadModel for SWC" );
159  ReadSwc rs( fileName );
160  Id model = parentId;
161  if ( !parentId.element()->cinfo()->isA( "Neuron" ) )
162  {
163  model = doCreate( "Neuron", parentId, modelName, 1 );
164  }
165  rs.build( model, 0.5e-3, 1.0, 1.0, 0.01 );
166  return model;
167  }
168  case KKIT:
169  {
170  string sc = solverClass;
171  ReadKkit rk;
172  Id ret = rk.read( fileName, modelName, parentId, sc);
173  return ret;
174  }
175  break;
176  case CSPACE:
177  {
178  string sc = solverClass;
179  ReadCspace rc;
180  Id ret = rc.readModelString( line, modelName, parentId, sc);
181  rc.makePlots( 1.0 );
182  return ret;
183  }
184  case UNKNOWN:
185  default:
186  cout << "Error: Shell::doLoadModel: File type of '" <<
187  fileName << "' is unknown\n";
188  }
189  return Id();
190 }
bool findModelParent(Id cwe, const string &path, Id &parentId, string &modelName)
Definition: LoadModels.cpp:81
ModelType findModelType(string filename, ifstream &fin, string &line)
Definition: LoadModels.cpp:24
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
ObjId cwe_
Current working Element.
Definition: Shell.h:639
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Definition: Shell.cpp:181
Id readModelString(const string &model, const string &modelname, Id pa, const string &solverClass)
Definition: ReadCspace.cpp:86
Id read(const string &filename, const string &cellname, Id parent)
Definition: ReadCell.cpp:108
Definition: LoadModels.h:18
bool isA(const string &ancestor) const
Definition: Cinfo.cpp:280
void makePlots(double plotdt)
Definition: ReadCspace.cpp:139
const Cinfo * cinfo() const
Definition: Element.cpp:66
Id read(const string &filename, const string &cellname, Id parent, const string &solverClass="Stoich")
Definition: ReadKkit.cpp:276
Definition: Id.h:17

+ Here is the call graph for this function:

void Shell::doMove ( Id  orig,
ObjId  newParent 
)

shifts orig Element (including offspring) to newParent. All old hierarchy, data, Msgs etc are preserved below the orig.

Definition at line 390 of file Shell.cpp.

References Neutral::child(), ObjId::element(), Id::element(), ObjId::eref(), Element::getName(), Neutral::isDescendant(), name, ObjId::path(), SetGet2< A1, A2 >::set(), and warning().

Referenced by addSpine(), ReadKkit::assignPoolCompartments(), ReadKkit::assignReacCompartments(), testMove(), and testObjIdToAndFromPath().

391 {
392  if ( orig == Id() )
393  {
394  cout << "Error: Shell::doMove: Cannot move root Element\n";
395  return;
396  }
397 
398  if ( newParent.element() == 0 )
399  {
400  cout << "Error: Shell::doMove: Cannot move object to null parent \n";
401  return;
402  }
403  if ( Neutral::isDescendant( newParent, orig ) )
404  {
405  cout << "Error: Shell::doMove: Cannot move object to descendant in tree\n";
406  return;
407 
408  }
409  const string& name = orig.element()->getName();
410  if ( Neutral::child( newParent.eref(), name ) != Id() )
411  {
412  stringstream ss;
413  ss << "Shell::doMove: Object with same name already present: '"
414  << newParent.path() << "/" << name << "'. Move failed.";
415  warning( ss.str() );
416  return;
417  }
418 
419  SetGet2< Id, ObjId >::set( ObjId(), "move", orig, newParent );
420  // innerMove( orig, newParent );
421 }
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
void warning(const string &text)
Definition: Shell.cpp:1001
static Id child(const Eref &e, const string &name)
Definition: Neutral.cpp:665
Definition: ObjId.h:20
static bool isDescendant(Id me, Id ancestor)
Definition: Neutral.cpp:647
string path() const
Definition: ObjId.cpp:119
Element * element() const
Definition: ObjId.cpp:124
static char name[]
Definition: mfield.cpp:401
Eref eref() const
Definition: ObjId.cpp:66
Definition: Id.h:17
const string & getName() const
Definition: Element.cpp:56
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2)
Definition: SetGet.h:365

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::doNonBlockingStart ( double  runtime)

Starts off simulation, to run for 'runtime' more than current time. This version returns at once, and the parser can go on to do other things. It has to check with the Shell::isRunning function (accessible as a MOOSE field) to find out if it is finished. Can call 'doStop', 'doTerminate' or 'doReinit' at any time to stop the run with increasing levels of prejudice.

void Shell::doQuit ( )

Cleanly quits simulation, wrapping up all nodes and threads.

Definition at line 327 of file Shell.cpp.

References SetGet0::set().

Referenced by launchParser(), main(), and testShellParserQuit().

328 {
329  SetGet0::set( ObjId(), "quit" );
330 }
Definition: ObjId.h:20
static bool set(const ObjId &dest, const string &field)
Definition: SetGet.h:103

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::doReacDiffMesh ( Id  baseCompartment)

This function builds a reac-diffusion mesh starting at the specified ChemCompt, which houses MeshEntry FieldElements. Assumes that the dimensions of the baseCompartment have just been redefined, and we now need to go through and update the child reaction system.

void Shell::doReinit ( )

Reinitializes simulation: time goes to zero, all scheduled objects are set to initial conditions. If simulation is already running, first stops it.

Definition at line 362 of file Shell.cpp.

References SetGet0::set().

Referenced by benchmarkMsg(), ReadKkit::read(), ReadKkit::run(), testCalcJunction(), testCellDiffn(), testCopyMsgOps(), testCylDiffn(), testCylDiffnWithStoich(), testGetMsg(), testMMenzProcess(), testRunGsolve(), testRunKsolve(), testSetupReac(), testSmallCellDiffn(), testStats(), and testTaperingCylDiffn().

363 {
364 
365  Id clockId( 1 );
366  SetGet0::set( clockId, "reinit" );
367 
368 }
static bool set(const ObjId &dest, const string &field)
Definition: SetGet.h:103
Definition: Id.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::doSaveModel ( Id  model,
const string &  fileName,
bool  qFlag = 0 
) const

Saves specified model to specified file, using filetype identified by filename extension. Currently known filetypes are: .g: Kkit model

Still to come: .p: GENESIS neuron morphology and channel spec file .sbml: SBML file .nml: NeuroML file .9ml: NineML file .snml: SigNeurML

Saves specified model to specified file, using filetype identified by filename extension. Currently known filetypes are: .g: Kkit model .cspace: cspace model

Still to come: .p: GENESIS neuron morphology and channel spec file .sbml: SBML file .nml: NeuroML file .9ml: NineML file .snml: SigNeurML

Definition at line 31 of file SaveModels.cpp.

References writeKkit().

33 {
34  // string modelFamily = Field< string >::get( model, "modelFamily" );
35  // if ( modelFamily != "kinetic" ) {
36  // cout << "Warning: Shell::doSaveModel: Do not know how to save "
37  // "model of family '" << modelFamily << "'.\n";
38  // return;
39  // }
40 
41  size_t pos = fileName.find( "." );
42  string fileType = fileName.substr( pos );
43 
44  if ( fileType == ".g" ) { // kkit model requested.
45  // cout << "Cannot write kkit model at this point\n";
46  writeKkit( model, fileName );
47  } else if (fileType == ".cspace"){
48  // writeCspace( model, fileName );
49  cout << "Cannot write cspace model at this point\n";
50  } else {
51  cout << "Warning: Shell::doSaveModel: Do not know how to save "
52  "model of file type '" << fileType << "'.\n";
53  }
54 }
void writeKkit(Id model, const string &fname)
Definition: WriteKkit.cpp:525

+ Here is the call graph for this function:

void Shell::doSetClock ( unsigned int  tickNum,
double  dt 
)

Definition at line 377 of file Shell.cpp.

References LookupField< L, A >::set().

Referenced by benchmarkMsg(), getShell(), initCinfo(), main(), makeReacTest(), ReadKkit::run(), setMethod(), testCalcJunction(), testCellDiffn(), testCopyMsgOps(), testCylDiffn(), testCylDiffnWithStoich(), testFibonacci(), testGetMsg(), testMMenzProcess(), testMpiFibonacci(), testRunGsolve(), testRunKsolve(), testShellAddMsg(), testShellParserStart(), testSmallCellDiffn(), testStats(), and testTaperingCylDiffn().

378 {
379  LookupField< unsigned int, double >::set( ObjId( 1 ), "tickDt", tickNum, dt );
380 }
static bool set(const ObjId &dest, const string &field, L index, A arg)
Definition: SetGet.h:467
Definition: ObjId.h:20

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::doSetParserIdleFlag ( bool  isParserIdle)

This function is called by the parser to tell the ProcessLoop to wait a bit between cycles. Used when we are waiting for user input and there is no point in having the ProcessLoop go at full speed. When flag is true, then the ProcessLoop will sleep a bit, when false it will work at full speed.

void Shell::doStart ( double  runtime,
bool  notify = false 
)

Starts off simulation, to run for 'runtime' more than current time. This version is blocking, and returns only when the simulation is done. If `nofity = true' then also notify user whenever 10% of simulation is over.

Definition at line 332 of file Shell.cpp.

References Streamer::cleanUp(), SetGet2< A1, A2 >::set(), and wildcardFind().

Referenced by benchmarkMsg(), ReadKkit::run(), testCalcJunction(), testCellDiffn(), testCopyMsgOps(), testCylDiffn(), testCylDiffnWithStoich(), testFibonacci(), testGetMsg(), testMMenzProcess(), testMpiFibonacci(), testRunGsolve(), testRunKsolve(), testSetupReac(), testShellAddMsg(), testShellParserStart(), testSmallCellDiffn(), testStats(), and testTaperingCylDiffn().

333 {
334  Id clockId( 1 );
335  SetGet2< double, bool >::set( clockId, "start", runtime, notify );
336 
337  /*-----------------------------------------------------------------------------
338  * Now that simulation is over, call cleanUp function of Streamer class
339  * objects. The purpose of this is to write whatever is left in tables to
340  * the output file.
341  *-----------------------------------------------------------------------------*/
342  vector< ObjId > streamers;
343  wildcardFind( "/##[TYPE=Streamer]", streamers );
344  // LOG( moose::debug, "total streamers " << streamers.size( ) );
345  for( vector<ObjId>::const_iterator itr = streamers.begin()
346  ; itr != streamers.end(); itr++ )
347  {
348  Streamer* pStreamer = reinterpret_cast<Streamer*>( itr->data( ) );
349  pStreamer->cleanUp( );
350  }
351 }
int wildcardFind(const string &path, vector< ObjId > &ret)
Definition: Wildcard.cpp:169
void cleanUp(void)
This function is called from Shell when simulation is called to write the left-over data to streamer ...
Definition: Streamer.cpp:249
Definition: Id.h:17
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2)
Definition: SetGet.h:365

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::doStop ( )

Cleanly stops simulation, ready to take up again from where the stop occurred. Waits till current operations are done.

Definition at line 370 of file Shell.cpp.

References SetGet0::set().

371 {
372  Id clockId( 1 );
373  SetGet0::set( clockId, "stop" );
374 }
static bool set(const ObjId &dest, const string &field)
Definition: SetGet.h:103
Definition: Id.h:17

+ Here is the call graph for this function:

void Shell::doSyncDataHandler ( Id  tgt)

This function synchronizes fieldDimension on the DataHandler across nodes. Used after function calls that might alter the number of Field entries in the table.. The tgt is the FieldElement whose fieldDimension needs updating.

void Shell::doTerminate ( )

Terminate ongoing simulation, with prejudice. Uncleanly stops simulation. Things may be in a mess with different objects at different times, but it stops at once.

void Shell::doUseClock ( string  path,
string  field,
unsigned int  tick 
)

Connects up process messages from the specified Tick to the targets on the path. Does so for whole Elements, not individual entries in the Element array. The target on the path usually has the 'process' field but other options are allowed, like 'init'

Definition at line 382 of file Shell.cpp.

References OneToAllMsg::numMsg(), and SetGet4< A1, A2, A3, A4 >::set().

Referenced by benchmarkMsg(), getShell(), main(), setMethod(), testCalcJunction(), testCellDiffn(), testCopyMsgOps(), testCylDiffn(), testCylDiffnWithStoich(), testGetMsg(), testMMenzProcess(), testMpiFibonacci(), testRunGsolve(), testRunKsolve(), testShellAddMsg(), testShellParserStart(), testSmallCellDiffn(), testStats(), and testTaperingCylDiffn().

383 {
384  unsigned int msgIndex = OneToAllMsg::numMsg();
386  "useClock", path, field, tick, msgIndex );
387  // innerUseClock( path, field, tick);
388 }
Definition: ObjId.h:20
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2, A3 arg3, A4 arg4)
Definition: SetGet.h:687
static char path[]
Definition: mfield.cpp:403
static unsigned int numMsg()
Assign the first DataId.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

string Shell::doVersion ( )

Returns version number of the software.

Definition at line 605 of file Shell.cpp.

References MOOSE_VERSION.

606 {
607  return MOOSE_VERSION;
608 }
#define MOOSE_VERSION
Definition: header.h:35
void Shell::dropClockMsgs ( const vector< ObjId > &  list,
const string &  field 
)
static

Utility function to unschedule the specified elist operating on the specified field, typically 'process'

Definition at line 886 of file Shell.cpp.

References Msg::deleteMsg(), DestFinfo::getFid(), and insertSharedMsgs().

Referenced by addClockMsgs().

888 {
889  vector< ObjId > msgs; // These are the messages to delete.
890  for ( vector< ObjId >::const_iterator
891  i = list.begin(); i != list.end(); ++i )
892  {
893  // Sanity check: shouldn't try to operate on already deleted objects
894  if ( i->element() )
895  {
896  const Finfo* f = i->element()->cinfo()->findFinfo( field );
897  const DestFinfo* df = dynamic_cast< const DestFinfo *>( f );
898  if ( df )
899  {
900  FuncId fid = df->getFid();
901 
902  // These are the messages to be zapped
903  vector< ObjId > caller;
904  if ( i->element()->getInputMsgs( caller, fid ) > 0 )
905  {
906  msgs.insert( msgs.end(), caller.begin(), caller.end() );
907  }
908  }
909  else
910  {
911  insertSharedMsgs( f, i->element(), msgs );
912  }
913  }
914  }
915  // Do the unique/erase bit. My favourite example of C++ hideousity.
916  sort( msgs.begin(), msgs.end() );
917  msgs.erase( unique( msgs.begin(), msgs.end() ), msgs.end() );
918  // Delete them.
919  for( vector< ObjId >::iterator i = msgs.begin(); i != msgs.end(); ++i )
920  Msg::deleteMsg( *i );
921 }
static void deleteMsg(ObjId mid)
Definition: Msg.cpp:52
FuncId getFid() const
Definition: DestFinfo.cpp:45
void insertSharedMsgs(const Finfo *f, const Element *e, vector< ObjId > &msgs)
Definition: Shell.cpp:863
unsigned int FuncId
Definition: header.h:42
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::error ( const string &  text)

Definition at line 1006 of file Shell.cpp.

1007 {
1008  cout << "Error: Shell:: " << text << endl;
1009 }
void Shell::expectVector ( bool  flag)

set the gettingVector_ flag

ObjId Shell::getCwe ( ) const

Returns the current working Element of the Shell

Definition at line 615 of file Shell.cpp.

References cwe_.

Referenced by Neuron::buildElist(), Neuron::getExprElist(), Neuron::getExprVal(), initCinfo(), and innerFind().

616 {
617  return cwe_;
618 }
ObjId cwe_
Current working Element.
Definition: Shell.h:639

+ Here is the caller graph for this function:

const ProcInfo* Shell::getProcInfo ( unsigned int  index) const
void Shell::handleAck ( unsigned int  ackNode,
unsigned int  status 
)

Generic handler for ack msgs from various nodes. Keeps track of which nodes have responded.

void Shell::handleAddMsg ( const Eref e,
string  msgType,
ObjId  src,
string  srcField,
ObjId  dest,
string  destField,
unsigned int  msgIndex 
)

Connects src to dest on appropriate fields, with specified msgType. This wrapper function sends the ack back to the master node.

Wrapper function, that does the ack. Other functions also use the inner function to build message trees, so we don't want it to emit multiple acks.

Definition at line 738 of file Shell.cpp.

References innerAddMsg(), and myNode().

Referenced by initCinfo().

741 {
742  // Node 0 will have already called innerAddMsg to get the msgIndex
743  if ( myNode() != 0 )
744  innerAddMsg( msgType, src, srcField, dest, destField, msgIndex );
745  /*
746  if ( innerAddMsg( msgType, src, srcField, dest, destField ) )
747  ack()->send( Eref( shelle_, 0 ), Shell::myNode(), OkStatus );
748  else
749  ack()->send( Eref( shelle_, 0), Shell::myNode(), ErrorStatus );
750  */
751 }
const Msg * innerAddMsg(string msgType, ObjId src, string srcField, ObjId dest, string destField, unsigned int msgIndex)
Definition: Shell.cpp:759
static unsigned int myNode()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::handleCopy ( const Eref e,
vector< ObjId args,
string  newName,
unsigned int  n,
bool  toGlobal,
bool  copyExtMsgs 
)

Deep copy of source element to target, renaming it to newName. The Args are orig, newParent, newElm where the newElm is the Id passed in for the root of the copy. All subsequent created Elements should have successive Ids. The copy may generate an array with n entries. Normally only copies msgs within the tree, but if the flag copyExtMsgs is true then it copies external Msgs too.

Definition at line 162 of file ShellCopy.cpp.

References innerCopy().

Referenced by initCinfo().

164 {
165  if ( !innerCopy( args, newName, n, toGlobal, copyExtMsgs ) ) {
166  cout << "Error on Shell::myNode()::Shell::handleCopy for " <<
167  newName << ", " << n << endl;
168  }
169  /*
170  static const Finfo* ackf =
171  Shell::initCinfo()->findFinfo( "ack" );
172  static const SrcFinfo2< unsigned int, unsigned int >*
173  ack = dynamic_cast< const SrcFinfo2< unsigned int, unsigned int >* >( ackf );
174  assert( ackf );
175  assert( ack );
176 
177  if ( innerCopy( args, newName, n, toGlobal, copyExtMsgs ) )
178  ack->send( Eref( shelle_, 0 ), Shell::myNode(), ErrorStatus );
179  else
180  ack->send( Eref( shelle_, 0 ), Shell::myNode(), OkStatus );
181  */
182 }
bool innerCopy(const vector< ObjId > &args, const string &newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
Does actual work of copying. Returns true on success.
Definition: ShellCopy.cpp:144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::handleCreate ( const Eref e,
string  type,
ObjId  parent,
Id  newElm,
string  name,
NodeBalance  nb,
unsigned int  parentMsgIndex 
)

This function handles the message request to create an Element. This request specifies the Id of the new Element and is handled on all nodes.

In due course we also have to set up the node decomposition of the Element, but for now the num indicates the total # of array entries. This gets a bit complicated if the Element is a multidim array.

Definition at line 638 of file Shell.cpp.

References innerCreate().

Referenced by initCinfo().

641 {
642  innerCreate( type, parent, newElm, name, nb, parentMsgIndex );
643 }
static char name[]
Definition: mfield.cpp:401
void innerCreate(string type, ObjId parent, Id newElm, string name, const NodeBalance &nb, unsigned int parentMsgIndex)
Definition: Shell.cpp:690

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::handleMove ( const Eref e,
Id  orig,
ObjId  newParent 
)

Handler to move Element orig onto the newParent.

Definition at line 851 of file Shell.cpp.

References innerMove().

Referenced by initCinfo().

852 {
853 
854  innerMove( orig, newParent );
855  /*
856  if ( innerMove( orig, newParent ) )
857  ack()->send( Eref( shelle_, 0 ), Shell::myNode(), OkStatus );
858  else
859  ack()->send( Eref( shelle_, 0 ), Shell::myNode(), ErrorStatus );
860  */
861 }
bool innerMove(Id orig, ObjId newParent)
Definition: Shell.cpp:826

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::handleQuit ( )

This function is NOT called when simulation ends normally.

Wraps up operations. Doesn't quit instantly, completes the current process cycle first.

Definition at line 990 of file Shell.cpp.

References keepLooping_.

Referenced by initCinfo().

991 {
993 }
static bool keepLooping_
Definition: Shell.h:583

+ Here is the caller graph for this function:

void Shell::handleSync ( const Eref e,
Id  elm,
FuncId  fid 
)

Handles sync of DataHandler indexing across nodes

void Shell::handleUseClock ( const Eref e,
string  path,
string  field,
unsigned int  tick,
unsigned int  msgIndex 
)

Definition at line 972 of file Shell.cpp.

References innerUseClock().

Referenced by initCinfo().

974 {
975  // cout << q->getProcInfo()->threadIndexInGroup << ": in Shell::handleUseClock with path " << path << endl << flush;
976  innerUseClock( path, field, tick, msgIndex );
977  /*
978  if ( innerUseClock( path, field, tick ) )
979  ack()->send( Eref( shelle_, 0 ),
980  Shell::myNode(), OkStatus );
981  else
982  ack()->send( Eref( shelle_, 0 ),
983  Shell::myNode(), ErrorStatus );
984  */
985 }
bool innerUseClock(string path, string field, unsigned int tick, unsigned int msgIndex)
Definition: Shell.cpp:948
static char path[]
Definition: mfield.cpp:403

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Shell::inBlockingParserCall ( )
static

True when the parser is in a call which is being blocked because it requires the event loop to complete some actions.

Definition at line 86 of file ShellThreads.cpp.

References isBlockedOnParser_.

87 {
88  return isBlockedOnParser_;
89 }
static bool isBlockedOnParser_
Definition: Shell.h:577
void Shell::initAck ( )

Initialize acks. This call should be done before the 'send' goes out, because with the wonders of threading we might get a response to the 'send' before this call is executed. This MUST be followed by a waitForAck call.

const Cinfo * Shell::initCinfo ( )
static

Definition at line 46 of file Shell.cpp.

References destroy(), doSetClock(), getCwe(), handleAddMsg(), handleCopy(), handleCreate(), handleMove(), handleQuit(), handleUseClock(), Neutral::initCinfo(), SimpleLogger::initializationTime, isRunning(), logger, setCwe(), and shellCinfo.

Referenced by init().

47 {
48 
50 // Value Finfos
53  "isRunning",
54  "Flag: Checks if simulation is in progress",
56 
57  static ValueFinfo< Shell, ObjId > cwe(
58  "cwe",
59  "Current working Element",
61  &Shell::getCwe );
62 
64 // Dest Finfos: Functions handled by Shell
66  static DestFinfo handleUseClock( "useClock",
67  "Deals with assignment of path to a given clock."
68  " Arguments: path, field, tick number. ",
71  );
72  static DestFinfo handleCreate( "create",
73  "create( class, parent, newElm, name, numData, isGlobal )",
75 
76  static DestFinfo handleDelete( "delete",
77  "When applied to a regular object, this function operates "
78  "on the Id (element) specified by the ObjId argument. "
79  "The function deletes the entire object "
80  "array on this Id, including all dataEntries on it,"
81  "all its messages, and all its children. The DataIndex here "
82  "is ignored, and all dataEntries are destroyed. \n"
83  "When applied to a message: Destroys only that one specific "
84  "message identified by the full ObjId. \n"
85  "Args: ObjId\n",
87 
88  static DestFinfo handleAddMsg( "addMsg",
89  "Makes a msg. Arguments are:"
90  " msgtype, src object, src field, dest object, dest field",
92  ( & Shell::handleAddMsg ) );
93  static DestFinfo handleQuit( "quit",
94  "Stops simulation running and quits the simulator",
96  static DestFinfo handleMove( "move",
97  "handleMove( Id orig, Id newParent ): "
98  "moves an Element to a new parent",
100  static DestFinfo handleCopy( "copy",
101  "handleCopy( vector< Id > args, string newName, unsigned int nCopies, bool toGlobal, bool copyExtMsgs ): "
102  " The vector< Id > has Id orig, Id newParent, Id newElm. "
103  "This function copies an Element and all its children to a new parent."
104  " May also expand out the original into nCopies copies."
105  " Normally all messages within the copy tree are also copied. "
106  " If the flag copyExtMsgs is true, then all msgs going out are also copied.",
107  new EpFunc5< Shell, vector< ObjId >, string, unsigned int, bool, bool >(
108  & Shell::handleCopy ) );
109 
110  static DestFinfo setclock( "setclock",
111  "Assigns clock ticks. Args: tick#, dt",
113 
114  static Finfo* shellFinfos[] =
115  {
116  &setclock,
118 // Shared msg
120  // &master,
121  // &worker,
122  &handleCreate,
123  &handleDelete,
124  &handleCopy,
125  &handleMove,
126  &handleAddMsg,
127  &handleQuit,
129  };
130 
131  static Dinfo< Shell > d;
132  static Cinfo shellCinfo (
133  "Shell",
135  shellFinfos,
136  sizeof( shellFinfos ) / sizeof( Finfo* ),
137  &d
138  //new Dinfo< Shell >()
139  );
140 
141 #ifdef ENABLE_LOGGER
142  float time = (float(clock() - t)/CLOCKS_PER_SEC);
143  logger.initializationTime.push_back( time );
144 #endif
145 
146  return &shellCinfo;
147 }
void handleCreate(const Eref &e, string type, ObjId parent, Id newElm, string name, NodeBalance nb, unsigned int parentMsgIndex)
Definition: Shell.cpp:638
void doSetClock(unsigned int tickNum, double dt)
Definition: Shell.cpp:377
Definition: Dinfo.h:60
void handleUseClock(const Eref &e, string path, string field, unsigned int tick, unsigned int msgIndex)
Definition: Shell.cpp:972
void handleMove(const Eref &e, Id orig, ObjId newParent)
Definition: Shell.cpp:851
Definition: EpFunc.h:64
static const Cinfo * shellCinfo
Definition: Shell.cpp:149
ObjId getCwe() const
Definition: Shell.cpp:615
void handleCopy(const Eref &e, vector< ObjId > args, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
Definition: ShellCopy.cpp:162
Definition: OpFunc.h:40
void destroy(const Eref &e, ObjId oid)
Definition: Shell.cpp:722
SimpleLogger logger
void setCwe(ObjId cwe)
Definition: Shell.cpp:610
bool isRunning() const
Definition: Shell.cpp:620
vector< float > initializationTime
Definition: OpFunc.h:13
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
Definition: Cinfo.h:18
void handleQuit()
This function is NOT called when simulation ends normally.
Definition: Shell.cpp:990
Definition: EpFunc.h:79
Definition: Shell.h:43
void handleAddMsg(const Eref &e, string msgType, ObjId src, string srcField, ObjId dest, string destField, unsigned int msgIndex)
Definition: Shell.cpp:738
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Msg * Shell::innerAddMsg ( string  msgType,
ObjId  src,
string  srcField,
ObjId  dest,
string  destField,
unsigned int  msgIndex 
)

Connects src to dest on appropriate fields, with specified msgType. This inner function does NOT send an ack. Returns true on success

The actual function that adds messages. Does NOT send an ack. The msgIndex specifies the index on which to place this message. If the value is zero it does an automatic placement. Returns zero on failure.

Definition at line 759 of file Shell.cpp.

References Finfo::addMsg(), Finfo::checkTarget(), Element::cinfo(), Id::element(), ObjId::eref(), Cinfo::findFinfo(), Element::getName(), ObjId::id, and myNode_.

Referenced by addClockMsgs(), doAddMsg(), and handleAddMsg().

762 {
763  /*
764  cout << myNode_ << ", Shell::handleAddMsg: " <<
765  msgType << ", " << mid <<
766  ", src =" << src << "." << srcField <<
767  ", dest =" << dest << "." << destField << "\n";
768  */
769  const Finfo* f1 = src.id.element()->cinfo()->findFinfo( srcField );
770  if ( f1 == 0 ) return 0;
771  const Finfo* f2 = dest.id.element()->cinfo()->findFinfo( destField );
772  if ( f2 == 0 ) return 0;
773 
774  // Should have been done before msgs request went out.
775  assert( f1->checkTarget( f2 ) );
776 
777  Msg *m = 0;
778  if ( msgType == "diagonal" || msgType == "Diagonal" )
779  {
780  m = new DiagonalMsg( src.id.element(), dest.id.element(),
781  msgIndex );
782  }
783  else if ( msgType == "sparse" || msgType == "Sparse" )
784  {
785  m = new SparseMsg( src.id.element(), dest.id.element(), msgIndex );
786  }
787  else if ( msgType == "Single" || msgType == "single" )
788  {
789  m = new SingleMsg( src.eref(), dest.eref(), msgIndex );
790  }
791  else if ( msgType == "OneToAll" || msgType == "oneToAll" )
792  {
793  m = new OneToAllMsg( src.eref(), dest.id.element(), msgIndex );
794  }
795  else if ( msgType == "AllToOne" || msgType == "allToOne" )
796  {
797  m = new OneToAllMsg( dest.eref(), src.id.element(), msgIndex ); // Little hack.
798  }
799  else if ( msgType == "OneToOne" || msgType == "oneToOne" )
800  {
801  m = new OneToOneMsg( src.eref(), dest.eref(), msgIndex );
802  }
803  else
804  {
805  cout << myNode_ <<
806  ": Error: Shell::handleAddMsg: msgType not known: "
807  << msgType << endl;
808  return m;
809  }
810  if ( m )
811  {
812  if ( f1->addMsg( f2, m->mid(), src.id.element() ) )
813  {
814  return m;
815  }
816  delete m;
817  m = 0;
818  }
819  cout << myNode_ <<
820  ": Error: Shell::handleAddMsg: Unable to make/connect Msg: "
821  << msgType << " from " << src.id.element()->getName() <<
822  " to " << dest.id.element()->getName() << endl;
823  return m;
824 }
static unsigned int myNode_
Definition: Shell.h:606
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
Id id
Definition: ObjId.h:98
virtual bool checkTarget(const Finfo *target) const
Definition: Finfo.h:81
virtual bool addMsg(const Finfo *target, ObjId mid, Element *src) const
Definition: Finfo.h:92
const Cinfo * cinfo() const
Definition: Element.cpp:66
Definition: Msg.h:18
Eref eref() const
Definition: ObjId.cpp:66
const string & getName() const
Definition: Element.cpp:56
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:

bool Shell::innerCopy ( const vector< ObjId > &  args,
const string &  newName,
unsigned int  n,
bool  toGlobal,
bool  copyExtMsgs 
)

Does actual work of copying. Returns true on success.

Definition at line 144 of file ShellCopy.cpp.

References innerCopyElements(), and innerCopyMsgs().

Referenced by handleCopy().

146 {
147  map< Id, Id > tree;
148  // args are orig, newParent, newElm.
149  assert( args.size() == 3 );
150  Element* e = innerCopyElements( args[0], args[1], args[2],
151  n, toGlobal, tree );
152  if ( !e ) {
153  return 0;
154  }
155  if ( newName != "" )
156  e->setName( newName );
157  //innerCopyData( orig, newParent );
158  innerCopyMsgs( tree, n, copyExtMsgs );
159  return 1;
160 }
void innerCopyMsgs(map< Id, Id > &tree, unsigned int n, bool copyExtMsgs)
Definition: ShellCopy.cpp:89
Element * innerCopyElements(Id orig, ObjId newParent, Id newId, unsigned int n, bool toGlobal, map< Id, Id > &tree)
Definition: ShellCopy.cpp:62

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::innerCreate ( string  type,
ObjId  parent,
Id  newElm,
string  name,
const NodeBalance nb,
unsigned int  msgIndex 
)

Function that does the actual work of creating a new Element. The Class of the Moose objects formed is specified by type. The NodeBalance specifies how many entries and how they are distributed across nodes. The parentMsgIndex specifies the index for the parent-child message.

This function actually creates the object. Runs on all nodes. Assumes we've already done all the argument checking.

Definition at line 690 of file Shell.cpp.

References adopt(), Cinfo::find(), Clock::lookupDefaultTick(), MooseBlockBalance, MooseGlobal, MooseSingleNode, Cinfo::name(), NodeBalance::numData, NodeBalance::policy, and Element::setTick().

Referenced by handleCreate(), and Cell::setupSolver().

693 {
694  const Cinfo* c = Cinfo::find( type );
695  if ( c )
696  {
697  Element* ret = 0;
698  switch ( nb.policy )
699  {
700  case MooseGlobal:
701  ret = new GlobalDataElement( newElm, c, name, nb.numData );
702  break;
703  case MooseBlockBalance:
704  ret = new LocalDataElement( newElm, c, name, nb.numData );
705  break;
706  case MooseSingleNode:
707  cout << "Error: Shell::innerCreate: Yet to implement SingleNodeDataElement. Making BlockBalance.\n";
708  ret = new LocalDataElement( newElm, c, name, nb.numData );
709  // ret = new SingleNodeDataElement( newElm, c, name, numData, nb.preferredNode );
710  break;
711  };
712  assert( ret );
713  adopt( parent, newElm, msgIndex );
714  ret->setTick( Clock::lookupDefaultTick( c->name() ) );
715  }
716  else
717  {
718  assert( 0 );
719  }
720 }
NodePolicy policy
Definition: Shell.h:39
static const Cinfo * find(const std::string &name)
Definition: Cinfo.cpp:200
const std::string & name() const
Definition: Cinfo.cpp:260
unsigned int numData
Definition: Shell.h:38
static unsigned int lookupDefaultTick(const string &className)
Definition: Clock.cpp:1035
static char name[]
Definition: mfield.cpp:401
static bool adopt(ObjId parent, Id child, unsigned int msgIndex)
Definition: Shell.cpp:654
void setTick(int t)
Definition: Element.cpp:251
Definition: Cinfo.h:18

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Shell::innerMove ( Id  orig,
ObjId  newParent 
)

Moves Element orig onto the newParent.

Definition at line 826 of file Shell.cpp.

References Finfo::addMsg(), Msg::deleteMsg(), ObjId::element(), Id::element(), ObjId::eref(), Element::findCaller(), Cinfo::findFinfo(), DestFinfo::getFid(), Element::getName(), Neutral::initCinfo(), and Msg::mid().

Referenced by handleMove().

827 {
828  static const Finfo* pf = Neutral::initCinfo()->findFinfo( "parentMsg" );
829  static const DestFinfo* pf2 = dynamic_cast< const DestFinfo* >( pf );
830  static const FuncId pafid = pf2->getFid();
831  static const Finfo* f1 = Neutral::initCinfo()->findFinfo( "childOut" );
832 
833  assert( !( orig == Id() ) );
834  assert( !( newParent.element() == 0 ) );
835 
836  ObjId mid = orig.element()->findCaller( pafid );
837  Msg::deleteMsg( mid );
838 
839  Msg* m = new OneToAllMsg( newParent.eref(), orig.element(), 0 );
840  assert( m );
841  if ( !f1->addMsg( pf, m->mid(), newParent.element() ) )
842  {
843  cout << "move: Error: unable to add parent->child msg from " <<
844  newParent.element()->getName() << " to " <<
845  orig.element()->getName() << "\n";
846  return 0;
847  }
848  return 1;
849 }
ObjId mid() const
Definition: Msg.h:106
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
Definition: ObjId.h:20
static void deleteMsg(ObjId mid)
Definition: Msg.cpp:52
ObjId findCaller(FuncId fid) const
Definition: Element.cpp:350
virtual bool addMsg(const Finfo *target, ObjId mid, Element *src) const
Definition: Finfo.h:92
FuncId getFid() const
Definition: DestFinfo.cpp:45
Definition: Msg.h:18
Element * element() const
Definition: ObjId.cpp:124
Eref eref() const
Definition: ObjId.cpp:66
Definition: Id.h:17
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
unsigned int FuncId
Definition: header.h:42
const string & getName() const
Definition: Element.cpp:56
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:

bool Shell::innerUseClock ( string  path,
string  field,
unsigned int  tick,
unsigned int  msgIndex 
)

Sets up scheduling for elements on the path.

Definition at line 948 of file Shell.cpp.

References addClockMsgs(), and wildcardFind().

Referenced by handleUseClock().

950 {
951  vector< ObjId > list;
952  wildcardFind( path, list ); // By default scans only Elements.
953  if ( list.size() == 0 )
954  {
955  // cout << "Warning: Shell::innerUseClock: no Elements found on path " << path << endl;
956  return 0;
957  }
958  // string tickField = "proc";
959  // Hack to get around a common error.
960  if ( field.substr( 0, 4 ) == "proc" || field.substr( 0, 4 ) == "Proc" )
961  field = "proc";
962  if ( field.substr( 0, 4 ) == "init" || field.substr( 0, 4 ) == "Init" )
963  field = "init";
964 
965  addClockMsgs( list, field, tick, msgIndex );
966  for ( vector< ObjId >::iterator
967  i = list.begin(); i != list.end(); ++i )
968  i->id.element()->innerSetTick( tick );
969  return 1;
970 }
int wildcardFind(const string &path, vector< ObjId > &ret)
Definition: Wildcard.cpp:169
void addClockMsgs(const vector< ObjId > &list, const string &field, unsigned int tick, unsigned int msgIndex)
Definition: Shell.cpp:924
static char path[]
Definition: mfield.cpp:403

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Shell::isAckPending ( ) const

Test for receipt of acks from all nodes

bool Shell::isNameValid ( const string &  name)
static

Checks that the provided name is valid for an object. This returns false if it finds the reserved path chars /#[]

Static func to check if an object name is legal. True if legal.

Definition at line 499 of file Shell.cpp.

Referenced by doCopy(), doCreate(), and Neutral::setName().

500 {
501  return ( name.length() > 0 &&
502  name.find_first_of( "[] #?\"/\\" ) == string::npos );
503 }
static char name[]
Definition: mfield.cpp:401

+ Here is the caller graph for this function:

static bool Shell::isParserIdle ( )
static

Flag to indicate if the parser is idle. If so, the main ProcessLoop should also slow down to avoid pounding on the CPUs

bool Shell::isRunning ( ) const

Returns flag to indicate whether simulation is still running

Definition at line 620 of file Shell.cpp.

References Eref::data(), Id::element(), and Id::eref().

Referenced by initCinfo().

621 {
622  static Id clockId( 1 );
623  assert( clockId.element() != 0 );
624 
625  return ( reinterpret_cast< const Clock* >( clockId.eref().data() ) )->isRunning();
626 }
Definition: Id.h:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool Shell::isSingleThreaded ( )
static

True in single-threaded mode. This is a special mode of the system in which it does not start up the event loop at all, and the whole thing operates on one thread, which is ultimately under the control of the parser. Note that this is distinct from running on one core. It is possible, and even recommended, to run in multithread mode even when the system has just one core to run it on.

bool Shell::keepLooping ( )
static

True as long as the main process loop is looping

Definition at line 996 of file Shell.cpp.

References keepLooping_.

Referenced by main().

997 {
998  return keepLooping_;
999 }
static bool keepLooping_
Definition: Shell.h:583

+ Here is the caller graph for this function:

void Shell::launchParser ( )
static

Launches Parser. Blocking when the parser blocks.

Definition at line 28 of file ShellThreads.cpp.

References Eref::data(), doQuit(), and Id::eref().

Referenced by main().

29 {
30  Id shellId;
31  Shell* s = reinterpret_cast< Shell* >( shellId.eref().data() );
32  bool quit = 0;
33 
34  cout << "moose : " << flush;
35  while ( !quit ) {
36  string temp;
37  cin >> temp;
38  if ( temp == "quit" || temp == "q" ) {
39  s->doQuit();
40  quit = 1;
41  }
42  }
43  cout << "\nQuitting Moose\n" << flush;
44 }
char * data() const
Definition: Eref.cpp:41
Eref eref() const
Definition: Id.cpp:125
void doQuit()
Definition: Shell.cpp:327
Definition: Id.h:17
Definition: Shell.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void Shell::launchThreads ( )
static

This function sets up the threading for the entire system. It creates all the worker threads and the threads for handling MPI and handling shell requests.

void Shell::loadBalance ( )
static

Stub for eventual function to handle load balancing. This must be called to set up default groups.

Regular shell function that requires that the information about the hardware have been loaded in. For now the function just assigns SimGroups

Definition at line 60 of file ShellThreads.cpp.

Referenced by init().

61 {
62  // Need more info here on how to set up groups distributed over
63  // nodes. In fact this will have to be computed _after_ the
64  // simulation is loaded. Will also need quite a bit of juggling between
65  // nodes when things get really scaled up.
66  //
67  // Note that the messages have to be rebuilt after this call.
68  // Note that this function is called independently on each node.
69 }

+ Here is the caller graph for this function:

unsigned int Shell::numCores ( )
static

Definition at line 71 of file ShellThreads.cpp.

References numCores_.

Referenced by nonMpiTests(), and setHardware().

72 {
73  return numCores_;
74 }
static unsigned int numCores_
Definition: Shell.h:588

+ Here is the caller graph for this function:

static unsigned int Shell::numProcessThreads ( )
static
static const ProcInfo* Shell::procInfo ( )
static

Static func for returning the ProcInfo of the shell.

static unsigned int Shell::reduceInt ( unsigned int  val)
static

Checks for highest 'val' on all nodes

void Shell::setCwe ( ObjId  cwe)

Assigns the current working Element of the Shell

Definition at line 610 of file Shell.cpp.

References cwe_.

Referenced by Neuron::buildElist(), Neuron::getExprElist(), Neuron::getExprVal(), initCinfo(), and testTreeTraversal().

611 {
612  cwe_ = val;
613 }
ObjId cwe_
Current working Element.
Definition: Shell.h:639

+ Here is the caller graph for this function:

void Shell::setHardware ( unsigned int  numCores,
unsigned int  numNodes,
unsigned int  myNode 
)
static

Assigns the hardware availability. Assumes that each node will have the same number of cores available.

Definition at line 47 of file ShellThreads.cpp.

References acked_, myNode(), myNode_, numCores(), numCores_, numNodes(), and numNodes_.

Referenced by init(), and nonMpiTests().

49 {
52  myNode_ = myNode;
53  acked_.resize( numNodes, 0 );
54 }
static unsigned int myNode_
Definition: Shell.h:606
static unsigned int numCores()
static unsigned int numNodes_
Definition: Shell.h:601
static unsigned int numCores_
Definition: Shell.h:588
static unsigned int myNode()
static vector< unsigned int > acked_
Definition: Shell.h:622
static unsigned int numNodes()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Shell::setShellElement ( Element shelle)

Definition at line 166 of file Shell.cpp.

References shelle_.

Referenced by init().

167 {
168  shelle_ = shelle;
169 }
Element * shelle_
Definition: Shell.h:551

+ Here is the caller graph for this function:

void Shell::start ( double  runTime)

Sets of a simulation for duration runTime. Handles cases including single-thread, multithread, and multinode

void Shell::waitForAck ( )

test for completion of request. This MUST be preceded by an initAck call.

void Shell::warning ( const string &  text)

Definition at line 1001 of file Shell.cpp.

References moose::showWarn().

Referenced by doCreate(), and doMove().

1002 {
1003  moose::showWarn( text );
1004 }
void showWarn(string msg)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

vector< unsigned int > Shell::acked_
staticprivate

Definition at line 622 of file Shell.h.

Referenced by setHardware().

ObjId Shell::cwe_
private

Current working Element.

Definition at line 639 of file Shell.h.

Referenced by destroy(), doFind(), doLoadModel(), getCwe(), and setCwe().

bool Shell::doReinit_
staticprivate

Flag to tell system to reinitialize. We use this to defer the actual operation to the 'process' call for a clean reinit.

Definition at line 629 of file Shell.h.

const unsigned int Shell::ErrorStatus = ~1
static

Definition at line 493 of file Shell.h.

vector< double* > Shell::getBuf_
private

Buffer into which return values from the 'get' command are placed Only index 0 is used for any single-value 'get' call. If it was the 'getVec' command then the array is filled up

Definition at line 558 of file Shell.h.

Referenced by Shell().

bool Shell::gettingVector_
private

Flag, used by the 'get' subsystem which maintains a buffer for returned value. True when the returned value is a vector.

Definition at line 564 of file Shell.h.

bool Shell::isBlockedOnParser_ = 0
staticprivate

Flag: True when the parser thread is blocked waiting for some system call to be handled by the threading and the MPI connected nodes.

Definition at line 577 of file Shell.h.

Referenced by inBlockingParserCall().

bool Shell::isParserIdle_
staticprivate

Definition at line 636 of file Shell.h.

bool Shell::keepLooping_ = 1
staticprivate

Flag: Tells the ProcessLoop to keep on going. Should only be altered during a barrier.

Definition at line 583 of file Shell.h.

Referenced by handleQuit(), and keepLooping().

unsigned int Shell::myNode_
staticprivate

Identifier for current node

Definition at line 606 of file Shell.h.

Referenced by doAddMsg(), innerAddMsg(), myNode(), and setHardware().

unsigned int Shell::numAcks_ = 0
staticprivate

Array of threads, initialized in launchThreads.

Definition at line 621 of file Shell.h.

unsigned int Shell::numCores_
staticprivate

Number of CPU cores in system.

Definition at line 588 of file Shell.h.

Referenced by numCores(), and setHardware().

unsigned int Shell::numGetVecReturns_
private

Counter, used by the 'get' subsystem in order to keep track of number of returned values, especially for getVec.

Definition at line 570 of file Shell.h.

unsigned int Shell::numNodes_
staticprivate

Number of nodes in MPI-based system. Each node may have many threads.

Definition at line 601 of file Shell.h.

Referenced by numNodes(), and setHardware().

unsigned int Shell::numProcessThreads_
staticprivate

Number of threads dedicated to the ProcessLoop. The parser thread is the master thread. Additional threads may be created for graphics, but not now.

Definition at line 595 of file Shell.h.

const unsigned int Shell::OkStatus = ~0
static

Definition at line 492 of file Shell.h.

ProcInfo Shell::p_
staticprivate

Shell owns its own ProcInfo, has global thread/node info. Used to talk to parser and for thread specification in setup operations.

Definition at line 613 of file Shell.h.

double Shell::runtime_
staticprivate

Simulation run time

Definition at line 634 of file Shell.h.

Element* Shell::shelle_
private

Definition at line 551 of file Shell.h.

Referenced by doCopy(), and setShellElement().

vector< ProcInfo > Shell::threadProcs_
staticprivate

Definition at line 615 of file Shell.h.


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