/** * Copyright 2013 the V8 project authors. All rights reserved. * Copyright 2009 Oliver Hunt <http://nerget.com> * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Update 10/21/2013: fixed loop variables at line 119
*/
var NavierStokes = new BenchmarkSuite('NavierStokes', [1484000],
[new Benchmark('NavierStokes', true, false,
180,
runNavierStokes,
setupNavierStokes,
tearDownNavierStokes, null,
16)]);
var solver = null; var nsFrameCounter = 0;
function runNavierStokes()
{
solver.update();
nsFrameCounter++;
this.result = 0; for (var i=7000;i<7100;i++) { this.result+=~~((dens[i]*10));
}
if (this.result!=77) { throw(new Error("checksum failed"));
}
}
function setupNavierStokes()
{
solver = new FluidField(null);
solver.setResolution(128, 128);
solver.setIterations(20);
solver.setDisplayFunction(function(){});
solver.setUICallback(prepareFrame);
solver.reset();
}
function tearDownNavierStokes()
{
solver = null;
}
function addPoints(field) { var n = 64; for (var i = 1; i <= n; i++) {
field.setVelocity(i, i, n, n);
field.setDensity(i, i, 5);
field.setVelocity(i, n - i, -n, -n);
field.setDensity(i, n - i, 20);
field.setVelocity(128 - i, n + i, -n, -n);
field.setDensity(128 - i, n + i, 30);
}
}
var framesTillAddingPoints = 0; var framesBetweenAddingPoints = 5;
function prepareFrame(field)
{ if (framesTillAddingPoints == 0) {
addPoints(field);
framesTillAddingPoints = framesBetweenAddingPoints;
framesBetweenAddingPoints++;
} else {
framesTillAddingPoints--;
}
}
// Code from Oliver Hunt (http://nerget.com/fluidSim/pressure.js) starts here. function FluidField(canvas) { function addFields(x, s, dt)
{ for (var i=0; i<size ; i++ ) x[i] += dt*s[i];
}
function set_bnd(b, x)
{ if (b===1) { for (var i = 1; i <= width; i++) {
x[i] = x[i + rowSize];
x[i + (height+1) *rowSize] = x[i + height * rowSize];
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.