From 0d7af9bbf02c34557c7fdb106ecab63c009672fc Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Sun, 22 Jul 2007 02:42:29 +0000
Subject: * Added Navier Stokes computational fluid dynamics algorithms to
libTerrain.Channel.
---
.../Channel/Manipulators/NavierStokes.cs | 33 +++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel')
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
}
}
- private void nsSimulate(int N, int rounds, double dt, double diff, double visc, double force, double source)
+ private void nsSimulate(int N, int rounds, double dt, double diff, double visc)
{
+ int size = (N * 2) * (N * 2);
+ double[] u = new double[size]; // Force, X axis
+ 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();
+
+ for (int i = 0; i < rounds; i++)
+ {
+ u_prev = u;
+ v_prev = v;
+ dens_prev = dens;
+
+ nsVelStep(N, ref u, ref v, ref u_prev, ref v_prev, visc, dt);
+ nsDensStep(N, ref dens, ref dens_prev, ref u, ref v, diff, dt);
+ }
+
+ nsBufferToDoubles(ref dens, N, ref this.map);
+ }
+
+ ///
+ /// Performs computational fluid dynamics on a channel
+ ///
+ /// The number of steps to perform (Recommended: 20)
+ /// Delta Time - The time between steps
+ /// Fluid diffusion rate
+ /// Fluid viscosity
+ public void navierStokes(int rounds, double dt, double diff, double visc)
+ {
+ nsSimulate(this.h, rounds, dt, diff, visc);
}
}
}
\ No newline at end of file
--
cgit v1.1