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

#include <OneToOneMsg.h>

+ Inheritance diagram for OneToOneMsg:
+ Collaboration diagram for OneToOneMsg:

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
 
 OneToOneMsg (const Eref &e1, const Eref &e2, unsigned int msgIndex)
 
void sources (vector< vector< Eref > > &v) const
 
void targets (vector< vector< Eref > > &v) const
 
 ~OneToOneMsg ()
 
- 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 ()
 

Private Attributes

DataId i1_
 
DataId i2_
 

Static Private Attributes

static Id managerId_
 
static vector< OneToOneMsg * > 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. If the dest array is a FieldElement, then it uses its internal DataId i2_ to fill in the DataIndex for the dest. The OneToOne matching is assumed to be between DataIndex on e1 and FieldIndex on e2.

Definition at line 22 of file OneToOneMsg.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file OneToOneMsg.cpp.

References msg_.

Referenced by copy().

19  : Msg( ObjId( managerId_, (msgIndex != 0) ? msgIndex: msg_.size() ),
20  e1.element(), e2.element() ),
21  i1_( e1.dataIndex() ),
22  i2_( e2.dataIndex() )
23 {
24  if ( msgIndex == 0 ) {
25  msg_.push_back( this );
26  } else {
27  if ( msg_.size() <= msgIndex )
28  msg_.resize( msgIndex + 1 );
29  msg_[ msgIndex ] = this;
30  }
31 }
static Id managerId_
Definition: OneToOneMsg.h:50
unsigned int dataIndex() const
Definition: Eref.h:50
Definition: ObjId.h:20
Element * element() const
Definition: Eref.h:42
static vector< OneToOneMsg * > msg_
Definition: OneToOneMsg.h:51
DataId i2_
Definition: OneToOneMsg.h:49
Msg(ObjId mid, Element *e1, Element *e2)
Constructor.
Definition: Msg.cpp:30
DataId i1_
Definition: OneToOneMsg.h:48

+ Here is the caller graph for this function:

OneToOneMsg::~OneToOneMsg ( )

Definition at line 33 of file OneToOneMsg.cpp.

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

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

Member Function Documentation

Msg * OneToOneMsg::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 128 of file OneToOneMsg.cpp.

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

130 {
131  const Element* orig = origSrc.element();
132  // This works both for 1-copy and for n-copies
133  OneToOneMsg* ret = 0;
134  if ( orig == e1() ) {
135  ret = new OneToOneMsg( newSrc.eref(), newTgt.eref(), 0 );
136  ret->e1()->addMsgAndFunc( ret->mid(), fid, b );
137  } else if ( orig == e2() ) {
138  ret = new OneToOneMsg( newTgt.eref(), newSrc.eref(), 0 );
139  ret->e2()->addMsgAndFunc( ret->mid(), fid, b );
140  } else
141  assert( 0 );
142  // ret->e1()->addMsgAndFunc( ret->mid(), fid, b );
143  return ret;
144 }
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
OneToOneMsg(const Eref &e1, const Eref &e2, unsigned int msgIndex)
Definition: OneToOneMsg.cpp:17
Element * e1() const
Definition: Msg.h:61

+ Here is the call graph for this function:

ObjId OneToOneMsg::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 118 of file OneToOneMsg.cpp.

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

119 {
120  if ( f.element() == e1() )
121  return ObjId( e2()->id(), f.dataIndex );
122  else if ( f.element() == e2() )
123  return ObjId( e1()->id(), f.dataIndex );
124 
125  return ObjId( 0, BADINDEX );
126 }
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 OneToOneMsg::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 46 of file OneToOneMsg.cpp.

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

47 {
48  if ( src.element() == e1_ ) {
49  if ( e2_->hasFields() )
50  return Eref( e2_, i2_, src.dataIndex() );
51  else
52  return Eref( e2_, src.dataIndex(), 0 );
53  } else if ( src.element() == e2_ ) {
54  return Eref( e1_, src.dataIndex() );
55  }
56  return Eref( 0, 0 );
57 }
unsigned int dataIndex() const
Definition: Eref.h:50
Element * element() const
Definition: Eref.h:42
DataId i2_
Definition: OneToOneMsg.h:49
virtual bool hasFields() const =0
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 * OneToOneMsg::initCinfo ( )
static

Setup function for Element-style access to Msg fields.

Definition at line 163 of file OneToOneMsg.cpp.

References Msg::initCinfo(), and msgCinfo.

Referenced by Msg::initMsgManagers().

164 {
166  // Field definitions. Nothing here.
168 
169  static Dinfo< short > dinfo;
170  static Cinfo msgCinfo (
171  "OneToOneMsg", // name
172  Msg::initCinfo(), // base class
173  0, // Finfo array
174  0, // Num Fields
175  &dinfo
176  );
177 
178  return &msgCinfo;
179 }
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 * OneToOneMsg::lookupMsg ( unsigned int  index)
static

