Documentation ¶
Overview ¶
package particles contains functions for manipulating particles with generic fields and ID-orderings.
Index ¶
- type EqualSplitUnigrid
- type Field
- type Float32
- type Float64
- type IDOrder
- type Particles
- type SplitScheme
- type Uint32
- type Uint64
- type Vec32
- type Vec64
- type ZMajorUnigrid
- func (g *ZMajorUnigrid) IDToIndex(id uint64) (idx [3]int, level int)
- func (g *ZMajorUnigrid) IDToLevel(id uint64) int
- func (g *ZMajorUnigrid) IndexToID(i [3]int, level int) uint64
- func (g *ZMajorUnigrid) LevelOrigin(level int) [3]int
- func (g *ZMajorUnigrid) LevelSpan(level int) [3]int
- func (g *ZMajorUnigrid) Levels() int
- func (g *ZMajorUnigrid) NTot() int64
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
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 ¶
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 ¶
NewFloat32 creates a field with a given name assoicated with a given array.
func (*Float32) CreateDestination ¶
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 ¶
NewFloat64 creates a field with a given name assoicated with a given array.
func (*Float64) CreateDestination ¶
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 ¶
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 (*Uint32) CreateDestination ¶
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 (*Uint64) CreateDestination ¶
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 (*Vec32) CreateDestination ¶
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 (*Vec64) CreateDestination ¶
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) 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