Skip to content

Commit e379525

Browse files
committed
Minor bugfix with graphics velocity color scale (GRAPHICS_U_MAX, def_scale_u)
1 parent db8496d commit e379525

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/defines.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define GRAPHICS_FRAME_WIDTH 3840 // set frame width if only GRAPHICS is enabled
3131
#define GRAPHICS_FRAME_HEIGHT 2160 // set frame height if only GRAPHICS is enabled
3232
#define GRAPHICS_BACKGROUND_COLOR 0x000000 // set background color; black background (default) = 0x000000, white background = 0xFFFFFF
33-
#define GRAPHICS_U_MAX 0.15f // maximum velocity for velocity coloring in units of LBM lattice speed of sound (c=1/sqrt(3)) (default: 0.15f)
33+
#define GRAPHICS_U_MAX 0.2f // maximum velocity for velocity coloring in units of LBM lattice speed of sound (c=1/sqrt(3)) (default: 0.2f)
3434
#define GRAPHICS_Q_CRITERION 0.0001f // Q-criterion value for Q-criterion isosurface visualization (default: 0.0001f)
3535
#define GRAPHICS_BOUNDARY_FORCE_SCALE 100.0f // scaling factor for visualization of forces on solid boundaries if VOLUME_FORCE is enabled and lbm.calculate_force_on_boundaries(); is called (default: 100.0f)
3636
#define GRAPHICS_STREAMLINE_SPARSE 4 // set how many streamlines there are every x lattice points

