- userFuncScalarUpdater
userFuncScalarUpdater¶
Works with VSimBase, VSimEM, VSimPD, VSimPA, and VSimVE licenses.
Sets scalar values to the result of a user-given function.
The Updater of kind = userFuncScalarUpdater
is a very
flexible updater on scalars based on the result of a user-given
<Expression> (see expression). The expression takes as
arguments scalars values, as well as time and time step. This
updater is basically the scalar version of the field updater
userFuncUpdater. See it for more details about
possible applications.
userFuncScalarUpdater Parameters¶
The userFuncScalarUpdater takes the following parameters:
- readScalars (optional string vector, default = [])
The names of the scalars to read. A read scalar name can be used as a variable in the definition of
updateFunction
.
- writeScalars (required string vector)
The names of the scalars to write.
- updateFunction (required parameter block)
A parameter block of type Expression and name
updateFunction
is required to define the function used to update the scalars. This block takes the same parameters as a expression UserFunc, except forinput
blocks and theinputOrder
parameter. The input variables for theexpression
are defined by the above parameters, so they are not to be specified in theupdateFunction
block. In addition, the expression can take the following input valiables:t: The time to which the updater been told to update its writeFields; c.f. toDtFrac in a MultiField UpdateStep).
dt: The most recent time step (\(\Delta t\)).
n: The current simulation step (an integer).
(These names are reserved—they cannot be used as scalar names.)
The Expression must return a vector with the same length as the number of writeScalars—each write scalar value will be set to the corresponding component of the return vector.
userFuncScalarUpdater Example¶
Here is a userFuncUpdater to set two scalars A4 and A5
<Updater userfuncUp>
kind = userFuncScalarUpdater
readScalars = [A1 A2 A3]
writeScalars = [A4 A5]
<Expression updateFunction>
expression = vector(A1 + 3.0*A2 + A3/5.0 + t + n/10 + 2.0*dt, n)
</Expression>
</Updater>