refactoring grid2 headers
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
c30cc6fcf8
commit
1b36112e24
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -38,6 +38,9 @@
|
|||||||
"limits": "c",
|
"limits": "c",
|
||||||
"boundsolver.h": "c",
|
"boundsolver.h": "c",
|
||||||
"randutils.h": "c",
|
"randutils.h": "c",
|
||||||
"mathutils.h": "c"
|
"mathutils.h": "c",
|
||||||
|
"velocity.h": "c",
|
||||||
|
"density.h": "c",
|
||||||
|
"grid2.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
67
src/main/c/includes/fluid/sim/grid2/density.h
Normal file
67
src/main/c/includes/fluid/sim/grid2/density.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
|
||||||
|
#ifndef FLUID_GRID2_DENSITY_H
|
||||||
|
#define FLUID_GRID2_DENSITY_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "fluid/env/environment.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually performs the advection
|
||||||
|
*/
|
||||||
|
void fluid_grid2_advect(uint32_t chunk_mask, int b, float ** jrd, float ** jrd0, float * u, float * v, float * w, float dt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds density to the density array
|
||||||
|
* @return The change in density within this chunk for this frame
|
||||||
|
*/
|
||||||
|
void fluid_grid2_addDensity(
|
||||||
|
Environment * environment,
|
||||||
|
int chunk_mask,
|
||||||
|
float ** d,
|
||||||
|
float ** d0,
|
||||||
|
float dt
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A single iteration of the jacobi to solve density diffusion
|
||||||
|
*/
|
||||||
|
void fluid_grid2_solveDiffuseDensity(
|
||||||
|
int chunk_mask,
|
||||||
|
float ** d,
|
||||||
|
float ** d0,
|
||||||
|
float ** jru,
|
||||||
|
float ** jrv,
|
||||||
|
float ** jrw,
|
||||||
|
float DIFFUSION_CONST,
|
||||||
|
float VISCOSITY_CONST,
|
||||||
|
float dt
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advects the density based on the vectors
|
||||||
|
*/
|
||||||
|
void fluid_grid2_advectDensity(uint32_t chunk_mask, float ** d, float ** d0, float ** ur, float ** vr, float ** wr, float dt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes the density array with a given ratio
|
||||||
|
*/
|
||||||
|
void fluid_grid2_normalizeDensity(float ** d, float ratio);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,9 +1,17 @@
|
|||||||
#ifndef FLUID_GRID2_SIMULATION_H
|
|
||||||
#define FLUID_GRID2_SIMULATION_H
|
|
||||||
|
|
||||||
#include "fluid/queue/chunk.h"
|
#ifndef FLUID_GRID2_MAINFUNC
|
||||||
|
#define FLUID_GRID2_MAINFUNC
|
||||||
|
|
||||||
|
|
||||||
#include "fluid/env/environment.h"
|
#include "fluid/env/environment.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the main simulation
|
* Performs the main simulation
|
||||||
* @param numChunks The number of chunks
|
* @param numChunks The number of chunks
|
||||||
@ -13,4 +21,49 @@
|
|||||||
*/
|
*/
|
||||||
void fluid_grid2_simulate(int numChunks, Chunk ** passedInChunks, Environment * environment, float timestep);
|
void fluid_grid2_simulate(int numChunks, Chunk ** passedInChunks, Environment * environment, float timestep);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main simulation function
|
||||||
|
*/
|
||||||
|
void fluid_grid2_simulate(
|
||||||
|
int numChunks,
|
||||||
|
Chunk ** passedInChunks,
|
||||||
|
Environment * environment,
|
||||||
|
jfloat timestep
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocates the arrays necessary for grid2 simulation
|
||||||
|
*/
|
||||||
|
void fluid_grid2_allocate_arrays();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
58
src/main/c/includes/fluid/sim/grid2/utilities.h
Normal file
58
src/main/c/includes/fluid/sim/grid2/utilities.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
#ifndef FLUID_GRID2_UTILITIES_H
|
||||||
|
#define FLUID_GRID2_UTILITIES_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds from a source array to a destination array
|
||||||
|
*/
|
||||||
|
void fluid_grid2_add_source(float * x, float * s, float dt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bounds of this cube to those of its neighbor
|
||||||
|
*/
|
||||||
|
void fluid_grid2_setBoundsToNeighborsRaw(
|
||||||
|
int chunk_mask,
|
||||||
|
int vector_dir,
|
||||||
|
float ** neighborArray
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This exclusively copies neighbors to make sure zeroing out stuff doesn't break sim
|
||||||
|
*/
|
||||||
|
void fluid_grid2_copyNeighborsRaw(
|
||||||
|
int chunk_mask,
|
||||||
|
int cx,
|
||||||
|
int vector_dir,
|
||||||
|
float ** neighborArray
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sums the density of the chunk
|
||||||
|
*/
|
||||||
|
double fluid_grid2_calculateSum(uint32_t chunk_mask, float ** d);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,8 +1,10 @@
|
|||||||
|
|
||||||
|
#ifndef FLUID_GRID2_VELOCITY
|
||||||
|
#define FLUID_GRID2_vELOCITY
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "fluid/env/environment.h"
|
#include "fluid/env/environment.h"
|
||||||
|
|
||||||
#ifndef FLUID_GRID2_MAINFUNC
|
|
||||||
#define FLUID_GRID2_MAINFUNC
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -12,27 +14,6 @@
|
|||||||
#define FLUID_GRID2_BOUND_DIR_W 3
|
#define FLUID_GRID2_BOUND_DIR_W 3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The main simulation function
|
|
||||||
*/
|
|
||||||
void fluid_grid2_simulate(
|
|
||||||
int numChunks,
|
|
||||||
Chunk ** passedInChunks,
|
|
||||||
Environment * environment,
|
|
||||||
jfloat timestep
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the sources to the destinations
|
* Adds the sources to the destinations
|
||||||
*/
|
*/
|
||||||
@ -49,28 +30,6 @@ void fluid_grid2_addSourceToVectors
|
|||||||
float VISCOSITY_CONST,
|
float VISCOSITY_CONST,
|
||||||
float dt);
|
float dt);
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds from a source array to a destination array
|
|
||||||
*/
|
|
||||||
void fluid_grid2_add_source(float * x, float * s, float dt);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Solves vector diffusion along all axis
|
|
||||||
*/
|
|
||||||
void fluid_grid2_solveVectorDiffuse (
|
|
||||||
int chunk_mask,
|
|
||||||
float ** jru,
|
|
||||||
float ** jrv,
|
|
||||||
float ** jrw,
|
|
||||||
float ** jru0,
|
|
||||||
float ** jrv0,
|
|
||||||
float ** jrw0,
|
|
||||||
float DIFFUSION_CONST,
|
|
||||||
float VISCOSITY_CONST,
|
|
||||||
float dt
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -140,6 +99,7 @@ void fluid_grid2_finalizeProjection(
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Advects u, v, and w
|
* Advects u, v, and w
|
||||||
*/
|
*/
|
||||||
@ -156,64 +116,23 @@ void fluid_grid2_advectVectors(
|
|||||||
float dt
|
float dt
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actually performs the advection
|
* Actually performs the advection
|
||||||
*/
|
*/
|
||||||
void fluid_grid2_advect(uint32_t chunk_mask, int b, float ** jrd, float ** jrd0, float * u, float * v, float * w, float dt);
|
void fluid_grid2_advect_velocity(uint32_t chunk_mask, int b, float ** jrd, float ** jrd0, float * u, float * v, float * w, float dt);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the bounds of this cube to those of its neighbor
|
|
||||||
*/
|
|
||||||
void fluid_grid2_setBoundsToNeighborsRaw(
|
|
||||||
int chunk_mask,
|
|
||||||
int vector_dir,
|
|
||||||
float ** neighborArray
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This exclusively copies neighbors to make sure zeroing out stuff doesn't break sim
|
|
||||||
*/
|
|
||||||
void fluid_grid2_copyNeighborsRaw(
|
|
||||||
int chunk_mask,
|
|
||||||
int cx,
|
|
||||||
int vector_dir,
|
|
||||||
float ** neighborArray
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds density to the density array
|
|
||||||
* @return The change in density within this chunk for this frame
|
|
||||||
*/
|
|
||||||
void fluid_grid2_addDensity(
|
|
||||||
Environment * environment,
|
|
||||||
int chunk_mask,
|
|
||||||
float ** d,
|
|
||||||
float ** d0,
|
|
||||||
float dt
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A single iteration of the jacobi to solve density diffusion
|
* Solves vector diffusion along all axis
|
||||||
*/
|
*/
|
||||||
void fluid_grid2_solveDiffuseDensity(
|
void fluid_grid2_solveVectorDiffuse (
|
||||||
int chunk_mask,
|
int chunk_mask,
|
||||||
float ** d,
|
|
||||||
float ** d0,
|
|
||||||
float ** jru,
|
float ** jru,
|
||||||
float ** jrv,
|
float ** jrv,
|
||||||
float ** jrw,
|
float ** jrw,
|
||||||
|
float ** jru0,
|
||||||
|
float ** jrv0,
|
||||||
|
float ** jrw0,
|
||||||
float DIFFUSION_CONST,
|
float DIFFUSION_CONST,
|
||||||
float VISCOSITY_CONST,
|
float VISCOSITY_CONST,
|
||||||
float dt
|
float dt
|
||||||
@ -223,56 +142,5 @@ void fluid_grid2_solveDiffuseDensity(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Advects the density based on the vectors
|
|
||||||
*/
|
|
||||||
void fluid_grid2_advectDensity(uint32_t chunk_mask, float ** d, float ** d0, float ** ur, float ** vr, float ** wr, float dt);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sums the density of the chunk
|
|
||||||
*/
|
|
||||||
double fluid_grid2_calculateSum(uint32_t chunk_mask, float ** d);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes the density array with a given ratio
|
|
||||||
*/
|
|
||||||
void fluid_grid2_normalizeDensity(float ** d, float ratio);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocates the arrays necessary for grid2 simulation
|
|
||||||
*/
|
|
||||||
void fluid_grid2_allocate_arrays();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -13,7 +13,7 @@
|
|||||||
#include "fluid/env/environment.h"
|
#include "fluid/env/environment.h"
|
||||||
#include "fluid/env/utilities.h"
|
#include "fluid/env/utilities.h"
|
||||||
#include "fluid/sim/grid/simulation.h"
|
#include "fluid/sim/grid/simulation.h"
|
||||||
#include "fluid/sim/grid2/simulation.h"
|
#include "fluid/sim/grid2/grid2.h"
|
||||||
#include "fluid/sim/simulator.h"
|
#include "fluid/sim/simulator.h"
|
||||||
#include "fluid/dispatch/dispatcher.h"
|
#include "fluid/dispatch/dispatcher.h"
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
#include "fluid/env/environment.h"
|
#include "fluid/env/environment.h"
|
||||||
#include "fluid/queue/chunk.h"
|
#include "fluid/queue/chunk.h"
|
||||||
#include "fluid/sim/grid2/solver_consts.h"
|
#include "fluid/sim/grid2/solver_consts.h"
|
||||||
|
#include "fluid/sim/grid2/utilities.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,10 +8,12 @@
|
|||||||
//fluid lib
|
//fluid lib
|
||||||
#include "fluid/env/utilities.h"
|
#include "fluid/env/utilities.h"
|
||||||
#include "fluid/queue/chunkmask.h"
|
#include "fluid/queue/chunkmask.h"
|
||||||
#include "fluid/sim/grid2/mainFunctions.h"
|
|
||||||
#include "fluid/queue/chunk.h"
|
#include "fluid/queue/chunk.h"
|
||||||
#include "fluid/sim/grid2/simulation.h"
|
#include "fluid/sim/grid2/grid2.h"
|
||||||
#include "fluid/sim/grid2/solver_consts.h"
|
#include "fluid/sim/grid2/solver_consts.h"
|
||||||
|
#include "fluid/sim/grid2/velocity.h"
|
||||||
|
#include "fluid/sim/grid2/density.h"
|
||||||
|
#include "fluid/sim/grid2/utilities.h"
|
||||||
|
|
||||||
#ifndef SAVE_STEPS
|
#ifndef SAVE_STEPS
|
||||||
#define SAVE_STEPS 0
|
#define SAVE_STEPS 0
|
||||||
|
|||||||
@ -6,7 +6,8 @@
|
|||||||
#include "fluid/queue/chunkmask.h"
|
#include "fluid/queue/chunkmask.h"
|
||||||
#include "fluid/queue/chunk.h"
|
#include "fluid/queue/chunk.h"
|
||||||
#include "fluid/sim/grid2/solver_consts.h"
|
#include "fluid/sim/grid2/solver_consts.h"
|
||||||
#include "fluid/sim/grid2/mainFunctions.h"
|
#include "fluid/sim/grid2/velocity.h"
|
||||||
|
#include "fluid/sim/grid2/utilities.h"
|
||||||
|
|
||||||
#define SET_BOUND_IGNORE 0
|
#define SET_BOUND_IGNORE 0
|
||||||
#define SET_BOUND_USE_NEIGHBOR 1
|
#define SET_BOUND_USE_NEIGHBOR 1
|
||||||
@ -398,15 +399,15 @@ void fluid_grid2_advectVectors(
|
|||||||
float VISCOSITY_CONST,
|
float VISCOSITY_CONST,
|
||||||
float dt
|
float dt
|
||||||
){
|
){
|
||||||
fluid_grid2_advect(chunk_mask,1,jru,jru0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
|
fluid_grid2_advect_velocity(chunk_mask,1,jru,jru0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
|
||||||
fluid_grid2_advect(chunk_mask,2,jrv,jrv0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
|
fluid_grid2_advect_velocity(chunk_mask,2,jrv,jrv0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
|
||||||
fluid_grid2_advect(chunk_mask,3,jrw,jrw0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
|
fluid_grid2_advect_velocity(chunk_mask,3,jrw,jrw0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actually performs the advection
|
* Actually performs the advection
|
||||||
*/
|
*/
|
||||||
void fluid_grid2_advect(uint32_t chunk_mask, int b, float ** jrd, float ** jrd0, float * u, float * v, float * w, float dt){
|
void fluid_grid2_advect_velocity(uint32_t chunk_mask, 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;
|
||||||
@ -5,7 +5,7 @@
|
|||||||
#include "fluid/dispatch/dispatcher.h"
|
#include "fluid/dispatch/dispatcher.h"
|
||||||
#include "fluid/sim/simulator.h"
|
#include "fluid/sim/simulator.h"
|
||||||
#include "fluid/sim/grid/simulation.h"
|
#include "fluid/sim/grid/simulation.h"
|
||||||
#include "fluid/sim/grid2/simulation.h"
|
#include "fluid/sim/grid2/grid2.h"
|
||||||
#include "fluid/sim/cellular/cellular.h"
|
#include "fluid/sim/cellular/cellular.h"
|
||||||
#include "fluid/queue/chunk.h"
|
#include "fluid/queue/chunk.h"
|
||||||
#include "fluid/env/environment.h"
|
#include "fluid/env/environment.h"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user