src/kernel.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,7 @@ string opencl_c_container() { return R( // ########################## begin of O
23782378
)+"#ifndef GRAPHICS_TEMPERATURE"+R(
23792379
const int c = iron_color(255.0f*def_scale_u*ul);
23802380
)+"#else"+R( // GRAPHICS_TEMPERATURE
2381-
const int c = iron_color(180.0f+250.0f*(T[n]-def_T_avg));
2381+
const int c = iron_color(167.0f+255.0f*(T[n]-def_T_avg));
23822382
)+"#endif"+R( // GRAPHICS_TEMPERATURE
23832383
draw_line(p0, p1, c, camera_cache, bitmap, zbuffer);
23842384
}
@@ -2396,7 +2396,7 @@ string opencl_c_container() { return R( // ########################## begin of O
23962396
float camera_cache[15]; // cache camera parameters in case the kernel draws more than one shape
23972397
for(uint i=0u; i<15u; i++) camera_cache[i] = camera[i];
23982398
const float3 p = position(coordinates(n));
2399-
const int c = rainbow_color(255.0f*2.0f*ul*def_scale_u); // coloring by velocity
2399+
const int c = rainbow_color(255.0f*def_scale_u*ul); // coloring by velocity
24002400
draw_line(p-(0.5f/ul)*un, p+(0.5f/ul)*un, c, camera_cache, bitmap, zbuffer);
24012401
}
24022402

@@ -2487,15 +2487,15 @@ string opencl_c_container() { return R( // ########################## begin of O
24872487
{
24882488
const float x1=p0.x, y1=p0.y, z1=p0.z, x0=1.0f-x1, y0=1.0f-y1, z0=1.0f-z1; // calculate interpolation factors
24892489
const float3 ui = (x0*y0*z0)*uj[0]+(x1*y0*z0)*uj[1]+(x1*y0*z1)*uj[2]+(x0*y0*z1)*uj[3]+(x0*y1*z0)*uj[4]+(x1*y1*z0)*uj[5]+(x1*y1*z1)*uj[6]+(x0*y1*z1)*uj[7]; // perform trilinear interpolation
2490-
c0 = lighting(rainbow_color(255.0f*2.0f*length(ui)*def_scale_u), p0+offset, normal, camera_cache); // rainbow_color(255.0f*2.0f*length(ui)*def_scale_u);
2490+
c0 = lighting(rainbow_color(255.0f*def_scale_u*length(ui)), p0+offset, normal, camera_cache); // rainbow_color(255.0f*def_scale_u*length(ui));
24912491
} {
24922492
const float x1=p1.x, y1=p1.y, z1=p1.z, x0=1.0f-x1, y0=1.0f-y1, z0=1.0f-z1; // calculate interpolation factors
24932493
const float3 ui = (x0*y0*z0)*uj[0]+(x1*y0*z0)*uj[1]+(x1*y0*z1)*uj[2]+(x0*y0*z1)*uj[3]+(x0*y1*z0)*uj[4]+(x1*y1*z0)*uj[5]+(x1*y1*z1)*uj[6]+(x0*y1*z1)*uj[7]; // perform trilinear interpolation
2494-
c1 = lighting(rainbow_color(255.0f*2.0f*length(ui)*def_scale_u), p1+offset, normal, camera_cache); // rainbow_color(255.0f*2.0f*length(ui)*def_scale_u);
2494+
c1 = lighting(rainbow_color(255.0f*def_scale_u*length(ui)), p1+offset, normal, camera_cache); // rainbow_color(255.0f*def_scale_u*length(ui));
24952495
} {
24962496
const float x1=p2.x, y1=p2.y, z1=p2.z, x0=1.0f-x1, y0=1.0f-y1, z0=1.0f-z1; // calculate interpolation factors
24972497
const float3 ui = (x0*y0*z0)*uj[0]+(x1*y0*z0)*uj[1]+(x1*y0*z1)*uj[2]+(x0*y0*z1)*uj[3]+(x0*y1*z0)*uj[4]+(x1*y1*z0)*uj[5]+(x1*y1*z1)*uj[6]+(x0*y1*z1)*uj[7]; // perform trilinear interpolation
2498-
c2 = lighting(rainbow_color(255.0f*2.0f*length(ui)*def_scale_u), p2+offset, normal, camera_cache); // rainbow_color(255.0f*2.0f*length(ui)*def_scale_u);
2498+
c2 = lighting(rainbow_color(255.0f*def_scale_u*length(ui)), p2+offset, normal, camera_cache); // rainbow_color(255.0f*def_scale_u*length(ui));
24992499
}
25002500
draw_triangle_interpolated(p0+offset, p1+offset, p2+offset, c0, c1, c2, camera_cache, bitmap, zbuffer); // draw triangle with interpolated colors
25012501
}

src/lbm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ string LBM_Domain::Graphics::device_defines() const { return
418418
"\n #define def_screen_width " +to_string(camera.width)+"u"
419419
"\n #define def_screen_height " +to_string(camera.height)+"u"
420420
"\n #define def_n " +to_string(1.333f)+"f" // refractive index of water
421-
"\n #define def_scale_u " +to_string(0.57735027f/(GRAPHICS_U_MAX))+"f"
421+
"\n #define def_scale_u " +to_string(1.0f/(0.57735027f*(GRAPHICS_U_MAX)))+"f"
422422
"\n #define def_scale_Q_min " +to_string(GRAPHICS_Q_CRITERION)+"f"
423423
"\n #define def_scale_F " +to_string(GRAPHICS_BOUNDARY_FORCE_SCALE)+"f"
424424
"\n #define def_streamline_sparse "+to_string(GRAPHICS_STREAMLINE_SPARSE)+"u"

src/setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@
457457
lbm.voxelize_mesh_on_device(rotor, TYPE_S, center, float3(0.0f), float3(0.0f, omega, 0.0f));
458458
const ulong N=lbm.get_N(); uint Nx=lbm.get_Nx(), Ny=lbm.get_Ny(), Nz=lbm.get_Nz(); for(ulong n=0ull; n<N; n++) { uint x=0u, y=0u, z=0u; lbm.coordinates(n, x, y, z);
459459
// ########################################################################### define geometry #############################################################################################
460-
if(lbm.flags[n]==0u) lbm.u.y[n] = 0.15f*u;
460+
if(lbm.flags[n]==0u) lbm.u.y[n] = 0.3f*u;
461461
if(x==0u||x==Nx-1u||y==0u||y==Ny-1u||z==0u||z==Nz-1u) lbm.flags[n] = TYPE_E; // all non periodic
462462
} // #########################################################################################################################################################################################
463463
key_4 = true;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy