More setup for multi chunk
This commit is contained in:
parent
d55ee5ac89
commit
311ef5d9e8
@ -110,23 +110,44 @@ public class FluidSim {
|
||||
for(int i = 0; i < DIM; i++){
|
||||
for(int j = 0; j < DIM; j++){
|
||||
for(int k = 0; k < DIM; k++){
|
||||
if(
|
||||
Math.abs(8 - i) < 4 &&
|
||||
Math.abs(j) < 4 &&
|
||||
Math.abs(16 - k) < 4 &&
|
||||
i < 17 && i > 0 &&
|
||||
j < 17 && j > 0 &&
|
||||
k < 17 && k > 0
|
||||
){
|
||||
xf.put(1);
|
||||
uf.put(18);
|
||||
vf.put(-1f);
|
||||
wf.put(rand.nextFloat() * 0.1f);
|
||||
if(offset.x == 1){
|
||||
if(
|
||||
Math.abs(5 - i) < 4 &&
|
||||
Math.abs(j) < 4 &&
|
||||
Math.abs(5 - 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);
|
||||
}
|
||||
} else {
|
||||
xf.put(0);
|
||||
uf.put(0);
|
||||
vf.put(0);
|
||||
wf.put(0);
|
||||
if(
|
||||
Math.abs(8 - i) < 4 &&
|
||||
Math.abs(j) < 4 &&
|
||||
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);
|
||||
diffuseDensity(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){
|
||||
for(int x = 0; x < simArray.length; x++){
|
||||
for(int y = 0; y < simArray[0].length; y++){
|
||||
@ -336,9 +368,9 @@ public class FluidSim {
|
||||
private void swapVectorFields(){
|
||||
ByteBuffer tmp;
|
||||
//swap x0 <-> x
|
||||
tmp = densityAddition;
|
||||
densityAddition = density[13];
|
||||
density[13] = tmp;
|
||||
// tmp = densityAddition;
|
||||
// densityAddition = density[13];
|
||||
// density[13] = tmp;
|
||||
//swap u0 <-> u
|
||||
tmp = uAdditionVector[13];
|
||||
uAdditionVector[13] = uVector[13];
|
||||
|
||||
@ -22,7 +22,7 @@ public class Main {
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
int dim = 1;
|
||||
int dim = 2;
|
||||
int i = 0;
|
||||
long time = 0;
|
||||
long lastTime = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user