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

#include <OneToOneDataIndexMsg.h>

+ Inheritance diagram for OneToOneDataIndexMsg:
+ Collaboration diagram for OneToOneDataIndexMsg:

Public Member Functions

Msgcopy (Id origSrc, Id newSrc, Id newTgt, FuncId fid, unsigned int b, unsigned int n) const
 
ObjId findOtherEnd (ObjId end) const
 
Eref firstTgt (const Eref &src) const
 
Id managerId () const
 
 OneToOneDataIndexMsg (const Eref &e1, const Eref &e2, unsigned int msgIndex)
 
void sources (vector< vector< Eref > > &v) const
 
void targets (vector< vector< Eref > > &v) const
 
 ~OneToOneDataIndexMsg ()
 
- Public Member Functions inherited from Msg
Elemente1 () const
 
Elemente2 () const
 
ObjId getAdjacent (ObjId) const
 
vector< string > getDestFieldsOnE1 () const
 
vector< string > getDestFieldsOnE2 () const
 
Id getE1 () const
 
Id getE2 () const
 
vector< string > getSrcFieldsOnE1 () const
 
vector< string > getSrcFieldsOnE2 () const
 
bool isForward (const Element *src) const
 
ObjId mid () const
 
 Msg (ObjId mid, Element *e1, Element *e2)
 Constructor. More...
 
virtual ~Msg ()
 Destructor. More...
 

Static Public Member Functions

static const CinfoinitCinfo ()
 Setup function for Element-style access to Msg fields. More...
 
static char * lookupMsg (unsigned int index)
 Static function for Msg access. More...
 
static unsigned int numMsg ()
 Msg lookup functions. More...
 
- Static Public Member Functions inherited from Msg
static void clearAllMsgs ()
 
static void deleteMsg (ObjId mid)
 
static const MsggetMsg (ObjId m)
 
static const CinfoinitCinfo ()
 
static unsigned int initMsgManagers ()
 
static bool isLastTrump ()
 True when MOOSE has been terminated and is being cleaned up. More...
 
static const MsglastMsg ()
 

Static Private Attributes

static Id managerId_
 
static vector
< OneToOneDataIndexMsg * > 
msg_
 

Friends

unsigned int Msg::initMsgManagers ()
 

Additional Inherited Members

- Protected Attributes inherited from Msg
Elemente1_
 Index of this Msg on the msg_ vector. More...
 
Elemente2_
 Element 1 attached to Msg. More...
 
ObjId mid_
 
- Static Protected Attributes inherited from Msg
static bool lastTrump_ = false
 Flag to indicate termination of program. More...
 
static Id msgManagerId_
 Element 2 attached to Msg. More...
 

Detailed Description

Manages a projection where each entry in source array connects to the corresponding entry (with same index) in dest array. If there is a mismatch in number of entries, the overhang is ignored. This differs from the regular OneToOne msg because even if the dest array is a FieldElement, it still does a mapping between the DataIndex of src and dest.

Definition at line 22 of file OneToOneDataIndexMsg.h.

Constructor & Destructor Documentation

OneToOneDataIndexMsg::OneToOneDataIndexMsg ( const Eref e1,
const Eref e2,
unsigned int  msgIndex 
)

Definition at line 17 of file OneToOneDataIndexMsg.cpp.

References msg_.

Referenced by copy().

20  : Msg( ObjId( managerId_, (msgIndex != 0) ? msgIndex: msg_.size() ),
21  e1.element(), e2.element() )
22 {
23  if ( msgIndex == 0 ) {
24  msg_.push_back( this );
25  } else {
26  if ( msg_.size() <= msgIndex )
27  msg_.resize( msgIndex + 1 );
28  msg_[ msgIndex ] = this;
29  }
30 }
Definition: ObjId.h:20
Element * element() const
Definition: Eref.h:42
static vector< OneToOneDataIndexMsg * > msg_
Msg(ObjId mid, Element *e1, Element *e2)
Constructor.
Definition: Msg.cpp:30

+ Here is the caller graph for this function:

OneToOneDataIndexMsg::~OneToOneDataIndexMsg ( )

Definition at line 32 of file OneToOneDataIndexMsg.cpp.

References ObjId::dataIndex, Msg::mid_, and msg_.

33 {
34  assert( mid_.dataIndex < msg_.size() );
35  msg_[ mid_.dataIndex ] = 0; // ensure deleted ptr isn't reused.
36 }
static vector< OneToOneDataIndexMsg * > msg_
ObjId mid_
Definition: Msg.h:178
unsigned int dataIndex
Definition: ObjId.h:99

