stam

package
v0.0.0-...-f38051e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2023 License: Unlicense Imports: 1 Imported by: 0

Documentation

Overview

Package stam simulates dye in a 2-D incompressible fluid

as presented by Joe Stam in Real-Time Fluid Dynamics for Games in 2003 https://www.josstam.com/_files/ugd/cf1fd6_9989229efbd34a26ba5ccd913721a2ac.pdf

see "begin stam" comment below for code transliterated from the paper

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fluid

type Fluid struct {
	Visc float64
	Diff float64
	// contains filtered or unexported fields
}

Fluid is a fluid model

func NewFluid

func NewFluid(gridSize int, visc, diff, dt float64, factory func(size int) ifc.Gridder) (fluid Fluid)

NewFluid creates a fluid model, given:

	gridSize: width and height of grid in terms of cells
           note: a boundary layer wraps around the grid so that it ranges from 0,0 to size+1,size+1
	visc:     viscocity of fluid
	diff:     diffusivity of dye in fluid
	dt:       change in time per step
	factory:  funcion returning an implementation of the Gridder interface

func (Fluid) AddDensity

func (fluid Fluid) AddDensity(i, j, n int, d float64)

AddDensity adds dye to a square of cells

func (Fluid) AddVelocity

func (fluid Fluid) AddVelocity(i, j, n int, u, v float64)

AddVelocity adds velocity to a square of cells

func (Fluid) Density

func (fluid Fluid) Density(i, j int) float64

Density gets dye density for a given cell

func (*Fluid) Level

func (fl *Fluid) Level(min float64)

Level subtracts a small amount of dye from all cells

func (Fluid) Max

func (fl Fluid) Max() (max float64)

Max finds the maximum dye density

func (Fluid) Min

func (fl Fluid) Min() (min float64)

Min finds the minimum dye density

func (*Fluid) Step

func (fl *Fluid) Step()

Step calculates the next state of the fluid

func (Fluid) Velocity

func (fluid Fluid) Velocity(i, j int) (u, v float64)

Velocity gets fluid velocity for a given cell

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL