Beispiel #1
0
void Pool::vRemesh( const Eref& e, const Qinfo* q, 
	double oldvol,
	unsigned int numTotalEntries, unsigned int startEntry, 
	const vector< unsigned int >& localIndices, 
	const vector< double >& vols )
{
	if ( e.index().value() != 0 )
		return;
	/*
	if ( q->addToStructuralQ() )
		return;
		*/
	Neutral* n = reinterpret_cast< Neutral* >( e.data() );
	assert( vols.size() > 0 );
	double concInit = nInit_ / ( NA * oldvol );
	if ( vols.size() != e.element()->dataHandler()->localEntries() )
		n->setLastDimension( e, q, vols.size() );
	// Note that at this point the Pool pointer may be invalid!
	// But we need to update the concs anyway.
	assert( e.element()->dataHandler()->localEntries() == vols.size() );
	Pool* pooldata = reinterpret_cast< Pool* >( e.data() );
	for ( unsigned int i = 0; i < vols.size(); ++i ) {
		pooldata[i].nInit_ = pooldata[i].n_ = concInit * vols[i] * NA;
	}
}
string SigNeur::getChannelMap( Eref e, const string& i )
{
	SigNeur* sn = static_cast< SigNeur* >( e.data() );
	map< string, string >::iterator j = sn->channelMap_.find( i );
	if ( j != sn->channelMap_.end() )
		return j->second;
	return "";
}
/////////////////////////////////////////////////////////////////
// Now test 'get' across nodes.
// Normally the 'get' call is invoked by the parser, which expects a
// value to come back. Note that the return must be asynchronous:
// the parser cannot block since we need to execute MPI polling
// operations on either side.
/////////////////////////////////////////////////////////////////
void testParGet( Id tnId, vector< Id >& testIds )
{
	unsigned int myNode = MuMPI::INTRA_COMM().Get_rank();
	unsigned int numNodes = MuMPI::INTRA_COMM().Get_size();
	Slot parGetSlot = initShellCinfo()->getSlot( "parallel.getSrc" );
	char name[20];
	string sname;
	if ( myNode == 0 ) {
		cout << "\ntesting parallel get" << flush;
	} else {
		sprintf( name, "foo%d", myNode * 2 );
		sname = name;
		set< string >( tnId.eref(), "name", sname );
	}
	MuMPI::INTRA_COMM().Barrier();
	Eref e = Id::shellId().eref();
	Shell* sh = static_cast< Shell* >( e.data() );
	vector< unsigned int > rids( numNodes, 0 );
	vector< string > ret( numNodes );
	unsigned int origSize = sh->freeRidStack_.size();
	ASSERT( origSize > 0 , "Stack initialized properly" );
	if ( myNode == 0 ) {
		for ( unsigned int i = 1; i < numNodes; i++ ) {
			rids[i] = 
				openOffNodeValueRequest< string >( sh, &ret[i], 1 );
			ASSERT( sh->freeRidStack_.size() == origSize - i, "stack in use" );
			sendTo3< Id, string, unsigned int >(
				Id::shellId().eref(), parGetSlot, i - 1,
				testIds[i - 1], "name", rids[i]
			);
		}
	}
	// Here we explicitly do what the closeOffNodeValueRequest handles.
	MuMPI::INTRA_COMM().Barrier();
	// Cycle a few times to make sure all data gets back to node 0
	for ( unsigned int i = 0; i < 5; i++ ) {
		pollPostmaster();
		MuMPI::INTRA_COMM().Barrier();
	}
	
	// Now go through to check all values have come back.
	if ( myNode == 0 ) {
		ASSERT( sh->freeRidStack_.size() == 1 + origSize - numNodes, 
			"Stack still waiting" );
		for ( unsigned int i = 1; i < numNodes; i++ ) {
			sprintf( name, "foo%d", i * 2 );
			sname = name;
			ASSERT( sh->offNodeData_[ rids[i] ].numPending == 0,
				"Pending requests cleared" );
			ASSERT( sh->offNodeData_[ rids[i] ].data == 
				static_cast< void* >( &ret[i] ), "Pointing to strings" );
			ASSERT( ret[ i ] == sname, "All values returned correctly" );
			// Clean up the debris
			sh->offNodeData_[ rids[i] ].data = 0;
			sh->freeRidStack_.push_back( rids[i] );
		}
	}
}
Beispiel #4
0
void Shell::destroy( const Eref& e, ObjId oid)
{
	Neutral *n = reinterpret_cast< Neutral* >( e.data() );
	assert( n );
	// cout << myNode_ << ": Shell::destroy done for element id: " << eid << ", name = " << eid.element()->getName() << endl;
	n->destroy( oid.eref(), 0 );
	if ( cwe_.id == oid.id )
		cwe_ = ObjId();
}
double PulseGen::getSecondDelay(Eref e)
{
    PulseGen* obj = static_cast <PulseGen*> (e.data());
    ASSERT( obj != NULL, "PulseGen::getSecondDelay(Eref ) - target data pointer is NULL.");
    if (obj->delay_.size() >= 2){
        return obj->delay_[obj->delay_.size() - 1];
    }
    return 0.0;
}
double BinSynchan::getReleaseCount( Eref e, const unsigned int& i )
{
	vector< BinSynInfo >& synapses = 
			static_cast< BinSynchan* >( e.data() )->synapses_;
	if ( i < synapses.size() )
            return synapses[i].getReleaseCount();
	cout << "Error: BinSynchan::getReleaseCount : Index " << i << 
			" out of range\n";
	return 0.0;
}
double PulseGen::getDelay(Eref e, const int& index)
{
    PulseGen* obj = static_cast <PulseGen*> (e.data());
    ASSERT( obj != NULL, "PulseGen::getDelay(Eref ) - target data pointer is NULL.");
    if (index >= 0 && index < obj->delay_.size()){
        return obj->delay_[index];
    } else {
        cout << "WARNING: PulseGen::getDelay - invalid index." << endl;
        return 0.0;
    }
}
			static double getDmap( Eref e, const string& s ) {
				map< string, double >::iterator i;
				LookupTestClass* atc = 
						static_cast< LookupTestClass* >( e.data() );
				i = atc->dmap.find( s );
				if ( i != atc->dmap.end() )
					return i->second;

				cout << "Error: LookupTestClass::getDvec: index not found \n";
				return 0.0;
			}
