From 3abdec8d1748e14894837290c2a5707673389182 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 23 Jul 2007 16:16:09 +0000 Subject: * Fixed a typecasting issue with Navier-Stokes algorithms in libTerrain. --- .../Channel/Manipulators/NavierStokes.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs index 43987d4..24ff37c 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs @@ -220,6 +220,20 @@ namespace libTerrain } } + private void nsDoublesToBuffer(double[,] doubles, int N, ref double[] dens) + { + int i; + int j; + + for (i = 0; i <= N; i++) + { + for (j = 0; j <= N; j++) + { + dens[nsIX(i, j, N)] = doubles[i, j]; + } + } + } + private void nsSimulate(int N, int rounds, double dt, double diff, double visc) { int size = (N * 2) * (N * 2); @@ -228,8 +242,11 @@ namespace libTerrain double[] v = new double[size]; // Force, Y axis double[] u_prev = new double[size]; double[] v_prev = new double[size]; - double[] dens = (double[])map.Clone(); - double[] dens_prev = (double[])map.Clone(); + double[] dens = new double[size]; + double[] dens_prev = new double[size]; + + nsDoublesToBuffer(this.map, N, ref dens); + nsDoublesToBuffer(this.map, N, ref dens_prev); for (int i = 0; i < rounds; i++) { -- cgit v1.1