Skip to content

Commit

Permalink
SOR working fully
Browse files Browse the repository at this point in the history
  • Loading branch information
20k committed Oct 6, 2019
1 parent 3737c82 commit 9f87cab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions fluid.cl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void fluid_jacobi(__read_only image2d_t xvector, __read_only image2d_t bvector,
}

__kernel
void fluid_jacobi_rb(__read_only image2d_t xvector, __read_only image2d_t bvector, __write_only image2d_t out, float alpha, float rbeta, int red)
void fluid_jacobi_rb(__read_only image2d_t xvector, __read_only image2d_t bvector, __write_only image2d_t out, float alpha, float rbeta, int red, float weight)
{
sampler_t sam = CLK_NORMALIZED_COORDS_FALSE |
CLK_ADDRESS_CLAMP_TO_EDGE |
Expand Down Expand Up @@ -124,14 +124,16 @@ void fluid_jacobi_rb(__read_only image2d_t xvector, __read_only image2d_t bvecto
if(pos.x == gw)
pos.x = 0;

float4 xC = read_imagef(xvector, sam, pos);

float4 xL = read_imagef(xvector, sam, pos - (int2){1, 0});
float4 xR = read_imagef(xvector, sam, pos + (int2){1, 0});
float4 xB = read_imagef(xvector, sam, pos - (int2){0, 1});
float4 xT = read_imagef(xvector, sam, pos + (int2){0, 1});

float4 bC = read_imagef(bvector, sam, pos);

float4 xnew = (xL + xR + xB + xT + alpha * bC) * rbeta;
float4 xnew = xC + weight * (xL + xR + xB + xT + alpha * bC - 4 * xC) * rbeta;

write_imagef(out, convert_int2(pos), xnew);
}
Expand Down
12 changes: 6 additions & 6 deletions fluid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ struct fluid_manager

cqueue.exec("fluid_divergence", divergence_args, velocity_dim, {16, 16});

int pressure_iterations_diff = 20;
int pressure_iterations_diff = 10;

///source of slowdown
///need the ability to create specific textures
Expand All @@ -549,7 +549,9 @@ struct fluid_manager
float rbeta = 1/4.f;

cl::buffer* p1 = get_pressure_buf(0);
//cl::buffer* p2 = get_pressure_buf(1);
cl::buffer* p2 = get_pressure_buf(1);

float optimal_w = 1.8;

int red = 0;

Expand All @@ -560,6 +562,7 @@ struct fluid_manager
pressure_args.push_back(alpha);
pressure_args.push_back(rbeta);
pressure_args.push_back(red);
pressure_args.push_back(optimal_w);

cqueue.exec("fluid_jacobi_rb", pressure_args, {velocity_dim.x() / 2, velocity_dim.y()}, {16, 16});

Expand All @@ -572,12 +575,9 @@ struct fluid_manager
pressure_args_red.push_back(alpha);
pressure_args_red.push_back(rbeta);
pressure_args_red.push_back(red);
pressure_args_red.push_back(optimal_w);

cqueue.exec("fluid_jacobi_rb", pressure_args_red, {velocity_dim.x() / 2, velocity_dim.y()}, {16, 16});

//flip_pressure();

//pressure_boundary(program, cqueue);
}

pressure_boundary(cqueue);
Expand Down

0 comments on commit 9f87cab

Please sign in to comment.