particles

package
v0.0.0-...-7eedc68 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

package particles contains functions for manipulating particles with generic fields and ID-orderings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EqualSplitUnigrid

type EqualSplitUnigrid struct {
	// contains filtered or unexported fields
}

EqualSplitUnigrid is a SplitScheme which splits a uniform-density grid into equal-sized sub-cubes. See the SplitScheme documentation for method descriptions.

func NewEqualSplitUnigrid

func NewEqualSplitUnigrid(
	hd snapio.Header, order IDOrder, nCube int, names []string,
) (*EqualSplitUnigrid, error)

NewEqualSplitUnigrid splits a simulation up into subgrids with nCube cubes on one side. vars gives the names of the fields to transfer over.

func (*EqualSplitUnigrid) Buffers

func (g *EqualSplitUnigrid) Buffers() []Particles

func (*EqualSplitUnigrid) Indices

func (g *EqualSplitUnigrid) Indices(
	id []uint64, from, to [][]int,
) (fromOut, toOut [][]int, err error)

type Field

type Field interface {
	// Len returns the length of the underlying array.
	Len() int
	// Name returns the name of the Field.
	Name() string
	// Data returns the underlying array as an interface{}.
	Data() interface{}
	// Transfer transfers data from the Field to the appropriately named field
	// in dest. Particles are transfer from the indices 'from' to the indices
	// 'to'. These indices are passed as arrays to amortize the cost of error
	// handling and type conversion.
	Transfer(dest Particles, from, to []int) error
	// CreateDestination creates output fields in p with the specified size
	// that have the correct names and types.
	CreateDestination(p Particles, n int)
}

Field is a generic interface around

func NewGenericField

func NewGenericField(name string, x interface{}) (Field, error)

NewGenericField creates the appropriate field for a given array. The supported types []uint32, []uint64, []float32, []float64, [][3]float32, [][3]float64.

type Float32

type Float32 struct {
	// contains filtered or unexported fields
}

Float32 implements the Field interface for []float32 data. See the Field interface for documentation of this struct's methods.

func NewFloat32

func NewFloat32(name string, x []float32) *Float32

NewFloat32 creates a field with a given name assoicated with a given array.

func (*Float32) CreateDestination

func (x *Float32) CreateDestination(p Particles, n int)

func (*Float32) Data

func (x *Float32) Data() interface{}

func (*Float32) Len

func (x *Float32) Len() int

func (*Float32) Name

func (x *Float32) Name() string

func (*Float32) Transfer

func (x *Float32) Transfer(dest Particles, from, to []int) error

type Float64

type Float64 struct {
	// contains filtered or unexported fields
}

Float64 implements the Field interface for []float32 data. See the Field interface for documentation of this struct's methods.

func NewFloat64

func NewFloat64(name string, x []float64) *Float64

NewFloat64 creates a field with a given name assoicated with a given array.

func (*Float64) CreateDestination

func (x *Float64) CreateDestination(p Particles, n int)

func (*Float64) Data

func (x *Float64) Data() interface{}

func (*Float64) Len

func (x *Float64) Len() int

func (*Float64) Name

func (x *Float64) Name() string

func (*Float64) Transfer

func (x *Float64) Transfer(dest Particles, from, to []int) error

type IDOrder

type IDOrder interface {
	// IDToIndex converts an ID to its 3-index equivalent in the level's grid.
	// It also returns the resolution level of the particle.
	IDToIndex(id uint64) (idx [3]int, level int)
	// IndexToID converts a 3-index within a level to its ID.
	IndexToID(i [3]int, level int) uint64

	// Levels returns the number of levels that this system of IDs uses.
	Levels() int
	// LevelOrigin returns a 3-index to the origin of a given level in units of
	// that resolution level.
	LevelOrigin(level int) [3]int
	// LevelSpan returns the 3-index representing the span of a given level in
	// units of that resolution level.
	LevelSpan(level int) [3]int

	// Ntot returns the total number of particles spanned by IDOrder.
	NTot() int64
}

IDOrder is an interface for mapping paritcles IDs to their 3D index into the simulation grid. This interface also supports mutli-reoslution simulations which are split up into "levels" of fixed resolution.

type Particles

type Particles map[string]Field

Particles represents the particles in a simulation or chunk of a simulation. It maps the name of each field (e.g. 'id', 'x', 'phi', etc.) to a Field.

func Split

func Split(
	scheme SplitScheme, files []snapio.File, vars []string,
) (p []Particles, err error, externalErr bool)

Split splits the particles in a series of Files into distinct Particles maps, which will be compressed individually into different output files. It's basically just a glue function for File and SplitScheme. The "id" field will not be copied over, even if it is supplied.

Split can encounter both external and internal errors and returns a boolean specifying which type of error it is returning.

type SplitScheme

