-
Notifications
You must be signed in to change notification settings - Fork 1
/
mfm.go
44 lines (37 loc) · 1.05 KB
/
mfm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package engine
import (
"github.com/kuchkin/mumax3-gneb/cuda"
"github.com/kuchkin/mumax3-gneb/data"
)
var (
MFM = NewScalarField("MFM", "arb.", "MFM image", SetMFM)
MFMLift inputValue
MFMTipSize inputValue
mfmconv_ *cuda.MFMConvolution
)
func init() {
MFMLift = numParam(50e-9, "MFMLift", "m", reinitmfmconv)
MFMTipSize = numParam(1e-3, "MFMDipole", "m", reinitmfmconv)
DeclLValue("MFMLift", &MFMLift, "MFM lift height")
DeclLValue("MFMDipole", &MFMTipSize, "Height of vertically magnetized part of MFM tip")
}
func SetMFM(dst *data.Slice) {
buf := cuda.Buffer(3, Mesh().Size())
defer cuda.Recycle(buf)
if mfmconv_ == nil {
reinitmfmconv()
}
msat := Msat.MSlice()
defer msat.Recycle()
mfmconv_.Exec(buf, M.Buffer(), geometry.Gpu(), msat)
cuda.Madd3(dst, buf.Comp(0), buf.Comp(1), buf.Comp(2), 1, 1, 1)
}
func reinitmfmconv() {
SetBusy(true)
defer SetBusy(false)
if mfmconv_ == nil {
mfmconv_ = cuda.NewMFM(Mesh(), MFMLift.v, MFMTipSize.v, *Flag_cachedir)
} else {
mfmconv_.Reinit(MFMLift.v, MFMTipSize.v, *Flag_cachedir)
}
}