Exemplo n.º 1
0
// average in userspace XYZ order
// does not yet take into account volume.
// pass volume parameter, possibly nil?
func average(b *data.Synced) []float64 {
	s := b.Read()
	defer b.ReadDone()
	nComp := s.NComp()
	avg := make([]float64, nComp)
	for i := range avg {
		I := swapIndex(i, nComp)
		avg[i] = float64(cuda.Sum(s.Comp(I))) / float64(s.Mesh().NCell())
	}
	return avg
}
Exemplo n.º 2
0
Arquivo: heun.go Projeto: shenyp09/mx3
func NewHeun(y *data.Synced, torqueFn func(bool) *data.Synced, postStep func(*data.Slice), dt, multiplier float64, time *float64) *Heun {
	util.Argument(dt > 0 && multiplier > 0)
	m := y.Mesh()
	dy0 := NewSlice(3, m)
	return &Heun{newSolverCommon(dt, multiplier, time), y, dy0, torqueFn, postStep}
}