-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin.h
More file actions
40 lines (30 loc) · 1.17 KB
/
bin.h
File metadata and controls
40 lines (30 loc) · 1.17 KB
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
#ifndef __BIN_H__
#define __BIN_H__
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "common.h"
typedef struct
{
int* indeces;
int bin_size;
int capacity;
}bin_t;
// This function will allocate initial memory for each bin
void init_grid(int num_bins, bin_t *bin_list);
// This function calculates the size of the bins, usually rectangular
void set_grid_size(int &x, int &y, int num_bins);
// This function bins particles to bins, should be called only before the simulation
void bin_particles(int n, particle_t *particles, int num_bins, bin_t *bin_list, double bin_x, double bin_y, int num_rows);
// Deallocate the memory of each bin
void clear_grid(int num_bins, bin_t *bin_list);
// Add particle i to bin j, dynamically adjust the bin size if necessary
void add_particle(bin_t *bin_list, int i, int j);
// Remove particle i from bin j
void remove_particle(bin_t *bin_list, int i, int j);
// This clears and reallocates memory for one col of the grid from start to end
void clear_bin_col(bin_t *bin_list, int start, int end, int col, int lda);
// Called only when debugging
void sanity_check(int n, int num_bins, bin_t *bin_list);
#endif