-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlattice.h
55 lines (39 loc) · 1.29 KB
/
lattice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef LATTICE_H
#define LATTICE_H
#include <vector>
#include <list>
#include <map>
#include <string>
struct Cell {
bool inSnowflake_before= false;
double vaporMass_before = 0;
double solidMass_before = 0;
double liquidMass_before = 0;
bool inSnowflake_after = false;
double vaporMass_after = 0;
double solidMass_after = 0;
double liquidMass_after = 0;
};
class Lattice: public std::vector<std::vector<Cell>>{
size_t latticeSize;
std::map<std::string, double> parameters;
std::list<std::pair<size_t, size_t>> boundary;
std::list<std::pair<size_t, size_t>> complementOfClosure;
public:
Lattice(size_t size, std::map<std::string, double> parameters);
void diffuse();
void freeze();
void attach();
void melt();
void addNoise();
void saveTo(std::string fileName) const;
private:
void freezeCenter();
void setDensityOutsideSnowflake();
void updateBoundaryAndComplementOfClosure();
void updateValuesOnBoundary();
void updateValuesOnComplementOfClosure();
std::list<std::pair<long int, long int>> getNeighboursIndicesOf(long int i, long int j) const;
void filterInvalidIndices(std::list<std::pair<long int, long int>> &indexList) const;
};
#endif