diff options
author | Adam Frisby | 2007-07-22 02:42:29 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-22 02:42:29 +0000 |
commit | 0d7af9bbf02c34557c7fdb106ecab63c009672fc (patch) | |
tree | 92f629f6e129f0a92c435b77df0cf990ed02e611 /OpenSim | |
parent | * More navier-stokes fun. Will finish it later. (diff) | |
download | opensim-SC_OLD-0d7af9bbf02c34557c7fdb106ecab63c009672fc.zip opensim-SC_OLD-0d7af9bbf02c34557c7fdb106ecab63c009672fc.tar.gz opensim-SC_OLD-0d7af9bbf02c34557c7fdb106ecab63c009672fc.tar.bz2 opensim-SC_OLD-0d7af9bbf02c34557c7fdb106ecab63c009672fc.tar.xz |
* Added Navier Stokes computational fluid dynamics algorithms to libTerrain.Channel.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs index df42487..f01b2860 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs | |||
@@ -220,9 +220,40 @@ namespace libTerrain | |||
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | private void nsSimulate(int N, int rounds, double dt, double diff, double visc, double force, double source) | 223 | private void nsSimulate(int N, int rounds, double dt, double diff, double visc) |
224 | { | 224 | { |
225 | int size = (N * 2) * (N * 2); | ||
225 | 226 | ||
227 | double[] u = new double[size]; // Force, X axis | ||
228 | double[] v = new double[size]; // Force, Y axis | ||
229 | double[] u_prev = new double[size]; | ||
230 | double[] v_prev = new double[size]; | ||
231 | double[] dens = (double[])map.Clone(); | ||
232 | double[] dens_prev = (double[])map.Clone(); | ||
233 | |||
234 | for (int i = 0; i < rounds; i++) | ||
235 | { | ||
236 | u_prev = u; | ||
237 | v_prev = v; | ||
238 | dens_prev = dens; | ||
239 | |||
240 | nsVelStep(N, ref u, ref v, ref u_prev, ref v_prev, visc, dt); | ||
241 | nsDensStep(N, ref dens, ref dens_prev, ref u, ref v, diff, dt); | ||
242 | } | ||
243 | |||
244 | nsBufferToDoubles(ref dens, N, ref this.map); | ||
245 | } | ||
246 | |||
247 | /// <summary> | ||
248 | /// Performs computational fluid dynamics on a channel | ||
249 | /// </summary> | ||
250 | /// <param name="rounds">The number of steps to perform (Recommended: 20)</param> | ||
251 | /// <param name="dt">Delta Time - The time between steps</param> | ||
252 | /// <param name="diff">Fluid diffusion rate</param> | ||
253 | /// <param name="visc">Fluid viscosity</param> | ||
254 | public void navierStokes(int rounds, double dt, double diff, double visc) | ||
255 | { | ||
256 | nsSimulate(this.h, rounds, dt, diff, visc); | ||
226 | } | 257 | } |
227 | } | 258 | } |
228 | } \ No newline at end of file | 259 | } \ No newline at end of file |