Beispiel #9
0
// vRemesh: All the work is done by the message from the compartment to the
// Stoich. None of the ZPools is remeshed directly. However, their
// DataHandlers need updating.
void ZPool::vRemesh( const Eref& e, const Qinfo* q, 
	double oldvol,
	unsigned int numTotalEntries, unsigned int startEntry, 
	const vector< unsigned int >& localIndices, 
	const vector< double >& vols )
{
	;
	if ( e.index().value() != 0 )
		return;
	Neutral* n = reinterpret_cast< Neutral* >( e.data() );
	if ( vols.size() != e.element()->dataHandler()->localEntries() )
		n->setLastDimension( e, q, vols.size() );
}
Beispiel #10
0
// Static func
void Shell::cleanSimulation()
{
	Eref sheller = Id().eref();
	Shell* s = reinterpret_cast< Shell* >( sheller.data() );
	vector< Id > kids;
	Neutral::children( sheller, kids );
	for ( vector< Id >::iterator i = kids.begin(); i != kids.end(); ++i )
	{
		if ( i->value() > 4 ) {
			cout << "Shell::cleanSimulation: deleted cruft at " << 
				i->value() << ": " << i->path() << endl;
			s->doDelete( *i );
		}
	}
}
double SigNeur::getSigDt( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->sigDt_;
}
string SigNeur::getSomaMethod( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->somaMethod_;
}
string SigNeur::getDendMethod( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->dendMethod_;
}
string SigNeur::getCellMethod( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->cellMethod_;
}
double IzhikevichNrn::getGamma(Eref e)
{
    return static_cast<IzhikevichNrn*>(e.data())->gamma_;
}                         
double SigNeur::getUpdateStep( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->updateStep_;
}
double SigNeur::getLambda( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->lambda_;
}
// created arrays
Id SigNeur::getCell( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->cell_;
}
			static double getDval( Eref e ) {
				return static_cast< LookupTestClass* >( e.data() )->dval;
			}
double IzhikevichNrn::getInitU(Eref e)
{
    return static_cast<IzhikevichNrn*>(e.data())->initU_;
}
double IzhikevichNrn::getInject(Eref e)
{
    return static_cast<IzhikevichNrn*>(e.data())->Im_;
}                        
double SigNeur::getCellDt( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->cellDt_;
}
double SigNeur::getDscale( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->Dscale_;
}
string SigNeur::getDendExclude( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->dendExclude_;
}
int SigNeur::getParallelMode( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->parallelMode_;
}
Id SigNeur::getSoma( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->soma_;
}
double SigNeur::getCalciumScale( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->calciumScale_;
}
double IzhikevichNrn::getBeta(Eref e)
{
    return static_cast<IzhikevichNrn*>(e.data())->beta_;
}                          
Id SigNeur::getSpine( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->spine_;
}
Id SigNeur::getDend( Eref e )
{
	return static_cast< SigNeur* >( e.data() )->dend_;
}