Reset platonic code.
[voro++.git] / branches / dynamic / src / dynamic.hh
blobd71f64f84041adaef016ee6e2332bc31833f0fec
1 // Voro++, a 3D cell-based Voronoi library
2 //
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : July 1st 2008
7 /** \file dynamic.hh
8 * \brief Header file for the dynamic extension classes, which add
9 * functionality for a variety of dynamic particle motions. */
11 #ifndef VOROPP_DYNAMIC_HH
12 #define VOROPP_DYNAMIC_HH
14 class cond_all {
15 public:
16 inline bool test(fpoint cx,fpoint cy,fpoint cz) {return true;}
19 class velocity_internal {
20 public:
21 velocity_internal(fpoint **&ive) : track_ve(true), ve(ive) {};
22 inline void vel(int ijk,int q,fpoint &x,fpoint &y,fpoint &z) {
23 x+=ve[ijk][3*q];
24 y+=ve[ijk][3*q+1];
25 z+=ve[ijk][3*q+2];
27 const bool track_ve;
28 private:
29 fpoint **&ve;
32 class velocity_brownian {
33 public:
34 velocity_brownian() : track_ve(false), mag(0.05), tmag(2*mag) {};
35 inline void vel(int ijk,int q,fpoint &x,fpoint &y,fpoint &z) {
36 x+=tmag*rnd()-mag;
37 y+=tmag*rnd()-mag;
38 z+=tmag*rnd()-mag;
40 const bool track_ve;
41 private:
42 const fpoint mag,tmag;
43 inline fpoint rnd() {return fpoint(rand())/RAND_MAX;}
46 class velocity_brownian2 {
47 public:
48 velocity_brownian2() : track_ve(false), mag(0.02), tmag(2*mag) {};
49 inline void vel(int ijk,int q,fpoint &x,fpoint &y,fpoint &z) {
50 fpoint dx,dy,dz;
51 do {
52 dx=tmag*rnd()-mag;
53 dy=tmag*rnd()-mag;
54 dz=tmag*rnd()-mag;
55 } while (dx*dx+dy*dy+dz*dz>=mag*mag);
56 x+=dx/*+0.0001*sin(y*3.1415926535897932384626433832795/20)*/;y+=dy;z+=dz;
58 const bool track_ve;
59 private:
60 const fpoint mag,tmag;
61 inline fpoint rnd() {return fpoint(rand())/RAND_MAX;}
64 class velocity_constant {
65 public:
66 velocity_constant(fpoint idx,fpoint idy,fpoint idz) : track_ve(false),
67 dx(idx), dy(idy), dz(idz) {};
68 inline void vel(int ijk,int q,fpoint &x,fpoint &y,fpoint &z) {
69 x+=dx;y+=dy;z+=dz;
71 const bool track_ve;
72 private:
73 const fpoint dx,dy,dz;
76 class velocity_gaussian {
77 public:
78 velocity_gaussian(fpoint icx,fpoint icy,fpoint icz,fpoint idx,fpoint idy,fpoint idz,fpoint idec)
79 : track_ve(false), cx(idx), cy(idy), cz(idz), dx(idx), dy(idy), dz(idz), dec(idec) {};
80 inline void vel(int ijk,int q,fpoint &x,fpoint &y,fpoint &z) {
81 fpoint ex=x-cx,ey=y-cy,ez=z-cz;
82 ex=exp(-dec*(ex*ex+ey*ey+ez*ez));
83 x+=ex*dx;y+=ex*dy;z+=ex*dz;
85 const bool track_ve;
86 private:
87 const fpoint cx,cy,cz;
88 const fpoint dx,dy,dz;
89 const fpoint dec;
92 template<class r_option>
93 class container_dynamic_base : public container_base<r_option> {
94 public:
95 container_dynamic_base(fpoint xa,fpoint xb,fpoint ya,fpoint yb,fpoint za,
96 fpoint zb,int xn,int yn,int zn,const bool xper,const bool yper,const bool zper,int memi);
97 ~container_dynamic_base();
98 using container_base<r_option>::xperiodic;
99 using container_base<r_option>::yperiodic;
100 using container_base<r_option>::zperiodic;
101 using container_base<r_option>::ax;
102 using container_base<r_option>::ay;
103 using container_base<r_option>::az;
104 using container_base<r_option>::bx;
105 using container_base<r_option>::by;
106 using container_base<r_option>::bz;
107 using container_base<r_option>::nx;
108 using container_base<r_option>::ny;
109 using container_base<r_option>::nz;
110 using container_base<r_option>::nxyz;
111 using container_base<r_option>::xsp;
112 using container_base<r_option>::ysp;
113 using container_base<r_option>::zsp;
114 using container_base<r_option>::co;
115 using container_base<r_option>::p;
116 using container_base<r_option>::sz;
117 using container_base<r_option>::id;
118 using container_base<r_option>::radius;
119 using container_base<r_option>::wall_number;
120 using container_base<r_option>::walls;
121 using container_base<r_option>::mem;
122 inline void clear_velocities();
123 inline void damp_velocities(fpoint damp);
124 void wall_diagnostic();
125 int count(fpoint x,fpoint y,fpoint z,fpoint r);
126 void spot(fpoint cx,fpoint cy,fpoint cz,fpoint dx,fpoint dy,fpoint dz,fpoint rad);
127 void gauss_spot(fpoint cx,fpoint cy,fpoint cz,fpoint dx,fpoint dy,fpoint dz,fpoint dec,fpoint rad);
128 void relax(fpoint cx,fpoint cy,fpoint cz,fpoint rad,fpoint alpha);
129 template<class cond_class>
130 void neighbor_distribution(int *bb,fpoint dr,int max);
131 template<class cond_class>
132 fpoint packing_badness();
133 void full_relax(fpoint alpha);
134 template<class v_class>
135 void local_move(v_class &vcl,fpoint cx,fpoint cy,fpoint cz,fpoint rad);
136 template<class v_class>
137 inline void move() {v_class vcl;move(vcl);}
138 template<class v_class>
139 void move(v_class &vcl);
140 void add_particle_memory(int i);
141 inline int full_count();
142 #ifdef YEAST_ROUTINES
143 void stick(fpoint alpha);
144 void draw_yeast_pov(const char *filename);
145 void draw_yeast_pov(ostream &os);
146 #endif
147 protected:
148 int *gh;
149 fpoint **ve;
150 velocity_internal v_inter;
151 private:
152 inline int step_mod(int a,int b);
153 inline int step_div(int a,int b);
154 inline int step_int(fpoint a);
155 inline void wall_contribution(int s,int l,fpoint cx,fpoint cy,fpoint cz,fpoint alpha);
156 inline void wall_badness(fpoint cx,fpoint cy,fpoint cz,fpoint &badcount);
159 /** The basic dynamic container class. */
160 typedef container_dynamic_base<radius_mono> container_dynamic;
162 /** The polydisperse dynamic container class. */
163 typedef container_dynamic_base<radius_poly> container_dynamic_poly;
165 #endif