Static function for Msg access.

Definition at line 153 of file OneToOneMsg.cpp.

References msg_.

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

154 {
155  assert( index < msg_.size() );
156  return reinterpret_cast< char* >( msg_[index] );
157 }
static vector< OneToOneMsg * > msg_
Definition: OneToOneMsg.h:51

+ Here is the caller graph for this function:

Id OneToOneMsg::managerId ( ) const

Definition at line 113 of file OneToOneMsg.cpp.

References managerId_.

114 {
116 }
static Id managerId_
Definition: OneToOneMsg.h:50
unsigned int OneToOneMsg::numMsg ( )
static

Msg lookup functions.

Static function for Msg access.

Definition at line 147 of file OneToOneMsg.cpp.

References msg_.

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

148 {
149  return msg_.size();
150 }
static vector< OneToOneMsg * > msg_
Definition: OneToOneMsg.h:51

+ Here is the caller graph for this function:

void OneToOneMsg::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 60 of file OneToOneMsg.cpp.

References Msg::e1_, Msg::e2_, Element::hasFields(), i2_, Eref::isDataHere(), Element::localDataStart(), Element::numData(), and Element::numField().

61 {
62  v.resize( 0 );
63  unsigned int n = e1_->numData();
64  if ( e2_->hasFields() ) {
65  if ( Eref( e2_, i2_ ).isDataHere() ) {
66  assert( i2_ > e2_->localDataStart() );
67  unsigned int nf = e2_->numField( i2_ - e2_->localDataStart() );
68  if ( n > nf )
69  n = nf;
70  v.resize( n );
71  for ( unsigned int i = 0; i < n; ++i ) {
72  v[i].resize( 1, Eref( e1_, i ) );
73  }
74  }
75  } else {
76  if ( n > e2_->numData() )
77  n = e2_->numData();
78  v.resize( e2_->numData() );
79  for ( unsigned int i = 0; i < n; ++i ) {
80  v[i].resize( 1, Eref( e1_, i ) );
81  }
82  }
83 }
bool isDataHere() const
Definition: Eref.cpp:47
DataId i2_
Definition: OneToOneMsg.h:49
virtual unsigned int numField(unsigned int rawIndex) const =0
Returns number of field entries for specified data.
virtual bool hasFields() const =0
Definition: Eref.h:26
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.
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 OneToOneMsg::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 85 of file OneToOneMsg.cpp.

References Msg::e1_, Msg::e2_, Element::hasFields(), i2_, Eref::isDataHere(), Element::localDataStart(), Element::numData(), Element::numField(), Element::numLocalData(), and resize().

86 {
87  unsigned int n = e1_->numData();
88  v.resize( e1_->numData() );
89  if ( e2_->hasFields() ) {
90  if ( Eref( e2_, i2_ ).isDataHere() ) {
91  assert( i2_ > e2_->localDataStart() );
92  unsigned int nf = e2_->numField( i2_ - e2_->localDataStart() );
93  if ( n > nf )
94  n = nf;
95  for ( unsigned int i = 0; i < n; ++i )
96  v[i].resize( 1, Eref( e2_, i2_, i ) );
97  } else { // Don't know target node # of entries, so send all.
98  unsigned int start = e1_->localDataStart();
99  unsigned int end = start + e1_->numLocalData();
100  for ( unsigned int i = start; i < end; ++i ) {
101  v[i].resize( 1, Eref( e2_, i2_, i ) );
102  }
103  }
104  } else {
105  if ( n > e2_->numData() )
106  n = e2_->numData();
107  for ( unsigned int i = 0; i < n; ++i ) {
108  v[i].resize( 1, Eref( e2_, i ) );
109  }
110  }
111 }
bool isDataHere() const
Definition: Eref.cpp:47
DataId i2_
Definition: OneToOneMsg.h:49
virtual unsigned int numField(unsigned int rawIndex) const =0
Returns number of field entries for specified data.
virtual bool hasFields() const =0
Definition: Eref.h:26
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.
Element * e1_
Index of this Msg on the msg_ vector.
Definition: Msg.h:180
virtual unsigned int numLocalData() const =0
Returns number of local data entries on this node.
vector< vector< T > > resize(vector< vector< T > >table, unsigned int n, T init)
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

DataId OneToOneMsg::i1_
private

Definition at line 48 of file OneToOneMsg.h.

DataId OneToOneMsg::i2_
private

Definition at line 49 of file OneToOneMsg.h.

Referenced by firstTgt(), sources(), and targets().

Id OneToOneMsg::managerId_
staticprivate

Definition at line 50 of file OneToOneMsg.h.

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

vector< OneToOneMsg * > OneToOneMsg::msg_
staticprivate

Definition at line 51 of file OneToOneMsg.h.

Referenced by lookupMsg(), numMsg(), OneToOneMsg(), and ~OneToOneMsg().


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