This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
date time ( uptime ) [ thread name/id ] file:line v| | |
2019-03-11 21:46:14.591 ( 0.000s) [main thread ] loguru.cpp:587 INFO| arguments: /mnt/c/Develop/LoggingWithLoguru/cmake-build-debug-wsl/LoggingWithLoguru | |
2019-03-11 21:46:14.591 ( 0.000s) [main thread ] loguru.cpp:590 INFO| Current dir: /mnt/c/Develop/LoggingWithLoguru/cmake-build-debug-wsl | |
2019-03-11 21:46:14.591 ( 0.000s) [main thread ] loguru.cpp:592 INFO| stderr verbosity: 0 | |
2019-03-11 21:46:14.592 ( 0.000s) [main thread ] loguru.cpp:593 INFO| ----------------------------------- | |
2019-03-11 21:46:14.592 ( 0.001s) [main thread ] loguru.cpp:751 INFO| Logging to 'important.log', mode: 'w', verbosity: 0 | |
2019-03-11 21:46:14.592 ( 0.001s) [main thread ] main.cpp:47 INFO| We are starting our complex threaded computation! | |
2019-03-11 21:46:14.592 ( 0.001s) [main thread ] main.cpp:15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <thread> | |
#include "loguru.hpp" | |
#include "loguru.cpp" | |
void sleep(int ms) | |
{ | |
//We can also inject parameters into the logging strings | |
VLOG_F(0, "Sleeping for %d ms", ms); | |
std::this_thread::sleep_for(std::chrono::milliseconds(ms)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const double Solver::G = 6.67408e-11; | |
const double Solver::EPSILON3 = 1e-9; | |
Solver::Solver(double mEpsilon) : mEpsilon(mEpsilon) {} | |
std::vector<Particle> Solver::solve(const std::vector<Particle> &particles) const { | |
std::vector<Particle> solution(particles.size()); | |
const double epsilon2 = mEpsilon*mEpsilon; | |
std::transform(begin(particles), end(particles), begin(solution), [&particles, epsilon2, epsilon = mEpsilon](Particle particle) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<Particle> ParticleBuilder::build(size_t numberOfParticles) | |
{ | |
std::vector<Particle> particle(numberOfParticles); | |
std::mt19937 mt(std::random_device{}()); | |
std::uniform_real_distribution real_dist(1.0, static_cast<double>(numberOfParticles)); | |
auto gen = std::bind(std::ref(real_dist), std::ref(mt)); | |
for(Particle &p : particle) { | |
p = mass(gen()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class Coordinate { | |
X, | |
Y | |
}; | |
class Vector2D { | |
public: | |
Vector2D(double x = 0.0, double y = 0.0) : mData{x, y} {} | |
double length() const { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
solverTest is a Catch v2.6.1 host application. | |
Run with -? for options | |
------------------------------------------------------------------------------- | |
Benchmarking euler | |
------------------------------------------------------------------------------- | |
/mnt/c/Develop/gravity/solverTest/src/solverTest.cpp:62 | |
............................................................................... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
solverTest is a Catch v2.6.1 host application. | |
Run with -? for options | |
------------------------------------------------------------------------------- | |
Benchmarking euler | |
------------------------------------------------------------------------------- | |
/mnt/c/Develop/gravity/solverTest/src/solverTest.cpp:62 | |
............................................................................... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
solverTest is a Catch v2.6.1 host application. | |
Run with -? for options | |
------------------------------------------------------------------------------- | |
Benchmarking euler | |
------------------------------------------------------------------------------- | |
/mnt/c/Develop/gravity/solverTest/src/solverTest.cpp:63 | |
............................................................................... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const double Solver::G = 6.67408e-11; | |
const double Solver::EPSILON = 1e-3; | |
Solver::Solver(double mEpsilon) : mEpsilon(mEpsilon) {} | |
std::vector<Particle> Solver::solve(const std::vector<Particle> &particles) const { | |
std::vector<Particle> solution = calculateAcceleration(particles); | |
solution = calculateVelocity(solution); | |
solution = calculatePosition(solution); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solver { | |
public: | |
explicit Solver(double mEpsilon); | |
std::vector<Particle> solve(const std::vector<Particle> &particles) const; | |
private: | |
std::vector<Particle> calculateAcceleration(const std::vector<Particle> &particles) const; | |
std::vector<Particle> calculateVelocity(const std::vector<Particle> &particles) const; | |
std::vector<Particle> calculatePosition(const std::vector<Particle> &particles) const; |