new benchmark -- fluidanimate for Scheduling
[IRC.git] / Robust / src / Benchmarks / Scheduling / PSFluidAnimate / Cell.java
1 // there is a current limitation of 16 particles per cell
2 // (this structure use to be a simple linked-list of particles but, due to
3 // improved cache locality, we get a huge performance increase by copying
4 // particles instead of referencing them)
5 public class Cell {
6     public int m_id;
7     public int m_numPars;
8     public Vec3[] m_p;
9     public Vec3[] m_hv;
10     public Vec3[] m_v;
11     public Vec3[] m_a;
12     public float[] m_density;
13         
14     public Cell(int _id) {
15         this.m_id = _id;
16         this.m_numPars = 0;
17         this.m_p = new Vec3[16];
18         this.m_hv = new Vec3[16];
19         this.m_v = new Vec3[16];
20         this.m_a = new Vec3[16];
21         this.m_density = new float[16];
22         init();
23     }
24     
25     public Cell clone() {
26         Cell copy = new Cell(this.m_id);
27         copy.m_numPars = this.m_numPars;
28         copy.m_p = new Vec3[16];
29         for(int i = 0; i < this.m_numPars; i++) {
30             copy.m_p[i] = this.m_p[i].clone();
31         }
32         copy.m_hv = new Vec3[16];
33         for(int i = 0; i < this.m_numPars; i++) {
34             copy.m_hv[i] = this.m_hv[i].clone();
35         }
36         copy.m_v = new Vec3[16];
37         for(int i = 0; i < this.m_numPars; i++) {
38             copy.m_v[i] = this.m_v[i].clone();
39         }
40         copy.m_a = new Vec3[16];
41         for(int i = 0; i < this.m_numPars; i++) {
42             copy.m_a[i] = this.m_a[i].clone();
43         }
44         copy.m_density = new float[16];
45         for(int i = 0; i < this.m_numPars; i++) {
46             copy.m_density[i] = this.m_density[i];
47         }
48         return copy;
49     }
50     
51     private void init() {
52         for(int i = 0; i < this.m_p.length; i++) {
53             this.m_p[i] = new Vec3();
54         }
55         for(int i = 0; i < this.m_hv.length; i++) {
56             this.m_hv[i] = new Vec3();
57         }
58         for(int i = 0; i < this.m_v.length; i++) {
59             this.m_v[i] = new Vec3();
60         }
61         for(int i = 0; i < this.m_a.length; i++) {
62             this.m_a[i] = new Vec3();
63         }
64         for(int i = 0; i < this.m_density.length; i++) {
65             this.m_density[i] = 0;
66         }
67     }
68 }