type SplitScheme interface {
	// Buffers returns the Paritcles maps for each file that the simulation
	// will be broken into. These Particles maps will be initialized with the
	// correct size and names, so this information should be passed to the
	// SplitScheme instructor.
	Buffers() []Particles
	// Indices writes the indices that the given IDs should be written to.
	// from[i][j] is the index into id of a particle that should be written to
	// file i and to[i][j] is the index of that particle in the Particles
	// arrays.
	Indices(id []uint64, from, to [][]int) (fromOut, toOut [][]int, err error)
}

SplitScheme is a strategy for splitting up a simulation's particles into regions that are contiguous in Lagrangian space.

type Uint32

type Uint32 struct {
	// contains filtered or unexported fields
}

Uint32 implements the Field interface for []uint32 data. See the Field interface for documentation of this struct's methods.

func NewUint32

func NewUint32(name string, x []uint32) *Uint32

NewUint32 creates a field with a given name assoicated with a given array.

func (*Uint32) CreateDestination

func (x *Uint32) CreateDestination(p Particles, n int)

func (*Uint32) Data

func (x *Uint32) Data() interface{}

func (*Uint32) Len

func (x *Uint32) Len() int

func (*Uint32) Name

func (x *Uint32) Name() string

func (*Uint32) Transfer

func (x *Uint32) Transfer(dest Particles, from, to []int) error

type Uint64

type Uint64 struct {
	// contains filtered or unexported fields
}

Uint64 implements the Field interface for []uint32 data. See the Field interface for documentation of this struct's methods.

func NewUint64

func NewUint64(name string, x []uint64) *Uint64

NewUint64 creates a field with a given name assoicated with a given array.

func (*Uint64) CreateDestination

func (x *Uint64) CreateDestination(p Particles, n int)

func (*Uint64) Data

func (x *Uint64) Data() interface{}

func (*Uint64) Len

func (x *Uint64) Len() int

func (*Uint64) Name

func (x *Uint64) Name() string

func (*Uint64) Transfer

func (x *Uint64) Transfer(dest Particles, from, to []int) error

type Vec32

type Vec32 struct {
	// contains filtered or unexported fields
}

Vec32 implements the Field interface for [][3]float32 data. See the Field interface for documentation of this struct's methods.

func NewVec32

func NewVec32(name string, x [][3]float32) *Vec32

NewVec32 creates a field with a given name assoicated with a given array.

func (*Vec32) CreateDestination

func (x *Vec32) CreateDestination(p Particles, n int)

func (*Vec32) Data

func (x *Vec32) Data() interface{}

func (*Vec32) Len

func (x *Vec32) Len() int

func (*Vec32) Name

func (x *Vec32) Name() string

func (*Vec32) Transfer

func (x *Vec32) Transfer(dest Particles, from, to []int) error

type Vec64

type Vec64 struct {
	// contains filtered or unexported fields
}

Vec64 implements the Field interface for [][3]float64 data. See the Field interface for documentation of this struct's methods.

func NewVec64

func NewVec64(name string, x [][3]float64) *Vec64

NewVec64 creates a field with a given name assoicated with a given array.

func (*Vec64) CreateDestination

func (x *Vec64) CreateDestination(p Particles, n int)

func (*Vec64) Data

func (x *Vec64) Data() interface{}

func (*Vec64) Len

func (x *Vec64) Len() int

func (*Vec64) Name

func (x *Vec64) Name() string

func (*Vec64) Transfer

func (x *Vec64) Transfer(dest Particles, from, to []int) error

type ZMajorUnigrid

type ZMajorUnigrid struct {
	// contains filtered or unexported fields
}

ZMajorUnigrid is the IDOrder of a z-major uniform-mass grid. This is the ordering used by, e.g., 2LPTic and many other codes. See the IDOrder interface for documentation of the methods.

func NewZMajorUnigrid

func NewZMajorUnigrid(n int) *ZMajorUnigrid

NewZMajorUnigrid returns a z-major uniform density grid with width n on each side.

func (*ZMajorUnigrid) IDToIndex

func (g *ZMajorUnigrid) IDToIndex(id uint64) (idx [3]int, level int)

func (*ZMajorUnigrid) IDToLevel

func (g *ZMajorUnigrid) IDToLevel(id uint64) int

func (*ZMajorUnigrid) IndexToID

func (g *ZMajorUnigrid) IndexToID(i [3]int, level int) uint64

func (*ZMajorUnigrid) LevelOrigin

func (g *ZMajorUnigrid) LevelOrigin(level int) [3]int

func (*ZMajorUnigrid) LevelSpan

func (g *ZMajorUnigrid) LevelSpan(level int) [3]int

func (*ZMajorUnigrid) Levels

func (g *ZMajorUnigrid) Levels() int

func (*ZMajorUnigrid) NTot

func (g *ZMajorUnigrid) NTot() int64

Jump to

Keyboard shortcuts

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