identify negative density bug
This commit is contained in:
parent
10c7a6c0c0
commit
4fa843b967
@ -46,6 +46,15 @@ LIBRARY_API void fluid_pressurecell_normalize_chunk(Environment * env, Chunk * c
|
|||||||
} else {
|
} else {
|
||||||
if(expected > 0.001f){
|
if(expected > 0.001f){
|
||||||
printf("We've managed to completely delete all density! (expected: %f) \n", expected);
|
printf("We've managed to completely delete all density! (expected: %f) \n", expected);
|
||||||
|
sum = 0;
|
||||||
|
for(x = 1; x < DIM-1; x++){
|
||||||
|
for(y = 1; y < DIM-1; y++){
|
||||||
|
for(z = 1; z < DIM-1; z++){
|
||||||
|
sum = sum + chunk->dTempCache[IX(x,y,z)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("dTempCache sum: %lf \n", sum);
|
||||||
}
|
}
|
||||||
chunk->pressureCellData.normalizationRatio = 1.0f;
|
chunk->pressureCellData.normalizationRatio = 1.0f;
|
||||||
}
|
}
|
||||||
@ -77,20 +86,25 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
int ghostIndex, adjacentIndex;
|
int ghostIndex, adjacentIndex;
|
||||||
float overdraw, estimatedLoss, invertedForce;
|
float overdraw, estimatedLoss, invertedForce;
|
||||||
int neighbor;
|
int neighbor;
|
||||||
|
|
||||||
//clear neighbor outgoing values
|
//clear neighbor outgoing values
|
||||||
for(int i = 0; i < 9; i++){
|
for(int i = 0; i < 9; i++){
|
||||||
chunk->pressureCellData.outgoingDensity[i] = 0;
|
chunk->pressureCellData.outgoingDensity[i] = 0;
|
||||||
chunk->pressureCellData.outgoingPressure[i] = 0;
|
chunk->pressureCellData.outgoingPressure[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//clear dtemp
|
//clear dtemp
|
||||||
for(x = 0; x < DIM; x++){
|
for(x = 0; x < DIM; x++){
|
||||||
for(y = 0; y < DIM; y++){
|
for(y = 0; y < DIM; y++){
|
||||||
for(z = 0; z < DIM; z++){
|
for(z = 0; z < DIM; z++){
|
||||||
dTemp[IX(x,y,z)] = dArr[IX(x,y,z)];
|
dTemp[IX(x,y,z)] = fmax(MIN_FLUID_VALUE,dArr[IX(x,y,z)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//check +x plane
|
//check +x plane
|
||||||
neighbor = CK(2,1,1);
|
neighbor = CK(2,1,1);
|
||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
@ -98,15 +112,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(y = 1; y < DIM-1; y++){
|
for(y = 1; y < DIM-1; y++){
|
||||||
ghostIndex = IX(DIM-1,x,y);
|
ghostIndex = IX(DIM-1,x,y);
|
||||||
adjacentIndex = IX(DIM-2,x,y);
|
adjacentIndex = IX(DIM-2,x,y);
|
||||||
if(uArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
if(uArr[adjacentIndex] > 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = 1.0f - fabs(uArr[adjacentIndex]);
|
invertedForce = 1.0f - fabs(uArr[adjacentIndex]);
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,6 +138,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//check -x plane
|
//check -x plane
|
||||||
neighbor = CK(0,1,1);
|
neighbor = CK(0,1,1);
|
||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
@ -129,15 +146,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(y = 1; y < DIM-1; y++){
|
for(y = 1; y < DIM-1; y++){
|
||||||
ghostIndex = IX(0,x,y);
|
ghostIndex = IX(0,x,y);
|
||||||
adjacentIndex = IX(1,x,y);
|
adjacentIndex = IX(1,x,y);
|
||||||
if(uArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
if(uArr[adjacentIndex] < 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = 1.0f - fabs(uArr[adjacentIndex]);
|
invertedForce = 1.0f - fabs(uArr[adjacentIndex]);
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,15 +180,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(y = 1; y < DIM-1; y++){
|
for(y = 1; y < DIM-1; y++){
|
||||||
ghostIndex = IX(x,DIM-1,y);
|
ghostIndex = IX(x,DIM-1,y);
|
||||||
adjacentIndex = IX(x,DIM-2,y);
|
adjacentIndex = IX(x,DIM-2,y);
|
||||||
if(vArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
if(vArr[adjacentIndex] > 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = 1.0f - fabs(vArr[adjacentIndex]);
|
invertedForce = 1.0f - fabs(vArr[adjacentIndex]);
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,6 +206,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//check -y plane
|
//check -y plane
|
||||||
neighbor = CK(1,0,1);
|
neighbor = CK(1,0,1);
|
||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
@ -192,15 +214,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(y = 1; y < DIM-1; y++){
|
for(y = 1; y < DIM-1; y++){
|
||||||
ghostIndex = IX(x,0,y);
|
ghostIndex = IX(x,0,y);
|
||||||
adjacentIndex = IX(x,1,y);
|
adjacentIndex = IX(x,1,y);
|
||||||
if(vArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
if(vArr[adjacentIndex] < 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = 1.0f - fabs(vArr[adjacentIndex]);
|
invertedForce = 1.0f - fabs(vArr[adjacentIndex]);
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,15 +248,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(y = 1; y < DIM-1; y++){
|
for(y = 1; y < DIM-1; y++){
|
||||||
ghostIndex = IX(x,y,DIM-1);
|
ghostIndex = IX(x,y,DIM-1);
|
||||||
adjacentIndex = IX(x,y,DIM-2);
|
adjacentIndex = IX(x,y,DIM-2);
|
||||||
if(wArr[adjacentIndex] > 0 && dArr[adjacentIndex] > 0){
|
if(wArr[adjacentIndex] > 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = 1.0f - fabs(wArr[adjacentIndex]);
|
invertedForce = 1.0f - fabs(wArr[adjacentIndex]);
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,6 +274,7 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//check -z plane
|
//check -z plane
|
||||||
neighbor = CK(1,1,0);
|
neighbor = CK(1,1,0);
|
||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
@ -255,15 +282,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(y = 1; y < DIM-1; y++){
|
for(y = 1; y < DIM-1; y++){
|
||||||
ghostIndex = IX(x,y,0);
|
ghostIndex = IX(x,y,0);
|
||||||
adjacentIndex = IX(x,y,1);
|
adjacentIndex = IX(x,y,1);
|
||||||
if(wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > 0){
|
if(wArr[adjacentIndex] < 0 && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = 1.0f - fabs(wArr[adjacentIndex]);
|
invertedForce = 1.0f - fabs(wArr[adjacentIndex]);
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,15 +335,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(0,0,x);
|
ghostIndex = IX(0,0,x);
|
||||||
adjacentIndex = IX(1,1,x);
|
adjacentIndex = IX(1,1,x);
|
||||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,15 +365,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(0,DIM-1,x);
|
ghostIndex = IX(0,DIM-1,x);
|
||||||
adjacentIndex = IX(1,DIM-2,x);
|
adjacentIndex = IX(1,DIM-2,x);
|
||||||
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,15 +395,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(DIM-1,0,x);
|
ghostIndex = IX(DIM-1,0,x);
|
||||||
adjacentIndex = IX(DIM-2,1,x);
|
adjacentIndex = IX(DIM-2,1,x);
|
||||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,15 +425,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(DIM-1,DIM-1,x);
|
ghostIndex = IX(DIM-1,DIM-1,x);
|
||||||
adjacentIndex = IX(DIM-2,DIM-2,x);
|
adjacentIndex = IX(DIM-2,DIM-2,x);
|
||||||
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,15 +461,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(0,x,0);
|
ghostIndex = IX(0,x,0);
|
||||||
adjacentIndex = IX(1,x,1);
|
adjacentIndex = IX(1,x,1);
|
||||||
if((uArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,15 +491,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(0,x,DIM-1);
|
ghostIndex = IX(0,x,DIM-1);
|
||||||
adjacentIndex = IX(1,x,DIM-2);
|
adjacentIndex = IX(1,x,DIM-2);
|
||||||
if((uArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,15 +521,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(DIM-1,x,0);
|
ghostIndex = IX(DIM-1,x,0);
|
||||||
adjacentIndex = IX(DIM-2,x,1);
|
adjacentIndex = IX(DIM-2,x,1);
|
||||||
if((uArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -508,15 +551,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(DIM-1,x,DIM-1);
|
ghostIndex = IX(DIM-1,x,DIM-1);
|
||||||
adjacentIndex = IX(DIM-2,x,DIM-2);
|
adjacentIndex = IX(DIM-2,x,DIM-2);
|
||||||
if((uArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -540,15 +585,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(x,0,0);
|
ghostIndex = IX(x,0,0);
|
||||||
adjacentIndex = IX(x,1,1);
|
adjacentIndex = IX(x,1,1);
|
||||||
if((vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -568,15 +615,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(x,0,DIM-1);
|
ghostIndex = IX(x,0,DIM-1);
|
||||||
adjacentIndex = IX(x,1,DIM-2);
|
adjacentIndex = IX(x,1,DIM-2);
|
||||||
if((vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -596,15 +645,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(x,DIM-1,0);
|
ghostIndex = IX(x,DIM-1,0);
|
||||||
adjacentIndex = IX(x,DIM-2,1);
|
adjacentIndex = IX(x,DIM-2,1);
|
||||||
if((vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -624,15 +675,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
for(x = 1; x < DIM-1; x++){
|
for(x = 1; x < DIM-1; x++){
|
||||||
ghostIndex = IX(x,DIM-1,DIM-1);
|
ghostIndex = IX(x,DIM-1,DIM-1);
|
||||||
adjacentIndex = IX(x,DIM-2,DIM-2);
|
adjacentIndex = IX(x,DIM-2,DIM-2);
|
||||||
if((vArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((vArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] - estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -685,15 +738,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
ghostIndex = IX(0,0,0);
|
ghostIndex = IX(0,0,0);
|
||||||
adjacentIndex = IX(1,1,1);
|
adjacentIndex = IX(1,1,1);
|
||||||
if((uArr[adjacentIndex] < 0 || vArr[adjacentIndex] < 0 || wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -711,15 +766,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
ghostIndex = IX(0,DIM-1,0);
|
ghostIndex = IX(0,DIM-1,0);
|
||||||
adjacentIndex = IX(1,DIM-2,1);
|
adjacentIndex = IX(1,DIM-2,1);
|
||||||
if((uArr[adjacentIndex] < 0 || vArr[adjacentIndex] > 0 || wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -736,15 +793,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
ghostIndex = IX(DIM-1,0,0);
|
ghostIndex = IX(DIM-1,0,0);
|
||||||
adjacentIndex = IX(DIM-2,1,1);
|
adjacentIndex = IX(DIM-2,1,1);
|
||||||
if((uArr[adjacentIndex] > 0 || vArr[adjacentIndex] < 0 || wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -762,15 +821,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
ghostIndex = IX(DIM-1,DIM-1,0);
|
ghostIndex = IX(DIM-1,DIM-1,0);
|
||||||
adjacentIndex = IX(DIM-2,DIM-2,1);
|
adjacentIndex = IX(DIM-2,DIM-2,1);
|
||||||
if((uArr[adjacentIndex] > 0 || vArr[adjacentIndex] > 0 || wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] > 0 && wArr[adjacentIndex] < 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -792,15 +853,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
ghostIndex = IX(0,0,DIM-1);
|
ghostIndex = IX(0,0,DIM-1);
|
||||||
adjacentIndex = IX(1,1,DIM-2);
|
adjacentIndex = IX(1,1,DIM-2);
|
||||||
if((uArr[adjacentIndex] < 0 || vArr[adjacentIndex] < 0 || wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -818,15 +881,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
ghostIndex = IX(0,DIM-1,DIM-1);
|
ghostIndex = IX(0,DIM-1,DIM-1);
|
||||||
adjacentIndex = IX(1,DIM-2,DIM-2);
|
adjacentIndex = IX(1,DIM-2,DIM-2);
|
||||||
if((uArr[adjacentIndex] < 0 || vArr[adjacentIndex] > 0 || wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] < 0 && vArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -843,15 +908,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
ghostIndex = IX(DIM-1,0,DIM-1);
|
ghostIndex = IX(DIM-1,0,DIM-1);
|
||||||
adjacentIndex = IX(DIM-2,1,DIM-2);
|
adjacentIndex = IX(DIM-2,1,DIM-2);
|
||||||
if((uArr[adjacentIndex] > 0 || vArr[adjacentIndex] < 0 || wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] < 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -869,15 +936,17 @@ LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk *
|
|||||||
if(chunk->d[neighbor] == NULL){
|
if(chunk->d[neighbor] == NULL){
|
||||||
ghostIndex = IX(DIM-1,DIM-1,DIM-1);
|
ghostIndex = IX(DIM-1,DIM-1,DIM-1);
|
||||||
adjacentIndex = IX(DIM-2,DIM-2,DIM-2);
|
adjacentIndex = IX(DIM-2,DIM-2,DIM-2);
|
||||||
if((uArr[adjacentIndex] > 0 || vArr[adjacentIndex] > 0 || wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > 0){
|
if((uArr[adjacentIndex] > 0 && vArr[adjacentIndex] > 0 && wArr[adjacentIndex] > 0) && dArr[adjacentIndex] > MIN_FLUID_VALUE){
|
||||||
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
invertedForce = (1.0f - fabs(uArr[adjacentIndex])) * (1.0f - fabs(vArr[adjacentIndex])) * (1.0f - fabs(wArr[adjacentIndex]));
|
||||||
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
if(invertedForce > MIN_FLUID_VALUE){
|
||||||
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
estimatedLoss = dArr[adjacentIndex] / invertedForce;
|
||||||
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
dTemp[adjacentIndex] = dArr[adjacentIndex] + estimatedLoss;
|
||||||
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
overdraw = dTemp[adjacentIndex] - MAX_FLUID_VALUE;
|
||||||
if(overdraw > 0){
|
pressure[adjacentIndex] = pressure[adjacentIndex] + FLUID_PRESSURECELL_RECAPTURE_PRESSURE;
|
||||||
chunk->pressureCellData.recaptureDensity += overdraw;
|
if(overdraw > 0){
|
||||||
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
chunk->pressureCellData.recaptureDensity += overdraw;
|
||||||
|
dTemp[adjacentIndex] = MAX_FLUID_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user