MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SrcFinfo.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2009 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 #include "header.h"
10 
16 const BindIndex SrcFinfo::BadBindIndex = 65535;
17 
18 SrcFinfo::SrcFinfo( const string& name, const string& doc )
19  : Finfo( name, doc ), bindIndex_( BadBindIndex )
20 { ; }
21 
23 {
25 }
26 
27 
29 {
30  // Treat this assertion as a warning that the SrcFinfo is being used
31  // without initialization.
32  assert( bindIndex_ != BadBindIndex );
33  return bindIndex_;
34 }
35 
37 {
38  bindIndex_ = b;
39 }
40 
41 bool SrcFinfo::checkTarget( const Finfo* target ) const
42 {
43  const DestFinfo* d = dynamic_cast< const DestFinfo* >( target );
44  if ( d ) {
45  return d->getOpFunc()->checkFinfo( this );
46  }
47  return 0;
48 }
49 
50 bool SrcFinfo::addMsg( const Finfo* target, ObjId mid, Element* src ) const
51 {
52  const DestFinfo* d = dynamic_cast< const DestFinfo* >( target );
53  if ( d ) {
54  if ( d->getOpFunc()->checkFinfo( this ) ) {
55  src->addMsgAndFunc( mid, d->getFid(), bindIndex_ );
56  return 1;
57  }
58  }
59  return 0;
60 }
62 
65 SrcFinfo0::SrcFinfo0( const string& name, const string& doc )
66  : SrcFinfo( name, doc )
67 { ; }
68 
69 class OpFunc0Base;
70 void SrcFinfo0::send( const Eref& e ) const {
71  const vector< MsgDigest >& md = e.msgDigest( getBindIndex() );
72  for ( vector< MsgDigest >::const_iterator
73  i = md.begin(); i != md.end(); ++i ) {
74  const OpFunc0Base* f =
75  dynamic_cast< const OpFunc0Base* >( i->func );
76  assert( f );
77  for ( vector< Eref >::const_iterator
78  j = i->targets.begin(); j != i->targets.end(); ++j ) {
79  if ( j->dataIndex() == ALLDATA ) {
80  Element* e = j->element();
81  unsigned int start = e->localDataStart();
82  unsigned int end = start + e->numData();
83  for ( unsigned int k = start; k < end; ++k )
84  f->op( Eref( e, k ) );
85  } else {
86  f->op( *j );
87  }
88  }
89  }
90 }
91 
92 void SrcFinfo0::sendBuffer( const Eref& e, double* buf ) const
93 {
94  send( e );
95 }
96 
SrcFinfo(const string &name, const string &doc)
Definition: SrcFinfo.cpp:18
BindIndex registerBindIndex()
Definition: Cinfo.cpp:109
unsigned short BindIndex
Definition: header.h:62
BindIndex getBindIndex() const
Definition: SrcFinfo.cpp:28
bool addMsg(const Finfo *target, ObjId mid, Element *src) const
Definition: SrcFinfo.cpp:50
void addMsgAndFunc(ObjId mid, FuncId fid, BindIndex bindIndex)
Definition: Element.cpp:128
Definition: ObjId.h:20
Element * element() const
Definition: Eref.h:42
virtual void op(const Eref &e) const =0
virtual bool checkFinfo(const Finfo *s) const =0
const unsigned int ALLDATA
Used by ObjId and Eref.
Definition: consts.cpp:22
const vector< MsgDigest > & msgDigest(unsigned int bindIndex) const
Definition: Eref.cpp:67
void sendBuffer(const Eref &e, double *buf) const
Definition: SrcFinfo.cpp:92
unsigned short bindIndex_
Definition: SrcFinfo.h:70
void setBindIndex(BindIndex b)
Definition: SrcFinfo.cpp:36
bool checkTarget(const Finfo *target) const
Definition: SrcFinfo.cpp:41
FuncId getFid() const
Definition: DestFinfo.cpp:45
Definition: Eref.h:26
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
const OpFunc * getOpFunc() const
Definition: DestFinfo.cpp:40
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.
static char name[]
Definition: mfield.cpp:401
void send(const Eref &e) const
Definition: SrcFinfo.cpp:70
static const BindIndex BadBindIndex
Definition: SrcFinfo.h:65
SrcFinfo0(const string &name, const string &doc)
Definition: SrcFinfo.cpp:65
Definition: Cinfo.h:18
Definition: Finfo.h:12
void registerFinfo(Cinfo *c)
Definition: SrcFinfo.cpp:22