////////////////////////////////////////////////////////////// // Process operations. ////////////////////////////////////////////////////////////// void Gsolve::process( const Eref& e, ProcPtr p ) { // cout << stoichPtr_ << " dsolve = " << dsolvePtr_ << endl; if ( !stoichPtr_ ) return; // First, handle incoming diffusion values. Note potential for // issues with roundoff if diffusion is not integral. if ( dsolvePtr_ ) { vector< double > dvalues( 4 ); dvalues[0] = 0; dvalues[1] = getNumLocalVoxels(); dvalues[2] = 0; dvalues[3] = stoichPtr_->getNumVarPools(); dsolvePtr_->getBlock( dvalues ); // Here we need to convert to integers, just in case. Normally // one would use a stochastic (integral) diffusion method with // the GSSA, but in mixed models it may be more complicated. vector< double >::iterator i = dvalues.begin() + 4; for ( ; i != dvalues.end(); ++i ) { // cout << *i << " " << round( *i ) << " "; *i = round( *i ); } setBlock( dvalues ); } // Second, take the arrived xCompt reac values and update S with them. // Here the roundoff issues are handled by the GssaVoxelPools functions for ( unsigned int i = 0; i < xfer_.size(); ++i ) { XferInfo& xf = xfer_[i]; // cout << xfer_.size() << " " << xf.xferVoxel.size() << endl; for ( unsigned int j = 0; j < xf.xferVoxel.size(); ++j ) { pools_[xf.xferVoxel[j]].xferIn( xf, j, &sys_ ); } } // Third, record the current value of pools as the reference for the // next cycle. for ( unsigned int i = 0; i < xfer_.size(); ++i ) { XferInfo& xf = xfer_[i]; for ( unsigned int j = 0; j < xf.xferVoxel.size(); ++j ) { pools_[xf.xferVoxel[j]].xferOut( j, xf.lastValues, xf.xferPoolIdx ); } } // Fourth, update the mol #s for ( vector< GssaVoxelPools >::iterator i = pools_.begin(); i != pools_.end(); ++i ) { i->advance( p, &sys_ ); } // Finally, assemble and send the integrated values off for the Dsolve. if ( dsolvePtr_ ) { vector< double > kvalues( 4 ); kvalues[0] = 0; kvalues[1] = getNumLocalVoxels(); kvalues[2] = 0; kvalues[3] = stoichPtr_->getNumVarPools(); getBlock( kvalues ); dsolvePtr_->setBlock( kvalues ); } }
////////////////////////////////////////////////////////////// // Process operations. ////////////////////////////////////////////////////////////// void Ksolve::process( const Eref& e, ProcPtr p ) { if ( isBuilt_ == false ) return; // First, handle incoming diffusion values, update S with those. if ( dsolvePtr_ ) { vector< double > dvalues( 4 ); dvalues[0] = 0; dvalues[1] = getNumLocalVoxels(); dvalues[2] = 0; dvalues[3] = stoichPtr_->getNumVarPools(); dsolvePtr_->getBlock( dvalues ); /* vector< double >::iterator i = dvalues.begin() + 4; for ( ; i != dvalues.end(); ++i ) cout << *i << " " << round( *i ) << endl; getBlock( kvalues ); vector< double >::iterator d = dvalues.begin() + 4; for ( vector< double >::iterator k = kvalues.begin() + 4; k != kvalues.end(); ++k ) *k++ = ( *k + *d )/2.0 setBlock( kvalues ); */ setBlock( dvalues ); } // Second, take the arrived xCompt reac values and update S with them. for ( unsigned int i = 0; i < xfer_.size(); ++i ) { const XferInfo& xf = xfer_[i]; // cout << xfer_.size() << " " << xf.xferVoxel.size() << endl; for ( unsigned int j = 0; j < xf.xferVoxel.size(); ++j ) { pools_[xf.xferVoxel[j]].xferIn( xf.xferPoolIdx, xf.values, xf.lastValues, j ); } } // Third, record the current value of pools as the reference for the // next cycle. for ( unsigned int i = 0; i < xfer_.size(); ++i ) { XferInfo& xf = xfer_[i]; for ( unsigned int j = 0; j < xf.xferVoxel.size(); ++j ) { pools_[xf.xferVoxel[j]].xferOut( j, xf.lastValues, xf.xferPoolIdx ); } } // Fourth, do the numerical integration for all reactions. for ( vector< VoxelPools >::iterator i = pools_.begin(); i != pools_.end(); ++i ) { i->advance( p ); } // Finally, assemble and send the integrated values off for the Dsolve. if ( dsolvePtr_ ) { vector< double > kvalues( 4 ); kvalues[0] = 0; kvalues[1] = getNumLocalVoxels(); kvalues[2] = 0; kvalues[3] = stoichPtr_->getNumVarPools(); getBlock( kvalues ); dsolvePtr_->setBlock( kvalues ); } }