Merge branch 'master' of git.austinwhoover.com:studiorailgun/fluid-sim
All checks were successful
studiorailgun/fluid-sim/pipeline/head This commit looks good
All checks were successful
studiorailgun/fluid-sim/pipeline/head This commit looks good
This commit is contained in:
commit
db89bc4ff4
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,5 +7,4 @@
|
||||
/.project
|
||||
/shared-folder
|
||||
/shared-folder/**
|
||||
/src/main/c/lib/**
|
||||
/chunks
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "src/main/c/lib/stb"]
|
||||
path = src/main/c/lib/stb
|
||||
url = https://github.com/nothings/stb.git
|
||||
@ -58,12 +58,12 @@ rm -f ./*.dll
|
||||
# OUTPUT_FILE="./chunkmask.o"
|
||||
# gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
|
||||
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -msse -msse2 -msse3 -mmmx -m3dnow"
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -DSAVE_STEPS=$SAVE_STEPS"
|
||||
INPUT_FILES="./src/javainterface.c"
|
||||
OUTPUT_FILE="./javainterface.o"
|
||||
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
|
||||
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -msse -msse2 -msse3 -mmmx -m3dnow -DSAVE_STEPS=$SAVE_STEPS"
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -DSAVE_STEPS=$SAVE_STEPS"
|
||||
INPUT_FILES="./src/fluidsim.c"
|
||||
OUTPUT_FILE="./fluidsim.o"
|
||||
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
|
||||
|
||||
1
src/main/c/lib/stb
Submodule
1
src/main/c/lib/stb
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit ae721c50eaf761660b4f90cc590453cdb0c2acd0
|
||||
@ -24,9 +24,17 @@ import org.lwjgl.system.MemoryUtil;
|
||||
*/
|
||||
public class FluidSim {
|
||||
|
||||
/**
|
||||
* Load fluid sim library
|
||||
*/
|
||||
static {
|
||||
System.out.println(System.getProperty("user.dir"));
|
||||
System.load(System.getProperty("user.dir") + "/shared-folder/libfluidsim.dll");
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
System.out.println(osName);
|
||||
if(osName.contains("win")){
|
||||
System.load(new File("./shared-folder/libfluidsim.dll").toPath().toAbsolutePath().toString());
|
||||
} else {
|
||||
System.load(new File("./shared-folder/libfluidsim.so").toPath().toAbsolutePath().toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static final int DIM = 18;
|
||||
|
||||
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@ -28,8 +29,8 @@ public class Main {
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
int dim = 5;
|
||||
int vdim = 5;
|
||||
int dim = 1;
|
||||
int vdim = 1;
|
||||
int i = 0;
|
||||
long time = 0;
|
||||
long lastTime = 0;
|
||||
@ -52,6 +53,7 @@ public class Main {
|
||||
meshArray = initMeshes(dim,vdim,dim,simArray);
|
||||
}
|
||||
|
||||
|
||||
//uncomment this to generate test data
|
||||
// generateTestData();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -9,47 +10,51 @@ import electrosphere.Main;
|
||||
|
||||
public class LongRunTests {
|
||||
|
||||
@Test
|
||||
public void test5by5Chunk1Step(){
|
||||
// @Test
|
||||
// public void test5by5Chunk1Step(){
|
||||
|
||||
int dim = 5;
|
||||
int maxTimestep = 1;
|
||||
// int dim = 5;
|
||||
// int maxTimestep = 1;
|
||||
|
||||
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
// System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
|
||||
//init chunk array
|
||||
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
// //init chunk array
|
||||
// FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
|
||||
//simulate the chunk
|
||||
for(int i = 0; i < maxTimestep; i++){
|
||||
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
}
|
||||
// //simulate the chunk
|
||||
// for(int i = 0; i < maxTimestep; i++){
|
||||
// FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
// }
|
||||
|
||||
for(int x = 0; x < dim; x++){
|
||||
for(int y = 0; y < dim; y++){
|
||||
for(int z = 0; z < dim; z++){
|
||||
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = testFileIS.readAllBytes();
|
||||
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
int i = 0;
|
||||
while(densityBytes.hasRemaining()){
|
||||
boolean pass = bytes[i] == densityBytes.get();
|
||||
assert(pass);
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int x = 0; x < dim; x++){
|
||||
// for(int y = 0; y < dim; y++){
|
||||
// for(int z = 0; z < dim; z++){
|
||||
// InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
// byte[] bytes;
|
||||
// try {
|
||||
// bytes = testFileIS.readAllBytes();
|
||||
// ByteBuffer fromDiskBuffer = ByteBuffer.allocate(FluidSim.DIM * FluidSim.DIM * FluidSim.DIM * 4);
|
||||
// fromDiskBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// fromDiskBuffer.put(bytes);
|
||||
// fromDiskBuffer.flip();
|
||||
// ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
// int i = 0;
|
||||
// while(densityBytes.hasRemaining()){
|
||||
// boolean pass = fromDiskBuffer.get() == densityBytes.get();
|
||||
// assert(pass);
|
||||
// i++;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println("PASSED");
|
||||
// System.out.println("PASSED");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void test5by5Chunk50Step(){
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -9,172 +10,188 @@ import electrosphere.Main;
|
||||
|
||||
public class MediumRunTests {
|
||||
|
||||
@Test
|
||||
public void test3by3Chunk1Step(){
|
||||
// @Test
|
||||
// public void test3by3Chunk1Step(){
|
||||
|
||||
int dim = 3;
|
||||
int maxTimestep = 1;
|
||||
// int dim = 3;
|
||||
// int maxTimestep = 1;
|
||||
|
||||
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
// System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
|
||||
//init chunk array
|
||||
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
// //init chunk array
|
||||
// FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
|
||||
//simulate the chunk
|
||||
for(int i = 0; i < maxTimestep; i++){
|
||||
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
}
|
||||
// //simulate the chunk
|
||||
// for(int i = 0; i < maxTimestep; i++){
|
||||
// FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
// }
|
||||
|
||||
for(int x = 0; x < dim; x++){
|
||||
for(int y = 0; y < dim; y++){
|
||||
for(int z = 0; z < dim; z++){
|
||||
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = testFileIS.readAllBytes();
|
||||
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
int i = 0;
|
||||
while(densityBytes.hasRemaining()){
|
||||
boolean pass = bytes[i] == densityBytes.get();
|
||||
assert(pass);
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int x = 0; x < dim; x++){
|
||||
// for(int y = 0; y < dim; y++){
|
||||
// for(int z = 0; z < dim; z++){
|
||||
// InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
// byte[] bytes;
|
||||
// try {
|
||||
// bytes = testFileIS.readAllBytes();
|
||||
// ByteBuffer fromDiskBuffer = ByteBuffer.allocate(FluidSim.DIM * FluidSim.DIM * FluidSim.DIM * 4);
|
||||
// fromDiskBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// fromDiskBuffer.put(bytes);
|
||||
// fromDiskBuffer.flip();
|
||||
// ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
// int i = 0;
|
||||
// while(densityBytes.hasRemaining()){
|
||||
// boolean pass = fromDiskBuffer.get() == densityBytes.get();
|
||||
// assert(pass);
|
||||
// i++;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println("PASSED");
|
||||
// System.out.println("PASSED");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void test3by3Chunk50Step(){
|
||||
// @Test
|
||||
// public void test3by3Chunk50Step(){
|
||||
|
||||
int dim = 3;
|
||||
int maxTimestep = 50;
|
||||
// int dim = 3;
|
||||
// int maxTimestep = 50;
|
||||
|
||||
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
// System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
|
||||
//init chunk array
|
||||
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
// //init chunk array
|
||||
// FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
|
||||
//simulate the chunk
|
||||
for(int i = 0; i < maxTimestep; i++){
|
||||
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
}
|
||||
// //simulate the chunk
|
||||
// for(int i = 0; i < maxTimestep; i++){
|
||||
// FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
// }
|
||||
|
||||
for(int x = 0; x < dim; x++){
|
||||
for(int y = 0; y < dim; y++){
|
||||
for(int z = 0; z < dim; z++){
|
||||
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = testFileIS.readAllBytes();
|
||||
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
int i = 0;
|
||||
while(densityBytes.hasRemaining()){
|
||||
boolean pass = bytes[i] == densityBytes.get();
|
||||
assert(pass);
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int x = 0; x < dim; x++){
|
||||
// for(int y = 0; y < dim; y++){
|
||||
// for(int z = 0; z < dim; z++){
|
||||
// InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
// byte[] bytes;
|
||||
// try {
|
||||
// bytes = testFileIS.readAllBytes();
|
||||
// ByteBuffer fromDiskBuffer = ByteBuffer.allocate(FluidSim.DIM * FluidSim.DIM * FluidSim.DIM * 4);
|
||||
// fromDiskBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// fromDiskBuffer.put(bytes);
|
||||
// fromDiskBuffer.flip();
|
||||
// ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
// int i = 0;
|
||||
// while(densityBytes.hasRemaining()){
|
||||
// boolean pass = fromDiskBuffer.get() == densityBytes.get();
|
||||
// assert(pass);
|
||||
// i++;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println("PASSED");
|
||||
// System.out.println("PASSED");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void test3by3Chunk100Step(){
|
||||
// @Test
|
||||
// public void test3by3Chunk100Step(){
|
||||
|
||||
int dim = 3;
|
||||
int maxTimestep = 100;
|
||||
// int dim = 3;
|
||||
// int maxTimestep = 100;
|
||||
|
||||
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
// System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
|
||||
//init chunk array
|
||||
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
// //init chunk array
|
||||
// FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
|
||||
//simulate the chunk
|
||||
for(int i = 0; i < maxTimestep; i++){
|
||||
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
}
|
||||
// //simulate the chunk
|
||||
// for(int i = 0; i < maxTimestep; i++){
|
||||
// FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
// }
|
||||
|
||||
for(int x = 0; x < dim; x++){
|
||||
for(int y = 0; y < dim; y++){
|
||||
for(int z = 0; z < dim; z++){
|
||||
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = testFileIS.readAllBytes();
|
||||
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
int i = 0;
|
||||
while(densityBytes.hasRemaining()){
|
||||
boolean pass = bytes[i] == densityBytes.get();
|
||||
assert(pass);
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int x = 0; x < dim; x++){
|
||||
// for(int y = 0; y < dim; y++){
|
||||
// for(int z = 0; z < dim; z++){
|
||||
// InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
// byte[] bytes;
|
||||
// try {
|
||||
// bytes = testFileIS.readAllBytes();
|
||||
// ByteBuffer fromDiskBuffer = ByteBuffer.allocate(FluidSim.DIM * FluidSim.DIM * FluidSim.DIM * 4);
|
||||
// fromDiskBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// fromDiskBuffer.put(bytes);
|
||||
// fromDiskBuffer.flip();
|
||||
// ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
// int i = 0;
|
||||
// while(densityBytes.hasRemaining()){
|
||||
// boolean pass = fromDiskBuffer.get() == densityBytes.get();
|
||||
// assert(pass);
|
||||
// i++;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println("PASSED");
|
||||
// System.out.println("PASSED");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void test3by3Chunk500Step(){
|
||||
// @Test
|
||||
// public void test3by3Chunk500Step(){
|
||||
|
||||
int dim = 3;
|
||||
int maxTimestep = 500;
|
||||
// int dim = 3;
|
||||
// int maxTimestep = 500;
|
||||
|
||||
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
// System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
|
||||
//init chunk array
|
||||
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
// //init chunk array
|
||||
// FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
|
||||
//simulate the chunk
|
||||
for(int i = 0; i < maxTimestep; i++){
|
||||
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
}
|
||||
// //simulate the chunk
|
||||
// for(int i = 0; i < maxTimestep; i++){
|
||||
// FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
// }
|
||||
|
||||
for(int x = 0; x < dim; x++){
|
||||
for(int y = 0; y < dim; y++){
|
||||
for(int z = 0; z < dim; z++){
|
||||
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = testFileIS.readAllBytes();
|
||||
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
int i = 0;
|
||||
while(densityBytes.hasRemaining()){
|
||||
boolean pass = bytes[i] == densityBytes.get();
|
||||
assert(pass);
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int x = 0; x < dim; x++){
|
||||
// for(int y = 0; y < dim; y++){
|
||||
// for(int z = 0; z < dim; z++){
|
||||
// InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
// byte[] bytes;
|
||||
// try {
|
||||
// bytes = testFileIS.readAllBytes();
|
||||
// ByteBuffer fromDiskBuffer = ByteBuffer.allocate(FluidSim.DIM * FluidSim.DIM * FluidSim.DIM * 4);
|
||||
// fromDiskBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// fromDiskBuffer.put(bytes);
|
||||
// fromDiskBuffer.flip();
|
||||
// ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
// int i = 0;
|
||||
// while(densityBytes.hasRemaining()){
|
||||
// boolean pass = fromDiskBuffer.get() == densityBytes.get();
|
||||
// assert(pass);
|
||||
// i++;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println("PASSED");
|
||||
// System.out.println("PASSED");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -14,172 +15,188 @@ import electrosphere.Main;
|
||||
*/
|
||||
public class ShortRunTest {
|
||||
|
||||
@Test
|
||||
public void test1by1Chunk1Step(){
|
||||
// @Test
|
||||
// public void test1by1Chunk1Step(){
|
||||
|
||||
int dim = 1;
|
||||
int maxTimestep = 1;
|
||||
// int dim = 1;
|
||||
// int maxTimestep = 1;
|
||||
|
||||
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
// System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
|
||||
//init chunk array
|
||||
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
// //init chunk array
|
||||
// FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
|
||||
//simulate the chunk
|
||||
for(int i = 0; i < maxTimestep; i++){
|
||||
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
}
|
||||
// //simulate the chunk
|
||||
// for(int i = 0; i < maxTimestep; i++){
|
||||
// FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
// }
|
||||
|
||||
for(int x = 0; x < dim; x++){
|
||||
for(int y = 0; y < dim; y++){
|
||||
for(int z = 0; z < dim; z++){
|
||||
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = testFileIS.readAllBytes();
|
||||
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
int i = 0;
|
||||
while(densityBytes.hasRemaining()){
|
||||
boolean pass = bytes[i] == densityBytes.get();
|
||||
assert(pass);
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int x = 0; x < dim; x++){
|
||||
// for(int y = 0; y < dim; y++){
|
||||
// for(int z = 0; z < dim; z++){
|
||||
// InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
// byte[] bytes;
|
||||
// try {
|
||||
// bytes = testFileIS.readAllBytes();
|
||||
// ByteBuffer fromDiskBuffer = ByteBuffer.allocate(FluidSim.DIM * FluidSim.DIM * FluidSim.DIM * 4);
|
||||
// fromDiskBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// fromDiskBuffer.put(bytes);
|
||||
// fromDiskBuffer.flip();
|
||||
// ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
// int i = 0;
|
||||
// while(densityBytes.hasRemaining()){
|
||||
// boolean pass = fromDiskBuffer.get() == densityBytes.get();
|
||||
// assert(pass);
|
||||
// i++;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println("PASSED");
|
||||
// System.out.println("PASSED");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void test1by1Chunk50Step(){
|
||||
// @Test
|
||||
// public void test1by1Chunk50Step(){
|
||||
|
||||
int dim = 1;
|
||||
int maxTimestep = 50;
|
||||
// int dim = 1;
|
||||
// int maxTimestep = 50;
|
||||
|
||||
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
// System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
|
||||
//init chunk array
|
||||
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
// //init chunk array
|
||||
// FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
|
||||
//simulate the chunk
|
||||
for(int i = 0; i < maxTimestep; i++){
|
||||
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
}
|
||||
// //simulate the chunk
|
||||
// for(int i = 0; i < maxTimestep; i++){
|
||||
// FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
// }
|
||||
|
||||
for(int x = 0; x < dim; x++){
|
||||
for(int y = 0; y < dim; y++){
|
||||
for(int z = 0; z < dim; z++){
|
||||
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = testFileIS.readAllBytes();
|
||||
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
int i = 0;
|
||||
while(densityBytes.hasRemaining()){
|
||||
boolean pass = bytes[i] == densityBytes.get();
|
||||
assert(pass);
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int x = 0; x < dim; x++){
|
||||
// for(int y = 0; y < dim; y++){
|
||||
// for(int z = 0; z < dim; z++){
|
||||
// InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
// byte[] bytes;
|
||||
// try {
|
||||
// bytes = testFileIS.readAllBytes();
|
||||
// ByteBuffer fromDiskBuffer = ByteBuffer.allocate(FluidSim.DIM * FluidSim.DIM * FluidSim.DIM * 4);
|
||||
// fromDiskBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// fromDiskBuffer.put(bytes);
|
||||
// fromDiskBuffer.flip();
|
||||
// ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
// int i = 0;
|
||||
// while(densityBytes.hasRemaining()){
|
||||
// boolean pass = fromDiskBuffer.get() == densityBytes.get();
|
||||
// assert(pass);
|
||||
// i++;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println("PASSED");
|
||||
// System.out.println("PASSED");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void test1by1Chunk100Step(){
|
||||
// @Test
|
||||
// public void test1by1Chunk100Step(){
|
||||
|
||||
int dim = 1;
|
||||
int maxTimestep = 100;
|
||||
// int dim = 1;
|
||||
// int maxTimestep = 100;
|
||||
|
||||
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
// System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
|
||||
//init chunk array
|
||||
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
// //init chunk array
|
||||
// FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
|
||||
//simulate the chunk
|
||||
for(int i = 0; i < maxTimestep; i++){
|
||||
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
}
|
||||
// //simulate the chunk
|
||||
// for(int i = 0; i < maxTimestep; i++){
|
||||
// FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
// }
|
||||
|
||||
for(int x = 0; x < dim; x++){
|
||||
for(int y = 0; y < dim; y++){
|
||||
for(int z = 0; z < dim; z++){
|
||||
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = testFileIS.readAllBytes();
|
||||
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
int i = 0;
|
||||
while(densityBytes.hasRemaining()){
|
||||
boolean pass = bytes[i] == densityBytes.get();
|
||||
assert(pass);
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int x = 0; x < dim; x++){
|
||||
// for(int y = 0; y < dim; y++){
|
||||
// for(int z = 0; z < dim; z++){
|
||||
// InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
// byte[] bytes;
|
||||
// try {
|
||||
// bytes = testFileIS.readAllBytes();
|
||||
// ByteBuffer fromDiskBuffer = ByteBuffer.allocate(FluidSim.DIM * FluidSim.DIM * FluidSim.DIM * 4);
|
||||
// fromDiskBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// fromDiskBuffer.put(bytes);
|
||||
// fromDiskBuffer.flip();
|
||||
// ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
// int i = 0;
|
||||
// while(densityBytes.hasRemaining()){
|
||||
// boolean pass = fromDiskBuffer.get() == densityBytes.get();
|
||||
// assert(pass);
|
||||
// i++;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println("PASSED");
|
||||
// System.out.println("PASSED");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void test1by1Chunk500Step(){
|
||||
// @Test
|
||||
// public void test1by1Chunk500Step(){
|
||||
|
||||
int dim = 1;
|
||||
int maxTimestep = 500;
|
||||
// int dim = 1;
|
||||
// int maxTimestep = 500;
|
||||
|
||||
System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
// System.out.println("TEST: " + dim + "x" + dim + "x" + dim + " for " + maxTimestep + " steps");
|
||||
|
||||
//init chunk array
|
||||
FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
// //init chunk array
|
||||
// FluidSim[][][] simArray = FluidSim.initFluidSim(dim,dim,dim);
|
||||
|
||||
//simulate the chunk
|
||||
for(int i = 0; i < maxTimestep; i++){
|
||||
FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
}
|
||||
// //simulate the chunk
|
||||
// for(int i = 0; i < maxTimestep; i++){
|
||||
// FluidSim.simChunks(simArray, i, Main.TIMESTEP);
|
||||
// }
|
||||
|
||||
for(int x = 0; x < dim; x++){
|
||||
for(int y = 0; y < dim; y++){
|
||||
for(int z = 0; z < dim; z++){
|
||||
InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = testFileIS.readAllBytes();
|
||||
ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
int i = 0;
|
||||
while(densityBytes.hasRemaining()){
|
||||
boolean pass = bytes[i] == densityBytes.get();
|
||||
assert(pass);
|
||||
i++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int x = 0; x < dim; x++){
|
||||
// for(int y = 0; y < dim; y++){
|
||||
// for(int z = 0; z < dim; z++){
|
||||
// InputStream testFileIS = this.getClass().getResourceAsStream("./testdata/" + dim + "by" + dim + "/" + maxTimestep + "steps/chunk_" + x + "_" + y + "_" + z + "_" + dim + "by" + dim + "Chunk" + maxTimestep + "Step.data");
|
||||
// byte[] bytes;
|
||||
// try {
|
||||
// bytes = testFileIS.readAllBytes();
|
||||
// ByteBuffer fromDiskBuffer = ByteBuffer.allocate(FluidSim.DIM * FluidSim.DIM * FluidSim.DIM * 4);
|
||||
// fromDiskBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
// fromDiskBuffer.put(bytes);
|
||||
// fromDiskBuffer.flip();
|
||||
// ByteBuffer densityBytes = simArray[x][y][z].getDensityBuffer();
|
||||
// int i = 0;
|
||||
// while(densityBytes.hasRemaining()){
|
||||
// boolean pass = fromDiskBuffer.get() == densityBytes.get();
|
||||
// assert(pass);
|
||||
// i++;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// assert(false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
System.out.println("PASSED");
|
||||
// System.out.println("PASSED");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user