MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ShellCopy.cpp File Reference
#include "header.h"
#include "OneToAllMsg.h"
#include "Shell.h"
#include "../scheduling/Clock.h"
+ Include dependency graph for ShellCopy.cpp:

Go to the source code of this file.

Functions

ElementinnerCopyElements (Id orig, ObjId newParent, Id newId, unsigned int n, bool toGlobal, map< Id, Id > &tree)
 
void innerCopyMsgs (map< Id, Id > &tree, unsigned int n, bool copyExtMsgs)
 

Function Documentation

Element* innerCopyElements ( Id  orig,
ObjId  newParent,
Id  newId,
unsigned int  n,
bool  toGlobal,
map< Id, Id > &  tree 
)

Runs in parallel on all nodes. Note that 'n' is the number of complete duplicates. If there were 10 dataEntries in the original, there will now be 10 x n.

Definition at line 62 of file ShellCopy.cpp.

References Shell::adopt(), Neutral::children(), Element::cinfo(), Element::copyElement(), ObjId::dataIndex, Id::element(), Id::eref(), Element::id(), Clock::lookupDefaultTick(), Cinfo::name(), Id::nextId(), Element::numData(), Neutral::parent(), and Element::setTick().

Referenced by Shell::innerCopy().

64 {
65  // Element* e = new Element( newId, orig.element(), n, toGlobal );
66  unsigned int newNumData = orig.element()->numData() * n;
67  Element* e = orig.element()->copyElement(
68  newParent, newId, newNumData, toGlobal );
69  assert( e );
70  Shell::adopt( newParent, newId, 0 );
71  e->setTick( Clock::lookupDefaultTick( e->cinfo()->name() ) );
72 
73  // cout << Shell::myNode() << ": Copy: orig= " << orig << ", newParent = " << newParent << ", newId = " << newId << endl;
74  tree[ orig ] = e->id();
75 
76  // cout << Shell::myNode() << ": ice, pa = " << newParent << ", pair= (" << orig << "," << e->id() << ")\n";
77  vector< Id > kids;
78  Neutral::children( orig.eref(), kids );
79 
80  for ( vector< Id >::iterator i = kids.begin(); i != kids.end(); ++i ) {
81  // Needed in case parent is not on zero dataIndex.
82  ObjId pa = Neutral::parent( *i );
83  ObjId newParent( e->id(), pa.dataIndex );
84  innerCopyElements( *i, newParent, Id::nextId(), n, toGlobal, tree );
85  }
86  return e;
87 }
static ObjId parent(const Eref &e)
Definition: Neutral.cpp:701
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
Definition: ObjId.h:20
Eref eref() const
Definition: Id.cpp:125
static void children(const Eref &e, vector< Id > &ret)
Definition: Neutral.cpp:342
Id id() const
Definition: Element.cpp:71
virtual Element * copyElement(Id newParent, Id newId, unsigned int n, bool toGlobal) const =0
const std::string & name() const
Definition: Cinfo.cpp:260
static Id nextId()
Definition: Id.cpp:132
Element * innerCopyElements(Id orig, ObjId newParent, Id newId, unsigned int n, bool toGlobal, map< Id, Id > &tree)
Definition: ShellCopy.cpp:62
static unsigned int lookupDefaultTick(const string &className)
Definition: Clock.cpp:1035
const Cinfo * cinfo() const
Definition: Element.cpp:66
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
static bool adopt(ObjId parent, Id child, unsigned int msgIndex)
Definition: Shell.cpp:654
void setTick(int t)
Definition: Element.cpp:251
unsigned int dataIndex
Definition: ObjId.h:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void innerCopyMsgs ( map< Id, Id > &  tree,
unsigned int  n,
bool  copyExtMsgs 
)

Definition at line 89 of file ShellCopy.cpp.

References Msg::copy(), Msg::e1(), Msg::e2(), Cinfo::findFinfo(), SrcFinfo::getBindIndex(), Msg::getMsg(), Element::getMsgAndFunc(), Element::id(), and Neutral::initCinfo().

Referenced by Shell::innerCopy().

90 {
91  static const Finfo* cf = Neutral::initCinfo()->findFinfo( "childOut" );
92  static const SrcFinfo1< int >* cf2 =
93  dynamic_cast< const SrcFinfo1< int >* >( cf );
94  assert( cf );
95  assert( cf2 );
96 
97  /*
98  cout << endl << Shell::myNode() << ": innerCopyMsg ";
99  for ( map< Id, Id >::const_iterator i = tree.begin();
100  i != tree.end(); ++i ) {
101  cout << " (" << i->first << "," << i->second << ") ";
102  }
103  cout << endl;
104  */
105  for ( map< Id, Id >::const_iterator i = tree.begin();
106  i != tree.end(); ++i ) {
107  Element *e = i->first.element();
108  unsigned int j = 0;
109  const vector< MsgFuncBinding >* b = e->getMsgAndFunc( j );
110  while ( b ) {
111  if ( j != cf2->getBindIndex() ) {
112  for ( vector< MsgFuncBinding >::const_iterator k =
113  b->begin();
114  k != b->end(); ++k ) {
115  ObjId mid = k->mid;
116  const Msg* m = Msg::getMsg( mid );
117  assert( m );
118  /*
119  cout << endl << Shell::myNode() << ": innerCopyMsg orig = (" <<
120  e->id() << ", " << e->getName() << "), e1 = (" <<
121  m->e1()->id() << ", " << m->e1()->getName() << "), e2 = (" <<
122  m->e2()->id() << ", " << m->e2()->getName() << "), fid = " <<
123  k->fid << ", mid = " << k->mid << endl;
124  */
125  map< Id, Id >::const_iterator tgt;
126  if ( m->e1() == e ) {
127  tgt = tree.find( m->e2()->id() );
128  } else if ( m->e2() == e ) {
129  tgt = tree.find( m->e1()->id() );
130  } else {
131  assert( 0 );
132  }
133  if ( tgt != tree.end() )
134  m->copy( e->id(), i->second, tgt->second,
135  k->fid, j, n );
136  }
137  }
138  b = e->getMsgAndFunc( ++j );
139  }
140  }
141 }
Element * e2() const
Definition: Msg.h:68
BindIndex getBindIndex() const
Definition: SrcFinfo.cpp:28
Definition: ObjId.h:20
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
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59
virtual Msg * copy(Id origSrc, Id newSrc, Id newTgt, FuncId fid, unsigned int b, unsigned int n) const =0
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
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: