Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65783767
ping_pong_balls_factory.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jun 6, 05:03
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Jun 8, 05:03 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17859245
Attached To
R9482 SP4E_Homework_Ashtari_Sieber
ping_pong_balls_factory.cc
View Options
#include "ping_pong_balls_factory.hh"
#include "compute_contact.hh"
#include "compute_verlet_integration.hh"
#include "csv_reader.hh"
#include "csv_writer.hh"
#include "ping_pong_ball.hh"
#include <cmath>
#include <iostream>
/* -------------------------------------------------------------------------- */
std::unique_ptr<Particle> PingPongBallsFactory::createParticle() {
return std::make_unique<PingPongBall>();
}
/* -------------------------------------------------------------------------- */
SystemEvolution&
PingPongBallsFactory::createSimulation(const std::string& fname,
Real timestep) {
this->system_evolution =
std::make_unique<SystemEvolution>(std::make_unique<System>());
CsvReader reader(fname);
reader.read(this->system_evolution->getSystem());
auto contact = std::make_shared<ComputeContact>();
auto verlet = std::make_shared<ComputeVerletIntegration>(timestep);
contact->setPenalty(1.);
verlet->addInteraction(contact);
this->system_evolution->addCompute(verlet);
return *system_evolution;
}
/* -------------------------------------------------------------------------- */
ParticlesFactoryInterface& PingPongBallsFactory::getInstance() {
if (not ParticlesFactoryInterface::factory)
ParticlesFactoryInterface::factory = new PingPongBallsFactory;
return *factory;
}
/* -------------------------------------------------------------------------- */
Event Timeline
Log In to Comment