Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91511958
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
Mon, Nov 11, 19:22
Size
1 KB
Mime Type
text/x-c
Expires
Wed, Nov 13, 19:22 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22276067
Attached To
R9490 Homework_sp4e_Peruzzo_SáezUribe
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