Renderer/src/main/c/includes/fluid/sim/grid2/velocity.h
austin 1b36112e24
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
refactoring grid2 headers
2024-12-09 18:01:27 -05:00

146 lines
2.8 KiB
C

#ifndef FLUID_GRID2_VELOCITY
#define FLUID_GRID2_vELOCITY
#include <stdint.h>
#include "fluid/env/environment.h"
#define FLUID_GRID2_BOUND_NO_DIR 0
#define FLUID_GRID2_BOUND_DIR_U 1
#define FLUID_GRID2_BOUND_DIR_V 2
#define FLUID_GRID2_BOUND_DIR_W 3
/**
* Adds the sources to the destinations
*/
void fluid_grid2_addSourceToVectors
(
int chunk_mask,
float ** jru,
float ** jrv,
float ** jrw,
float ** jru0,
float ** jrv0,
float ** jrw0,
float DIFFUSION_CONST,
float VISCOSITY_CONST,
float dt);
/**
* 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 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
*/
void fluid_grid2_setupProjection(
int chunk_mask,
float ** ur,
float ** vr,
float ** wr,
float ** pr,
float ** divr,
float DIFFUSION_CONST,
float VISCOSITY_CONST,
float dt
);
/**
* 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
*/
void fluid_grid2_solveProjection(
int chunk_mask,
float ** jru,
float ** jrv,
float ** jrw,
float ** jru0,
float ** jrv0,
float ** jrw0,
float DIFFUSION_CONST,
float VISCOSITY_CONST,
float dt
);
/**
* Finalizes a projection.
* This subtracts the difference delta along the approximated gradient field.
* Thus we are left with an approximately mass-conserved field.
*/
void fluid_grid2_finalizeProjection(
int chunk_mask,
float ** jru,
float ** jrv,
float ** jrw,
float ** jru0,
float ** jrv0,
float ** jrw0,
float DIFFUSION_CONST,
float VISCOSITY_CONST,
float dt
);
/*
* Advects u, v, and w
*/
void fluid_grid2_advectVectors(
int chunk_mask,
float ** jru,
float ** jrv,
float ** jrw,
float ** jru0,
float ** jrv0,
float ** jrw0,
float DIFFUSION_CONST,
float VISCOSITY_CONST,
float dt
);
/**
* Actually performs the advection
*/
void fluid_grid2_advect_velocity(uint32_t chunk_mask, int b, float ** jrd, float ** jrd0, float * u, float * v, float * w, 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
);
#endif