Documentation ¶
Overview ¶
The mumax engine stores the entire simulation state and provides methods to run the simulation. An engine is typically steered by a driver, like a python program or command line interface.
Index ¶
- Constants
- func AddTermToQuant(sumQuant, term *Quant)
- func AtLeast1(q *Quant)
- func GetVariable(argMap map[string]string, name string) string
- func Init()
- func Int(q *Quant)
- func IsGoodCUFFTSize(n int) bool
- func IsGoodGridSize(size []int) bool
- func IsGoodGridSize1(direction, n int) bool
- func LoadBDFAM12(e *Engine)
- func LoadBDFEuler(e *Engine)
- func LoadEuler(e *Engine)
- func LoadRK12(e *Engine)
- func NonNegative(q *Quant)
- func NonZero(q *Quant)
- func PadSize(size []int, periodic []int) []int
- func ParseArgument(m map[string]string, v string)
- func PosInt(q *Quant)
- func Positive(q *Quant)
- func ReadDump(fname string) *host.Array
- func ReadFile(fname string) *host.Array
- func ReadPNG(fname string) *host.Array
- func RegisterInputFormat(extension string, readFunc func(string) *host.Array)
- func RegisterModule(name, description string, loadfunc func(e *Engine))
- func RegisterModuleArgs(name, description string, args Arguments, ...)
- func RegisterOutputFormat(format OutputFormat)
- func Resample(in *host.Array, size2 []int) *host.Array
- func RunDot(infile, format string)
- func TexGen()
- func Uint(q *Quant)
- func Write(out io.Writer, a *host.Array)
- type API
- func (a API) AddDeltaQuant(src, ref string)
- func (a API) Add_To(sumQuantity, newQuantity string)
- func (a API) Add_To_Weighted(sumQuantity, newQuantity string, weight float64)
- func (a API) AutoSave(quantity string, format string, options []string, period float64) (handle int)
- func (a API) AutoTabulate(quantities []string, filename string, period float64) (handle int)
- func (a API) DebugField(quantity string) *host.Array
- func (a API) DebugV(quantity string) []float64
- func (a API) Debug_DisableUpdate(quantity string)
- func (a API) Debug_GC()
- func (a API) Debug_GetArray(quant string) *host.Array
- func (a API) Debug_Invalidate(quantity string)
- func (a API) Debug_Update(quantity string)
- func (a API) Debug_VerifyAll()
- func (a API) Echo(str string)
- func (a API) FileNumberFormat(format string)
- func (a API) GetArray(quantity string) *host.Array
- func (a API) GetCell(quant string, x, y, z int) []float64
- func (a API) GetCellSize() (x, y, z float64)
- func (a API) GetGridSize() (x, y, z int)
- func (a API) GetMask(quantity string) *host.Array
- func (a API) GetPeriodic() (x, y, z int)
- func (a API) GetS(quantity string) float64
- func (a API) GetTime(tag string) float64
- func (a API) GetV(quantity string) []float64
- func (a API) GetWorldSize() (x, y, z float64)
- func (a API) Load(name string)
- func (a API) LoadArgs(name string, ins, deps, outs []string)
- func (a API) New_MaxAbs(newQuantity, inputQuantity string)
- func (a API) New_MaxNorm(newQuantity, inputQuantity string)
- func (a API) New_Peak(newQuantity, inputQuantity string)
- func (a API) OutputDirectory() string
- func (a API) OutputID() int
- func (a API) PrintStats()
- func (a API) ReadFile(filename string) *host.Array
- func (a API) RecoverState(dst, src string)
- func (a API) Remove(handle int)
- func (a API) ResetTimer(tag string)
- func (a API) Run(duration float64)
- func (a API) Run_Until_Larger(quantity string, value float64)
- func (a API) Run_Until_Smaller(quantity string, value float64)
- func (a API) Save(quantity string, format string, options []string)
- func (a API) SaveAs(quantity string, format string, options []string, filename string)
- func (a API) SaveGraph(file string)
- func (a API) SaveState(dst, src string)
- func (a API) SetArray(quantity string, field *host.Array)
- func (a API) SetArray_File(quantity string, filename string)
- func (a API) SetCell(quant string, x, y, z int, value []float64)
- func (a API) SetCellSize(x, y, z float64)
- func (a API) SetGridSize(x, y, z int)
- func (a API) SetMask(quantity string, mask *host.Array)
- func (a API) SetMask_File(quantity string, filename string)
- func (a API) SetPeriodic(x, y, z int)
- func (a API) SetS(quantity string, value float64)
- func (a API) SetV(quantity string, value []float64)
- func (a API) SetVMap(yName, xName string, yValue [][]float64, xValue []float64)
- func (a API) StartTimer(tag string)
- func (a API) Step()
- func (a API) Steps(N int)
- func (a API) StopTimer(tag string)
- func (a API) Sync()
- func (a API) Tabulate(quantities []string, filename string)
- func (a API) Unit(quantity string) string
- type AddTermUpdater
- type Arguments
- type ArrayPool
- type AutoSave
- type AutoTabulate
- type AverageUpdater
- type BDFAM12
- type BDFEuler
- type Engine
- func (e *Engine) AddDeltaQuant(in, ref string)
- func (e *Engine) AddNewQuant(name string, nComp int, kind QuantKind, unit Unit, desc ...string) *Quant
- func (e *Engine) AddPDE1(y, diff string)
- func (e *Engine) AddQuant(q *Quant)
- func (e *Engine) AddTimeDerivative(q *Quant)
- func (e *Engine) AutoFilename(quant, format string) string
- func (e *Engine) AutoSave(quant string, format string, options []string, period float64) (handle int)
- func (e *Engine) AutoTabulate(quants []string, filename string, period float64) (handle int)
- func (e *Engine) CellSize() []float64
- func (e *Engine) CellVolume() float64
- func (e *Engine) Close()
- func (e *Engine) Depends(childQuantity string, parentQuantities ...string)
- func (e *Engine) GridSize() []int
- func (e *Engine) HasModule(name string) bool
- func (e *Engine) HasQuant(name string) bool
- func (e *Engine) LoadModule(name string)
- func (e *Engine) LoadModuleArgs(name string, ins, deps, outs []string)
- func (e *Engine) NCell() int
- func (e *Engine) NewHandle() int
- func (e *Engine) OutputID() int
- func (e *Engine) PaddedSize() []int
- func (e *Engine) Periodic() []int
- func (e *Engine) Quant(name string) *Quant
- func (e *Engine) RecoverState(out, in string)
- func (e *Engine) Relative(filename string) string
- func (e *Engine) RemoveHandle(handle int)
- func (e *Engine) Run(duration float64)
- func (e *Engine) SaveAs(q *Quant, format string, options []string, filename string)
- func (e *Engine) SaveAsAppend(q *Quant, format string, options []string, filename string)
- func (e *Engine) SaveState(out, in string)
- func (e *Engine) SetCellSize(size []float64)
- func (e *Engine) SetGridSize(size3D []int)
- func (e *Engine) SetOutputDirectory(dir string)
- func (e *Engine) SetPeriodic(p []int)
- func (e *Engine) SetSolver(s Solver)
- func (e *Engine) Stats() string
- func (e *Engine) Step()
- func (e *Engine) Steps(N int)
- func (e *Engine) String() string
- func (e *Engine) Tabulate(quants []string, filename string)
- func (e *Engine) UpdateEqRHS()
- func (e *Engine) WorldSize() []float64
- func (e *Engine) WriteDot(out io.Writer)
- type Equation
- type EulerSolver
- type FFTUpdater
- type FormatDump
- type HeunSolver
- type Invalidator
- type MaxAbsUpdater
- type MaxNormUpdater
- type Module
- type Notifier
- type OutputFormat
- type PeakUpdater
- type PointwiseOfUpdater
- type Quant
- func (sum *Quant) Add(parent *Quant)
- func (q *Quant) Array() *gpu.Array
- func (q *Quant) Buffer(kind QuantKind) *host.Array
- func (orig *Quant) Component(comp int) *Quant
- func (q *Quant) CopyFromQuant(qin *Quant)
- func (q *Quant) FullName() string
- func (q *Quant) GetUpdater() Updater
- func (q *Quant) Invalidate()
- func (q *Quant) IsSpaceDependent() bool
- func (q *Quant) Kind() QuantKind
- func (q *Quant) Multiplier() []float64
- func (q *Quant) NComp() int
- func (q *Quant) Name() string
- func (q *Quant) Scalar() float64
- func (q *Quant) SetComponent(comp int, val float64)
- func (q *Quant) SetField(field *host.Array)
- func (q *Quant) SetMask(field *host.Array)
- func (q *Quant) SetScalar(val float64)
- func (q *Quant) SetUpToDate(status bool)
- func (q *Quant) SetUpdater(u Updater)
- func (q *Quant) SetValue(val []float64)
- func (q *Quant) SetVerifier(f func(*Quant))
- func (q *Quant) Size3D() []int
- func (q *Quant) String() string
- func (q *Quant) Unit() Unit
- func (q *Quant) Update()
- func (q *Quant) Updater() Updater
- func (q *Quant) Verify()
- type QuantKind
- type RK12Solver
- type ReduceUpdater
- type SDotUpdater
- type Solver
- type SumNode
- type SumReduceUpdater
- type SumUpdater
- type Table
- type Unit
- type Updater
- func NewAverageUpdater(in, out *Quant) Updater
- func NewMaxAbsUpdater(in, out *Quant) Updater
- func NewMaxNormUpdater(in, out *Quant) Updater
- func NewPeakUpdater(input, peak *Quant) Updater
- func NewSDotUpdater(sum, parent1, parent2 *Quant, scaling float64) Updater
- func NewSumReduceUpdater(in, out *Quant) Updater
- func NewSumUpdater(sum *Quant) Updater
- type ΔUpdater
Constants ¶
const ( FINE_T = 100 // subdivision of time interval in dispersion calculation B_EXT = 1e-4 // the amplitude of excitation used in dispersion calculation OUT_FORMAT = "dump" N_TC = 24 )
const ( EQN_INVALID = iota // not used EQN_PDE1 // dy/dt=f(y,t) )
const ( SCALAR = 1 // Number VECTOR = 3 // Vector SYMMTENS = 6 // Symmetric tensor TENS = 9 // General tensor )
Number of components.
const ArgDelim = "="
const (
T_MAGIC = 0x0A317423 // First 32-bit word of tensor blob. Identifies the format. Little-endian ASCII for "#t1\n"
)
const UPDATE_DASH = 150 * 1e6
refresh dashboard every x nanoseconds
Variables ¶
This section is empty.
Functions ¶
func AddTermToQuant ¶
func AddTermToQuant(sumQuant, term *Quant)
func IsGoodCUFFTSize ¶
Checks if size = 2^n * {1,3,5,7}, which is very suited as CUFFT transform size.
func IsGoodGridSize ¶
func IsGoodGridSize1 ¶
Stricter than IsGoodCUFFTSize(): Should be a good CUFFT size and meet alignment requirements.
func LoadBDFAM12 ¶
func LoadBDFAM12(e *Engine)
func LoadBDFEuler ¶
func LoadBDFEuler(e *Engine)
func PadSize ¶
Add padding x 2 in all directions where periodic == 0, except when a dimension == 1 (no padding neccesary)
func ParseArgument ¶
func RegisterInputFormat ¶
func RegisterModule ¶
Registers a module in the list of known modules. Each module should register itself in its init() function.
func RegisterModuleArgs ¶
func RegisterOutputFormat ¶
func RegisterOutputFormat(format OutputFormat)
registers an output format
func Resample ¶
Returns a new host array of size size2, re-sized from the input array by nearest-neighbor interpolation.
Types ¶
type API ¶
type API struct {
Engine *Engine
}
The API methods are accessible to the end-user through scripting languages.
func (API) AddDeltaQuant ¶
func (API) Add_To ¶
Add a new quantity to the multi-physics engine, its value is added to the (existing) sumQuantity. E.g.: Add_To("H", "H_1") adds a new external field H_1 that will be added to H.
func (API) Add_To_Weighted ¶
func (API) AutoSave ¶
func (a API) AutoSave(quantity string, format string, options []string, period float64) (handle int)
Saves a space-dependent quantity periodically, every period (expressed in seconds). Output appears in the output directory with automatically generated file names. E.g., for a quantity named "m", and format "txt" the generated files will be:
m00000.txt m00001.txt m00002.txt...
See FilenameFormat() for setting the number of zeros. Returns an integer handle that can be used to manipulate the auto-save entry. E.g. remove(handle) stops auto-saving it. @see filenumberfomat
func (API) AutoTabulate ¶
Saves any number of space-independent quantities periodically, every period (expressed in seconds). The values are appended to the file. Returns an integer handle that can be used to manipulate the auto-save entry. E.g. remove(handle) stops auto-saving it.
func (API) Debug_DisableUpdate ¶
DEBUG: removes the updater of this quantity
func (API) Debug_GetArray ¶
FOR DEBUG ONLY. Gets the quantity's array, raw.
func (API) Debug_Invalidate ¶
DEBUG: manually update the quantity state
func (API) Debug_Update ¶
DEBUG: manually update the quantity state
func (API) FileNumberFormat ¶
Sets a global C-style printf format string used to generate file names for automatically saved files. The default "%06d" generates, e.g., "m000001.txt". "%d" would generate, e.g., "m1.txt".
func (API) GetArray ¶
Gets a space-dependent quantity. If the quantity uses a mask, the result is equal to GetMask() * GetValue()
func (API) GetCellSize ¶
Get the cell size. WARNING: convert to ZYX, internal units
func (API) GetGridSize ¶
Get the grid size. WARNING: convert to ZYX
func (API) GetMask ¶
Gets a space-dependent quantity. If the quantity uses a mask, the result is equal to GetMask() * GetValue()
func (API) GetPeriodic ¶
Get the periodicity WARNING: convert to ZYX, internal units
func (API) GetS ¶
Get the value of a scalar, space-independent quantity. Similar to GetValue, but returns a single number.
func (API) GetV ¶
Get the value of a space-independent or masked quantity. Returns an array with vector components or an array with just one element in case of a scalar quantity.
func (API) GetWorldSize ¶
Get the toal size, in meters, of the simulated world.
func (API) New_MaxAbs ¶
Add a new quantity to the multi-physics engine, its value is the maximum of the absolute value of inputQuantity. E.g.: New_MaxAbs("max_torque", "torque") adds a new quantity "max_torque" whose value is max(abs(torque)). For vector quantities, the maximum is taken over all components.
func (API) New_MaxNorm ¶
Add a new quantity to the multi-physics engine, its value is the maximum norm of inputQuantity (a 3-component vector). E.g.: New_MaxNorm("maxnorm_torque", "torque") adds a new quantity "maxnorm_torque" whose value is max(norm(torque)).
func (API) OutputDirectory ¶
Returns the output directory for the running simulation.
func (API) OutputID ¶
Returns the output ID corresponding to the current simulation time. All automatic output uses this number to identify the time corresponding to the saved quantity.
func (API) RecoverState ¶
func (API) Remove ¶
Removes the object with given handle. E.g.:
handle = autosave(...) remove(handle) # stops auto-saving
func (API) Run_Until_Larger ¶
Runs the simulation until quantity a > quantity b
func (API) Run_Until_Smaller ¶
Runs the simulation until quantity a < value
func (API) Save ¶
Saves a space-dependent quantity, once. Uses the specified format and gives an automatic file name (like "m000001.png"). See also: Save()
func (API) SaveAs ¶
Saves a space-dependent quantity, once. Uses the specified format and file name.
func (API) SaveGraph ¶
Saves an image file of the physics graph using the given file name. The extension determines the output format. E.g.: .png, .svg, ... A file with a .dot extension will be written as well. Rendering requires the package "graphviz" to be installed.
func (API) SetArray_File ¶
Like SetArray but reads the array from a file.
func (API) SetCellSize ¶
Set the cell size. WARNING: convert to ZYX
func (API) SetGridSize ¶
Set the grid size. WARNING: convert to ZYX
func (API) SetMask ¶
Sets a space-dependent multiplier mask for the quantity. The value of the quantity (set by SetValue), will be multiplied by the mask value in each point of space. The mask is dimensionless and typically contains values between 0 and 1.
func (API) SetMask_File ¶
Like SetMask but reads the mask from a file.
func (API) SetPeriodic ¶
Set periodic boundary conditions in each direction. A value of 0 means no periodicity in that direction (the default). A nonzero value means the system is infinitely reproduced in that direction. The magnitude of the nonzero value is a hint of how accurately the infinite character should be approached, if applicable. E.g.: for the ferromagnetic exchange interaction, any nonzero value will give the same result: perfect infinite periodicity. But for the magnetostatic interaction, the magnitude of the nonzero value may be used as a hint where to cut off the magnetic field.
func (API) SetV ¶
Set value of a quantity. The quantity must be of type VALUE or MASK. If the quantity is a MASK, the value will be multiplied by a space-dependent mask which typically contains dimensionless numbers between 0 and 1.
func (API) StartTimer ¶
DEBUG: start a timer with a given identifier tag
func (API) Sync ¶
func (a API) Sync()
Should be called at the end of each input file to make sure the input script does not terminate too early.
type AddTermUpdater ¶
type AddTermUpdater struct { SumUpdater // contains filtered or unexported fields }
func NewAddTermUpdater ¶
func NewAddTermUpdater(orig *Quant) *AddTermUpdater
func (*AddTermUpdater) Update ¶
func (u *AddTermUpdater) Update()
type Arguments ¶
type Arguments struct { InsMap map[string]string // the string-to-string map of the input quantities DepsMap map[string]string // the string-to-string map of the dependencies OutsMap map[string]string // the string-to-string map of the output quantities }
A physics module. Loading it adds various quantity nodes to the engine.
func GetParsedArgumentsMap ¶
type AutoSave ¶
type AutoSave struct {
// contains filtered or unexported fields
}
Saves a field (scalar field, vector field, etc) periodically.
type AutoTabulate ¶
type AutoTabulate struct {
// contains filtered or unexported fields
}
Saves a value (scalar field, vector field, etc) periodically.
type AverageUpdater ¶
type AverageUpdater ReduceUpdater
Updates an average quantity
func (*AverageUpdater) Update ¶
func (this *AverageUpdater) Update()
type BDFAM12 ¶
type BDFAM12 struct {
// contains filtered or unexported fields
}
The adaptive implicit method, predictor: Implicit Euler, corrector: Trapezoidal
func (*BDFAM12) Dependencies ¶
type BDFEuler ¶
type BDFEuler struct {
// contains filtered or unexported fields
}
Naive Backward Euler solver
func (*BDFEuler) Dependencies ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the heart of a multiphysics simulation. The engine stores named quantities like "m", "B", "alpha", ... An acyclic graph structure consisting of interconnected quantities determines what should be calculated and when.
func (*Engine) AddDeltaQuant ¶
func (*Engine) AddNewQuant ¶
func (e *Engine) AddNewQuant(name string, nComp int, kind QuantKind, unit Unit, desc ...string) *Quant
Constructs and adds an arbitrary quantity. (Also returns it, but it's not necessarily used further) Name tag is case-independent. TODO: refactor AddQuant(q*Quant) TODO: NewQuant should take size from global engine.
func (*Engine) AddPDE1 ¶
Add a 1st order partial differential equation:
d y / d t = diff
E.g.: ODE1("m", "torque") No direct dependency should be declared between the arguments.
func (*Engine) AddTimeDerivative ¶
Load time derivative of quant if not yet present
func (*Engine) AutoFilename ¶
Generates an automatic file name for the quantity, given the output format. E.g., "dir.out/m000007.omf" see: outputDir, filenameFormat
func (*Engine) AutoSave ¶
func (e *Engine) AutoSave(quant string, format string, options []string, period float64) (handle int)
Saves the quantity periodically.
func (*Engine) AutoTabulate ¶
See api.go
func (*Engine) Depends ¶
Mark childQuantity to depend on parentQuantity. Multiply adding the same dependency has no effect.
func (*Engine) LoadModule ¶
Low-level module load, not aware of dependencies
func (*Engine) LoadModuleArgs ¶
Low-level module load, not aware of dependencies
func (*Engine) NewHandle ¶
Returns ++_handleCount. Used to identify objects like crontabs so they can later by manipulated through this ID.
func (*Engine) OutputID ¶
Gets an ID number to identify the current time. Used to number output files. E.g. the 7 in "m000007.omf". Files with the same OutputID correspond to the same simulation time.
func (*Engine) PaddedSize ¶
Returns the grid size after zero padding
func (*Engine) RecoverState ¶
func (*Engine) Relative ¶
Resolves a file name relative to the output directory, unless the name begins with a /.
func (*Engine) RemoveHandle ¶
Looks for an object with the handle number and removes it. Currently only looks in the crontabs.
func (*Engine) SaveAsAppend ¶
Append the quantity once in the specified format and file name
func (*Engine) SetOutputDirectory ¶
INTERNAL: Used by frontend to set the output dir
func (*Engine) SetPeriodic ¶
Sets the periodicity in each dimension
func (*Engine) Step ¶
func (e *Engine) Step()
Takes one time step. It is the solver's responsibility to Update/Invalidate its dependencies as needed.
func (*Engine) UpdateEqRHS ¶
func (e *Engine) UpdateEqRHS()
type Equation ¶
type Equation struct {
// contains filtered or unexported fields
}
Type representing a differential equation
type EulerSolver ¶
type EulerSolver struct { }
Euler solver
func (*EulerSolver) Dependencies ¶
func (s *EulerSolver) Dependencies() (children, parents []string)
func (*EulerSolver) Step ¶
func (s *EulerSolver) Step()
type FFTUpdater ¶
type FFTUpdater struct {
// contains filtered or unexported fields
}
Update FFT of quantity
func NewFFTUpdater ¶
func NewFFTUpdater(qin, qout *Quant) *FFTUpdater
func (*FFTUpdater) Update ¶
func (u *FFTUpdater) Update()
type FormatDump ¶
type FormatDump struct{}
func (*FormatDump) Name ¶
func (f *FormatDump) Name() string
type HeunSolver ¶
type HeunSolver struct {
// contains filtered or unexported fields
}
func NewHeun ¶
func NewHeun(e *Engine) *HeunSolver
func (*HeunSolver) Step ¶
func (s *HeunSolver) Step()
type Invalidator ¶
type Invalidator interface {
Invalidate()
}
Invalidate() is called after each invalidation of a Quant.
type MaxAbsUpdater ¶
type MaxAbsUpdater ReduceUpdater
Updates a maximum of absolute values
func (*MaxAbsUpdater) Update ¶
func (this *MaxAbsUpdater) Update()
type MaxNormUpdater ¶
type MaxNormUpdater ReduceUpdater
Updates the maximum norm of a 3-vector array
func (*MaxNormUpdater) Update ¶
func (this *MaxNormUpdater) Update()
type Module ¶
type Module struct { Name string // Name to identify to module to the machine Description string // Human-readable description of what the module does Args Arguments // The map of arguments and their default values LoadFunc func(e *Engine, args ...Arguments) // Loads this module's quantities and dependencies into the engine }
type Notifier ¶
type Notifier interface {
Notify(e *Engine) // Notifies the crontab that a step has been taken, so it can take action if needed
}
type OutputFormat ¶
type OutputFormat interface { Name() string // Name to register the format under. E.g. "txt". Also used as file extension Write(out io.Writer, q *Quant, options []string) // Writes the quantity buffer to out }
A general output format for space-dependent quantities.
func GetOutputFormat ¶
func GetOutputFormat(name string) OutputFormat
Retrieves an output format from its name. E.g. "txt", "omf"
type PeakUpdater ¶
type PeakUpdater struct {
// contains filtered or unexported fields
}
func (*PeakUpdater) Update ¶
func (u *PeakUpdater) Update()
type PointwiseOfUpdater ¶
type PointwiseOfUpdater struct {
// contains filtered or unexported fields
}
Updates a quantity according to a point-wise defined function of argument.
func (*PointwiseOfUpdater) AppendMap ¶
func (p *PointwiseOfUpdater) AppendMap(x []float64, y [][]float64)
func (*PointwiseOfUpdater) Update ¶
func (field *PointwiseOfUpdater) Update()
type Quant ¶
type Quant struct {
// contains filtered or unexported fields
}
A quantity represents a scalar/vector/tensor field,value or mask.
* By "value" we mean a single, space-independent scalar,vector or tensor. * By "field" we mean a space-dependent field of scalars, vectors or tensors. * By "mask" we mean the point-wise multiplication of a field by a value.
Typically a mask represents A(r) * f(t), a pointwise multiplication of an N-vector function of space A(r) by an N-vector function of time f(t). A(r) is an array, f(t) is the multiplier which will be updated every time step. When a mask's array contains NULL pointers for each gpu, the mask is independent of space. The array is then interpreted as 1(r), the unit field. In this way, masks that happen to be constant values in space (homogeneous) can be efficiently represented. TODO: deduplicate identical mask arrays by setting identical pointers?
Quantities are the nodes of an acyclic graph representing the differential equation to be solved.
func NewQuant ¶
func NewQuant(name string, nComp int, size3D []int, kind QuantKind, unit Unit, cpuOnly bool, desc ...string) *Quant
Returns a new quantity. See Quant.init(). TODO: make desc obligatory
func (*Quant) Buffer ¶
Transfers the quantity from GPU to host. The quantities host buffer is allocated when needed. The transfer is only done when needed, i.e., when bufferUpToDate == false. Multiplies by the multiplier and handles masks correctly. Does not Update().
func (*Quant) Component ¶
Quantity representing a single component of the original, with shared underlying storage. The returned Quant's name and dependencies still have to be set.
func (*Quant) CopyFromQuant ¶
func (*Quant) Invalidate ¶
func (q *Quant) Invalidate()
Opposite of Update. Sets upToDate flag of this node and all its children (which depend on this node) to false.
func (*Quant) IsSpaceDependent ¶
True if the quantity varies in space.
func (*Quant) Multiplier ¶
func (*Quant) SetComponent ¶
Sets one component of a VALUE quantity.
func (*Quant) SetUpToDate ¶
func (*Quant) SetVerifier ¶
Sets a verifier func, called each time the user attempts to set the quantity.
type QuantKind ¶
type QuantKind int
Kind of quantity: VALUE, FIELD or MASK
const ( VALUE QuantKind = 1 << (1 + iota) // A value is constant in space. Has a multiplier (to store the value) but a nil *array. FIELD // A field is space-dependent. Has no multiplier but allocated array. MASK // A mask is a point-wise multiplication of a field with a value. Has an array (possibly with NULL parts) and a multiplier. )
type RK12Solver ¶
type RK12Solver struct {
// contains filtered or unexported fields
}
func (*RK12Solver) Dependencies ¶
func (s *RK12Solver) Dependencies() (children, parents []string)
Declares this solver's special dependencies
type ReduceUpdater ¶
type ReduceUpdater struct {
// contains filtered or unexported fields
}
Superclass for all reduce updaters.
func NewReduceUpdater ¶
func NewReduceUpdater(in, out *Quant) *ReduceUpdater
New reducing updater. Automatically sets the dependency in -> out.
type SDotUpdater ¶
type SDotUpdater struct {
// contains filtered or unexported fields
}
func (*SDotUpdater) Update ¶
func (u *SDotUpdater) Update()
type Solver ¶
type Solver interface { Step() // Takes one time step Dependencies() (children, parents []string) // Reports dependencies apart from the normal input/output. E.g.: time, dt,maxerror }
type SumReduceUpdater ¶
type SumReduceUpdater ReduceUpdater
Updates an average quantity
func (*SumReduceUpdater) Update ¶
func (this *SumReduceUpdater) Update()
type SumUpdater ¶
type SumUpdater struct {
// contains filtered or unexported fields
}
func (*SumUpdater) AddParent ¶
func (u *SumUpdater) AddParent(name string)
Add parent with weight 1.
func (*SumUpdater) MAddParent ¶
func (u *SumUpdater) MAddParent(name string, weight float64)
Adds a parent to the sum, i.e., its value*weight will be added to the sum
func (*SumUpdater) Update ¶
func (u *SumUpdater) Update()
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table refers to an open data table to which space-independent output is appended during the simulation.
type Updater ¶
type Updater interface {
Update()
}
Update() is called to update the value of a Quant.
func NewAverageUpdater ¶
Returns an updater that writes the average of in to out
func NewMaxAbsUpdater ¶
Returns an updater that writes the maximum of absolute values of in to out
func NewMaxNormUpdater ¶
Returns an updater that writes the maximum of absolute values of in to out
func NewPeakUpdater ¶
func NewSDotUpdater ¶
takes dot product
func NewSumReduceUpdater ¶
Returns an updater that writes the average of in to out
func NewSumUpdater ¶
Source Files ¶
- api.go
- arraypool.go
- doc.go
- engine.go
- engine_graphviz.go
- equation.go
- field.go
- format_dump.go
- gridsize.go
- input.go
- inputformat_dump.go
- inputformat_png.go
- module.go
- notifier.go
- notify_autosave.go
- notify_tabulate.go
- outputformat.go
- quant.go
- quantkind.go
- resample.go
- solve_am01.go
- solve_euler.go
- solve_euler_backward.go
- solve_heun.go
- solve_rk12.go
- solver.go
- sumnode.go
- table.go
- tensoroutput.go
- texgen.go
- timederivative.go
- unit.go
- update_addterm.go
- update_delta.go
- update_fft.go
- update_peak.go
- update_pointwiseof.go
- update_reduce.go
- update_sdot.go
- update_sum.go
- updater.go
- verify.go
- zeropad.go