work on flux propagation
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
02611038f2
commit
4a71b7d26a
@ -4,11 +4,20 @@
|
|||||||
#include "fluid/queue/chunk.h"
|
#include "fluid/queue/chunk.h"
|
||||||
#include "fluid/env/environment.h"
|
#include "fluid/env/environment.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value where there is no pressure
|
||||||
|
*/
|
||||||
|
#define NO_PRESSURE 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the flux stored in the ghost cells of this chunk
|
* Updates the flux stored in the ghost cells of this chunk
|
||||||
*/
|
*/
|
||||||
void fluid_grid2_update_ghost_flux(Environment * environment, Chunk * chunk);
|
void fluid_grid2_update_ghost_flux(Environment * environment, Chunk * chunk);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimaates the ghost flux for this chunk
|
||||||
|
*/
|
||||||
|
void fluid_grid2_estimate_ghost_flux(float ** arrays);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1,12 +1,357 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "fluid/env/utilities.h"
|
||||||
|
#include "fluid/queue/chunk.h"
|
||||||
|
#include "fluid/queue/chunkmask.h"
|
||||||
#include "fluid/sim/grid2/flux.h"
|
#include "fluid/sim/grid2/flux.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimaates the ghost flux for this chunk
|
||||||
|
*/
|
||||||
|
void fluid_grid2_estimate_ghost_flux(float ** arrays){
|
||||||
|
int i, j;
|
||||||
|
int neighborIndex;
|
||||||
|
//x+ face
|
||||||
|
neighborIndex = CK(2,1,1);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, i, j)] = arrays[neighborIndex][IX( 1, i, j)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
for(j = 1; j < DIM; j++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, i, j)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//x- face
|
||||||
|
neighborIndex = CK(0,1,1);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX(0, i, j)] = arrays[neighborIndex][IX(DIM-2, i, j)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX(0, i, j)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//y+ face
|
||||||
|
neighborIndex = CK(1,2,1);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX( i, DIM-1, j)] = arrays[neighborIndex][IX( i, 1, j)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX( i, DIM-1, j)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//y- face
|
||||||
|
neighborIndex = CK(1,0,1);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX(i, 0, j)] = arrays[neighborIndex][IX( i, DIM-2, j)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX(i, 0, j)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//z+ face
|
||||||
|
neighborIndex = CK(1,1,2);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX( i, j, DIM-1)] = arrays[neighborIndex][IX( i, j, 1)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX( i, j, DIM-1)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//z- face
|
||||||
|
neighborIndex = CK(1,1,0);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX(i, j, 0)] = arrays[neighborIndex][IX( i, j, DIM-2)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
for(j = 1; j < DIM-1; j++){
|
||||||
|
arrays[CENTER_LOC][IX(i, j, 0)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// edges
|
||||||
|
//
|
||||||
|
|
||||||
|
//x+ y+ edge
|
||||||
|
neighborIndex = CK(2,2,1);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, DIM-1, i)] = arrays[neighborIndex][IX( 1, 1, i)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, DIM-1, i)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//x+ y- edge
|
||||||
|
neighborIndex = CK(2,0,1);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, 0, i)] = arrays[neighborIndex][IX( 1, DIM-2, i)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, 0, i)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//x- y+ edge
|
||||||
|
neighborIndex = CK(0,2,1);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX( 0, DIM-1, i)] = arrays[neighborIndex][IX( DIM-2, 1, i)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX( 0, DIM-1, i)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//x- y- edge
|
||||||
|
neighborIndex = CK(0,0,1);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX( 0, 0, i)] = arrays[neighborIndex][IX( DIM-2, DIM-2, i)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX( 0, 0, i)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//x+ z+ edge
|
||||||
|
neighborIndex = CK(2,1,2);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, i, DIM-1)] = arrays[neighborIndex][IX( 1, i, 1)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, i, DIM-1)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//x+ z- edge
|
||||||
|
neighborIndex = CK(2,1,0);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, i, 0)] = arrays[neighborIndex][IX( 1, i, DIM-2)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, i, 0)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//x- z+ edge
|
||||||
|
neighborIndex = CK(0,1,2);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX( 0, i, DIM-1)] = arrays[neighborIndex][IX( DIM-2, i, 1)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX( 0, i, DIM-1)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//x- z- edge
|
||||||
|
neighborIndex = CK(0,1,0);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX( 0, i, 0)] = arrays[neighborIndex][IX( DIM-2, i, DIM-2)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX( 0, i, 0)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//y+ z+ edge
|
||||||
|
neighborIndex = CK(1,2,2);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX( i, DIM-1, DIM-1)] = arrays[neighborIndex][IX( i, 1, 1)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX( i, DIM-1, DIM-1)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//y+ z- edge
|
||||||
|
neighborIndex = CK(1,2,0);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX( i,DIM-1, 0)] = arrays[neighborIndex][IX( i, 1, DIM-2)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX( i,DIM-1, 0)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//y- z+ edge
|
||||||
|
neighborIndex = CK(1,0,2);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX( i, 0, DIM-1)] = arrays[neighborIndex][IX( i, DIM-2, 1)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX( i, 0, DIM-1)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//y- z- edge
|
||||||
|
neighborIndex = CK(1,0,0);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
for(i = 1; i < DIM-1; i++){
|
||||||
|
arrays[CENTER_LOC][IX( i, 0, 0)] = arrays[neighborIndex][IX( i, DIM-2, DIM-2)];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(i = 1; i < DIM; i++){
|
||||||
|
arrays[CENTER_LOC][IX( i, 0, 0)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// CORNERS
|
||||||
|
//
|
||||||
|
|
||||||
|
//x+ y+ z+ corner
|
||||||
|
neighborIndex = CK(2,2,2);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, DIM-1, DIM-1)] = arrays[neighborIndex][IX( 1, 1, 1)];
|
||||||
|
} else {
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, DIM-1, DIM-1)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//x+ y+ z- corner
|
||||||
|
neighborIndex = CK(2,2,0);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, DIM-1, 0)] = arrays[neighborIndex][IX( 1, 1, DIM-2)];
|
||||||
|
} else {
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, DIM-1, 0)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//x+ y- z+ corner
|
||||||
|
neighborIndex = CK(2,0,2);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, 0, DIM-1)] = arrays[neighborIndex][IX( 1, DIM-2, 1)];
|
||||||
|
} else {
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, 0, DIM-1)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//x+ y- z- corner
|
||||||
|
neighborIndex = CK(2,0,0);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, 0, 0)] = arrays[neighborIndex][IX( 1, DIM-2, DIM-2)];
|
||||||
|
} else {
|
||||||
|
arrays[CENTER_LOC][IX(DIM-1, 0, 0)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//x- y+ z+ corner
|
||||||
|
neighborIndex = CK(0,2,2);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
arrays[CENTER_LOC][IX(0, DIM-1, DIM-1)] = arrays[neighborIndex][IX( DIM-2, 1, 1)];
|
||||||
|
} else {
|
||||||
|
arrays[CENTER_LOC][IX(0, DIM-1, DIM-1)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//x- y+ z- corner
|
||||||
|
neighborIndex = CK(0,2,0);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
arrays[CENTER_LOC][IX(0, DIM-1, 0)] = arrays[neighborIndex][IX( DIM-2, 1, DIM-2)];
|
||||||
|
} else {
|
||||||
|
arrays[CENTER_LOC][IX(0, DIM-1, 0)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//x- y- z+ corner
|
||||||
|
neighborIndex = CK(0,0,2);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
arrays[CENTER_LOC][IX(0, 0, DIM-1)] = arrays[neighborIndex][IX( DIM-2, DIM-2, 1)];
|
||||||
|
} else {
|
||||||
|
arrays[CENTER_LOC][IX(0, 0, DIM-1)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//x- y- z- corner
|
||||||
|
neighborIndex = CK(0,0,0);
|
||||||
|
if(arrays[neighborIndex] != NULL){
|
||||||
|
arrays[CENTER_LOC][IX(0, 0, 0)] = arrays[neighborIndex][IX( DIM-2, DIM-2, DIM-2)];
|
||||||
|
} else {
|
||||||
|
arrays[CENTER_LOC][IX(0, 0, 0)] = NO_PRESSURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the flux stored in the ghost cells of this chunk
|
* Updates the flux stored in the ghost cells of this chunk
|
||||||
*/
|
*/
|
||||||
void fluid_grid2_update_ghost_flux(Environment * environment, Chunk * chunk){
|
void fluid_grid2_update_ghost_flux(Environment * environment, Chunk * chunk){
|
||||||
|
fluid_grid2_estimate_ghost_flux(chunk->scalarPotentialCache);
|
||||||
}
|
}
|
||||||
@ -10,6 +10,7 @@
|
|||||||
#include "fluid/env/utilities.h"
|
#include "fluid/env/utilities.h"
|
||||||
#include "fluid/queue/chunkmask.h"
|
#include "fluid/queue/chunkmask.h"
|
||||||
#include "fluid/queue/chunk.h"
|
#include "fluid/queue/chunk.h"
|
||||||
|
#include "fluid/sim/grid2/flux.h"
|
||||||
#include "fluid/sim/grid2/grid2.h"
|
#include "fluid/sim/grid2/grid2.h"
|
||||||
#include "fluid/sim/grid2/solver_consts.h"
|
#include "fluid/sim/grid2/solver_consts.h"
|
||||||
#include "fluid/sim/grid2/velocity.h"
|
#include "fluid/sim/grid2/velocity.h"
|
||||||
@ -39,10 +40,23 @@ LIBRARY_API void fluid_grid2_simulate(
|
|||||||
Chunk ** chunks = passedInChunks;
|
Chunk ** chunks = passedInChunks;
|
||||||
double start, end, perMilli;
|
double start, end, perMilli;
|
||||||
|
|
||||||
|
//
|
||||||
|
//This is the section of non-parallel code
|
||||||
|
//
|
||||||
|
|
||||||
//update ODE solver data
|
//update ODE solver data
|
||||||
environment->state.grid2.diffuseData.dt = timestep;
|
environment->state.grid2.diffuseData.dt = timestep;
|
||||||
|
for(int i = 0; i < numChunks; i++){
|
||||||
|
Chunk * currentChunk = chunks[i];
|
||||||
|
fluid_grid2_update_ghost_flux(environment,currentChunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//Everything below here should be emberassingly parallel
|
||||||
|
//
|
||||||
gettimeofday(&tv,NULL);
|
gettimeofday(&tv,NULL);
|
||||||
start = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
start = 1000000.0 * tv.tv_sec + tv.tv_usec;
|
||||||
//maintenance
|
//maintenance
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user