Documentation
¶
Overview ¶
package geom provides routines and types for dealing with an array of geometry-related tasks.
package geom contains routines for computing geometrical quantities in a box with periodic boundary conditions.
Index ¶
- Constants
- Variables
- func DistributeUnit(vecBuf []Vec)
- type CellBounds
- func (cb1 *CellBounds) Intersect(cb2 *CellBounds, width int) bool
- func (cb1 *CellBounds) IntersectUnbounded(cb2 *CellBounds) bool
- func (vcb *CellBounds) ScaleVecsDomain(cb *CellBounds, vs []Vec, cells int, boxWidth float64)
- func (vcb *CellBounds) ScaleVecsSegment(vs []Vec, cells int, boxWidth float64)
- type DerivOp
- type DerivOptions
- type Grid
- type GridLocation
- func (g *GridLocation) Curl(vecs, out [3][]float32, op *DerivOptions)
- func (g *GridLocation) Deriv(vals, out []float32, axis int, opt *DerivOptions)
- func (g *GridLocation) Divergence(vecs [3][]float32, out []float32, op *DerivOptions)
- func (g *GridLocation) Gradient(vals []float32, out [3][]float32, op *DerivOptions)
- func (g *GridLocation) Init(origin, width [3]int, boxWidth float64, cells int)
- type Tetra
- func (t *Tetra) Barycenter() *Vec
- func (t *Tetra) CellBounds(cellWidth float64) *CellBounds
- func (t *Tetra) CellBoundsAt(cellWidth float64, cb *CellBounds)
- func (t *Tetra) Contains(v *Vec) bool
- func (tet *Tetra) Distribute(xs, ys, zs []float64, vecBuf []Vec)
- func (tet *Tetra) DistributeTetra(pts []Vec, out []Vec)
- func (tet *Tetra) DistributeTetra64(pts []Vec, out [][3]float64)
- func (t *Tetra) Init(c0, c1, c2, c3 *Vec) *Tetra
- func (tet *Tetra) RandomSample(gen *rand.Generator, randBuf []float64, vecBuf []Vec)
- func (t *Tetra) Volume() float64
- type TetraIdxs
- type Vec
- func (v1 *Vec) Add(v2 *Vec) *Vec
- func (v1 *Vec) AddAt(v2, out *Vec) *Vec
- func (v1 *Vec) AddSelf(v2 *Vec) *Vec
- func (v1 *Vec) Cross(v2 *Vec) *Vec
- func (v2 *Vec) CrossAt(v1, out *Vec) *Vec
- func (v1 *Vec) CrossSelf(v2 *Vec) *Vec
- func (v1 *Vec) Dot(v2 *Vec) float64
- func (v *Vec) Mod(width float64) *Vec
- func (v *Vec) ModAt(width float64, out *Vec) *Vec
- func (v *Vec) ModSelf(width float64) *Vec
- func (v *Vec) Norm() float64
- func (v *Vec) Scale(k float64) *Vec
- func (v *Vec) ScaleAt(k float64, out *Vec) *Vec
- func (v *Vec) ScaleSelf(k float64) *Vec
- func (v1 *Vec) Sub(v2 *Vec, width float64) *Vec
- func (v1 *Vec) SubAt(v2 *Vec, width float64, out *Vec) *Vec
- func (v1 *Vec) SubSelf(v2 *Vec, width float64) *Vec
Constants ¶
const ( // TetraDirCount is the number of orientations that a tetrahedron can have // within a cube. Should be iterated over when calling TetraIdxs.Init(). TetraDirCount = 6 TetraCenteredCount = 8 )
Variables ¶
var DerivOptionsDefault = &DerivOptions{false, None, 4}
var ( // Yeah, this one was super fun to figure out. Dirs = [TetraDirCount][2][3]int64{ {{1, 0, 0}, {1, 1, 0}}, {{1, 0, 0}, {1, 0, 1}}, {{0, 1, 0}, {1, 1, 0}}, {{0, 0, 1}, {1, 0, 1}}, {{0, 1, 0}, {0, 1, 1}}, {{0, 0, 1}, {0, 1, 1}}, } )
Functions ¶
func DistributeUnit ¶
func DistributeUnit(vecBuf []Vec)
DistributeUnit distributes a set of points in a unit cube across a unit tetrahedron and stores the results to vecBuf.
Types ¶
type CellBounds ¶
type CellBounds struct {
Origin, Width [3]int
}
CellBounds represents a bounding box aligned to grid cells.
func (*CellBounds) Intersect ¶
func (cb1 *CellBounds) Intersect(cb2 *CellBounds, width int) bool
Intersect retursn true if the two bounding boxes overlap and false otherwise.
func (*CellBounds) IntersectUnbounded ¶
func (cb1 *CellBounds) IntersectUnbounded(cb2 *CellBounds) bool
func (*CellBounds) ScaleVecsDomain ¶
func (vcb *CellBounds) ScaleVecsDomain( cb *CellBounds, vs []Vec, cells int, boxWidth float64, )
func (*CellBounds) ScaleVecsSegment ¶
func (vcb *CellBounds) ScaleVecsSegment( vs []Vec, cells int, boxWidth float64, )
type DerivOptions ¶
type Grid ¶
type Grid struct { CellBounds Length, Area, Volume int // contains filtered or unexported fields }
Grid provides an interface for reasoning over a 1D slice as if it were a 3D grid.
func (*Grid) BoundsCheck ¶
BoundsCheck returns true if the given coordinates are within the Grid and false otherwise.
type GridLocation ¶
GridLocation is a Grid which also specifies a physical location within a periodic super-grid.
func NewGridLocation ¶
func NewGridLocation( origin, width [3]int, boxWidth float64, cells int, ) *GridLocation
func (*GridLocation) Curl ¶
func (g *GridLocation) Curl( vecs, out [3][]float32, op *DerivOptions, )
func (*GridLocation) Deriv ¶
func (g *GridLocation) Deriv( vals, out []float32, axis int, opt *DerivOptions, )
func (*GridLocation) Divergence ¶
func (g *GridLocation) Divergence( vecs [3][]float32, out []float32, op *DerivOptions, )
func (*GridLocation) Gradient ¶
func (g *GridLocation) Gradient( vals []float32, out [3][]float32, op *DerivOptions, )
type Tetra ¶
type Tetra struct { Corners [4]Vec // contains filtered or unexported fields }
Tetra is a tetrahedron with points inside a box with periodic boundary conditions.
NOTE: To speed up computations, Tetra contains a number of non-trivial private fields. If there is a need to store a large number of tetrahedra, it is advised to construct a slice of [4]Points instead and switch to Tetra instances only for calculations.
func NewTetra ¶
NewTetra creates a new tetrahedron with corners at the specified positions within a periodic box of the given width.
func (*Tetra) Barycenter ¶
Barycenter computes the barycenter of a tetrahedron.
func (*Tetra) CellBounds ¶
func (t *Tetra) CellBounds(cellWidth float64) *CellBounds
CellBounds returns the smallest enclosing set of cell bounds around a tetrahedron.
func (*Tetra) CellBoundsAt ¶
func (t *Tetra) CellBoundsAt(cellWidth float64, cb *CellBounds)
CellBoundsAt is the same as CellBounds, but is done in-place.
func (*Tetra) Contains ¶
Contains returns true if a tetrahedron contains the given point and false otherwise.
func (*Tetra) Distribute ¶
Distribute converts a sequences of points generated uniformly within a unit cube to be distributed uniformly within the base tetrahedron. The results are placed in vecBuf.
func (*Tetra) DistributeTetra ¶
DistributeTetra takes a set of points distributed across a unit tetrahedron and distributes them across the given tetrahedron through barycentric coordinate transformations.
func (*Tetra) DistributeTetra64 ¶
I hate that this function exists. Go, you make my life so hard sometimes.
func (*Tetra) RandomSample ¶
RandomSample fills a buffer of vecotrs with points generated uniformly at random from within a tetrahedron. The length of randBuf must be three times the length of vecBuf.
type TetraIdxs ¶
type TetraIdxs [4]int64
TetraIdxs are the indices of particles whichare the corners of a tetrahedron.
func NewTetraIdxs ¶
NewTetraIdxs creates a collection of indices corresponding to a tetrhedron with an anchor point at the given index. The parameter dir selects a particular tetrahedron configuration and must line in the range [0, TetraDirCount).
func (*TetraIdxs) Init ¶
Init initializes a TetraIdxs collection using the same rules as NewTetraIdxs.
func (*TetraIdxs) InitCartesian ¶
InitCartesian works the same as Init, but doesn't take periodic boundaries into account for some reason.
type Vec ¶
type Vec [3]float32
Vec represents a 3D vector. All vector methods which return vectors will also contain *Self() and *At() variants which compute the operation in-place and at the specified location, respectively. All output vectors are valid unless they overlap with an input vector but are not equal to that vector.
func (*Vec) Mod ¶
Mod calculates the value of a vector within the fundamental domain of a box with period boundary condiitions of the given width.