diff options
author | Adrian Kummerlaender | 2019-02-20 23:52:02 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2019-02-20 23:52:02 +0100 |
commit | 409ca238ec8f4f405443931947b2a85c03754bc9 (patch) | |
tree | 414c6cfb7d8f454272269b2460032b9f33315d04 /src | |
parent | 823a9dade6e36760a827aae6ac841b8c582a7935 (diff) | |
download | compustream-409ca238ec8f4f405443931947b2a85c03754bc9.tar compustream-409ca238ec8f4f405443931947b2a85c03754bc9.tar.gz compustream-409ca238ec8f4f405443931947b2a85c03754bc9.tar.bz2 compustream-409ca238ec8f4f405443931947b2a85c03754bc9.tar.lz compustream-409ca238ec8f4f405443931947b2a85c03754bc9.tar.xz compustream-409ca238ec8f4f405443931947b2a85c03754bc9.tar.zst compustream-409ca238ec8f4f405443931947b2a85c03754bc9.zip |
Initialize cells using their equilibrium distribution
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer/vertex/lattice_cell_buffer.cc | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/buffer/vertex/lattice_cell_buffer.cc b/src/buffer/vertex/lattice_cell_buffer.cc index e8cfc08..2011b14 100644 --- a/src/buffer/vertex/lattice_cell_buffer.cc +++ b/src/buffer/vertex/lattice_cell_buffer.cc @@ -2,23 +2,29 @@ #include <vector> +std::vector<GLfloat> makeLattice(GLuint nX, GLuint nY) { + std::vector<GLfloat> data(9*nX*nY, GLfloat{}); + + const GLfloat equilibrium[9] { + 1./36., 1./9., 1./36., + 1./9. , 4./9., 1./9. , + 1./36 , 1./9., 1./36. + }; + + for (int i = 0; i < nX*nY; ++i) { + for (int q = 0; q < 9; ++q) { + data[9*i+q] = equilibrium[q]; + } + } + + return data; +} + LatticeCellBuffer::LatticeCellBuffer(GLuint nX, GLuint nY) { glGenVertexArrays(1, &_array); glGenBuffers(1, &_buffer); - std::vector<GLfloat> data(9*nX*nY, GLfloat{1./9.}); - /*const int insetX = 0.45*nX; - const int insetY = 0.45*nY; - - for (int x = insetX; x < nX-insetX; x++) { - for (int y = insetY; y < nY-insetY; y++) { - for ( int i = -1; i <= 1; ++i ) { - for ( int j = -1; j <= 1; ++j ) { - data[9*nX*y + 9*x + (i+1)*3 + j+1] = 0.5; - } - } - } - }*/ + const std::vector<GLfloat> data = makeLattice(nX, nY); glBindVertexArray(_array); glBindBuffer(GL_ARRAY_BUFFER, _buffer); |