void SSnapshot::runEvent() const { double locdt = dt; #ifdef DYNAMO_DEBUG if (boost::math::isnan(dt)) M_throw() << "A NAN system event time has been found"; #endif Sim->dSysTime += locdt; Sim->ptrScheduler->stream(locdt); //dynamics must be updated first Sim->dynamics.stream(locdt); dt += _period; locdt += Sim->freestreamAcc; Sim->freestreamAcc = 0; //This is done here as most ticker properties require it Sim->dynamics.getLiouvillean().updateAllParticles(); BOOST_FOREACH(shared_ptr<OutputPlugin>& Ptr, Sim->outputPlugins) Ptr->eventUpdate(*this, NEventData(), locdt); std::string filename = magnet::string::search_replace("Snapshot.%i.xml.bz2", "%i", boost::lexical_cast<std::string>(_saveCounter++)); Sim->writeXMLfile(filename, _applyBC); }
void SysTicker::runEvent() const { double locdt = dt; #ifdef DYNAMO_DEBUG if (std::isnan(dt)) M_throw() << "A NAN system event time has been found"; #endif Sim->systemTime += locdt; Sim->ptrScheduler->stream(locdt); //dynamics must be updated first Sim->stream(locdt); dt += period; //This is done here as most ticker properties require it Sim->dynamics->updateAllParticles(); for (shared_ptr<OutputPlugin>& Ptr : Sim->outputPlugins) { shared_ptr<OPTicker> ptr = std::dynamic_pointer_cast<OPTicker>(Ptr); if (ptr) ptr->ticker(); } for (shared_ptr<OutputPlugin>& Ptr : Sim->outputPlugins) Ptr->eventUpdate(*this, NEventData(), locdt); }
NEventData SysTicker::runEvent() { dt += period; //This is done here as most ticker properties require it Sim->dynamics->updateAllParticles(); for (shared_ptr<OutputPlugin>& Ptr : Sim->outputPlugins) { shared_ptr<OPTicker> ptr = std::dynamic_pointer_cast<OPTicker>(Ptr); if (ptr) ptr->ticker(); } return NEventData(); }
NEventData SysSnapshot::runEvent() { if (_eventPeriod) dt = HUGE_VAL; else dt += _period; Sim->dynamics->updateAllParticles(); std::string filename = magnet::string::search_replace("Snapshot."+_format+".xml.bz2", "%COUNT", boost::lexical_cast<std::string>(_saveCounter)); filename = magnet::string::search_replace(filename, "%ID", boost::lexical_cast<std::string>(Sim->stateID)); Sim->writeXMLfile(filename, _applyBC); dout << "Printing SNAPSHOT" << std::endl; filename = magnet::string::search_replace("Snapshot.output."+_format+".xml.bz2", "%COUNT", boost::lexical_cast<std::string>(_saveCounter++)); filename = magnet::string::search_replace(filename, "%ID", boost::lexical_cast<std::string>(Sim->stateID)); Sim->outputData(filename); return NEventData(); }
void SysSnapshot::runEvent() { double locdt = dt; if (_eventPeriod) { locdt = 0; dt = HUGE_VAL; } else dt += _period; #ifdef DYNAMO_DEBUG if (std::isnan(locdt)) M_throw() << "A NAN system event time has been found"; #endif Sim->systemTime += locdt; Sim->ptrScheduler->stream(locdt); //dynamics must be updated first Sim->stream(locdt); //This is done here as most ticker properties require it Sim->dynamics->updateAllParticles(); for (shared_ptr<OutputPlugin>& Ptr : Sim->outputPlugins) Ptr->eventUpdate(*this, NEventData(), locdt); std::string filename = magnet::string::search_replace("Snapshot."+_format+".xml.bz2", "%COUNT", boost::lexical_cast<std::string>(_saveCounter)); filename = magnet::string::search_replace(filename, "%ID", boost::lexical_cast<std::string>(Sim->simID)); Sim->writeXMLfile(filename, _applyBC); dout << "Printing SNAPSHOT" << std::endl; filename = magnet::string::search_replace("Snapshot.output."+_format+".xml.bz2", "%COUNT", boost::lexical_cast<std::string>(_saveCounter++)); filename = magnet::string::search_replace(filename, "%ID", boost::lexical_cast<std::string>(Sim->simID)); Sim->outputData(filename); }
NEventData SVisualizer::runEvent() { if (_window->dynamoParticleSync()) Sim->dynamics->updateAllParticles(); for (shared_ptr<System>& system : Sim->systems) { shared_ptr<SysRotateGravity> rgrav = std::dynamic_pointer_cast<SysRotateGravity>(system); if (!rgrav) continue; std::shared_ptr<DynGravity> dynamics = std::dynamic_pointer_cast<DynGravity>(Sim->dynamics); if (dynamics) _window->getGLContext()->queueTask(std::bind(&magnet::GL::Camera::setUp, &(_window->getCamera()), -dynamics->getGravityVector(), rgrav->getAxis())); break; } _window->simupdateTick(Sim->systemTime / Sim->units.unitTime()); //Now that the update has been performed, set up the next "tick" dt = _window->getUpdateInterval() * Sim->units.unitTime(); _lastUpdate = boost::posix_time::microsec_clock::local_time(); return NEventData(); }
void SVisualizer::runEvent() { //Dont rewind in time, the -HUGE_VAL time is only used to ensure //the event takes place before any event, including negative time events. if (dt == -HUGE_VAL) dt = 0; //Actually move forward the system time Sim->systemTime += dt; Sim->ptrScheduler->stream(dt); //dynamics must be updated first Sim->stream(dt); if (_window->dynamoParticleSync()) Sim->dynamics->updateAllParticles(); for (shared_ptr<OutputPlugin>& Ptr : Sim->outputPlugins) Ptr->eventUpdate(*this, NEventData(), dt); for (shared_ptr<System>& system : Sim->systems) { shared_ptr<SysRotateGravity> rgrav = std::dynamic_pointer_cast<SysRotateGravity>(system); if (!rgrav) continue; std::shared_ptr<DynGravity> dynamics = std::dynamic_pointer_cast<DynGravity>(Sim->dynamics); if (dynamics) _window->getGLContext()->queueTask(std::bind(&magnet::GL::Camera::setUp, &(_window->getCamera()), -dynamics->getGravityVector(), rgrav->getAxis())); break; } _window->simupdateTick(Sim->systemTime / Sim->units.unitTime()); //Now that the update has been performed, set up the next "tick" dt = _window->getUpdateInterval() * Sim->units.unitTime(); _lastUpdate = boost::posix_time::microsec_clock::local_time(); }
void CSRingDSMC::runEvent() const { double locdt = dt; #ifdef DYNAMO_DEBUG if (boost::math::isnan(locdt)) M_throw() << "A NAN system event time has been found"; #endif Sim->dSysTime += locdt; Sim->ptrScheduler->stream(locdt); //dynamics must be updated first Sim->dynamics.stream(locdt); dt = tstep; locdt += Sim->freestreamAcc; Sim->freestreamAcc = 0; BOOST_FOREACH(std::tr1::shared_ptr<OutputPlugin>& Ptr, Sim->outputPlugins) Ptr->eventUpdate(*this, NEventData(), locdt); //////////////////// T(1,2) operator double intPart; double fracpart = std::modf(maxprob12 * range1->size(), &intPart); size_t nmax = static_cast<size_t>(intPart) + (Sim->uniform_sampler() < fracpart); { boost::variate_generator <dynamo::baseRNG&, boost::uniform_int<size_t> > id1sampler(Sim->ranGenerator, boost::uniform_int<size_t>(0, (range1->size()/2) - 1)); for (size_t n = 0; n < nmax; ++n) { size_t pairID(id1sampler()); const Particle& p1(Sim->particleList[*(range1->begin() + 2 * pairID)]); const Particle& p2(Sim->particleList[*(range1->begin() + 2 * pairID + 1)]); Sim->dynamics.getLiouvillean().updateParticlePair(p1, p2); CPDData PDat; for (size_t iDim(0); iDim < NDIM; ++iDim) PDat.rij[iDim] = Sim->normal_sampler(); PDat.rij *= diameter / PDat.rij.nrm(); if (Sim->dynamics.getLiouvillean().DSMCSpheresTest (p1, p2, maxprob12, factor12, PDat)) { ++Sim->eventCount; ++n12; const PairEventData SDat(Sim->dynamics.getLiouvillean().DSMCSpheresRun(p1, p2, e, PDat)); Sim->signalParticleUpdate(SDat); Sim->ptrScheduler->fullUpdate(p1, p2); BOOST_FOREACH(std::tr1::shared_ptr<OutputPlugin>& Ptr, Sim->outputPlugins) Ptr->eventUpdate(*this, SDat, 0.0); } } } //////////////////// T(1,3) operator { fracpart = std::modf(maxprob13 * range1->size(), &intPart); nmax = static_cast<size_t>(intPart) + (Sim->uniform_sampler() < fracpart); boost::variate_generator <dynamo::baseRNG&, boost::uniform_int<size_t> > id1sampler(Sim->ranGenerator, boost::uniform_int<size_t>(0, range1->size() - 1)); for (size_t n = 0; n < nmax; ++n) { const Particle& p1(Sim->particleList[*(range1->begin() + id1sampler())]); size_t secondID(id1sampler()); while ((secondID == p1.getID()) || ((secondID % 2) ? ((secondID-1) == p1.getID()) : ((secondID+1) == p1.getID()))) secondID = id1sampler(); const Particle& p2(Sim->particleList[*(range1->begin() + secondID)]); Sim->dynamics.getLiouvillean().updateParticlePair(p1, p2); CPDData PDat; for (size_t iDim(0); iDim < NDIM; ++iDim) PDat.rij[iDim] = Sim->normal_sampler(); PDat.rij *= diameter / PDat.rij.nrm(); if (Sim->dynamics.getLiouvillean().DSMCSpheresTest (p1, p2, maxprob13, factor13, PDat)) { ++Sim->eventCount; ++n13; const PairEventData SDat(Sim->dynamics.getLiouvillean().DSMCSpheresRun(p1, p2, e, PDat)); Sim->signalParticleUpdate(SDat); Sim->ptrScheduler->fullUpdate(p1, p2); BOOST_FOREACH(std::tr1::shared_ptr<OutputPlugin>& Ptr, Sim->outputPlugins) Ptr->eventUpdate(*this, SDat, 0.0); } } } }