better time tracking for grid2
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
eed5f79130
commit
c96113133d
19
src/main/c/includes/fluid/env/environment.h
vendored
19
src/main/c/includes/fluid/env/environment.h
vendored
@ -65,6 +65,22 @@ typedef struct {
|
|||||||
float dt;
|
float dt;
|
||||||
} FluidSimConsts;
|
} FluidSimConsts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time tracking for the fluid simulator
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
//density data
|
||||||
|
double densityTotal;
|
||||||
|
double densityDiffuse;
|
||||||
|
double densityAdvect;
|
||||||
|
|
||||||
|
//velocity data
|
||||||
|
double velocityTotal;
|
||||||
|
double velocityDiffuse;
|
||||||
|
double velocityAdvect;
|
||||||
|
double velocityProject;
|
||||||
|
} FluidTimeTracking;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for tracking the change in density over time of the environment
|
* Used for tracking the change in density over time of the environment
|
||||||
*/
|
*/
|
||||||
@ -72,9 +88,8 @@ typedef struct {
|
|||||||
double existingDensity;
|
double existingDensity;
|
||||||
double newDensity;
|
double newDensity;
|
||||||
double normalizationRatio;
|
double normalizationRatio;
|
||||||
double densityTime;
|
|
||||||
double velocityTime;
|
|
||||||
int frame;
|
int frame;
|
||||||
|
FluidTimeTracking timeTracking;
|
||||||
} FluidSimState;
|
} FluidSimState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -91,7 +91,17 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
|
|
||||||
//solve vector diffusion
|
//solve vector diffusion
|
||||||
fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep);
|
fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep);
|
||||||
|
}
|
||||||
|
|
||||||
|
//time tracking
|
||||||
|
gettimeofday(&tv,NULL);
|
||||||
|
end = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
||||||
|
perMilli = (end - start) / 1000.0f;
|
||||||
|
environment->state.timeTracking.velocityDiffuse = perMilli;
|
||||||
|
start = end;
|
||||||
|
|
||||||
|
for(int i = 0; i < numChunks; i++){
|
||||||
|
Chunk * currentChunk = chunks[i];
|
||||||
//setup projection
|
//setup projection
|
||||||
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
||||||
|
|
||||||
@ -106,10 +116,31 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
fluid_grid2_flip_arrays(currentChunk->u,currentChunk->u0);
|
fluid_grid2_flip_arrays(currentChunk->u,currentChunk->u0);
|
||||||
fluid_grid2_flip_arrays(currentChunk->v,currentChunk->v0);
|
fluid_grid2_flip_arrays(currentChunk->v,currentChunk->v0);
|
||||||
fluid_grid2_flip_arrays(currentChunk->w,currentChunk->w0);
|
fluid_grid2_flip_arrays(currentChunk->w,currentChunk->w0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//time tracking
|
||||||
|
gettimeofday(&tv,NULL);
|
||||||
|
end = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
||||||
|
perMilli = (end - start) / 1000.0f;
|
||||||
|
environment->state.timeTracking.velocityProject = perMilli;
|
||||||
|
start = end;
|
||||||
|
|
||||||
|
for(int i = 0; i < numChunks; i++){
|
||||||
|
Chunk * currentChunk = chunks[i];
|
||||||
//advect
|
//advect
|
||||||
fluid_grid2_advectVectors(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep);
|
fluid_grid2_advectVectors(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//time tracking
|
||||||
|
gettimeofday(&tv,NULL);
|
||||||
|
end = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
||||||
|
perMilli = (end - start) / 1000.0f;
|
||||||
|
environment->state.timeTracking.velocityAdvect = perMilli;
|
||||||
|
start = end;
|
||||||
|
|
||||||
|
for(int i = 0; i < numChunks; i++){
|
||||||
|
Chunk * currentChunk = chunks[i];
|
||||||
//setup projection
|
//setup projection
|
||||||
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
|
||||||
//Perform main projection solver
|
//Perform main projection solver
|
||||||
@ -119,11 +150,11 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//get time at end
|
//time tracking
|
||||||
gettimeofday(&tv,NULL);
|
gettimeofday(&tv,NULL);
|
||||||
end = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
end = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
||||||
perMilli = (end - start) / 1000.0f;
|
perMilli = (end - start) / 1000.0f;
|
||||||
environment->state.velocityTime = perMilli;
|
environment->state.timeTracking.velocityProject = environment->state.timeTracking.velocityProject + perMilli;
|
||||||
start = end;
|
start = end;
|
||||||
|
|
||||||
///------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
///------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -146,14 +177,23 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
|
|
||||||
fluid_grid2_addDensity(environment,currentChunk->d,currentChunk->d0,timestep);
|
fluid_grid2_addDensity(environment,currentChunk->d,currentChunk->d0,timestep);
|
||||||
environment->state.existingDensity = environment->state.existingDensity + fluid_grid2_calculateSum(currentChunk->d);
|
environment->state.existingDensity = environment->state.existingDensity + fluid_grid2_calculateSum(currentChunk->d);
|
||||||
|
|
||||||
//swap all density arrays
|
//swap all density arrays
|
||||||
fluid_grid2_flip_arrays(currentChunk->d,currentChunk->d0);
|
fluid_grid2_flip_arrays(currentChunk->d,currentChunk->d0);
|
||||||
//diffuse density
|
//diffuse density
|
||||||
fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,timestep);
|
fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,timestep);
|
||||||
//swap all density arrays
|
//swap all density arrays
|
||||||
fluid_grid2_flip_arrays(currentChunk->d,currentChunk->d0);
|
fluid_grid2_flip_arrays(currentChunk->d,currentChunk->d0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//time tracking
|
||||||
|
gettimeofday(&tv,NULL);
|
||||||
|
end = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
||||||
|
perMilli = (end - start) / 1000.0f;
|
||||||
|
environment->state.timeTracking.densityDiffuse = perMilli;
|
||||||
|
start = end;
|
||||||
|
|
||||||
|
for(int i = 0; i < numChunks; i++){
|
||||||
|
Chunk * currentChunk = chunks[i];
|
||||||
//advect density
|
//advect density
|
||||||
fluid_grid2_advectDensity(currentChunk->d,currentChunk->d0,currentChunk->u,currentChunk->v,currentChunk->w,timestep);
|
fluid_grid2_advectDensity(currentChunk->d,currentChunk->d0,currentChunk->u,currentChunk->v,currentChunk->w,timestep);
|
||||||
}
|
}
|
||||||
@ -162,7 +202,16 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
gettimeofday(&tv,NULL);
|
gettimeofday(&tv,NULL);
|
||||||
end = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
end = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
||||||
perMilli = (end - start) / 1000.0f;
|
perMilli = (end - start) / 1000.0f;
|
||||||
environment->state.densityTime = perMilli;
|
environment->state.timeTracking.densityAdvect = perMilli;
|
||||||
|
|
||||||
|
|
||||||
|
//summarize time tracking
|
||||||
|
environment->state.timeTracking.densityTotal = environment->state.timeTracking.densityAdvect + environment->state.timeTracking.densityDiffuse;
|
||||||
|
environment->state.timeTracking.velocityTotal =
|
||||||
|
environment->state.timeTracking.velocityDiffuse +
|
||||||
|
environment->state.timeTracking.velocityAdvect +
|
||||||
|
environment->state.timeTracking.velocityProject
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -110,8 +110,13 @@ int fluid_sim_grid2_speed_test1(){
|
|||||||
printf("Frame time per chunk (micro): %lf \n",avgPerChunk);
|
printf("Frame time per chunk (micro): %lf \n",avgPerChunk);
|
||||||
printf("Frame time per chunk (milli): %lf \n",perMilli);
|
printf("Frame time per chunk (milli): %lf \n",perMilli);
|
||||||
printf("Target time (milli): %f \n",TIME_PER_CHUNK);
|
printf("Target time (milli): %f \n",TIME_PER_CHUNK);
|
||||||
printf("Velocity time (milli): %f \n",env->state.velocityTime);
|
printf("Velocity time (milli): %f \n",env->state.timeTracking.velocityTotal);
|
||||||
printf("Density time (milli): %f \n",env->state.densityTime);
|
printf(" - Advect (milli): %f \n",env->state.timeTracking.velocityAdvect);
|
||||||
|
printf(" - Diffuse (milli): %f \n",env->state.timeTracking.velocityDiffuse);
|
||||||
|
printf(" - Project (milli): %f \n",env->state.timeTracking.velocityProject);
|
||||||
|
printf("Density time (milli): %f \n",env->state.timeTracking.densityTotal);
|
||||||
|
printf(" - Advect (milli): %f \n",env->state.timeTracking.densityAdvect);
|
||||||
|
printf(" - Diffuse (milli): %f \n",env->state.timeTracking.densityDiffuse);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
rVal++;
|
rVal++;
|
||||||
}
|
}
|
||||||
@ -164,8 +169,13 @@ int fluid_sim_grid2_speed_test2(){
|
|||||||
printf("Frame time per chunk (micro): %lf \n",avgPerChunk);
|
printf("Frame time per chunk (micro): %lf \n",avgPerChunk);
|
||||||
printf("Frame time per chunk (milli): %lf \n",perMilli);
|
printf("Frame time per chunk (milli): %lf \n",perMilli);
|
||||||
printf("Target time (milli): %f \n",TIME_PER_CHUNK);
|
printf("Target time (milli): %f \n",TIME_PER_CHUNK);
|
||||||
printf("Velocity time (milli): %f \n",env->state.velocityTime);
|
printf("Velocity time (milli): %f \n",env->state.timeTracking.velocityTotal);
|
||||||
printf("Density time (milli): %f \n",env->state.densityTime);
|
printf(" - Advect (milli): %f \n",env->state.timeTracking.velocityAdvect);
|
||||||
|
printf(" - Diffuse (milli): %f \n",env->state.timeTracking.velocityDiffuse);
|
||||||
|
printf(" - Project (milli): %f \n",env->state.timeTracking.velocityProject);
|
||||||
|
printf("Density time (milli): %f \n",env->state.timeTracking.densityTotal);
|
||||||
|
printf(" - Advect (milli): %f \n",env->state.timeTracking.densityAdvect);
|
||||||
|
printf(" - Diffuse (milli): %f \n",env->state.timeTracking.densityDiffuse);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
rVal++;
|
rVal++;
|
||||||
}
|
}
|
||||||
@ -218,8 +228,13 @@ int fluid_sim_grid2_speed_test3(){
|
|||||||
printf("Frame time per chunk (micro): %lf \n",avgPerChunk);
|
printf("Frame time per chunk (micro): %lf \n",avgPerChunk);
|
||||||
printf("Frame time per chunk (milli): %lf \n",perMilli);
|
printf("Frame time per chunk (milli): %lf \n",perMilli);
|
||||||
printf("Target time (milli): %f \n",TIME_PER_CHUNK);
|
printf("Target time (milli): %f \n",TIME_PER_CHUNK);
|
||||||
printf("Velocity time (milli): %f \n",env->state.velocityTime);
|
printf("Velocity time (milli): %f \n",env->state.timeTracking.velocityTotal);
|
||||||
printf("Density time (milli): %f \n",env->state.densityTime);
|
printf(" - Advect (milli): %f \n",env->state.timeTracking.velocityAdvect);
|
||||||
|
printf(" - Diffuse (milli): %f \n",env->state.timeTracking.velocityDiffuse);
|
||||||
|
printf(" - Project (milli): %f \n",env->state.timeTracking.velocityProject);
|
||||||
|
printf("Density time (milli): %f \n",env->state.timeTracking.densityTotal);
|
||||||
|
printf(" - Advect (milli): %f \n",env->state.timeTracking.densityAdvect);
|
||||||
|
printf(" - Diffuse (milli): %f \n",env->state.timeTracking.densityDiffuse);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
rVal++;
|
rVal++;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user