More setup for multi chunk

This commit is contained in:
unknown 2023-07-24 18:08:51 -04:00
parent d55ee5ac89
commit 311ef5d9e8
2 changed files with 52 additions and 20 deletions

View File

@ -110,23 +110,44 @@ public class FluidSim {
for(int i = 0; i < DIM; i++){ for(int i = 0; i < DIM; i++){
for(int j = 0; j < DIM; j++){ for(int j = 0; j < DIM; j++){
for(int k = 0; k < DIM; k++){ for(int k = 0; k < DIM; k++){
if( if(offset.x == 1){
Math.abs(8 - i) < 4 && if(
Math.abs(j) < 4 && Math.abs(5 - i) < 4 &&
Math.abs(16 - k) < 4 && Math.abs(j) < 4 &&
i < 17 && i > 0 && Math.abs(5 - k) < 4 &&
j < 17 && j > 0 && i < 17 && i > 0 &&
k < 17 && k > 0 j < 17 && j > 0 &&
){ k < 17 && k > 0
xf.put(1); ){
uf.put(18); xf.put(1);
vf.put(-1f); uf.put(1);
wf.put(rand.nextFloat() * 0.1f); vf.put(-1f);
wf.put(rand.nextFloat() * 0.1f);
} else {
xf.put(0);
uf.put(0);
vf.put(0);
wf.put(0);
}
} else { } else {
xf.put(0); if(
uf.put(0); Math.abs(8 - i) < 4 &&
vf.put(0); Math.abs(j) < 4 &&
wf.put(0); Math.abs(16 - k) < 4 &&
i < 17 && i > 0 &&
j < 17 && j > 0 &&
k < 17 && k > 0
){
xf.put(1);
uf.put(1);
vf.put(-1f);
wf.put(rand.nextFloat() * 0.1f);
} else {
xf.put(0);
uf.put(0);
vf.put(0);
wf.put(0);
}
} }
} }
} }
@ -167,6 +188,7 @@ public class FluidSim {
addDensity(simArray, timestep); addDensity(simArray, timestep);
diffuseDensity(simArray, timestep); diffuseDensity(simArray, timestep);
advectDensity(simArray, timestep); advectDensity(simArray, timestep);
// mirrorNeighborDensities(simArray, timestep);
@ -323,6 +345,16 @@ public class FluidSim {
} }
} }
private static void mirrorNeighborDensities(FluidSim[][][] simArray, float timestep){
for(int x = 0; x < simArray.length; x++){
for(int y = 0; y < simArray[0].length; y++){
for(int z = 0; z < simArray[0][0].length; z++){
simArray[x][y][z].setBoundsToNeighborsWrapper(0, simArray[x][y][z].density);
}
}
}
}
private static void swapAllVectorFields(FluidSim[][][] simArray, float timestep){ private static void swapAllVectorFields(FluidSim[][][] simArray, float timestep){
for(int x = 0; x < simArray.length; x++){ for(int x = 0; x < simArray.length; x++){
for(int y = 0; y < simArray[0].length; y++){ for(int y = 0; y < simArray[0].length; y++){
@ -336,9 +368,9 @@ public class FluidSim {
private void swapVectorFields(){ private void swapVectorFields(){
ByteBuffer tmp; ByteBuffer tmp;
//swap x0 <-> x //swap x0 <-> x
tmp = densityAddition; // tmp = densityAddition;
densityAddition = density[13]; // densityAddition = density[13];
density[13] = tmp; // density[13] = tmp;
//swap u0 <-> u //swap u0 <-> u
tmp = uAdditionVector[13]; tmp = uAdditionVector[13];
uAdditionVector[13] = uVector[13]; uAdditionVector[13] = uVector[13];

View File

@ -22,7 +22,7 @@ public class Main {
public static void main(String args[]){ public static void main(String args[]){
int dim = 1; int dim = 2;
int i = 0; int i = 0;
long time = 0; long time = 0;
long lastTime = 0; long lastTime = 0;