func writeOvf2Header(out io.Writer, q *data.Slice, time, tstep float64) { gridsize := q.Mesh().Size() cellsize := q.Mesh().CellSize() fmt.Fprintln(out, "# OOMMF OVF 2.0") fmt.Fprintln(out, "#") hdr(out, "Segment count", "1") fmt.Fprintln(out, "#") hdr(out, "Begin", "Segment") hdr(out, "Begin", "Header") fmt.Fprintln(out, "#") hdr(out, "Title", q.Tag()) // TODO hdr(out, "meshtype", "rectangular") hdr(out, "meshunit", "m") hdr(out, "xmin", 0) hdr(out, "ymin", 0) hdr(out, "zmin", 0) hdr(out, "xmax", cellsize[Z]*float64(gridsize[Z])) hdr(out, "ymax", cellsize[Y]*float64(gridsize[Y])) hdr(out, "zmax", cellsize[X]*float64(gridsize[X])) name := q.Tag() var labels []interface{} if q.NComp() == 1 { labels = []interface{}{name} } else { for i := 0; i < q.NComp(); i++ { labels = append(labels, name+"_"+string('x'+i)) } } hdr(out, "valuedim", q.NComp()) hdr(out, "valuelabels", labels...) // TODO unit := q.Unit() if unit == "" { unit = "1" } if q.NComp() == 1 { hdr(out, "valueunits", unit) } else { hdr(out, "valueunits", unit, unit, unit) } // We don't really have stages fmt.Fprintln(out, "# Desc: Stage simulation time: ", tstep, " s") fmt.Fprintln(out, "# Desc: Total simulation time: ", time, " s") hdr(out, "xbase", cellsize[Z]/2) hdr(out, "ybase", cellsize[Y]/2) hdr(out, "zbase", cellsize[X]/2) hdr(out, "xnodes", gridsize[Z]) hdr(out, "ynodes", gridsize[Y]) hdr(out, "znodes", gridsize[X]) hdr(out, "xstepsize", cellsize[Z]) hdr(out, "ystepsize", cellsize[Y]) hdr(out, "zstepsize", cellsize[X]) fmt.Fprintln(out, "#") hdr(out, "End", "Header") fmt.Fprintln(out, "#") }