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