Member Function Documentation

Msg * OneToOneDataIndexMsg::copy ( Id  origSrc,
Id  newSrc,
Id  newTgt,
FuncId  fid,
unsigned int  b,
unsigned int  n 
) const
virtual

Make a copy of this Msg. The original msg was on origSrc. The new Msg should go from newSrc to newTgt, and have the function fid, on bindIndex b. The copy may have to be a higher-order Msg type to handle arrays if n > 1. Note that n is not the number of msgs, but the multiplier by which numData will be scaled.

Implements Msg.

Definition at line 94 of file OneToOneDataIndexMsg.cpp.

References Element::addMsgAndFunc(), Msg::e1(), Msg::e2(), Id::element(), Id::eref(), Msg::mid(), and OneToOneDataIndexMsg().

96 {
97  const Element* orig = origSrc.element();
98  // This works both for 1-copy and for n-copies
99  OneToOneDataIndexMsg* ret = 0;
100  if ( orig == e1() ) {
101  ret = new OneToOneDataIndexMsg( newSrc.eref(), newTgt.eref(), 0 );
102  ret->e1()->addMsgAndFunc( ret->mid(), fid, b );
103  } else if ( orig == e2() ) {
104  ret = new OneToOneDataIndexMsg( newTgt.eref(), newSrc.eref(), 0 );
105  ret->e2()->addMsgAndFunc( ret->mid(), fid, b );
106  } else
107  assert( 0 );
108  // ret->e1()->addMsgAndFunc( ret->mid(), fid, b );
109  return ret;
110 }
Element * e2() const
Definition: Msg.h:68
ObjId mid() const
Definition: Msg.h:106
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
void addMsgAndFunc(ObjId mid, FuncId fid, BindIndex bindIndex)
Definition: Element.cpp:128
Eref eref() const
Definition: Id.cpp:125
Element * e1() const
Definition: Msg.h:61
OneToOneDataIndexMsg(const Eref &e1, const Eref &e2, unsigned int msgIndex)

+ Here is the call graph for this function:

ObjId OneToOneDataIndexMsg::findOtherEnd ( ObjId  ) const
virtual

Find the other end of this Msg. In most cases this is a straightforward return of e1 or e2, plus perhaps a DataId. But in some complex msgs we need to figure out DataIds that match with the target. In many-to-one cases we just return the first entry. If no Element match, return ObjId( Id(), DataId::bad() ) If Element e matches but not DataId, return ObjId( e.id(), DataId::bad() )

Implements Msg.

Definition at line 84 of file OneToOneDataIndexMsg.cpp.

References BADINDEX, ObjId::dataIndex, Msg::e1(), Msg::e2(), ObjId::element(), and Element::id().

85 {
86  if ( f.element() == e1() )
87  return ObjId( e2()->id(), f.dataIndex );
88  else if ( f.element() == e2() )
89  return ObjId( e1()->id(), f.dataIndex );
90 
91  return ObjId( 0, BADINDEX );
92 }
Element * e2() const
Definition: Msg.h:68
Definition: ObjId.h:20
Id id() const
Definition: Element.cpp:71
Element * e1() const
Definition: Msg.h:61
const unsigned int BADINDEX
Used by ObjId and Eref.
Definition: consts.cpp:25

+ Here is the call graph for this function:

Eref OneToOneDataIndexMsg::firstTgt ( const Eref src) const
virtual

This is a little tricky because we might be mapping between data entries and field entries here. May wish also to apply to exec operations. At this point, the effect of trying to go between regular data entries and field entries is undefined.

Implements Msg.

Definition at line 45 of file OneToOneDataIndexMsg.cpp.

References Eref::dataIndex(), Msg::e1_, Msg::e2_, and Eref::element().

46 {
47  if ( src.element() == e1_ ) {
48  return Eref( e2_, src.dataIndex(), 0 );
49  } else if ( src.element() == e2_ ) {
50  return Eref( e1_, src.dataIndex() );
51  }
52  return Eref( 0, 0 );
53 }
unsigned int dataIndex() const
Definition: Eref.h:50
Element * element() const
Definition: Eref.h:42
Definition: Eref.h:26
Element * e1_
Index of this Msg on the msg_ vector.
Definition: Msg.h:180
Element * e2_
Element 1 attached to Msg.
Definition: Msg.h:181

