Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79838331
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
Wed, Aug 28, 12:47
Size
1 KB
Mime Type
text/x-c
Expires
Fri, Aug 30, 12:47 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
19949212
Attached To
R7554 sp4e_exercices
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