/** * 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. */ Eref OneToOneDataIndexMsg::firstTgt( const Eref& src ) const { if ( src.element() == e1_ ) { return Eref( e2_, src.dataIndex(), 0 ); } else if ( src.element() == e2_ ) { return Eref( e1_, src.dataIndex() ); } return Eref( 0, 0 ); }
/** * 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. */ Eref OneToOneMsg::firstTgt( const Eref& src ) const { if ( src.element() == e1_ ) { if ( e2_->hasFields() ) return Eref( e2_, i2_, src.dataIndex() ); else return Eref( e2_, src.dataIndex(), 0 ); } else if ( src.element() == e2_ ) { return Eref( e1_, src.dataIndex() ); } return Eref( 0, 0 ); }
SingleMsg::SingleMsg( const Eref& e1, const Eref& e2, unsigned int msgIndex) : Msg( ObjId( managerId_, (msgIndex != 0 ) ? msgIndex: msg_.size() ), e1.element(), e2.element() ), i1_( e1.dataIndex() ), i2_( e2.dataIndex() ), f2_( e2.fieldIndex() ) { if ( msgIndex == 0 ) { msg_.push_back( this ); return; } else if ( msg_.size() <= msgIndex ) { msg_.resize( msgIndex + 1 ); } msg_[ msgIndex ] = this; }
OneToOneMsg::OneToOneMsg( const Eref& e1, const Eref& e2, unsigned int msgIndex ) : Msg( ObjId( managerId_, (msgIndex != 0) ? msgIndex: msg_.size() ), e1.element(), e2.element() ), i1_( e1.dataIndex() ), i2_( e2.dataIndex() ) { if ( msgIndex == 0 ) { msg_.push_back( this ); } else { if ( msg_.size() <= msgIndex ) msg_.resize( msgIndex + 1 ); msg_[ msgIndex ] = this; } }
// static function Id Neutral::child( const Eref& e, const string& name ) { static const Finfo* pf = neutralCinfo->findFinfo( "parentMsg" ); static const DestFinfo* pf2 = dynamic_cast< const DestFinfo* >( pf ); static const FuncId pafid = pf2->getFid(); static const Finfo* cf = neutralCinfo->findFinfo( "childOut" ); static const SrcFinfo* cf2 = dynamic_cast< const SrcFinfo* >( cf ); static const BindIndex bi = cf2->getBindIndex(); const vector< MsgFuncBinding >* bvec = e.element()->getMsgAndFunc( bi ); vector< Id > ret; for ( vector< MsgFuncBinding >::const_iterator i = bvec->begin(); i != bvec->end(); ++i ) { if ( i->fid == pafid ) { const Msg* m = Msg::getMsg( i->mid ); assert( m ); Element* e2 = m->e2(); if ( e2->getName() == name ) { if ( e.dataIndex() == ALLDATA ) {// Child of any index is OK return e2->id(); } else { ObjId parent = m->findOtherEnd( m->getE2() ); // If child is a fieldElement, then all parent indices // are permitted. Otherwise insist parent dataIndex OK. if ( e2->hasFields() || parent == e.objId() ) return e2->id(); } } } } return Id(); }
unsigned int Ksolve::getVoxelIndex( const Eref& e ) const { unsigned int ret = e.dataIndex(); if ( ret < startVoxel_ || ret >= startVoxel_ + pools_.size() ) return OFFNODE; return ret - startVoxel_; }
/** * Assigns the Stoich Id to the parent. */ void MeshEntry::reinit( const Eref& e, ProcPtr info ) { if ( e.dataIndex() == 0 ) { ObjId pa = Neutral::parent( e ); // parent_->lookupStoich( pa ); } }
/// Utility function to find the size of a pool. We assume one-to-one /// match between pool indices and mesh indices: that is what they are for. double lookupVolumeFromMesh( const Eref& e ) { ObjId compt = getCompt( e.id() ); if ( compt == ObjId() ) return 1.0; return LookupField< unsigned int, double >:: get( compt, "oneVoxelVolume", e.dataIndex() ); }
// Static function void Neutral::children( const Eref& e, vector< Id >& ret ) { /* vector< Id > temp; getNeighbors( ret, neutralCinfo->findFinfo( "childOut" ) ); for ( vector< Id >::iterator i = temp.begin(); i != temp.end(); ++i ) { if ( ret } */ static const Finfo* pf = neutralCinfo->findFinfo( "parentMsg" ); static const DestFinfo* pf2 = dynamic_cast< const DestFinfo* >( pf ); static const FuncId pafid = pf2->getFid(); static const Finfo* cf = neutralCinfo->findFinfo( "childOut" ); static const SrcFinfo* cf2 = dynamic_cast< const SrcFinfo* >( cf ); static const BindIndex bi = cf2->getBindIndex(); const vector< MsgFuncBinding >* bvec = e.element()->getMsgAndFunc( bi ); for ( vector< MsgFuncBinding >::const_iterator i = bvec->begin(); i != bvec->end(); ++i ) { if ( i->fid == pafid ) { const Msg* m = Msg::getMsg( i->mid ); assert( m ); vector< vector< Eref > > kids; m->targets( kids ); if ( e.dataIndex() == ALLDATA ) { for ( vector< vector< Eref > >::iterator i = kids.begin(); i != kids.end(); ++i ) { for ( vector< Eref >::iterator j = i->begin(); j != i->end(); ++j ) ret.push_back( j->id() ); } } else { const vector< Eref >& temp = kids[e.dataIndex()]; for ( vector< Eref >::const_iterator i = temp.begin(); i != temp.end(); ++i ) ret.push_back( i->id() ); } } } }
void Synapse::addSpike( const Eref& e, double time ) { static bool report = false; static unsigned int tgtDataIndex = 0; // static unsigned int tgtFieldIndex = 0; if ( report && e.dataIndex() == tgtDataIndex ) { cout << " " << time << "," << e.fieldIndex(); } handler_->addSpike( e.fieldIndex(), time + delay_, weight_ ); }
void HDF5DataWriter::reinit(const Eref & e, ProcPtr p) { steps_ = 0; for (unsigned int ii = 0; ii < data_.size(); ++ii){ H5Dclose(datasets_[ii]); } data_.clear(); src_.clear(); func_.clear(); datasets_.clear(); unsigned int numTgt = e.element()->getMsgTargetAndFunctions(e.dataIndex(), requestOut(), src_, func_); assert(numTgt == src_.size()); // TODO: what to do when reinit is called? Close the existing file // and open a new one in append mode? Or keep adding to the // current file? if (filename_.empty()){ filename_ = "moose_data.h5"; } if (filehandle_ > 0 ){ close(); } if (numTgt == 0){ return; } openFile(); for (unsigned int ii = 0; ii < src_.size(); ++ii){ string varname = func_[ii]; size_t found = varname.find("get"); if (found == 0){ varname = varname.substr(3); if (varname.length() == 0){ varname = func_[ii]; } else { // TODO: there is no way we can get back the original // field-name case. tolower will get the right name in // most cases as field names start with lower case by // convention in MOOSE. varname[0] = tolower(varname[0]); } } assert(varname.length() > 0); string path = src_[ii].path() + "/" + varname; hid_t dataset_id = getDataset(path); datasets_.push_back(dataset_id); } data_.resize(src_.size()); }
Eref SparseMsg::firstTgt( const Eref& src ) const { if ( matrix_.nEntries() == 0 ) return Eref( 0, 0 ); if ( src.element() == e1_ ) { const unsigned int* fieldIndex; const unsigned int* colIndex; unsigned int n = matrix_.getRow( src.dataIndex(), &fieldIndex, &colIndex ); if ( n != 0 ) { return Eref( e2_, colIndex[0], fieldIndex[0] ); } } else if ( src.element() == e2_ ) { return Eref( e1_, 0 ); } return Eref( 0, 0 ); }
vector< string > Neutral::getMsgDestFunctions( const Eref& e, string field ) const { vector< string > ret( 0 ); const Finfo* finfo = e.element()->cinfo()->findFinfo( field ); const SrcFinfo* sf = dynamic_cast< const SrcFinfo* >( finfo ); if ( sf ) { vector< ObjId > tgt; vector< string > func; e.element()->getMsgTargetAndFunctions( e.dataIndex(), sf, tgt, func ); return func; } else { cout << "Warning: Neutral::getMsgDestFunctions: Id.Field '" << e.id().path() << "." << field << "' not found or not a SrcFinfo\n"; } return ret; }
void NSDFWriter::sortOutUniformSources(const Eref& eref) { vars_.clear(); classFieldToSrcIndex_.clear(); objectField_.clear(); objectFieldToIndex_.clear(); const SrcFinfo * requestOut = (SrcFinfo*)eref.element()->cinfo()->findFinfo("requestOut"); unsigned int numTgt = eref.element()->getMsgTargetAndFunctions(eref.dataIndex(), requestOut, src_, func_); assert(numTgt == src_.size()); ///////////////////////////////////////////////////////////// // Go through all the sources and determine the index of the // source message in the dataset ///////////////////////////////////////////////////////////// for (unsigned int ii = 0; ii < func_.size(); ++ii){ string varname = func_[ii]; size_t found = varname.find("get"); if (found == 0){ varname = varname.substr(3); if (varname.length() == 0){ varname = func_[ii]; } else { varname[0] = tolower(varname[0]); } } assert(varname.length() > 0); string className = Field<string>::get(src_[ii], "className"); string datasetPath = className + "/"+ varname; classFieldToSrcIndex_[datasetPath].push_back(ii); vars_.push_back(varname); } data_.resize(numTgt); }
void Neutral::setNumField( const Eref& e, unsigned int num ) { assert( e.isDataHere() ); unsigned int rawIndex = e.element()->rawIndex( e.dataIndex() ); e.element()->resizeField( rawIndex, num ); }
double MeshEntry::getVolume( const Eref& e ) const { return parent_->getMeshEntryVolume( e.dataIndex() ); // return parent_->getMeshEntryVolume( e.fieldIndex() ); }
unsigned int Neutral::getIndex( const Eref& e ) const { return e.dataIndex(); }
unsigned int Neutral::getNumField( const Eref& e ) const { assert( e.isDataHere() ); unsigned int rawIndex = e.element()->rawIndex( e.dataIndex() ); return e.element()->numField( rawIndex ); }