+ Here is the call graph for this function:

const Cinfo * OneToOneDataIndexMsg::initCinfo ( )
static

Setup function for Element-style access to Msg fields.

Definition at line 129 of file OneToOneDataIndexMsg.cpp.

References Msg::initCinfo(), and msgCinfo.

Referenced by Msg::initMsgManagers().

130 {
132  // Field definitions. Nothing here.
134 
135  static Dinfo< short > dinfo;
136  static Cinfo msgCinfo (
137  "OneToOneDataIndexMsg", // name
138  Msg::initCinfo(), // base class
139  0, // Finfo array
140  0, // Num Fields
141  &dinfo
142  );
143 
144  return &msgCinfo;
145 }
Definition: Dinfo.h:60
static const Cinfo * msgCinfo
Definition: Msg.cpp:233
Definition: Cinfo.h:18
static const Cinfo * initCinfo()
Definition: Msg.cpp:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char * OneToOneDataIndexMsg::lookupMsg ( unsigned int  index)
static

Static function for Msg access.

Definition at line 119 of file OneToOneDataIndexMsg.cpp.

References msg_.

Referenced by Msg::initMsgManagers().

120 {
121  assert( index < msg_.size() );
122  return reinterpret_cast< char* >( msg_[index] );
123 }
static vector< OneToOneDataIndexMsg * > msg_

+ Here is the caller graph for this function:

Id OneToOneDataIndexMsg::managerId ( ) const

Definition at line 79 of file OneToOneDataIndexMsg.cpp.

References managerId_.

80 {
82 }
unsigned int OneToOneDataIndexMsg::numMsg ( )
static

Msg lookup functions.

Static function for Msg access.

Definition at line 113 of file OneToOneDataIndexMsg.cpp.

References msg_.

Referenced by Msg::initMsgManagers().

114 {
115  return msg_.size();
116 }
static vector< OneToOneDataIndexMsg * > msg_

+ Here is the caller graph for this function:

void OneToOneDataIndexMsg::sources ( vector< vector< Eref > > &  v) const
virtual

Return all the sources of e2 from e1, that is, all the msgs coming into specified entries on e2 from e1.

ALLDATA used when the sources include all data entries on a source. Indexing is v[dataId in range e2.numData][src list]

Implements Msg.

Definition at line 56 of file OneToOneDataIndexMsg.cpp.

References Msg::e1_, Msg::e2_, and Element::numData().

57 {
58  v.resize( 0 );
59  unsigned int n = e1_->numData();
60  if ( n > e2_->numData() )
61  n = e2_->numData();
62  v.resize( e2_->numData() );
63  for ( unsigned int i = 0; i < n; ++i ) {
64  v[i].resize( 1, Eref( e1_, i ) );
65  }
66 }
Definition: Eref.h:26
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
Element * e1_
Index of this Msg on the msg_ vector.
Definition: Msg.h:180
Element * e2_
Element 1 attached to Msg.
Definition: Msg.h:181

+ Here is the call graph for this function:

void OneToOneDataIndexMsg::targets ( vector< vector< Eref > > &  v) const
virtual

Return all the targets of e1 on e2, that is, all the msgs going from specified entries on e1 to e2. ALLDATA used when the targets include all data entries on a target. Indexing is v[dataId in range e1.numData][tgt list]

Implements Msg.

Definition at line 68 of file OneToOneDataIndexMsg.cpp.

References Msg::e1_, Msg::e2_, and Element::numData().

69 {
70  unsigned int n = e1_->numData();
71  v.resize( e1_->numData() );
72  if ( n > e2_->numData() )
73  n = e2_->numData();
74  for ( unsigned int i = 0; i < n; ++i ) {
75  v[i].resize( 1, Eref( e2_, i ) );
76  }
77 }
Definition: Eref.h:26
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
Element * e1_
Index of this Msg on the msg_ vector.
Definition: Msg.h:180
Element * e2_
Element 1 attached to Msg.
Definition: Msg.h:181

+ Here is the call graph for this function:

Friends And Related Function Documentation

unsigned int Msg::initMsgManagers ( )
friend

Member Data Documentation

Id OneToOneDataIndexMsg::managerId_
staticprivate

Definition at line 48 of file OneToOneDataIndexMsg.h.

Referenced by Msg::initMsgManagers(), and managerId().

vector< OneToOneDataIndexMsg * > OneToOneDataIndexMsg::msg_
staticprivate

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