Exemplo n.º 1
0
func SaveKernel(fname string, kernel *data.Slice) error {
	f, err := os.OpenFile(fname, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666)
	if err != nil {
		return err
	}
	out := bufio.NewWriter(f)
	defer out.Flush()
	oommf.WriteOVF2(out, kernel, data.Meta{}, "binary 4")
	return nil
}
Exemplo n.º 2
0
Arquivo: save.go Projeto: jsampaio/3
// synchronous save
func saveAs_sync(fname string, s *data.Slice, info data.Meta, format OutputFormat) {
	f, err := httpfs.Create(fname)
	util.FatalErr(err)
	defer f.Close()

	switch format {
	case OVF1_TEXT:
		oommf.WriteOVF1(f, s, info, "text")
	case OVF1_BINARY:
		oommf.WriteOVF1(f, s, info, "binary 4")
	case OVF2_TEXT:
		oommf.WriteOVF2(f, s, info, "text")
	case OVF2_BINARY:
		oommf.WriteOVF2(f, s, info, "binary 4")
	case DUMP:
		dump.Write(f, s, info)
	default:
		panic("invalid output format")
	}

}
Exemplo n.º 3
0
func output3D(D [][]complex64, reduce func(complex64) float32, size [3]int, prefix string, deltaF float32) {
	const NCOMP = 1
	for i := 0; i < len(D)/2; i++ {
		d := D[i]
		MHz := int((float32(i) * deltaF) / 1e6)
		fname := fmt.Sprintf("%sf%06dMHz.ovf", prefix, MHz)
		slice := data.NewSlice(NCOMP, size)
		doReduce(slice.Host()[0], d, reduce)
		meta := data.Meta{}
		log.Println(fname)
		f := httpfs.MustCreate(fname)
		oommf.WriteOVF2(f, slice, meta, "binary")
		f.Close()
	}
}
Exemplo n.º 4
0
func main() {

	cuda.Init(0)
	defer Close()

	Nx := 512
	Ny := 128
	Nz := 1

	cellsize := 5.0e-9
	SetGridSize(Nx, Ny, Nz)
	thickness := 40e-9
	//width := float64(Ny) * cellsize
	length := float64(Nx) * cellsize
	SetCellSize(cellsize, cellsize, thickness/float64(Nz))

	mask := data.NewSlice(3, Mesh().Size())
	wireX := -length * 0.45
	//wireY := 0.0
	wireZ := thickness * 5.0

	for h := 0; h < 10; h++ {
		for i := 0; i < Nx; i++ {
			for j := 0; j < Ny; j++ {
				r := Index2Coord(i, j, 0)
				r = r.Sub(Vector(wireX+float64(h)*cellsize, r.Y(), wireZ))

				B := Vector(0, 0, 0)
				current := Vector(0, 1, 0)
				B = r.Cross(current).Mul(Mu0 / (2 * math.Pi * math.Pow(r.Len(), 2)))

				mask.Set(0, i, j, 0, B.X())
				mask.Set(1, i, j, 0, B.Y())
				mask.Set(2, i, j, 0, B.Z())
			}
		}
	}

	f, _ := os.OpenFile("antenna.ovf", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
	defer f.Close()
	oommf.WriteOVF2(f, mask, data.Meta{}, "binary 4")
}
Exemplo n.º 5
0
Arquivo: main.go Projeto: kyeongdong/3
func outputOVF2(f *data.Slice, info data.Meta, out io.Writer) {
	oommf.WriteOVF2(out, f, info, *flag_ovf2)
}