本文整理汇总了Golang中code/google/com/p/mx3/data.Slice.Unit方法的典型用法代码示例。如果您正苦于以下问题:Golang Slice.Unit方法的具体用法?Golang Slice.Unit怎么用?Golang Slice.Unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/google/com/p/mx3/data.Slice
的用法示例。
在下文中一共展示了Slice.Unit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: writeOvf2Header
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, "#")
}