integrate cmake + ninja
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
251f6d2c66
commit
cb9dc3170d
1
.gitignore
vendored
1
.gitignore
vendored
@ -72,3 +72,4 @@
|
|||||||
|
|
||||||
#native libraries
|
#native libraries
|
||||||
/shared-folder
|
/shared-folder
|
||||||
|
/out
|
||||||
29
.vscode/tasks.json
vendored
Normal file
29
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "cmake",
|
||||||
|
"label": "CMake: build",
|
||||||
|
"command": "build",
|
||||||
|
"targets": [
|
||||||
|
"all"
|
||||||
|
],
|
||||||
|
"preset": "${command:cmake.activeBuildPresetName}",
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"detail": "CMake template build task"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cmake",
|
||||||
|
"label": "CMake: clean rebuild",
|
||||||
|
"command": "cleanRebuild",
|
||||||
|
"targets": [
|
||||||
|
"all"
|
||||||
|
],
|
||||||
|
"preset": "${command:cmake.activeBuildPresetName}",
|
||||||
|
"group": "build",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"detail": "CMake template clean rebuild task"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
26
CMakeLists.txt
Normal file
26
CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.10.0)
|
||||||
|
project(StormEngine VERSION 0.1.0 LANGUAGES C)
|
||||||
|
|
||||||
|
# Find sources
|
||||||
|
file(GLOB_RECURSE SOURCES src/fluid/src/**.c)
|
||||||
|
|
||||||
|
#include header files
|
||||||
|
include_directories(src/fluid/includes)
|
||||||
|
|
||||||
|
#include jni
|
||||||
|
find_package(JNI REQUIRED)
|
||||||
|
include_directories(${JNI_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
#include architecture flags
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -mavx -mavx2")
|
||||||
|
|
||||||
|
#emit to shared-folder
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/shared-folder)
|
||||||
|
|
||||||
|
#Create shared library
|
||||||
|
add_library(StormEngine SHARED ${SOURCES})
|
||||||
|
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
17
CMakePresets.json
Normal file
17
CMakePresets.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"version": 8,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"displayName": "Default",
|
||||||
|
"description": "Sets Ninja generator, build and install directory",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/out/build/${presetName}",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug",
|
||||||
|
"CMAKE_TOOLCHAIN_FILE": "",
|
||||||
|
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -22,6 +22,8 @@ When cloning the repo, make sure to grab all submodules with `git clone --recurs
|
|||||||
2. From choco install
|
2. From choco install
|
||||||
- [mingw](https://community.chocolatey.org/packages/mingw)
|
- [mingw](https://community.chocolatey.org/packages/mingw)
|
||||||
- [make](https://community.chocolatey.org/packages/make)
|
- [make](https://community.chocolatey.org/packages/make)
|
||||||
|
- [cmake](https://community.chocolatey.org/packages/cmake)
|
||||||
|
- [ninja](https://community.chocolatey.org/packages/ninja)
|
||||||
|
|
||||||
3. Run build.sh
|
3. Run build.sh
|
||||||
|
|
||||||
|
|||||||
21
build.sh
21
build.sh
@ -16,12 +16,29 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#completely clear build directory
|
##
|
||||||
|
## INIT RELEASE FOLDER
|
||||||
|
##
|
||||||
rm -rf ./build
|
rm -rf ./build
|
||||||
#build directory structure
|
|
||||||
mkdir build
|
mkdir build
|
||||||
mkdir ./build/assets
|
mkdir ./build/assets
|
||||||
mkdir ./build/shared-folder
|
mkdir ./build/shared-folder
|
||||||
|
|
||||||
|
##
|
||||||
|
## BUILD NATIVE CODE
|
||||||
|
##
|
||||||
|
#completely clear native code build directory
|
||||||
|
rm -rf ./out
|
||||||
|
rm -rf ./shared-folder
|
||||||
|
#build native code
|
||||||
|
mkdir shared-folder
|
||||||
|
mkdir out
|
||||||
|
mkdir ./out/build
|
||||||
|
mkdir ./out/build/default
|
||||||
|
cmake --preset=default
|
||||||
|
cmake --build ./out/build/default
|
||||||
|
|
||||||
|
|
||||||
#compile project and copy into build dir
|
#compile project and copy into build dir
|
||||||
mvn clean package
|
mvn clean package
|
||||||
cp ./target/Renderer-${BUILD_VER}.jar ./build/engine.jar
|
cp ./target/Renderer-${BUILD_VER}.jar ./build/engine.jar
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
#maven.buildNumber.plugin properties file
|
#maven.buildNumber.plugin properties file
|
||||||
#Sun Dec 01 19:28:46 EST 2024
|
#Sun Dec 01 23:35:09 EST 2024
|
||||||
buildNumber=504
|
buildNumber=512
|
||||||
|
|||||||
@ -1218,6 +1218,7 @@ Awake fluid chunks based on neighbor state
|
|||||||
Fluid chunk conditionally send update based on sleep status
|
Fluid chunk conditionally send update based on sleep status
|
||||||
Fluid simulation normalization ratio
|
Fluid simulation normalization ratio
|
||||||
Stabilized static liquids
|
Stabilized static liquids
|
||||||
|
Integrate CMake + Ninja
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@ -561,7 +561,7 @@
|
|||||||
<SAVE_STEPS>0</SAVE_STEPS>
|
<SAVE_STEPS>0</SAVE_STEPS>
|
||||||
</environmentVariables>
|
</environmentVariables>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument>./src/fluid/compile.sh</argument>
|
<argument>./src/main/c/build.sh</argument>
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
static inline void addSourceToVectors
|
void addSourceToVectors
|
||||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -17,7 +17,7 @@ static inline void addSourceToVectors
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
static inline void solveVectorDiffuse
|
void solveVectorDiffuse
|
||||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -25,7 +25,7 @@ static inline void solveVectorDiffuse
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
static inline void setupProjection
|
void setupProjection
|
||||||
(
|
(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
@ -43,7 +43,7 @@ static inline void setupProjection
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
static inline void solveProjection
|
void solveProjection
|
||||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -51,7 +51,7 @@ static inline void solveProjection
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
static inline void finalizeProjection
|
void finalizeProjection
|
||||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -59,21 +59,21 @@ static inline void finalizeProjection
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
static inline void advectVectors
|
void advectVectors
|
||||||
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
(int, int, float **, float **, float **, float **, float **, float **, float, float, float);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds density to the density array
|
* Adds density to the density array
|
||||||
* @return The change in density within this chunk for this frame
|
* @return The change in density within this chunk for this frame
|
||||||
*/
|
*/
|
||||||
static inline void addDensity(Environment * environment, int, int, float **, float **, float);
|
void addDensity(Environment * environment, 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
|
||||||
*/
|
*/
|
||||||
static inline void solveDiffuseDensity
|
void solveDiffuseDensity
|
||||||
(int, int, float **, float **, float **, float **, float **, float, float, float);
|
(int, int, float **, float **, float **, float **, float **, float, float, float);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -81,7 +81,7 @@ static inline void 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
|
||||||
*/
|
*/
|
||||||
static inline void advectDensity(uint32_t chunk_mask, int N, float ** d, float ** d0, float ** ur, float ** vr, float ** wr, float dt);
|
void advectDensity(uint32_t chunk_mask, int N, float ** d, float ** d0, float ** ur, float ** vr, float ** wr, float dt);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,16 +92,16 @@ double calculateSum(uint32_t chunk_mask, int N, float ** d);
|
|||||||
/**
|
/**
|
||||||
* Normalizes the density array with a given ratio
|
* Normalizes the density array with a given ratio
|
||||||
*/
|
*/
|
||||||
static inline void normalizeDensity(int N, float ** d, float ratio);
|
void normalizeDensity(int N, float ** d, float ratio);
|
||||||
|
|
||||||
static inline void setBoundsToNeighborsRaw
|
void setBoundsToNeighborsRaw
|
||||||
(
|
(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
int vector_dir,
|
int vector_dir,
|
||||||
float ** neighborArray);
|
float ** neighborArray);
|
||||||
|
|
||||||
static inline void copyNeighborsRaw
|
void copyNeighborsRaw
|
||||||
(
|
(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#ifndef SOLVER_CONSTS_H
|
#ifndef SOLVER_CONSTS_H
|
||||||
#define SOLVER_CONSTS_H
|
#define SOLVER_CONSTS_H
|
||||||
|
|
||||||
#define LINEARSOLVERTIMES 5
|
#define LINEARSOLVERTIMES 3
|
||||||
#define VECTOR_DIFFUSE_TIMES 1
|
#define VECTOR_DIFFUSE_TIMES 1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1,16 +1,19 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
#include "../includes/utilities.h"
|
#include "../includes/utilities.h"
|
||||||
#include "../includes/chunkmask.h"
|
#include "../includes/chunkmask.h"
|
||||||
|
#include "../includes/environment.h"
|
||||||
|
#include "../includes/chunk.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds density to the density array
|
* Adds density to the density array
|
||||||
* @return The change in density within this chunk for this frame
|
* @return The change in density within this chunk for this frame
|
||||||
*/
|
*/
|
||||||
static inline void addDensity(
|
void addDensity(
|
||||||
Environment * environment,
|
Environment * environment,
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
@ -37,7 +40,7 @@ static inline void addDensity(
|
|||||||
/*
|
/*
|
||||||
* A single iteration of the jacobi to solve density diffusion
|
* A single iteration of the jacobi to solve density diffusion
|
||||||
*/
|
*/
|
||||||
static inline void solveDiffuseDensity(
|
void solveDiffuseDensity(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
float ** d,
|
float ** d,
|
||||||
@ -88,7 +91,7 @@ static inline void solveDiffuseDensity(
|
|||||||
/**
|
/**
|
||||||
* Advects the density based on the vectors
|
* Advects the density based on the vectors
|
||||||
*/
|
*/
|
||||||
static inline void advectDensity(uint32_t chunk_mask, int N, float ** d, float ** d0, float ** ur, float ** vr, float ** wr, float dt){
|
void advectDensity(uint32_t chunk_mask, int N, float ** d, float ** d0, float ** ur, float ** vr, float ** wr, 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;
|
||||||
|
|||||||
@ -5,10 +5,6 @@
|
|||||||
#include "../includes/mainFunctions.h"
|
#include "../includes/mainFunctions.h"
|
||||||
#include "../includes/chunk.h"
|
#include "../includes/chunk.h"
|
||||||
#include "../includes/simulation.h"
|
#include "../includes/simulation.h"
|
||||||
|
|
||||||
#include "./chunkmask.c"
|
|
||||||
#include "./velocitystep.c"
|
|
||||||
#include "./densitystep.c"
|
|
||||||
#include "../includes/solver_consts.h"
|
#include "../includes/solver_consts.h"
|
||||||
|
|
||||||
#ifndef SAVE_STEPS
|
#ifndef SAVE_STEPS
|
||||||
@ -42,12 +38,12 @@ void simulate(
|
|||||||
chunks = passedInChunks;
|
chunks = passedInChunks;
|
||||||
|
|
||||||
// printf("%p\n",chunks[0].d);
|
// printf("%p\n",chunks[0].d);
|
||||||
saveStep(chunks[0]->u[CENTER_LOC], "./chunks/beginU");
|
// saveStep(chunks[0]->u[CENTER_LOC], "./chunks/beginU");
|
||||||
saveStep(chunks[0]->v[CENTER_LOC], "./chunks/beginV");
|
// saveStep(chunks[0]->v[CENTER_LOC], "./chunks/beginV");
|
||||||
saveStep(chunks[0]->w[CENTER_LOC], "./chunks/beginW");
|
// saveStep(chunks[0]->w[CENTER_LOC], "./chunks/beginW");
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/beginU0");
|
// saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/beginU0");
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/beginV0");
|
// saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/beginV0");
|
||||||
saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/beginW0");
|
// saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/beginW0");
|
||||||
|
|
||||||
//solve chunk mask
|
//solve chunk mask
|
||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
@ -66,12 +62,12 @@ void simulate(
|
|||||||
VISCOSITY_CONSTANT,
|
VISCOSITY_CONSTANT,
|
||||||
timestep
|
timestep
|
||||||
);
|
);
|
||||||
saveStep(currentChunk->u[CENTER_LOC], "./chunks/addSrcU");
|
// saveStep(currentChunk->u[CENTER_LOC], "./chunks/addSrcU");
|
||||||
saveStep(currentChunk->v[CENTER_LOC], "./chunks/addSrcV");
|
// saveStep(currentChunk->v[CENTER_LOC], "./chunks/addSrcV");
|
||||||
saveStep(currentChunk->w[CENTER_LOC], "./chunks/addSrcW");
|
// saveStep(currentChunk->w[CENTER_LOC], "./chunks/addSrcW");
|
||||||
saveStep(currentChunk->u0[CENTER_LOC], "./chunks/addSrcU0");
|
// saveStep(currentChunk->u0[CENTER_LOC], "./chunks/addSrcU0");
|
||||||
saveStep(currentChunk->v0[CENTER_LOC], "./chunks/addSrcV0");
|
// saveStep(currentChunk->v0[CENTER_LOC], "./chunks/addSrcV0");
|
||||||
saveStep(currentChunk->w0[CENTER_LOC], "./chunks/addSrcW0");
|
// saveStep(currentChunk->w0[CENTER_LOC], "./chunks/addSrcW0");
|
||||||
}
|
}
|
||||||
//swap all vector fields
|
//swap all vector fields
|
||||||
{
|
{
|
||||||
@ -107,12 +103,12 @@ void simulate(
|
|||||||
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,3,currentChunk->w0);
|
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,3,currentChunk->w0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveStep(chunks[0]->u[CENTER_LOC], "./chunks/swapU");
|
// saveStep(chunks[0]->u[CENTER_LOC], "./chunks/swapU");
|
||||||
saveStep(chunks[0]->v[CENTER_LOC], "./chunks/swapV");
|
// saveStep(chunks[0]->v[CENTER_LOC], "./chunks/swapV");
|
||||||
saveStep(chunks[0]->w[CENTER_LOC], "./chunks/swapW");
|
// saveStep(chunks[0]->w[CENTER_LOC], "./chunks/swapW");
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/swapU0");
|
// saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/swapU0");
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/swapV0");
|
// saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/swapV0");
|
||||||
saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/swapW0");
|
// saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/swapW0");
|
||||||
// printf("after swap vecs u\n");
|
// printf("after swap vecs u\n");
|
||||||
// printLayer(chunks[0]->u[CENTER_LOC],targetLayer);
|
// printLayer(chunks[0]->u[CENTER_LOC],targetLayer);
|
||||||
// printf("after swap vecs u0\n");
|
// printf("after swap vecs u0\n");
|
||||||
@ -125,20 +121,20 @@ void simulate(
|
|||||||
Chunk * currentChunk = chunks[i];
|
Chunk * currentChunk = chunks[i];
|
||||||
solveVectorDiffuse(DIM,currentChunk->chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
solveVectorDiffuse(DIM,currentChunk->chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||||
}
|
}
|
||||||
if(SAVE_STEPS){
|
// if(SAVE_STEPS){
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseUStep%dx", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseUStep%dx", l);
|
||||||
saveStep(chunks[0]->u[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->u[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseUStep%dx0", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseUStep%dx0", l);
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->u0[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseVStep%dx", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseVStep%dx", l);
|
||||||
saveStep(chunks[0]->v[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->v[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseVStep%dx0", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseVStep%dx0", l);
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->v0[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseWStep%dx", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseWStep%dx", l);
|
||||||
saveStep(chunks[0]->w[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->w[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseWStep%dx0", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseWStep%dx0", l);
|
||||||
saveStep(chunks[0]->w0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->w0[CENTER_LOC], fileNameBuff);
|
||||||
}
|
// }
|
||||||
//update array for vectors
|
//update array for vectors
|
||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
Chunk * currentChunk = chunks[i];
|
Chunk * currentChunk = chunks[i];
|
||||||
@ -155,28 +151,28 @@ void simulate(
|
|||||||
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,0,currentChunk->v0);
|
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,0,currentChunk->v0);
|
||||||
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,0,currentChunk->w0);
|
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,0,currentChunk->w0);
|
||||||
}
|
}
|
||||||
if(SAVE_STEPS){
|
// if(SAVE_STEPS){
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseUStep%dxBnd", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseUStep%dxBnd", l);
|
||||||
saveStep(chunks[0]->u[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->u[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseUStep%dx0Bnd", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseUStep%dx0Bnd", l);
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->u0[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseVStep%dxBnd", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseVStep%dxBnd", l);
|
||||||
saveStep(chunks[0]->v[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->v[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseVStep%dx0Bnd", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseVStep%dx0Bnd", l);
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->v0[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseWStep%dxBnd", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseWStep%dxBnd", l);
|
||||||
saveStep(chunks[0]->w[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->w[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/diffuseWStep%dx0Bnd", l);
|
// sprintf(fileNameBuff, "./chunks/diffuseWStep%dx0Bnd", l);
|
||||||
saveStep(chunks[0]->w0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->w0[CENTER_LOC], fileNameBuff);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveStep(chunks[0]->u[CENTER_LOC], "./chunks/diffuseU");
|
// saveStep(chunks[0]->u[CENTER_LOC], "./chunks/diffuseU");
|
||||||
saveStep(chunks[0]->v[CENTER_LOC], "./chunks/diffuseV");
|
// saveStep(chunks[0]->v[CENTER_LOC], "./chunks/diffuseV");
|
||||||
saveStep(chunks[0]->w[CENTER_LOC], "./chunks/diffuseW");
|
// saveStep(chunks[0]->w[CENTER_LOC], "./chunks/diffuseW");
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/diffuseU0");
|
// saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/diffuseU0");
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/diffuseV0");
|
// saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/diffuseV0");
|
||||||
saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/diffuseW0");
|
// saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/diffuseW0");
|
||||||
//solve projection
|
//solve projection
|
||||||
{
|
{
|
||||||
//update array for vectors
|
//update array for vectors
|
||||||
@ -199,8 +195,8 @@ void simulate(
|
|||||||
setupProjection(DIM,currentChunk->chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
setupProjection(DIM,currentChunk->chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/setupProj1Div");
|
// saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/setupProj1Div");
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/setupProj1P");
|
// saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/setupProj1P");
|
||||||
|
|
||||||
//update array for vectors
|
//update array for vectors
|
||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
@ -211,8 +207,8 @@ void simulate(
|
|||||||
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,0,currentChunk->v0);
|
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,0,currentChunk->v0);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/setupProj1DivBnd");
|
// saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/setupProj1DivBnd");
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/setupProj1PBnd");
|
// saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/setupProj1PBnd");
|
||||||
|
|
||||||
//samples u0, v0
|
//samples u0, v0
|
||||||
//sets u0
|
//sets u0
|
||||||
@ -224,23 +220,23 @@ void simulate(
|
|||||||
Chunk * currentChunk = chunks[i];
|
Chunk * currentChunk = chunks[i];
|
||||||
solveProjection(DIM,currentChunk->chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
solveProjection(DIM,currentChunk->chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||||
}
|
}
|
||||||
if(SAVE_STEPS){
|
// if(SAVE_STEPS){
|
||||||
sprintf(fileNameBuff, "./chunks/proj1Step%dx", l);
|
// sprintf(fileNameBuff, "./chunks/proj1Step%dx", l);
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->u0[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/proj1Step%dx0", l);
|
// sprintf(fileNameBuff, "./chunks/proj1Step%dx0", l);
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->v0[CENTER_LOC], fileNameBuff);
|
||||||
}
|
// }
|
||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
Chunk * currentChunk = chunks[i];
|
Chunk * currentChunk = chunks[i];
|
||||||
setBoundsToNeighborsRaw(DIM,currentChunk->chunkMask,0,currentChunk->u0);
|
setBoundsToNeighborsRaw(DIM,currentChunk->chunkMask,0,currentChunk->u0);
|
||||||
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,0,currentChunk->u0);
|
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,0,currentChunk->u0);
|
||||||
}
|
}
|
||||||
if(SAVE_STEPS){
|
// if(SAVE_STEPS){
|
||||||
sprintf(fileNameBuff, "./chunks/proj1Step%dxBnd", l);
|
// sprintf(fileNameBuff, "./chunks/proj1Step%dxBnd", l);
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->u0[CENTER_LOC], fileNameBuff);
|
||||||
sprintf(fileNameBuff, "./chunks/proj1Step%dx0Bnd", l);
|
// sprintf(fileNameBuff, "./chunks/proj1Step%dx0Bnd", l);
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], fileNameBuff);
|
// saveStep(chunks[0]->v0[CENTER_LOC], fileNameBuff);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
//samples u,v,w,u0
|
//samples u,v,w,u0
|
||||||
//sets u,v,w
|
//sets u,v,w
|
||||||
@ -250,9 +246,9 @@ void simulate(
|
|||||||
finalizeProjection(DIM,currentChunk->chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
finalizeProjection(DIM,currentChunk->chunkMask,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,DIFFUSION_CONSTANT,VISCOSITY_CONSTANT,timestep);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveStep(chunks[0]->u[CENTER_LOC], "./chunks/finalizeProj1U");
|
// saveStep(chunks[0]->u[CENTER_LOC], "./chunks/finalizeProj1U");
|
||||||
saveStep(chunks[0]->v[CENTER_LOC], "./chunks/finalizeProj1V");
|
// saveStep(chunks[0]->v[CENTER_LOC], "./chunks/finalizeProj1V");
|
||||||
saveStep(chunks[0]->w[CENTER_LOC], "./chunks/finalizeProj1W");
|
// saveStep(chunks[0]->w[CENTER_LOC], "./chunks/finalizeProj1W");
|
||||||
// exit(0);
|
// exit(0);
|
||||||
//set boundaries a final time for u,v,w
|
//set boundaries a final time for u,v,w
|
||||||
//...
|
//...
|
||||||
@ -272,12 +268,12 @@ void simulate(
|
|||||||
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,3,currentChunk->w0);
|
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,3,currentChunk->w0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveStep(chunks[0]->u[CENTER_LOC], "./chunks/projU");
|
// saveStep(chunks[0]->u[CENTER_LOC], "./chunks/projU");
|
||||||
saveStep(chunks[0]->v[CENTER_LOC], "./chunks/projV");
|
// saveStep(chunks[0]->v[CENTER_LOC], "./chunks/projV");
|
||||||
saveStep(chunks[0]->w[CENTER_LOC], "./chunks/projW");
|
// saveStep(chunks[0]->w[CENTER_LOC], "./chunks/projW");
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/projU0");
|
// saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/projU0");
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/projV0");
|
// saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/projV0");
|
||||||
saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/projW0");
|
// saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/projW0");
|
||||||
// exit(0);
|
// exit(0);
|
||||||
//swap all vector fields
|
//swap all vector fields
|
||||||
{
|
{
|
||||||
@ -313,12 +309,12 @@ void simulate(
|
|||||||
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,3,currentChunk->w0);
|
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,3,currentChunk->w0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveStep(chunks[0]->u[CENTER_LOC], "./chunks/swap2U");
|
// saveStep(chunks[0]->u[CENTER_LOC], "./chunks/swap2U");
|
||||||
saveStep(chunks[0]->v[CENTER_LOC], "./chunks/swap2V");
|
// saveStep(chunks[0]->v[CENTER_LOC], "./chunks/swap2V");
|
||||||
saveStep(chunks[0]->w[CENTER_LOC], "./chunks/swap2W");
|
// saveStep(chunks[0]->w[CENTER_LOC], "./chunks/swap2W");
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/swap2U0");
|
// saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/swap2U0");
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/swap2V0");
|
// saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/swap2V0");
|
||||||
saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/swap2W0");
|
// saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/swap2W0");
|
||||||
//advect vectors across boundaries
|
//advect vectors across boundaries
|
||||||
{
|
{
|
||||||
//update border arrs
|
//update border arrs
|
||||||
@ -353,12 +349,12 @@ void simulate(
|
|||||||
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,3,currentChunk->w);
|
copyNeighborsRaw(DIM,currentChunk->chunkMask,0,3,currentChunk->w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveStep(chunks[0]->u[CENTER_LOC], "./chunks/advectU");
|
// saveStep(chunks[0]->u[CENTER_LOC], "./chunks/advectU");
|
||||||
saveStep(chunks[0]->v[CENTER_LOC], "./chunks/advectV");
|
// saveStep(chunks[0]->v[CENTER_LOC], "./chunks/advectV");
|
||||||
saveStep(chunks[0]->w[CENTER_LOC], "./chunks/advectW");
|
// saveStep(chunks[0]->w[CENTER_LOC], "./chunks/advectW");
|
||||||
saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/advectU0");
|
// saveStep(chunks[0]->u0[CENTER_LOC], "./chunks/advectU0");
|
||||||
saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/advectV0");
|
// saveStep(chunks[0]->v0[CENTER_LOC], "./chunks/advectV0");
|
||||||
saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/advectW0");
|
// saveStep(chunks[0]->w0[CENTER_LOC], "./chunks/advectW0");
|
||||||
//solve projection
|
//solve projection
|
||||||
{
|
{
|
||||||
//update array for vectors
|
//update array for vectors
|
||||||
|
|||||||
@ -16,14 +16,14 @@
|
|||||||
#define SET_BOUND_IGNORE 0
|
#define SET_BOUND_IGNORE 0
|
||||||
#define SET_BOUND_USE_NEIGHBOR 1
|
#define SET_BOUND_USE_NEIGHBOR 1
|
||||||
|
|
||||||
static inline void add_source(int N, float * x, float * s, float dt);
|
void add_source(int N, float * x, float * s, float dt);
|
||||||
static inline void advect(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
|
||||||
*/
|
*/
|
||||||
static inline void addSourceToVectors
|
void addSourceToVectors
|
||||||
(
|
(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
@ -44,7 +44,7 @@ static inline void addSourceToVectors
|
|||||||
/**
|
/**
|
||||||
* Adds from a source array to a destination array
|
* Adds from a source array to a destination array
|
||||||
*/
|
*/
|
||||||
static inline void add_source(int N, float * x, float * s, float dt){
|
void add_source(int N, float * x, float * s, float dt){
|
||||||
int i;
|
int i;
|
||||||
int size=N*N*N;
|
int size=N*N*N;
|
||||||
for(i=0; i<size; i++){
|
for(i=0; i<size; i++){
|
||||||
@ -55,7 +55,7 @@ static inline void add_source(int N, float * x, float * s, float dt){
|
|||||||
/*
|
/*
|
||||||
* Solves vector diffusion along all axis
|
* Solves vector diffusion along all axis
|
||||||
*/
|
*/
|
||||||
static inline void solveVectorDiffuse (
|
void solveVectorDiffuse (
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
float ** jru,
|
float ** jru,
|
||||||
@ -160,10 +160,21 @@ static inline void solveVectorDiffuse (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Sets up a projection system of equations
|
* Sets up a projection system of equations
|
||||||
|
* It stores the first derivative of the field in pr, and zeroes out divr.
|
||||||
|
* This allows you to calculate the second derivative into divr using the derivative stored in pr.
|
||||||
|
* @param N The dimension of the grid
|
||||||
|
* @param ur The x velocity grid
|
||||||
|
* @param vr The y velocity grid
|
||||||
|
* @param wr The z velocity grid
|
||||||
|
* @param pr The grid that will contain the first derivative
|
||||||
|
* @param divr The grid that will be zeroed out in preparation of the solver
|
||||||
|
* @param DIFFUSION_CONST The diffusion constant
|
||||||
|
* @param VISCOSITY_CONST The viscosity constant
|
||||||
|
* @param dt The timestep for the simulation
|
||||||
*/
|
*/
|
||||||
static inline void setupProjection(
|
void setupProjection(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
float ** ur,
|
float ** ur,
|
||||||
@ -243,10 +254,13 @@ static inline void setupProjection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Solves a projection system of equations
|
* Solves a projection system of equations.
|
||||||
|
* This performs a single iteration across a the p grid to approximate the gradient field.
|
||||||
|
* @param jru0 The gradient field
|
||||||
|
* @param jrv0 The first derivative field
|
||||||
*/
|
*/
|
||||||
static inline void solveProjection(
|
void solveProjection(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
float ** jru,
|
float ** jru,
|
||||||
@ -294,10 +308,12 @@ static inline void solveProjection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Finalizes a projection (subtract curl, set bounds, etc)
|
* Finalizes a projection.
|
||||||
|
* This subtracts the difference delta along the approximated gradient field.
|
||||||
|
* Thus we are left with an approximately mass-conserved field.
|
||||||
*/
|
*/
|
||||||
static inline void finalizeProjection(
|
void finalizeProjection(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
float ** jru,
|
float ** jru,
|
||||||
@ -381,7 +397,7 @@ static inline void finalizeProjection(
|
|||||||
/*
|
/*
|
||||||
* Advects u, v, and w
|
* Advects u, v, and w
|
||||||
*/
|
*/
|
||||||
static inline void advectVectors(
|
void advectVectors(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
float ** jru,
|
float ** jru,
|
||||||
@ -402,7 +418,7 @@ static inline void advectVectors(
|
|||||||
/**
|
/**
|
||||||
* Actually performs the advection
|
* Actually performs the advection
|
||||||
*/
|
*/
|
||||||
static inline void advect(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;
|
||||||
@ -647,7 +663,7 @@ static inline void advect(uint32_t chunk_mask, int N, int b, float ** jrd, float
|
|||||||
/**
|
/**
|
||||||
* Sets the bounds of this cube to those of its neighbor
|
* Sets the bounds of this cube to those of its neighbor
|
||||||
*/
|
*/
|
||||||
static inline void setBoundsToNeighborsRaw(
|
void setBoundsToNeighborsRaw(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
int vector_dir,
|
int vector_dir,
|
||||||
@ -701,7 +717,7 @@ static inline void 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
|
||||||
*/
|
*/
|
||||||
static inline void copyNeighborsRaw(
|
void copyNeighborsRaw(
|
||||||
int N,
|
int N,
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
int cx,
|
int cx,
|
||||||
|
|||||||
3
src/main/c/build.sh
Normal file
3
src/main/c/build.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#Builds the native code
|
||||||
|
cmake --preset=default
|
||||||
|
cmake --build ./out/build/default
|
||||||
@ -21,6 +21,12 @@ extern "C" {
|
|||||||
#define electrosphere_server_fluid_manager_ServerFluidChunk_BUFFER_DIM 18L
|
#define electrosphere_server_fluid_manager_ServerFluidChunk_BUFFER_DIM 18L
|
||||||
#undef electrosphere_server_fluid_manager_ServerFluidChunk_BUFFER_SIZE
|
#undef electrosphere_server_fluid_manager_ServerFluidChunk_BUFFER_SIZE
|
||||||
#define electrosphere_server_fluid_manager_ServerFluidChunk_BUFFER_SIZE 5832L
|
#define electrosphere_server_fluid_manager_ServerFluidChunk_BUFFER_SIZE 5832L
|
||||||
|
#undef electrosphere_server_fluid_manager_ServerFluidChunk_IS_HOMOGENOUS
|
||||||
|
#define electrosphere_server_fluid_manager_ServerFluidChunk_IS_HOMOGENOUS 1.0f
|
||||||
|
#undef electrosphere_server_fluid_manager_ServerFluidChunk_IS_NOT_HOMOGENOUS
|
||||||
|
#define electrosphere_server_fluid_manager_ServerFluidChunk_IS_NOT_HOMOGENOUS 0.0f
|
||||||
|
#undef electrosphere_server_fluid_manager_ServerFluidChunk_HOMOGENOUS_BUFFER_SIZE
|
||||||
|
#define electrosphere_server_fluid_manager_ServerFluidChunk_HOMOGENOUS_BUFFER_SIZE 4L
|
||||||
/*
|
/*
|
||||||
* Class: electrosphere_server_fluid_manager_ServerFluidChunk
|
* Class: electrosphere_server_fluid_manager_ServerFluidChunk
|
||||||
* Method: allocate
|
* Method: allocate
|
||||||
|
|||||||
@ -42,9 +42,9 @@ public class FluidAcceleratedSimulator implements ServerFluidSimulator {
|
|||||||
String osName = System.getProperty("os.name").toLowerCase();
|
String osName = System.getProperty("os.name").toLowerCase();
|
||||||
String libPath = LIB_DIR;
|
String libPath = LIB_DIR;
|
||||||
if(osName.contains("win")){
|
if(osName.contains("win")){
|
||||||
libPath = libPath + "/libfluidsim.dll";
|
libPath = libPath + "/libStormEngine.dll";
|
||||||
} else {
|
} else {
|
||||||
libPath = libPath + "/libfluidsim.so";
|
libPath = libPath + "/libStormEngine.so";
|
||||||
}
|
}
|
||||||
String absolutePath = new File(libPath).toPath().toAbsolutePath().toString();
|
String absolutePath = new File(libPath).toPath().toAbsolutePath().toString();
|
||||||
System.load(absolutePath);
|
System.load(absolutePath);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user