Documentation
¶
Index ¶
- Variables
- func FormDialog(ctx core.Widget, v any, title string)
- func GPUInit()
- func GPURelease()
- func Laplacian26(x, y, z, vidx, tidx int32, ctr float32) float32
- func PotentialEnergy26(x, y, z, vidx, tidx int32, ctr float32) float32
- func ReadFromGPU(vars ...GPUVars)
- func RunDone(syncVars ...GPUVars)
- func RunGPUSync()
- func RunOneWave1DKernel(n int, syncVars ...GPUVars)
- func RunOneWave3DKernel(n int, syncVars ...GPUVars)
- func RunWave1DKernel(n int)
- func RunWave1DKernelCPU(n int)
- func RunWave1DKernelGPU(n int)
- func RunWave3DKernel(n int)
- func RunWave3DKernelCPU(n int)
- func RunWave3DKernelGPU(n int)
- func SyncFromGPU(vars ...GPUVars)
- func ToGPU(vars ...GPUVars)
- func ToGPUTensorStrides()
- func Wave1DKernel(i uint32)
- func Wave3DKernel(i uint32)
- type Config
- type Context
- type CurPrev
- func (i CurPrev) Desc() string
- func (i CurPrev) Int64() int64
- func (i CurPrev) MarshalText() ([]byte, error)
- func (i *CurPrev) SetInt64(in int64)
- func (i *CurPrev) SetString(s string) error
- func (i CurPrev) String() string
- func (i *CurPrev) UnmarshalText(text []byte) error
- func (i CurPrev) Values() []enums.Enum
- type Display
- type Edges
- type Equations
- func (i Equations) Desc() string
- func (i Equations) Int64() int64
- func (i Equations) MarshalText() ([]byte, error)
- func (i *Equations) SetInt64(in int64)
- func (i *Equations) SetString(s string) error
- func (i Equations) String() string
- func (i *Equations) UnmarshalText(text []byte) error
- func (i Equations) Values() []enums.Enum
- type GPUVars
- func (i GPUVars) Desc() string
- func (i GPUVars) Int64() int64
- func (i GPUVars) MarshalText() ([]byte, error)
- func (i *GPUVars) SetInt64(in int64)
- func (i *GPUVars) SetString(s string) error
- func (i GPUVars) String() string
- func (i *GPUVars) UnmarshalText(text []byte) error
- func (i GPUVars) Values() []enums.Enum
- type GUI
- func (gui *GUI) AddView(tabName string) *View
- func (gui *GUI) FinalizeGUI(closePrompt bool)
- func (gui *GUI) GoUpdateWindow()
- func (gui *GUI) IsRunning() bool
- func (gui *GUI) MakeBody(b tree.Node, sim *Sim, fsroot fs.FS, appname, title, about string)
- func (gui *GUI) MakeToolbar(p *tree.Plan)
- func (gui *GUI) SetStopNow()
- func (gui *GUI) StartRun()
- func (gui *GUI) StopNow() bool
- func (gui *GUI) Stopped()
- func (gui *GUI) UpdateWindow()
- type NPanels
- func (i NPanels) Desc() string
- func (i NPanels) Int64() int64
- func (i NPanels) MarshalText() ([]byte, error)
- func (np NPanels) N() int
- func (i *NPanels) SetInt64(in int64)
- func (i *NPanels) SetString(s string) error
- func (i NPanels) String() string
- func (i *NPanels) UnmarshalText(text []byte) error
- func (i NPanels) Values() []enums.Enum
- type PanelView
- type Parameters
- type PlaneMesh
- func (pm *PlaneMesh) MeshSize() (nVtx, nIndex int, hasColor bool)
- func (pm *PlaneMesh) Set(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)
- func (pm *PlaneMesh) SetBars(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)
- func (pm *PlaneMesh) SetPlane(vtxAry, normAry, texAry, clrAry math32.ArrayF32, idxAry math32.ArrayU32)
- type PlaneObj
- type Scene
- type Settings
- type Sim
- func (ss *Sim) ConfigGUI(b tree.Node)
- func (ss *Sim) ConfigSim()
- func (ss *Sim) ConfigState()
- func (ss *Sim) ConfigVars()
- func (ss *Sim) CopyCurToPrev()
- func (ss *Sim) Init()
- func (ss *Sim) InitRandSeed(run int)
- func (ss *Sim) MovingWavePacket(vr enums.Enum, dim math32.Dims, ctr math32.Vector3i, ...)
- func (ss *Sim) Run()
- func (ss *Sim) RunNoGUI()
- func (ss *Sim) Sine(vr enums.Enum, dim math32.Dims, period, phase, amp, off float32)
- func (ss *Sim) StepN(n int)
- func (ss *Sim) StepRun()
- func (ss *Sim) Stopped()
- func (ss *Sim) UpdateView()
- func (ss *Sim) ViewInit(fun func(view *View))
- func (ss *Sim) WaveConfig()
- type Units
- type VarSettinger
- type VarSettings
- type View
- func (vw *View) GoUpdateView()
- func (vw *View) Init()
- func (vw *View) MakeToolbar(p *tree.Plan)
- func (vw *View) MakeViewbar(p *tree.Plan)
- func (vw *View) PlaneAtNumber(no int) *xyz.Group
- func (vw *View) Planes() *xyz.Group
- func (vw *View) SceneXYZ() *xyz.Scene
- func (vw *View) SetCounters(ctrs string)
- func (vw *View) SetCurPrev(curprv CurPrev, panelNo int)
- func (vw *View) SetMode(mode ViewModes, panelNo int)
- func (t *View) SetPanels(v [4]PanelView) *View
- func (t *View) SetSettings(v Settings) *View
- func (t *View) SetSize(v math32.Vector3i) *View
- func (t *View) SetStart(v math32.Vector3i) *View
- func (vw *View) SetVar(vr enums.Enum, panelNo int)
- func (t *View) SetVarSettings(v map[enums.Enum]*VarSettings) *View
- func (vw *View) UpdateImpl()
- func (vw *View) UpdatePlanes()
- func (vw *View) UpdateView()
- func (vw *View) ValColor(raw float32) (scaled float32, clr color.RGBA)
- func (vw *View) VarsListUpdate()
- func (vw *View) ViewDefaults(se *xyz.Scene)
- type ViewModes
- func (i ViewModes) Desc() string
- func (i ViewModes) Int64() int64
- func (i ViewModes) MarshalText() ([]byte, error)
- func (i *ViewModes) SetInt64(in int64)
- func (i *ViewModes) SetString(s string) error
- func (i ViewModes) String() string
- func (i *ViewModes) UnmarshalText(text []byte) error
- func (i ViewModes) Values() []enums.Enum
- type WaveStates
- func (i WaveStates) Desc() string
- func (i WaveStates) Int64() int64
- func (i WaveStates) MarshalText() ([]byte, error)
- func (i *WaveStates) SetInt64(in int64)
- func (i *WaveStates) SetString(s string) error
- func (ws WaveStates) SetVarSettings(vs *VarSettings)
- func (i WaveStates) String() string
- func (i *WaveStates) UnmarshalText(text []byte) error
- func (i WaveStates) Values() []enums.Enum
Constants ¶
This section is empty.
Variables ¶
var ( // GPUInitialized is true once the GPU system has been initialized. // Prevents multiple initializations. GPUInitialized bool // ComputeGPU is the compute gpu device. // Set this prior to calling GPUInit() to use an existing device. ComputeGPU *gpu.GPU // BorrowedGPU is true if our ComputeGPU is set externally, // versus created specifically for this system. If external, // we don't release it. BorrowedGPU bool // UseGPU indicates whether to use GPU vs. CPU. UseGPU bool )
var ( // Params contains the full set of simulation parameters. //gosl:group Params //gosl:read-only Params []Parameters // NeighOffs are neighborhood offsets for 3D 26 neighbors: [26][3] //gosl:dims 2 NeighOffs *tensor.Int32 // LaplacianWts are Laplacian weighting factors for 3D 26 neighbors. //gosl:dims 1 LaplacianWts *tensor.Float32 // Ctx has the Context state values. //gosl:group State Ctx []Context // State is the overall wave state, with inner-most index being the current // and previous states. [Z][Y][X][VarsN][2] // The display shows X-Y planes stacked in the Z dimension. //gosl:dims 5 State *tensor.Float32 )
vars are all the global vars for GPU / CPU computation.
var GPUSystem *gpu.ComputeSystem
GPUSystem is a GPU compute System with kernels operating on the same set of data variables.
var MinUnitHeight = float32(1.0e-6)
MinUnitHeight ensures that there is always at least some dimensionality to the unit cubes -- affects transparency rendering etc
var NilColor = color.RGBA{0x20, 0x20, 0x20, 0x40}
var TensorStrides tensor.Uint32
Tensor stride variables
Functions ¶
func FormDialog ¶
FormDialog opens a dialog in a new, separate window for viewing / editing the given struct object, in the context of the given ctx widget.
func GPUInit ¶
func GPUInit()
GPUInit initializes the GPU compute system, configuring system(s), variables and kernels. It is safe to call multiple times: detects if already run.
func GPURelease ¶
func GPURelease()
GPURelease releases the GPU compute system resources. Call this at program exit.
func Laplacian26 ¶
Laplacian26 computes the 3D Laplacian across 26 neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. ctr is the center value.
func PotentialEnergy26 ¶
PotentialEnergy26 computes the 3D potential energy across 26 neighbors, for given x,y,z center coordinates, variable index vidx, and cur / prev time index tidx. ctr is the center value.
func ReadFromGPU ¶
func ReadFromGPU(vars ...GPUVars)
ReadFromGPU starts the process of copying vars to the GPU.
func RunDone ¶
func RunDone(syncVars ...GPUVars)
RunDone must be called after Run* calls to start compute kernels. This actually submits the kernel jobs to the GPU, and adds commands to synchronize the given variables back from the GPU to the CPU. After this function completes, the GPU results will be available in the specified variables.
func RunGPUSync ¶
func RunGPUSync()
RunGPUSync can be called to synchronize data between CPU and GPU. Any prior ToGPU* calls will execute to send data to the GPU, and any subsequent RunDone* calls will copy data back from the GPU.
func RunOneWave1DKernel ¶
RunOneWave1DKernel runs the Wave1DKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunOneWave3DKernel ¶
RunOneWave3DKernel runs the Wave3DKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. This version then calls RunDone with the given variables to sync after the Run, for a single-shot Run-and-Done call. If multiple kernels can be run in sequence, it is much more efficient to do multiple Run* calls followed by a RunDone call.
func RunWave1DKernel ¶
func RunWave1DKernel(n int)
RunWave1DKernel runs the Wave1DKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneWave1DKernel call does Run and Done for a single run-and-sync case.
func RunWave1DKernelCPU ¶
func RunWave1DKernelCPU(n int)
RunWave1DKernelCPU runs the Wave1DKernel kernel on the CPU.
func RunWave1DKernelGPU ¶
func RunWave1DKernelGPU(n int)
RunWave1DKernelGPU runs the Wave1DKernel kernel on the GPU. See RunWave1DKernel for more info.
func RunWave3DKernel ¶
func RunWave3DKernel(n int)
RunWave3DKernel runs the Wave3DKernel kernel with given number of elements, on either the CPU or GPU depending on the UseGPU variable. Can call multiple Run* kernels in a row, which are then all launched in the same command submission on the GPU, which is by far the most efficient. MUST call RunDone (with optional vars to sync) after all Run calls. Alternatively, a single-shot RunOneWave3DKernel call does Run and Done for a single run-and-sync case.
func RunWave3DKernelCPU ¶
func RunWave3DKernelCPU(n int)
RunWave3DKernelCPU runs the Wave3DKernel kernel on the CPU.
func RunWave3DKernelGPU ¶
func RunWave3DKernelGPU(n int)
RunWave3DKernelGPU runs the Wave3DKernel kernel on the GPU. See RunWave3DKernel for more info.
func SyncFromGPU ¶
func SyncFromGPU(vars ...GPUVars)
SyncFromGPU synchronizes vars from the GPU to the actual variable.
func ToGPUTensorStrides ¶
func ToGPUTensorStrides()
ToGPUTensorStrides gets tensor strides and starts copying to the GPU.
func Wave1DKernel ¶
func Wave1DKernel(i uint32)
Wave1DKernel is the kernel for computing the Wave1D equations.
func Wave3DKernel ¶
func Wave3DKernel(i uint32)
Wave3DKernel is the kernel for computing the Wave3D equations.
Types ¶
type Config ¶
type Config struct {
// GPU determines whether to use the GPU.
GPU bool `default:"true"`
// GUI determines whether to show the GUI.
GUI bool `default:"true"`
// Equation to run
Equation Equations
// Size of Universe to run. This is only the active portion, excluding
// edges at all sizes (add 2 to each dim).
Size math32.Vector3i
// ViewInterval is how often to update the view
ViewInterval int `min:"1"`
// MaxSteps is the maximum number of steps to run.
MaxSteps int
}
Config contains overall simulation configuration options.
type Context ¶
type Context struct {
// Size is the 3D size of the state, EXCLUSIVE of edges (add 2 to each dim).
Size slvec.Vector3i
// Step is the current simulation timestep.
Step int32
// CurState is either 0 or 1, indicating which state variables
// are currently being updated on this compute pass.
CurState int32
// contains filtered or unexported fields
}
Context contains all simulation counters and other context. This is only other state shared with GPU.
func GetCtx ¶
GetCtx returns a pointer to the given global variable: Ctx []Context at given index. This directly processed in the GPU code, so this function call is an equivalent for the CPU.
func (*Context) PrevState ¶
PrevState returns the index for the previous state, relative to CurState.
func (*Context) StateCoords ¶
StateCoords returns the x,y,z coordinates for given index into the state, where index is in Size units of active states, excluding edges. Resulting coords have 1 added to each, so they are valid coordinates into actual State. returns false if the index is out of range for size.
type CurPrev ¶
type CurPrev int32 //enums:enum
CurPrev for Current vs Previous state access.
const CurPrevN CurPrev = 2
CurPrevN is the highest valid value for type CurPrev, plus one.
func CurPrevValues ¶
func CurPrevValues() []CurPrev
CurPrevValues returns all possible values for the type CurPrev.
func (CurPrev) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*CurPrev) SetString ¶
SetString sets the CurPrev value from its string representation, and returns an error if the string is invalid.
func (*CurPrev) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Display ¶
type Display struct {
// On determines if display is updated.
On bool
// Interval is the number of time steps between display updates.
Interval int
}
Display contains display parameters.
type Edges ¶
type Edges int32 //enums:enum
Edges determines how to handle the edges.
const EdgesN Edges = 2
EdgesN is the highest valid value for type Edges, plus one.
func EdgesValues ¶
func EdgesValues() []Edges
EdgesValues returns all possible values for the type Edges.
func (Edges) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Edges) SetString ¶
SetString sets the Edges value from its string representation, and returns an error if the string is invalid.
func (*Edges) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Equations ¶
type Equations int32 //enums:enum
Equations are the different implemented equations to simulate.
const EquationsN Equations = 2
EquationsN is the highest valid value for type Equations, plus one.
func EquationsValues ¶
func EquationsValues() []Equations
EquationsValues returns all possible values for the type Equations.
func (Equations) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Equations) SetString ¶
SetString sets the Equations value from its string representation, and returns an error if the string is invalid.
func (*Equations) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type GPUVars ¶
type GPUVars int32 //enums:enum
GPUVars is an enum for GPU variables, for specifying what to sync.
const GPUVarsN GPUVars = 5
GPUVarsN is the highest valid value for type GPUVars, plus one.
func GPUVarsValues ¶
func GPUVarsValues() []GPUVars
GPUVarsValues returns all possible values for the type GPUVars.
func (GPUVars) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*GPUVars) SetString ¶
SetString sets the GPUVars value from its string representation, and returns an error if the string is invalid.
func (*GPUVars) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type GUI ¶
type GUI struct {
lab.Browser
// Active is true if the GUI is configured and running
Active bool `display:"-"`
// SimForm displays the Sim object fields in the left panel.
SimForm *core.Form `display:"-"`
// Body is the entire content of the sim window.
Body *core.Body `display:"-"`
// view if created.
View *View
// contains filtered or unexported fields
}
GUI manages all standard elements of a simulation Graphical User Interface
func NewGUIBody ¶
NewGUIBody returns a new GUI, with an initialized Body by calling [gui.MakeBody].
func (*GUI) FinalizeGUI ¶
FinalizeGUI wraps the end functionality of the GUI
func (*GUI) GoUpdateWindow ¶
func (gui *GUI) GoUpdateWindow()
GoUpdateWindow triggers an update on window body, for calling from a separate goroutine.
func (*GUI) MakeBody ¶
MakeBody initializes default Body with a top-level core.Splits containing a core.Form editor of the given sim object, and a filetree for the data filesystem rooted at fsroot, and with given app name, title, and about information. The first arg is an optional existing core.Body to make into: if nil then a new body is made first.
func (*GUI) MakeToolbar ¶
func (*GUI) SetStopNow ¶
func (gui *GUI) SetStopNow()
SetStopNow sets the stopNow flag to true, under a mutex.
func (*GUI) StartRun ¶
func (gui *GUI) StartRun()
StartRun should be called whenever a process starts running. It sets stopNow = false and isRunning = true under a mutex.
func (*GUI) Stopped ¶
func (gui *GUI) Stopped()
Stopped is called when a run method stops running, from a separate goroutine (do not call from main event loop). Turns off the isRunning flag, calls OnStop, and calls GoUpdateWindow to update window state.
func (*GUI) UpdateWindow ¶
func (gui *GUI) UpdateWindow()
UpdateWindow triggers an update on window body, to be called from within the normal event processing loop. See GoUpdateWindow for version to call from separate goroutine.
type NPanels ¶
type NPanels int32 //enums:enum -trim-prefix=Panels
NPanels selects number of panels.
const NPanelsN NPanels = 3
NPanelsN is the highest valid value for type NPanels, plus one.
func NPanelsValues ¶
func NPanelsValues() []NPanels
NPanelsValues returns all possible values for the type NPanels.
func (NPanels) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*NPanels) SetString ¶
SetString sets the NPanels value from its string representation, and returns an error if the string is invalid.
func (*NPanels) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type PanelView ¶
type PanelView struct {
// Variable to display.
Var enums.Enum
// Select which state to view
CurPrev CurPrev
// Mode is how the state values are displayed for this panel.
Mode ViewModes
// Offset is an additional offset from the global Start,
// enforced to be within the displayable size.
Offset math32.Vector3i
}
PanelView for what each panel in the View renders.
type Parameters ¶
type Parameters struct {
// Edges determines how to handle the edges.
Edges Edges
// DoEnergy determines if energy is computed (when not necessary).
DoEnergy slbool.Bool
// Units are the relevant unit factors.
Units Units
// contains filtered or unexported fields
}
Parameters contains the full set of simulation parameters. this is uploaded to the GPU.
func GetParams ¶
func GetParams(idx uint32) *Parameters
GetParams returns a pointer to the given global variable: Params []Parameters at given index. This directly processed in the GPU code, so this function call is an equivalent for the CPU.
func (*Parameters) Defaults ¶
func (pr *Parameters) Defaults()
func (*Parameters) Update ¶
func (pr *Parameters) Update()
type PlaneMesh ¶
PlaneMesh is a xyz.Mesh that represents an X-Y plane through the state. It is dynamically updated using theUpdate method which only resets the essential Vertex elements. The geometry is literal in the size: 0,0,0 lower-left corner and increasing X,Z in display for the X,Y plane. Display applies an overall scaling to make it fit within the larger view.
func NewPlaneMesh ¶
NewPlaneMesh adds PlaneMesh mesh to given scene for given layer
type Scene ¶
Scene is a Widget for managing the 3D Scene of the NetView
func NewScene ¶
NewScene returns a new Scene with the given optional parent: Scene is a Widget for managing the 3D Scene of the NetView
func (*Scene) MouseDownEvent ¶
type Settings ¶
type Settings struct {
// Number of different panels, each capable of displaying a different variable, mode,
// and location in the state.
NPanels NPanels
// Mode is how the state values are displayed.
Mode ViewModes
// Height is how high the values are, in normalized units.
Height float32
// size of a single bar element, where 1 = full width and no space.. .9 default
BarSize float32 `min:"0.1" max:"1" step:"0.1" default:"0.9"`
// name of color map to use
ColorMap core.ColorMapName `display:"-"`
// size of the labels
LabelSize float32 `min:"0.01" max:".1" step:"0.01" default:"0.05"`
// opacity (0-1) of zero values. greater magnitude values become increasingly
// opaque on either side of this minimum.
ZeroAlpha float32 `min:"0" max:"1" step:"0.1" default:"0.5"`
}
Settings for how the View is rendered.
type Sim ¶
type Sim struct {
// Params contains the current simulation parameters.
Params *Parameters `new-window:"+" display:"no-inline"`
// Config contains the broader running configuration.
Config *Config `new-window:"+" display:"no-inline"`
// ConfigFunc is run at initial configuration, after all default configuration,
// and can then change any parameters etc.
ConfigFunc func(sim *Sim) `display:"-"`
// InitFunc is run at initialization, and should be used to set
// the initial State, using functions in init.
InitFunc func(sim *Sim) `display:"-"`
// Root is the root tensorfs directory, where all stats and other misc sim data goes.
Root *tensorfs.Node `display:"-"`
// Stats has the stats directory within Root.
Stats *tensorfs.Node `display:"-"`
// Current has the current stats values within Stats.
Current *tensorfs.Node `display:"-"`
// GUI manages all the GUI elements
GUI GUI // `display:"-"`
// StateVars points the current state variables in effect.
StateVars enums.Enum `display:"-"`
// Rand is the random number generator for the network.
// all random calls must use this.
// Set seed here for weight initialization values.
Rand randx.Rand `display:"-"`
// Random seed to be set at the start of configuring
// the network and initializing the weights.
// Set this to get a different set of weights.
RandSeed int64 `display:"-"`
// RandSeeds is a list of random seeds to use for each run.
RandSeeds randx.Seeds `display:"-"`
// contains filtered or unexported fields
}
Sim contains everything for the simulation.
func (*Sim) ConfigState ¶
func (ss *Sim) ConfigState()
func (*Sim) ConfigVars ¶
func (ss *Sim) ConfigVars()
func (*Sim) CopyCurToPrev ¶
func (ss *Sim) CopyCurToPrev()
CopyCurToPrev copies the current values to previous values for all variables.
func (*Sim) Init ¶
func (ss *Sim) Init()
Init initializes the state and prepares everything for running.
func (*Sim) InitRandSeed ¶
func (*Sim) MovingWavePacket ¶
func (ss *Sim) MovingWavePacket(vr enums.Enum, dim math32.Dims, ctr math32.Vector3i, dir, period, width, phase, amp float32)
MovingWavePacket adds moving wave packet along given dimension, to given variable.
func (*Sim) Run ¶
func (ss *Sim) Run()
Run runs until stopped or Step > MaxSteps. Must be called by goroutine.
func (*Sim) StepRun ¶
func (ss *Sim) StepRun()
StepRun does one step of running. Must be called from goroutine.
func (*Sim) UpdateView ¶
func (ss *Sim) UpdateView()
func (*Sim) ViewInit ¶
ViewInit adds given function to view initialization functions. Called in order added -- equations typically set default init for specific equations (e.g., variable).
func (*Sim) WaveConfig ¶
func (ss *Sim) WaveConfig()
type Units ¶
type Units struct {
// C is the speed of light factor
C float32
// CSq = C^2
CSq float32 `edit:"-"`
// Inv2CSq = 1 / 2C^2
Inv2CSq float32 `edit:"-"`
// contains filtered or unexported fields
}
Units contains all the relevant units
type VarSettinger ¶
type VarSettinger interface {
SetVarSettings(vs *VarSettings)
}
VarSettinger sets variable parameters
type VarSettings ¶
type VarSettings struct {
// the variable
Var enums.Enum
// keep Min - Max centered around 0, and use negative heights for units
// else use full min-max range for height (no negative heights)
ZeroCtr bool
// range to display
Range minmax.Range32 `display:"inline"`
// if not using fixed range, this is the actual range of data
MinMax minmax.F32 `display:"inline"`
}
VarSettings holds parameters for display of each variable
func (*VarSettings) Defaults ¶
func (vs *VarSettings) Defaults()
Defaults sets default values if otherwise not set
type View ¶
type View struct {
core.Frame
// Var determines the set of variables being used.
// actual variable to view is in the PanelView.
Var enums.Enum `set:"-"`
// Pannels are the view settings per panel (4 max).
Panels [4]PanelView
// Starting front-left corner location within state.
Start math32.Vector3i
// Size of planes
Size math32.Vector3i
// parameters for the list of variables to view
VarSettings map[enums.Enum]*VarSettings
// Settings are parameters controlling how the view is rendered
Settings Settings
// Counters are displayed at the bottom: time, etc.
Counters string `set:"-" display:"-"`
sync.Mutex
// contains filtered or unexported fields
}
View is a Cogent Core Widget that provides a 3D view into state.
func NewView ¶
NewView returns a new View with the given optional parent: View is a Cogent Core Widget that provides a 3D view into state.
func (*View) GoUpdateView ¶
func (vw *View) GoUpdateView()
GoUpdateView is the update call to make from another go routine it does the proper blocking to coordinate with GUI updates generated on the main GUI thread.
func (*View) MakeToolbar ¶
func (*View) MakeViewbar ¶
func (*View) PlaneAtNumber ¶
PlaneAtNumber returns the xyz.Group that represents given plane number. nil if not found.
func (*View) SetCounters ¶
SetCounters sets the counters widget view display at bottom of netview
func (*View) SetCurPrev ¶
SetCurPrev sets the current vs. previous state viewing
func (*View) SetMode ¶
SetMode sets the display mode for given panel number. if panelNo < 0 then sets default for all panels.
func (*View) SetPanels ¶
SetPanels sets the View.Panels: Pannels are the view settings per panel (4 max).
func (*View) SetSettings ¶
SetSettings sets the View.Settings: Settings are parameters controlling how the view is rendered
func (*View) SetStart ¶
SetStart sets the View.Start: Starting front-left corner location within state.
func (*View) SetVar ¶
SetVar sets the variable to view and updates the display, for given panel number. If panelNo is -1, then this sets the global default for all panels, and doesn't update display.
func (*View) SetVarSettings ¶
func (t *View) SetVarSettings(v map[enums.Enum]*VarSettings) *View
SetVarSettings sets the View.VarSettings: parameters for the list of variables to view
func (*View) UpdateImpl ¶
func (vw *View) UpdateImpl()
UpdateImpl does the guts of updating -- backend for Update or GoUpdate
func (*View) UpdatePlanes ¶
func (vw *View) UpdatePlanes()
UpdatePlanes updates the planes display with any structural or current data changes. Very fast if no structural changes.
func (*View) UpdateView ¶
func (vw *View) UpdateView()
UpdateView updates the display based on last recorded state of network.
func (*View) ValColor ¶
ValColor returns the raw value, scaled value, and color representation for given raw value
func (*View) VarsListUpdate ¶
func (vw *View) VarsListUpdate()
VarsListUpdate updates the list of network variables
func (*View) ViewDefaults ¶
ViewDefaults are the default 3D view params
type ViewModes ¶
type ViewModes int32 //enums:enum
ViewModes are different ways of displaying wave states.
const ViewModesN ViewModes = 2
ViewModesN is the highest valid value for type ViewModes, plus one.
func ViewModesValues ¶
func ViewModesValues() []ViewModes
ViewModesValues returns all possible values for the type ViewModes.
func (ViewModes) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*ViewModes) SetString ¶
SetString sets the ViewModes value from its string representation, and returns an error if the string is invalid.
func (*ViewModes) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type WaveStates ¶
type WaveStates int32 //enums:enum -trim-prefix=Wave
WaveStates are the state variables for Wave equations.
const ( // WavePos is the position (height) wave state variable. WavePos WaveStates = iota // WaveVel is the velocity of wave state variable. WaveVel // WaveForce is the net force computed from neighbors. WaveForce // WaveKinetic is the kinetic energy. WaveKinetic // WavePotential is the potential energy. WavePotential // WaveEnergy is the total kinetic + potential energy. WaveEnergy )
const WaveStatesN WaveStates = 6
WaveStatesN is the highest valid value for type WaveStates, plus one.
func WaveStatesValues ¶
func WaveStatesValues() []WaveStates
WaveStatesValues returns all possible values for the type WaveStates.
func (WaveStates) Desc ¶
func (i WaveStates) Desc() string
Desc returns the description of the WaveStates value.
func (WaveStates) Int64 ¶
func (i WaveStates) Int64() int64
Int64 returns the WaveStates value as an int64.
func (WaveStates) MarshalText ¶
func (i WaveStates) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*WaveStates) SetInt64 ¶
func (i *WaveStates) SetInt64(in int64)
SetInt64 sets the WaveStates value from an int64.
func (*WaveStates) SetString ¶
func (i *WaveStates) SetString(s string) error
SetString sets the WaveStates value from its string representation, and returns an error if the string is invalid.
func (WaveStates) SetVarSettings ¶
func (ws WaveStates) SetVarSettings(vs *VarSettings)
func (WaveStates) String ¶
func (i WaveStates) String() string
String returns the string representation of this WaveStates value.
func (*WaveStates) UnmarshalText ¶
func (i *WaveStates) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (WaveStates) Values ¶
func (i WaveStates) Values() []enums.Enum
Values returns all possible values for the type WaveStates.