remove JNI from core routines
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:
parent
eac79e0afc
commit
6f052e48e6
@ -41,22 +41,22 @@ rm -f ./*.dll
|
||||
|
||||
|
||||
#compile object files
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -O1"
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -Ofast"
|
||||
INPUT_FILES="./densitystep.c"
|
||||
OUTPUT_FILE="./densitystep.o"
|
||||
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
|
||||
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -O1"
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -Ofast"
|
||||
INPUT_FILES="./velocitystep.c"
|
||||
OUTPUT_FILE="./velocitystep.o"
|
||||
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
|
||||
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -O1"
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -Ofast"
|
||||
INPUT_FILES="./chunkmask.c"
|
||||
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 -O1"
|
||||
COMPILE_FLAGS="-c -fPIC -m64 -Ofast"
|
||||
INPUT_FILES="./fluidsim.c"
|
||||
OUTPUT_FILE="./fluidsim.o"
|
||||
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
#include <immintrin.h>
|
||||
#include <stdint.h>
|
||||
@ -6,21 +5,20 @@
|
||||
#include "includes/utilities.h"
|
||||
#include "includes/chunkmask.h"
|
||||
|
||||
void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, float ** d, float ** d0, float * u, float * v, float * w, float dt);
|
||||
void advectDensity(uint32_t chunk_mask, int N, int b, float ** d, float ** d0, float * u, float * v, float * w, float dt);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: addDensity
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;F)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_addDensity
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
void Java_electrosphere_FluidSim_addDensity
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
float ** d,
|
||||
float ** d0,
|
||||
jfloat dt){
|
||||
float dt){
|
||||
int i;
|
||||
int size=N*N*N;
|
||||
float * x = GET_ARR_RAW(env,d,CENTER_LOC);
|
||||
@ -35,19 +33,18 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_addDensity
|
||||
* Method: solveDiffuseDensity
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveDiffuseDensity
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
void Java_electrosphere_FluidSim_solveDiffuseDensity
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
float ** d,
|
||||
float ** d0,
|
||||
float ** jru,
|
||||
float ** jrv,
|
||||
float ** jrw,
|
||||
jfloat DIFFUSION_CONST,
|
||||
jfloat VISCOSITY_CONST,
|
||||
jfloat dt){
|
||||
float DIFFUSION_CONST,
|
||||
float VISCOSITY_CONST,
|
||||
float dt){
|
||||
float a=dt*DIFFUSION_CONST*N*N*N;
|
||||
float c=1+6*a;
|
||||
int i, j, k, l, m;
|
||||
@ -89,23 +86,22 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveDiffuseDensity
|
||||
* Method: advectDensity
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_advectDensity
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
void Java_electrosphere_FluidSim_advectDensity
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
float ** d,
|
||||
float ** d0,
|
||||
float ** jru,
|
||||
float ** jrv,
|
||||
float ** jrw,
|
||||
jfloat DIFFUSION_CONST,
|
||||
jfloat VISCOSITY_CONST,
|
||||
jfloat dt){
|
||||
advectDensity(env,chunk_mask,N,3,d,d0,GET_ARR_RAW(env,jru,CENTER_LOC),GET_ARR_RAW(env,jrv,CENTER_LOC),GET_ARR_RAW(env,jrw,CENTER_LOC),dt);
|
||||
float DIFFUSION_CONST,
|
||||
float VISCOSITY_CONST,
|
||||
float dt){
|
||||
advectDensity(chunk_mask,N,3,d,d0,GET_ARR_RAW(env,jru,CENTER_LOC),GET_ARR_RAW(env,jrv,CENTER_LOC),GET_ARR_RAW(env,jrw,CENTER_LOC),dt);
|
||||
}
|
||||
|
||||
void advectDensity(JNIEnv * env, uint32_t chunk_mask, int N, int b, float ** d, float ** d0, float * u, float * v, float * w, float dt){
|
||||
void advectDensity(uint32_t chunk_mask, int N, int b, float ** d, float ** d0, float * u, float * v, float * w, float dt){
|
||||
int i, j, k, i0, j0, k0, i1, j1, k1;
|
||||
int m,n,o;
|
||||
float x, y, z, s0, t0, s1, t1, u1, u0, dtx,dty,dtz;
|
||||
|
||||
@ -179,8 +179,6 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
// v0 = getBuffArr(v0JId);
|
||||
// w0 = getBuffArr(w0JId);
|
||||
Java_electrosphere_FluidSim_addSourceToVectors(
|
||||
env,
|
||||
chunkJRaw,
|
||||
DIM,
|
||||
chunkMask,
|
||||
currentChunk->u,
|
||||
@ -232,12 +230,12 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w0);
|
||||
}
|
||||
}
|
||||
//solve vector diffusion
|
||||
@ -256,7 +254,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
Java_electrosphere_FluidSim_solveVectorDiffuse(env,chunkJRaw,DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_solveVectorDiffuse(DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
//update array for vectors
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
@ -271,12 +269,12 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -295,16 +293,16 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v0);
|
||||
}
|
||||
//setup projection
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
@ -319,7 +317,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
Java_electrosphere_FluidSim_setupProjection(env,chunkJRaw,DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_setupProjection(DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
//update array for vectors
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
@ -334,10 +332,10 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v0);
|
||||
}
|
||||
//samples u0, v0
|
||||
//sets u0
|
||||
@ -357,7 +355,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
Java_electrosphere_FluidSim_solveProjection(env,chunkJRaw,DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_solveProjection(DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
Chunk * currentChunk = chunks[i];
|
||||
@ -371,8 +369,8 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
}
|
||||
}
|
||||
//samples u,v,w,u0
|
||||
@ -390,7 +388,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
Java_electrosphere_FluidSim_finalizeProjection(env,chunkJRaw,DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_finalizeProjection(DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
//set boundaries a final time for u,v,w
|
||||
//...
|
||||
@ -406,18 +404,18 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w0);
|
||||
}
|
||||
}
|
||||
//swap all vector fields
|
||||
@ -458,12 +456,12 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w0);
|
||||
}
|
||||
}
|
||||
//advect vectors across boundaries
|
||||
@ -481,18 +479,18 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w0);
|
||||
}
|
||||
//advect
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
@ -507,7 +505,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
Java_electrosphere_FluidSim_advectVectors(env,chunkJRaw,DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_advectVectors(DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
//update neighbor arr
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
@ -522,12 +520,12 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w);
|
||||
}
|
||||
}
|
||||
//solve projection
|
||||
@ -545,16 +543,16 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v0);
|
||||
}
|
||||
//setup projection
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
@ -569,7 +567,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
Java_electrosphere_FluidSim_setupProjection(env,chunkJRaw,DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_setupProjection(DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
//update array for vectors
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
@ -584,10 +582,10 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v0);
|
||||
}
|
||||
//samples u0, v0
|
||||
//sets u0
|
||||
@ -607,7 +605,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
Java_electrosphere_FluidSim_solveProjection(env,chunkJRaw,DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_solveProjection(DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
Chunk * currentChunk = chunks[i];
|
||||
@ -621,8 +619,8 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
}
|
||||
}
|
||||
//samples u,v,w,u0
|
||||
@ -640,7 +638,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
Java_electrosphere_FluidSim_finalizeProjection(env,chunkJRaw,DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_finalizeProjection(DIM,chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
//set boundaries a final time for u,v,w
|
||||
//...
|
||||
@ -656,18 +654,18 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u0 = currentChunk->ju0;
|
||||
v0 = currentChunk->jv0;
|
||||
w0 = currentChunk->jw0;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,3,currentChunk->w0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,3,currentChunk->w0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,1,currentChunk->u0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,2,currentChunk->v0);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,3,currentChunk->w0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,1,currentChunk->u0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,2,currentChunk->v0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,3,currentChunk->w0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -689,7 +687,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
Chunk * currentChunk = chunks[i];
|
||||
chunkJRaw = currentChunk->jchunk;
|
||||
chunkMask = currentChunk->chunkMask;
|
||||
Java_electrosphere_FluidSim_addDensity(env,chunkJRaw,DIM,chunkMask,currentChunk->d,currentChunk->d0,timestep);
|
||||
Java_electrosphere_FluidSim_addDensity(DIM,chunkMask,currentChunk->d,currentChunk->d0,timestep);
|
||||
}
|
||||
}
|
||||
//swap all density arrays
|
||||
@ -711,8 +709,8 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
chunkMask = currentChunk->chunkMask;
|
||||
jd = currentChunk->jd;
|
||||
jd0 = currentChunk->jd0;
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,0,currentChunk->d);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,0,currentChunk->d0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,0,currentChunk->d);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,0,currentChunk->d0);
|
||||
}
|
||||
}
|
||||
//diffuse density
|
||||
@ -725,13 +723,13 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
u = currentChunk->ju;
|
||||
v = currentChunk->jv;
|
||||
w = currentChunk->jw;
|
||||
Java_electrosphere_FluidSim_solveDiffuseDensity(env,chunkJRaw,DIM,chunkMask,currentChunk->d,currentChunk->d0,currentChunk->u,currentChunk->v,currentChunk->w,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_solveDiffuseDensity(DIM,chunkMask,currentChunk->d,currentChunk->d0,currentChunk->u,currentChunk->v,currentChunk->w,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
for(int i = 0; i < numChunks; i++){
|
||||
Chunk * currentChunk = chunks[i];
|
||||
chunkJRaw = currentChunk->jchunk;
|
||||
chunkMask = currentChunk->chunkMask;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,currentChunk->d);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,0,currentChunk->d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -751,8 +749,8 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
Chunk * currentChunk = chunks[i];
|
||||
chunkJRaw = currentChunk->jchunk;
|
||||
chunkMask = currentChunk->chunkMask;
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,0,currentChunk->d);
|
||||
copyNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,0,currentChunk->d0);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,0,currentChunk->d);
|
||||
copyNeighborsRaw(DIM,chunkMask,0,0,currentChunk->d0);
|
||||
}
|
||||
}
|
||||
//advect density
|
||||
@ -761,7 +759,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
Chunk * currentChunk = chunks[i];
|
||||
chunkJRaw = currentChunk->jchunk;
|
||||
chunkMask = currentChunk->chunkMask;
|
||||
Java_electrosphere_FluidSim_advectDensity(env,chunkJRaw,DIM,chunkMask,currentChunk->d,currentChunk->d0,currentChunk->u,currentChunk->v,currentChunk->w,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
Java_electrosphere_FluidSim_advectDensity(DIM,chunkMask,currentChunk->d,currentChunk->d0,currentChunk->u,currentChunk->v,currentChunk->w,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||
}
|
||||
}
|
||||
//mirror densities
|
||||
@ -770,7 +768,7 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_simulate(
|
||||
Chunk * currentChunk = chunks[i];
|
||||
chunkJRaw = currentChunk->jchunk;
|
||||
chunkMask = currentChunk->chunkMask;
|
||||
setBoundsToNeighborsRaw(env,chunkJRaw,DIM,chunkMask,0,currentChunk->d);
|
||||
setBoundsToNeighborsRaw(DIM,chunkMask,0,currentChunk->d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,88 +16,86 @@ JNIEXPORT jint JNICALL Java_electrosphere_FluidSim_calculateChunkMask
|
||||
* Method: addSourceToVectors
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_addSourceToVectors
|
||||
(JNIEnv *, jobject, jint, jint, float **, float **, float **, float **, float **, float **, jfloat, jfloat, jfloat);
|
||||
void Java_electrosphere_FluidSim_addSourceToVectors
|
||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: solveVectorDiffuse
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveVectorDiffuse
|
||||
(JNIEnv *, jobject, jint, jint, float **, float **, float **, float **, float **, float **, jfloat, jfloat, jfloat);
|
||||
void Java_electrosphere_FluidSim_solveVectorDiffuse
|
||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: setupProjection
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_setupProjection
|
||||
(JNIEnv *, jobject, jint, jint, float **, float **, float **, float **, float **, float **, jfloat, jfloat, jfloat);
|
||||
void Java_electrosphere_FluidSim_setupProjection
|
||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: solveProjection
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveProjection
|
||||
(JNIEnv *, jobject, jint, jint, float **, float **, float **, float **, float **, float **, jfloat, jfloat, jfloat);
|
||||
void Java_electrosphere_FluidSim_solveProjection
|
||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: finalizeProjection
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_finalizeProjection
|
||||
(JNIEnv *, jobject, jint, jint, float **, float **, float **, float **, float **, float **, jfloat, jfloat, jfloat);
|
||||
void Java_electrosphere_FluidSim_finalizeProjection
|
||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: advectVectors
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_advectVectors
|
||||
(JNIEnv *, jobject, jint, jint, float **, float **, float **, float **, float **, float **, jfloat, jfloat, jfloat);
|
||||
void Java_electrosphere_FluidSim_advectVectors
|
||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: addDensity
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;F)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_addDensity
|
||||
(JNIEnv *, jobject, jint, jint, float **, float **, jfloat);
|
||||
void Java_electrosphere_FluidSim_addDensity
|
||||
(int, int, float **, float **, float);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: solveDiffuseDensity
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveDiffuseDensity
|
||||
(JNIEnv *, jobject, jint, jint, float **, float **, float **, float **, float **, jfloat, jfloat, jfloat);
|
||||
void Java_electrosphere_FluidSim_solveDiffuseDensity
|
||||
(int, int, float **, float **, float **, float **, float **, float, float, float);
|
||||
|
||||
/*
|
||||
* Class: electrosphere_FluidSim
|
||||
* Method: advectDensity
|
||||
* Signature: (II[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;[Ljava/nio/ByteBuffer;FFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_advectDensity
|
||||
(JNIEnv *, jobject, jint, jint, float **, float **, float **, float **, float **, jfloat, jfloat, jfloat);
|
||||
void Java_electrosphere_FluidSim_advectDensity
|
||||
(int, int, float **, float **, float **, float **, float **, float, float, float);
|
||||
|
||||
JNIEXPORT void JNICALL setBoundsToNeighborsRaw
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
jint vector_dir,
|
||||
void setBoundsToNeighborsRaw
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
int vector_dir,
|
||||
float ** neighborArray);
|
||||
|
||||
JNIEXPORT void JNICALL copyNeighborsRaw
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
jint cx,
|
||||
jint vector_dir,
|
||||
void copyNeighborsRaw
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
int cx,
|
||||
int vector_dir,
|
||||
float ** neighborArray);
|
||||
|
||||
#endif
|
||||
@ -1,4 +1,3 @@
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
#include <immintrin.h>
|
||||
#include <stdint.h>
|
||||
@ -16,26 +15,25 @@
|
||||
#define SET_BOUND_USE_NEIGHBOR 1
|
||||
|
||||
void add_source(int N, float * x, float * s, float dt);
|
||||
void advect(JNIEnv * env, uint32_t chunk_mask, int N, int b, float ** jrd, float ** jrd0, float * u, float * v, float * w, float dt);
|
||||
void advect(uint32_t chunk_mask, int N, int b, float ** jrd, float ** jrd0, float * u, float * v, float * w, float dt);
|
||||
|
||||
|
||||
/*
|
||||
* Adds force to all vectors
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_addSourceToVectors
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
void Java_electrosphere_FluidSim_addSourceToVectors
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
float ** jru,
|
||||
float ** jrv,
|
||||
float ** jrw,
|
||||
float ** jru0,
|
||||
float ** jrv0,
|
||||
float ** jrw0,
|
||||
jfloat DIFFUSION_CONST,
|
||||
jfloat VISCOSITY_CONST,
|
||||
jfloat dt){
|
||||
float DIFFUSION_CONST,
|
||||
float VISCOSITY_CONST,
|
||||
float dt){
|
||||
add_source(N,GET_ARR_RAW(env,jru,CENTER_LOC),GET_ARR_RAW(env,jru0,CENTER_LOC),dt);
|
||||
add_source(N,GET_ARR_RAW(env,jrv,CENTER_LOC),GET_ARR_RAW(env,jrv0,CENTER_LOC),dt);
|
||||
add_source(N,GET_ARR_RAW(env,jrw,CENTER_LOC),GET_ARR_RAW(env,jrw0,CENTER_LOC),dt);
|
||||
@ -52,20 +50,19 @@ void add_source(int N, float * x, float * s, float dt){
|
||||
/*
|
||||
* Solves vector diffusion along all axis
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveVectorDiffuse
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
void Java_electrosphere_FluidSim_solveVectorDiffuse
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
float ** jru,
|
||||
float ** jrv,
|
||||
float ** jrw,
|
||||
float ** jru0,
|
||||
float ** jrv0,
|
||||
float ** jrw0,
|
||||
jfloat DIFFUSION_CONST,
|
||||
jfloat VISCOSITY_CONST,
|
||||
jfloat dt){
|
||||
float DIFFUSION_CONST,
|
||||
float VISCOSITY_CONST,
|
||||
float dt){
|
||||
float a=dt*VISCOSITY_CONST*N*N*N;
|
||||
float c=1+6*a;
|
||||
int i, j, k, l, m;
|
||||
@ -161,20 +158,19 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveVectorDiffuse
|
||||
/*
|
||||
* Sets up a projection system of equations
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_setupProjection
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
void Java_electrosphere_FluidSim_setupProjection
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
float ** jru,
|
||||
float ** jrv,
|
||||
float ** jrw,
|
||||
float ** jru0,
|
||||
float ** jrv0,
|
||||
float ** jrw0,
|
||||
jfloat DIFFUSION_CONST,
|
||||
jfloat VISCOSITY_CONST,
|
||||
jfloat dt){
|
||||
float DIFFUSION_CONST,
|
||||
float VISCOSITY_CONST,
|
||||
float dt){
|
||||
int i, j, k;
|
||||
|
||||
__m256 xVector = _mm256_set1_ps(N);
|
||||
@ -256,20 +252,19 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_setupProjection
|
||||
/*
|
||||
* Solves a projection system of equations
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveProjection
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
void Java_electrosphere_FluidSim_solveProjection
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
float ** jru,
|
||||
float ** jrv,
|
||||
float ** jrw,
|
||||
float ** jru0,
|
||||
float ** jrv0,
|
||||
float ** jrw0,
|
||||
jfloat DIFFUSION_CONST,
|
||||
jfloat VISCOSITY_CONST,
|
||||
jfloat dt){
|
||||
float DIFFUSION_CONST,
|
||||
float VISCOSITY_CONST,
|
||||
float dt){
|
||||
int a = 1;
|
||||
int c = 6;
|
||||
int i, j, k, l, m;
|
||||
@ -311,20 +306,19 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_solveProjection
|
||||
/*
|
||||
* Finalizes a projection (subtract curl, set bounds, etc)
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_finalizeProjection
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
void Java_electrosphere_FluidSim_finalizeProjection
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
float ** jru,
|
||||
float ** jrv,
|
||||
float ** jrw,
|
||||
float ** jru0,
|
||||
float ** jrv0,
|
||||
float ** jrw0,
|
||||
jfloat DIFFUSION_CONST,
|
||||
jfloat VISCOSITY_CONST,
|
||||
jfloat dt){
|
||||
float DIFFUSION_CONST,
|
||||
float VISCOSITY_CONST,
|
||||
float dt){
|
||||
int i, j, k;
|
||||
// __m256 constScalar = _mm256_set1_ps(0.5f*N);
|
||||
__m256 xScalar = _mm256_set1_ps(0.5*N);
|
||||
@ -406,27 +400,26 @@ JNIEXPORT void JNICALL Java_electrosphere_FluidSim_finalizeProjection
|
||||
/*
|
||||
* Advects u, v, and w
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_electrosphere_FluidSim_advectVectors
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
void Java_electrosphere_FluidSim_advectVectors
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
float ** jru,
|
||||
float ** jrv,
|
||||
float ** jrw,
|
||||
float ** jru0,
|
||||
float ** jrv0,
|
||||
float ** jrw0,
|
||||
jfloat DIFFUSION_CONST,
|
||||
jfloat VISCOSITY_CONST,
|
||||
jfloat dt){
|
||||
advect(env,chunk_mask,N,1,jru,jru0,GET_ARR_RAW(env,jru0,CENTER_LOC),GET_ARR_RAW(env,jrv0,CENTER_LOC),GET_ARR_RAW(env,jrw0,CENTER_LOC),dt);
|
||||
advect(env,chunk_mask,N,2,jrv,jrv0,GET_ARR_RAW(env,jru0,CENTER_LOC),GET_ARR_RAW(env,jrv0,CENTER_LOC),GET_ARR_RAW(env,jrw0,CENTER_LOC),dt);
|
||||
advect(env,chunk_mask,N,3,jrw,jrw0,GET_ARR_RAW(env,jru0,CENTER_LOC),GET_ARR_RAW(env,jrv0,CENTER_LOC),GET_ARR_RAW(env,jrw0,CENTER_LOC),dt);
|
||||
float DIFFUSION_CONST,
|
||||
float VISCOSITY_CONST,
|
||||
float dt){
|
||||
advect(chunk_mask,N,1,jru,jru0,GET_ARR_RAW(env,jru0,CENTER_LOC),GET_ARR_RAW(env,jrv0,CENTER_LOC),GET_ARR_RAW(env,jrw0,CENTER_LOC),dt);
|
||||
advect(chunk_mask,N,2,jrv,jrv0,GET_ARR_RAW(env,jru0,CENTER_LOC),GET_ARR_RAW(env,jrv0,CENTER_LOC),GET_ARR_RAW(env,jrw0,CENTER_LOC),dt);
|
||||
advect(chunk_mask,N,3,jrw,jrw0,GET_ARR_RAW(env,jru0,CENTER_LOC),GET_ARR_RAW(env,jrv0,CENTER_LOC),GET_ARR_RAW(env,jrw0,CENTER_LOC),dt);
|
||||
}
|
||||
|
||||
|
||||
void advect(JNIEnv * env, uint32_t chunk_mask, int N, int b, float ** jrd, float ** jrd0, float * u, float * v, float * w, float dt){
|
||||
void advect(uint32_t chunk_mask, int N, int b, float ** jrd, float ** jrd0, float * u, float * v, float * w, float dt){
|
||||
int i, j, k, i0, j0, k0, i1, j1, k1;
|
||||
int m,n,o;
|
||||
float x, y, z, s0, t0, s1, t1, u1, u0, dtx,dty,dtz;
|
||||
@ -668,12 +661,11 @@ void advect(JNIEnv * env, uint32_t chunk_mask, int N, int b, float ** jrd, float
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL setBoundsToNeighborsRaw
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
jint vector_dir,
|
||||
void setBoundsToNeighborsRaw
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
int vector_dir,
|
||||
float ** neighborArray){
|
||||
int DIM = N;
|
||||
float * target = GET_ARR_RAW(env,neighborArray,CENTER_LOC);
|
||||
@ -729,13 +721,12 @@ JNIEXPORT void JNICALL setBoundsToNeighborsRaw
|
||||
/**
|
||||
* This exclusively copies neighbors to make sure zeroing out stuff doesn't break sim
|
||||
*/
|
||||
JNIEXPORT void JNICALL copyNeighborsRaw
|
||||
(JNIEnv * env,
|
||||
jobject this,
|
||||
jint N,
|
||||
jint chunk_mask,
|
||||
jint cx,
|
||||
jint vector_dir,
|
||||
void copyNeighborsRaw
|
||||
(
|
||||
int N,
|
||||
int chunk_mask,
|
||||
int cx,
|
||||
int vector_dir,
|
||||
float ** neighborArray){
|
||||
int DIM = N;
|
||||
float * target = GET_ARR_RAW(env,neighborArray,CENTER_LOC);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user