Format
This commit is contained in:
parent
f79763eee4
commit
496c1022db
@ -90,8 +90,7 @@ int DLASystem::checkStop() {
|
||||
cout << "STOP" << endl;
|
||||
glutPostRedisplay(); // update display
|
||||
return 1;
|
||||
}
|
||||
else return 0;
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
// add a particle to the system at a specific position
|
||||
@ -213,8 +212,7 @@ void DLASystem::moveLastParticle() {
|
||||
logfile << numParticles << " " << clusterRadius << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// if we get to here then we are trying to move to an occupied site
|
||||
// (this should never happen as long as the sticking probability is 1.0)
|
||||
cout << "reject " << rr << endl;
|
||||
@ -279,7 +277,6 @@ DLASystem::~DLASystem() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this draws the system
|
||||
void DLASystem::DrawSquares() {
|
||||
|
||||
|
||||
16
DLASystem.h
16
DLASystem.h
@ -5,7 +5,9 @@
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include <math.h>
|
||||
#include <random>
|
||||
#include <string>
|
||||
@ -81,6 +83,7 @@ class DLASystem {
|
||||
|
||||
// constructor
|
||||
DLASystem(Window *set_win);
|
||||
|
||||
// destructor
|
||||
~DLASystem();
|
||||
|
||||
@ -95,16 +98,23 @@ class DLASystem {
|
||||
|
||||
// stop/start the algorithm
|
||||
void setRunning() { if (checkStop() == 0) running = 1; }
|
||||
|
||||
void pauseRunning() { running = 0; }
|
||||
|
||||
// set whether it runs fast or slow
|
||||
void setSlow() { slowNotFast = 1; }
|
||||
|
||||
void setFast() { slowNotFast = 0; }
|
||||
|
||||
void setSuperFast() { slowNotFast = -1; }
|
||||
|
||||
// set which part of the grid is visible on the screen
|
||||
// basically the screen shows co-ordinates -vv < x < vv
|
||||
// where vv is the input value
|
||||
void setViewSize(double vv) { viewSize = vv; drawScale = 2.0/viewSize; }
|
||||
void setViewSize(double vv) {
|
||||
viewSize = vv;
|
||||
drawScale = 2.0 / viewSize;
|
||||
}
|
||||
|
||||
// if the killcircle is almost as big as the view then increase the view
|
||||
void updateViewSize();
|
||||
@ -117,6 +127,7 @@ class DLASystem {
|
||||
|
||||
// set and read grid entries associated with a given position
|
||||
void setGrid(double pos[], int val);
|
||||
|
||||
int readGrid(double pos[]);
|
||||
|
||||
// return the distance of a given point from the origin
|
||||
@ -126,10 +137,12 @@ class DLASystem {
|
||||
|
||||
// set whether there is an active particle in the system or not
|
||||
void setParticleActive() { lastParticleIsActive = 1; }
|
||||
|
||||
void setParticleInactive() { lastParticleIsActive = 0; }
|
||||
|
||||
// add a particle at pos
|
||||
void addParticle(double pos[]);
|
||||
|
||||
// add a particle at a random point on the addCircle
|
||||
void addParticleOnAddCircle();
|
||||
|
||||
@ -150,5 +163,6 @@ class DLASystem {
|
||||
// it would be better for an OOP philosophy to make these member functions for the Window class
|
||||
// but we are being a bit lazy here
|
||||
void setWinBackgroundWhite() { glClearColor(1.0, 1.0, 1.0, 1.0); }
|
||||
|
||||
void setWinBackgroundBlack() { glClearColor(0.0, 0.0, 0.0, 0.0); }
|
||||
};
|
||||
|
||||
@ -9,12 +9,14 @@ class Particle {
|
||||
Particle() {
|
||||
pos = new double[dim];
|
||||
}
|
||||
|
||||
// constructor, with a specified initial position
|
||||
Particle(double set_pos[]) {
|
||||
pos = new double[dim];
|
||||
for (int d = 0; d < dim; d++)
|
||||
pos[d] = set_pos[d];
|
||||
}
|
||||
|
||||
// destructor
|
||||
~Particle() { delete[] pos; }
|
||||
};
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
|
||||
// constructor
|
||||
Window::Window(int set_size[], string &set_title) {
|
||||
size[0]=set_size[0]; size[1]=set_size[1];
|
||||
size[0] = set_size[0];
|
||||
size[1] = set_size[1];
|
||||
title = set_title;
|
||||
|
||||
locateOnScreen();
|
||||
|
||||
@ -13,8 +13,11 @@ using namespace std;
|
||||
// functions which are needed for openGL go into a namespace so that we can identify them
|
||||
namespace drawFuncs {
|
||||
void handleKeypress(unsigned char key, int x, int y);
|
||||
|
||||
void display(void);
|
||||
|
||||
void update(int val);
|
||||
|
||||
void introMessage();
|
||||
}
|
||||
|
||||
|
||||
9
rnd.h
9
rnd.h
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <random>
|
||||
|
||||
// ... don't worry how this all works
|
||||
@ -22,12 +23,18 @@ public:
|
||||
intmax = new std::uniform_int_distribution<int>(0, genMax);
|
||||
real01 = new std::uniform_real_distribution<double>(0.0, 1.0);
|
||||
}
|
||||
|
||||
// destructor
|
||||
~rnd() { delete intmax; delete real01; }
|
||||
~rnd() {
|
||||
delete intmax;
|
||||
delete real01;
|
||||
}
|
||||
|
||||
// set the random seed
|
||||
void setSeed(int seed) { generator.seed(seed); }
|
||||
|
||||
// member functions for generating random double in [0,1] and random integer in [0,max-1]
|
||||
double random01() { return (*real01)(generator); }
|
||||
|
||||
int randomInt(int max) { return (*intmax)(generator) % max; }
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user