Unverified Commit 5c29118f authored by Guillaume Anciaux's avatar Guillaume Anciaux
Browse files

adding the exercise of today

parent f3e30afd
step-*.csv
doc/html
\ No newline at end of file
This diff is collapsed.
---
Language: Cpp
BasedOnStyle: LLVM
Standard: Cpp11
AlwaysBreakTemplateDeclarations: true
PointerAlignment: Left
SpacesBeforeTrailingComments: 2
#FixNamespaceComments: true
...
step-*.csv
build
starting_point
\ No newline at end of file
cmake_minimum_required (VERSION 2.6)
project (Particles)
set(CMAKE_CXX_STANDARD 14)
add_executable(particles
main.cc
vector.cc
compute_boundary.cc
compute_verlet_integration.cc
particle.cc
planet.cc
compute_gravity.cc
csv_reader.cc
particles_factory_interface.cc
planets_factory.cc
compute_contact.cc
compute_kinetic_energy.cc
csv_writer.cc
system.cc
compute_energy.cc
compute_potential_energy.cc
ping_pong_ball.cc
system_evolution.cc
ping_pong_balls_factory.cc
compute_interaction.cc)
This diff is collapsed.
0 0 0 0 0 0 1e-4 0 0 1 sun
1 0 0 0 1 0 -1e-4 0 0 1e-4 earth
#ifndef __COMPUTE__HH__
#define __COMPUTE__HH__
/* -------------------------------------------------------------------------- */
#include "system.hh"
/* -------------------------------------------------------------------------- */
//! Base class for all compute
class Compute {
public:
//! Virtual destructor needed because we have subclasses
virtual ~Compute() = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
//! Compute is pure virtual
virtual void compute(System& system) = 0;
};
/* -------------------------------------------------------------------------- */
#endif //__COMPUTE__HH__
#include "compute_boundary.hh"
/* -------------------------------------------------------------------------- */
ComputeBoundary::ComputeBoundary(const Vector& xmin, const Vector& xmax) {}
/* -------------------------------------------------------------------------- */
void ComputeBoundary::compute(System& system) {}
/* -------------------------------------------------------------------------- */
#ifndef __COMPUTE_BOUNDARY__HH__
#define __COMPUTE_BOUNDARY__HH__
/* -------------------------------------------------------------------------- */
#include "compute.hh"
/* -------------------------------------------------------------------------- */
//! Compute interaction with simulation box
class ComputeBoundary : public Compute {
// Constructors/Destructors
public:
ComputeBoundary(const Vector& xmin, const Vector& xmax);
// Methods
public:
void compute(System& system) override;
// Members
protected:
Vector xmin, xmax;
};
/* -------------------------------------------------------------------------- */
#endif //__COMPUTE_BOUNDARY__HH__
#include "compute_contact.hh"
#include "ping_pong_ball.hh"
#include <cmath>
/* -------------------------------------------------------------------------- */
void ComputeContact::setPenalty(Real penalty) {}
/* -------------------------------------------------------------------------- */
void ComputeContact::compute(System& system) {}
#ifndef __COMPUTE_CONTACT__HH__
#define __COMPUTE_CONTACT__HH__
/* -------------------------------------------------------------------------- */
#include "compute_interaction.hh"
//! Compute contact interaction between ping-pong balls
class ComputeContact : public ComputeInteraction {
// Virtual implementation
public:
//! Penalty contact implementation
void compute(System& system) override;
// Accessors
public:
//! Set penalty
void setPenalty(Real penalty);
// Members
protected:
Real penalty;
};
/* -------------------------------------------------------------------------- */
#endif //__COMPUTE_CONTACT__HH__
#include "compute_energy.hh"
/* -------------------------------------------------------------------------- */
#ifndef __COMPUTE_ENERGY__HH__
#define __COMPUTE_ENERGY__HH__
/* -------------------------------------------------------------------------- */
#include "compute.hh"
//! Base class for energy computation
class ComputeEnergy : public Compute {
// Methods
public:
Real getValue() { return value; }
protected:
Real value;
};
/* -------------------------------------------------------------------------- */
#endif //__COMPUTE_ENERGY__HH__
#include "compute_gravity.hh"
#include <cmath>
/* -------------------------------------------------------------------------- */
void ComputeGravity::compute(System& system) {}
#ifndef __COMPUTE_GRAVITY__HH__
#define __COMPUTE_GRAVITY__HH__
/* -------------------------------------------------------------------------- */
#include "compute_interaction.hh"
//! Compute Newton gravity interaction
class ComputeGravity : public ComputeInteraction {
// Virtual implementation
public:
//! Newton gravity implementation
void compute(System& system) override;
// Accessors
public:
//! set the gravitational constant
void setG(Real G);
// Members
private:
//! newton constant
Real G = 1.;
};
/* -------------------------------------------------------------------------- */
#endif //__COMPUTE_GRAVITY__HH__
#include "compute_interaction.hh"
#include <cmath>
/* -------------------------------------------------------------------------- */
#ifndef __COMPUTE_INTERACTION__HH__
#define __COMPUTE_INTERACTION__HH__
/* -------------------------------------------------------------------------- */
#include "compute.hh"
//! Base class for interaction computation
class ComputeInteraction : public Compute {};
/* -------------------------------------------------------------------------- */
#endif //__COMPUTE_INTERACTION__HH__
#include "compute_kinetic_energy.hh"
/* -------------------------------------------------------------------------- */
void ComputeKineticEnergy::compute(System& system) {}
/* -------------------------------------------------------------------------- */
#ifndef __COMPUTE_KINETIC_ENERGY__HH__
#define __COMPUTE_KINETIC_ENERGY__HH__
/* -------------------------------------------------------------------------- */
#include "compute_energy.hh"
//! Compute kinetic energy of system
class ComputeKineticEnergy : public ComputeEnergy {
public:
void compute(System& system) override;
};
/* -------------------------------------------------------------------------- */
#endif //__COMPUTE_KINETIC_ENERGY__HH__
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment