Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] View of /branches/charisee/ertest/vispaper/viso3d/hiso3d.diderot
 [diderot] / branches / charisee / ertest / vispaper / viso3d / hiso3d.diderot

# View of /branches/charisee/ertest/vispaper/viso3d/hiso3d.diderot

Mon Mar 2 21:43:27 2015 UTC (4 years, 5 months ago) by glk
File size: 1428 byte(s)
tweaks
/*

../../../bin/diderotc hiso3d.diderot \
&& ./hiso3d \
&& unu dice -i hiso3d.txt -a 0 -o ./ \
&& unu jhisto -i {0,1}.nrrd -b 400 400 -min -1.2 -1.2 -max 1.2 1.2 -t float | \
unu 1op log1p | \
unu quantize -b 8 -o tmp.png \
&& unu jhisto -i {1,2}.nrrd -b 400 400 -min -1.2 -1.2 -max 1.2 1.2 -t float | \
unu 1op log1p | \
unu quantize -b 8 | unu join -i tmp.png - -a 0 -o hiso3d.png \
&& rm -f {0,1,2}.nrrd \
&& open hiso3d.png

*/

field#1(3)[] F= V•(∇×V) - 0.18; // seems to work correctly

int grid = 50;
int stepsMax = 10;
real epsilon = 0.000001;

strand RootFind(real xi,real xj, real xk) {
output vec3 x = [xi,xj,xk];
int steps = 0;
update {
// Stop if we're no longer inside or taken too many steps.
if (!inside(x, V) || steps > stepsMax)
die;
// subsequent expressions are undefined if |∇F| is zero
if (|∇F(x)| == 0.0)
die;
// the Newton-Raphson step
vec3 delta = normalize(∇F(x)) * F(x)/|∇F(x)|;
// we've converged if the change is small enough
if (|delta| < epsilon)
stabilize;
x -= delta;
steps += 1;
}
}

initially { RootFind(lerp(-2, 2, -0.5, ui, grid-0.5),
lerp(-2, 2, -0.5, vi, grid-0.5),
lerp(-2, 2, -0.5, wi, grid-0.5))
| wi in 0..(grid-1), vi in 0..(grid-1), ui in 0..(grid-1) };