Wiki
Clone wikiSimflowny / Simml_macros
SimML: macro tags
- auxiliaryEquations
- fieldFromAuxiliaryEquations
- boundary
- checkFinalization
- functionCall
- flux
- sharedVariable
- sources
- diagonalize
- undiagonalize
- maxCharSpeed & positiveCharSpeed & negativeCharSpeed
- maxCharSpeedCoordinate & positiveCharSpeedCoordinate & negativeCharSpeedCoordinate
- currentCell
- incrementCoordinate & decrementCoordinate
- incrementCoordinate2 & decrementCoordinate2
- incrementCoordinate1incrementCoordinate2 & incrementCoordinate1decrementCoordinate2 & decrementCoordinate1incrementCoordinate2 & decrementCoordinate1decrementCoordinate2
- sign
- particleVolume
- readFromFileQuintic
- readFromFileLinear1D & readFromFileLinear2D & readFromFileLinear3D
- readFromFileLinearWithDerivatives1D & readFromFileLinearWithDerivatives2D & readFromFileLinearWithDerivatives3D
- findCoordFromFile1D & findCoordFromFile2D & findCoordFromFile3D
Tag | PDE | Infix |
---|---|---|
auxiliaryEquations | X | |
fieldFromAuxiliaryEquations | X | |
boundary | X | |
checkFinalization | X | |
functionCall | X | $fc |
flux | X | $flx |
sharedVariable | X | $sv |
sources | X | $src |
diagonalize | X | |
undiagonalize | X | |
maxCharSpeed | X | $mcs |
positiveCharSpeed | X | $pcs |
negativeCharSpeed | X | $ncs |
maxCharSpeedCoordinate | X | $mcsc |
positiveCharSpeedCoordinate | X | $pcsc |
negativeCharSpeedCoordinate | X | $ncsc |
currentCell | X | $cc |
incrementCoordinate | X | $ic_X |
decrementCoordinate | X | $dc_X |
incrementCoordinate2 | X | $ic2_X |
decrementCoordinate2 | X | $dc2_X |
incrementCoordinate1incrementCoordinate2 | X | $icic_X_X |
incrementCoordinate1decrementCoordinate2 | X | $icdc_X_X |
decrementCoordinate1incrementCoordinate2 | X | $dcic_X_X |
decrementCoordinate1decrementCoordinate2 | X | $dcdc_X_X |
sign | X | $sign |
particleVolume | X | $pv |
readFromFileQuintic | X | $rffq |
readFromFileLinear1D | X | $rffl1d |
readFromFileLinear2D | X | $rffl2d |
readFromFileLinear3D | X | $rffl3d |
readFromFileLinearWithDerivatives1D | X | $rfflwd1d |
readFromFileLinearWithDerivatives2D | X | $rfflwd2d |
readFromFileLinearWithDerivatives3D | X | $rfflwd3d |
findCoordFromFile1D | X | $fcff1d |
findCoordFromFile2D | X | $fcff2d |
findCoordFromFile3D | X | $fcff3d |
auxiliaryEquations
Tag used to deploy the model auxiliary equations taking the content of the tag as a variable wildcard.
Scope
Discretization schema
Usage
The content of the tag is the variable in which the auxiliary equations will be based.
Example
![images/UserGuide/simml/auxiliaryEquations.png](images/UserGuide/simml/auxiliaryEquations.png)
In this case, the auxiliary equations will use a specific shared variable.
fieldFromAuxiliaryEquations
Tag used to deploy the model conversion from auxiliary equations to fields taking the content of the tag as a variable wildcard.
Scope
Discretization schema
Usage
The content of the tag is the variable in which the conversion be based.
Example
![images/UserGuide/simml/fieldFromAuxiliaryEquations.png](images/UserGuide/simml/fieldFromAuxiliaryEquations.png)
boundary
Tag used to deploy the boundary conditions depending on the parameters and problem definition.
Scope
Discretization schema
Usage
The typeAtt attribute indicates when the boundaries should be calculated with fluxes or fields. The two possible values are flux and field. This tag is optional, the default value is field.
The variable tag defines the variable in which the boundaries will be based.
The previousVariable is used to calculate some type of boundary conditions which requires the usage of the previous state of the variable.
The stencil tag specifies the width of the boundary in terms of cells.
Example
![images/UserGuide/simml/boundary.png](images/UserGuide/simml/boundary.png)
checkFinalization
Tag used to check the finalization condition during the simulation at a specific location. This will generate a conditional clause with the finalization condition.
Note: Simulations checks the finalization by default at the end of a time step. Using this instruction allows the user to create a discretization schema which checks during the execution of time steps.
Scope
Discretization schemas.
Usage
The content of the tag is the variable in which the conditions variables will be based.
Example
![images/UserGuide/simml/checkFinalization.png](images/UserGuide/simml/checkFinalization.png)
In this example, the simulation will stop if the previous step of any field is greater than half of the two previous step of the same field.
flux
This instruction is used to call the flux functions from the PDEs.
Scope
Discretization schema (Inside math tags).
Infix
$flx
Usage
Fluxes are one of the components in which Simflowny decompose PDEs. When discretizing a problem, at a certain point, one want to get the flux information from the equations. For instance, to calculate centered differences one get the flux of the previous cell and subtract it to the flux of the next cell. In order to allow this calculations, the fluxes should be called within mathematical expressions.
Furthermore, fluxes can be expressions with different degrees of complexity. So, it is simpler to treat the fluxes as function calls. For instance:
![images/UserGuide/simml/fluxes_example.png](images/UserGuide/simml/fluxes_example.png)
One may call to the Flux \(F_x\), which uses the fields P, mx, my and ρ, but instead of using the fields directly, using a derivated fields P', mx', my' and ρ'. When writing a discretization schema, the writer does not know the quantity of fields needed by the flux, so instead of passing all of them as the arguments of the call, a base variable is used. Following the example,
![images/UserGuide/simml/flux_prime.png](images/UserGuide/simml/flux_prime.png)
Where u is a wildcard for any field.
As a consequence, the usage within a mathematical expression is like $flx(F$i$f, variable)
, where variable can be any variable and F$i$f is the way Simflowny identifies the flux function name.
Example
![images/UserGuide/simml/fluxes.png](images/UserGuide/simml/fluxes.png)
Flux_$i$f($cc)
represents a group of variables called Flux with subindices representing all the combinations of spatial coordinates and fields. The $cc meaning currentCell indicates that the variable is asigned in the current cell. For instance, it could represents \(Flux_x\rho (i,j)\).
The left hand side of the equation represents a flux call ($flx(...)
). The first parameter is the flux function name. The second one is the a variable to use inside the flux to represent the fields. For instance, it could represents \(\rho _eps(i,j)\).
sharedVariable
Shared variables are variables that are common for all the regions within the simulation. So a change on the value from one region can be seen by another region. The common use is to set final substep fields as shared (rk1, rk2 variables in RK3 schemas, for instance).
Notice that a regular non shared variable is only visible to the region it belongs. Only fields and auxiliary fields are shared variables by default.
Scope
Discretization schema (Inside math tags).
Infix
$sv
Usage
The $sv directive wrapping a variable indicates that the variable is considered as shared variable.
Example
![images/UserGuide/simml/sharedVariable.png](images/UserGuide/simml/sharedVariable.png)
The variable k1$f($cc)
is considered a shared variable since it is inside the $sv directive.
functionCall
This tag is used to make a call to an imported function in a discretization schema.
Scope
Discretization schema (Inside math tags).
Infix
$fc
Usage
The $fc directive encloses the function name to call and all its parameters.
Example
![images/UserGuide/simml/functionCall.png](images/UserGuide/simml/functionCall.png)
This instruction will call a function with name weno and passes six more variables, defined previously.
sources
Tag used within a mathematical expression to get the PDE source using the content of the tag as a base variable.
Scope
Discretization schema (Inside math tags).
Infix
$src
Usage
The $src directive needs a variable to be used as a reference for the source's field replacements.
Example
![images/UserGuide/simml/sources.png](images/UserGuide/simml/sources.png)
The variable Sources_$f
will store the sources for every field with the values for the field variable at the current time step. For example, if the sources of the current PDE are \(S^{(Bx)} = \left(-a\right)\mbox{ }{Bx}\), then the instruction would be \(Sources_Bx = \left(-a\right)\mbox{ }{Bx^n}\).
diagonalize
Tag used for diagonalization purposes. Uses the diagonalization defined in the model using the eigen vectors.
Scope
Discretization schema.
Usage
During the definition of the Characteristic Decomposition, in the model definiton, the user is required to introduce the coefficients of the (un)diagonalization expressions; this is, eigenvectors written as a linear combination of the evolution fields (or viceversa). Now here, the DSL can take advantage of this fact and use a different variable for the coefficients than for fields and eigenvectors. In particular: the variable parameter is the variable to be used for the fields of the diagonalization, as well as for the resulting eigenvector; the timeSlice parameter is the variable to be used for the fields in the coefficients of the linear combination.
Example
![images/UserGuide/simml/diagonalize.png](images/UserGuide/simml/diagonalize.png)
undiagonalize
Tag used for diagonalization purposes. Undiagonalizes using the eigen vector undiagonalization information.
Scope
Discretization schema.
Usage
The variable parameter is the variable to be used for the eigenvectors of the undiagonalization, as well as for the resulting fields. The timeSlice parameter is the variable or timeSlice to be used for the fields in the coefficients of the linear combination.
Example
![images/UserGuide/simml/undiagonalize.png](images/UserGuide/simml/undiagonalize.png)
maxCharSpeed & positiveCharSpeed & negativeCharSpeed
Tag used to introduce the maximum, positive or negatve characteristic speed inside a mathematical expression.
Scope
Discretization schema (Inside math tags).
Infix
$mcs, $pcs, $ncs
Usage
The $mcs, $pcs and $ncs directives need a variable to be used as a reference for the speed's field replacements.
Example
![images/UserGuide/simml/maxCharSpeed.png](images/UserGuide/simml/maxCharSpeed.png)
If the characteristic speeds would be \(c \ast u\), \(-c \ast u\) and \(0\), it would generate \(Speed(i) = max(c \ast u^n(i), -c \ast u^n(i), 0)\).
maxCharSpeedCoordinate & positiveCharSpeedCoordinate & negativeCharSpeedCoordinate
Tag used to introduce the maximum, positive or negative characteristic speed inside a mathematical expression differentiated by the spatial coordinates.
Scope
Discretization schema (Inside math tags).
Infix
$mcsc, $pcsc, $ncsc
Usage
The $mcsc, $pcsc, $ncsc directives need a variable to be used as a reference for the speed's field replacements.
Example
![images/UserGuide/simml/maxCharSpeedCoordinate.png](images/UserGuide/simml/maxCharSpeedCoordinate.png)
Imagine there are two spatial coordinates (x and y) with \(x + u\) as the speed in x, and \(y + u\) and \(y - u\) as speeds in y, being u a field. Then, the instructions generated would be \(Speedx(i) = x + u^n(i)\) and \(Speedy(i) = max(y + u^n(i), y - u^n(i))\).
currentCell
Tag used within mathematical expressions to identify the current cell index for the variables stored in the mesh.
Scope
Discretization schema (Inside math tags).
Infix
$cc
Usage
No parameters are needed.
Example
![images/UserGuide/simml/currentCell.png](images/UserGuide/simml/currentCell.png)
The previous picture shows an example of the currentCell usage. This mathematical expression represents a Forward Difference function, where the value would be the difference between the value for the variable in the next cell and the current one.
incrementCoordinate & decrementCoordinate
Tags used within a mathematical expression to access neighbour cells.
Scope
Discretization schema (Inside math tags).
Infix
$ic $dc
Usage
This tag requires the number of cells to increment or decrement from the current one. The parameter have to be added as sufix to the infix notation.
Example
![images/UserGuide/simml/incrementCoordinate.png](images/UserGuide/simml/incrementCoordinate.png)
The capture above shows the code for the centered differences function. The flux variable from the previous cell is subtracted to the value of the next cell (and divided by twice times delta x).
incrementCoordinate2 & decrementCoordinate2
Tags used within a parabolicTermsContext tag inside a mathematical expression to access neighbour cells for the second spatial coordinate.
Scope
Discretization schema (Inside math tags). The math element including one of these tags must be within a parabolicTermsContext tag.
Infix
$ic2 $dc2
Usage
This tag requires the number of cells to increment or decrement from the current one. The parameter have to be added as sufix to the infix notation.
Example
![images/UserGuide/simml/incrementCoordinate2.png](images/UserGuide/simml/incrementCoordinate2.png)
incrementCoordinate1incrementCoordinate2 & incrementCoordinate1decrementCoordinate2 & decrementCoordinate1incrementCoordinate2 & decrementCoordinate1decrementCoordinate2
Tags used to access neighbour cells for the first and the second spatial coordinate at the same time.
Scope
Discretization schema (Inside math tags).
Infix
$icic $icdc $dcic $dcdc
Usage
This tag requires the number of cells (for the first and second coordinate) to increment or decrement from the current cell.
The parameters have to be added as sufixes to the infix notation.
If the first and second coordinate are the same for the current parabilc term combination, the first one is applied and the second one ignored.
Example
![images/UserGuide/simml/icic.png](images/UserGuide/simml/icic.png)
The image shows how theses tags are used to access indices for a crossed derivative.
sign
Tag to calculate sign of a variable.
Scope
Simml code (Inside math tags).
Infix
$sign
Usage
The $sign directive needs a variable to get sign from.
Example
![images/UserGuide/simml/sign.png](images/UserGuide/simml/sign.png)
The sign of p_a - p_b will be calculated.
particleVolume
Calculates the particle volume using the given variable wildcard.
Scope
Discretization schema (Inside math tags).
Infix
$pv
Usage
The $pv directive needs a variable to be used as a reference for the volume field replacements.
Example
![images/UserGuide/simml/particleVolume.png](images/UserGuide/simml/particleVolume.png)
The particle volume is calculated for the neighbour particle ($np).
readFromFileQuintic
Tag used to interpolate (with quintic order) values from an external HDF5 table. Table format should be as follows: * Could have any dimensionality in coordinates (i.e 1D, 2D or 3D coordinates) * The coordinate values must be in a separate dataset called coordX, being X the number of the coordinate. Numbering must be correlative beginning from 0. * There must be a dataset called nvars with the total number of fields with data (excluding coordinates). * Every field must be in a separate dataset called varX, being X the number of the field. Numbering must be correlative beginning from 0. The size of the fields must match dimensionality. For instance in a 2D with first dimension having 400 values and second dimension having 250 values, every field must have 400x250 values in a 2D dataset.
Scope
Any section (Inside math tags).
Infix
$rffq
Usage
The number of parameters are variable, depending on the number of coordinates and variables to get, readFromFileQuintic(FileName, NCoords, NVars, CoordInputValue1, ..., OutputVar1, ..., VarIndex1, ...):
- FileName: name of the file to read from (without the .h5 extension).
- NCoords: number of coordinates in file.
- NVars: number of fields to read.
- CoordInputValues (Multiple): values for each coordinate to get position for interpolation of values (number of arguments must be NCoords).
- OutputVars (Multiple): variables to write output into (number of arguments must be NVars).
- VarIndices (Multiple): indices of the field datasets whose interpolations will be written into OutputVars (number of arguments must be NVars).
They can be used independent from the dimensionality of the problem. For instance, readFromFile1D can be used in a 3D problem. In that way, a user could map a radial initial condition from a 3D problem, calculating the corresponding radius of a cell and passing it to the function.
readFromFileLinear1D & readFromFileLinear2D & readFromFileLinear3D
Tag used to interpolate (with linear order) values from an external HDF5 table. Table format should be as follows: * Could have any dimensionality in coordinates (i.e 1D, 2D or 3D coordinates) * The coordinate values must be in a separate dataset called coordX, being X the number of the coordinate. Numbering must be correlative beginning from 0. * There must be a dataset called nvars with the total number of fields with data (excluding coordinates). * Every field must be in a separate dataset called varX, being X the number of the field. Numbering must be correlative beginning from 0. The size of the fields must match dimensionality. For instance in a 2D with first dimension having 400 values and second dimension having 250 values, every field must have 400x250 values in a 2D dataset.
Scope
Any section (Inside math tags).
Infix
$rffl1d, $rffl2d or $rffl3d
Usage
The number of parameters are variable, depending on the number of coordinates and variables to get, readFromFileLinear(X)D(FileName, NCoords, NVars, CoordInputValue1, ..., OutputVar1, ..., VarIndex1, ...):
- FileName: name of the file to read from (without the .h5 extension).
- NCoords: number of coordinates in file.
- NVars: number of fields to read.
- CoordInputValues (Multiple): values for each coordinate to get position for interpolation of values (number of arguments must be NCoords).
- OutputVars (Multiple): variables to write output into (number of arguments must be NVars).
- VarIndices (Multiple): indices of the field datasets whose interpolations will be written into OutputVars (number of arguments must be NVars).
They can be used independent from the dimensionality of the problem. For instance, readFromFile1D can be used in a 3D problem. In that way, a user could map a radial initial condition from a 3D problem, calculating the corresponding radius of a cell and passing it to the function.
readFromFileLinearWithDerivatives1D & readFromFileLinearWithDerivatives2D & readFromFileLinearWithDerivatives3D
Tag used to interpolate (with linear order) values from an external HDF5 table. It also calculates derivatives of coordinates for all required fields. Table format should be as follows: * Could have any dimensionality in coordinates (i.e 1D, 2D or 3D coordinates) * The coordinate values must be in a separate dataset called coordX, being X the number of the coordinate. Numbering must be correlative beginning from 0. * There must be a dataset called nvars with the total number of fields with data (excluding coordinates). * Every field must be in a separate dataset called varX, being X the number of the field. Numbering must be correlative beginning from 0. The size of the fields must match dimensionality. For instance in a 2D with first dimension having 400 values and second dimension having 250 values, every field must have 400x250 values in a 2D dataset.
Scope
Any section (Inside math tags).
Infix
$rfflwd1d, $rfflwd2d or $rfflwd3d
Usage
The number of parameters are variable, depending on the number of coordinates and variables to get, readFromFileLinearWithDerivatives(X)D(FileName, NCoords, NVars, CoordInputValue1, ..., OutputVar1, ..., VarIndex1, ...):
- FileName: name of the file to read from (without the .h5 extension).
- NCoords: number of coordinates in file.
- NVars: number of fields to read.
- CoordInputValues (Multiple): values for each coordinate to get position for interpolation of values (number of arguments must be NCoords).
- OutputVars (Multiple): variables to write output into (number of arguments must be NVars).
- VarIndices (Multiple): indices of the field datasets whose interpolations will be written into OutputVars (number of arguments must be NVars).
- Derivatives (Multiple): variables to write derivatives. Order: der_coord0_var0, der_coord1_var0, ..., der_coord0_var1, der_coord1_var1, ...
They can be used independent from the dimensionality of the problem. For instance, readFromFileLinearWithDerivatives1D can be used in a 3D problem. In that way, a user could map a radial initial condition from a 3D problem, calculating the corresponding radius of a cell and passing it to the function.
findCoordFromFile1D & findCoordFromFile2D & findCoordFromFile3D
Given a value and some coordinates, the function calculates the value for the unknown coordinate that fits better from an external HDF5 table. Table format should be as follows: * Could have any dimensionality in coordinates (i.e 1D, 2D or 3D coordinates) * The coordinate values must be in a separate dataset called coordX, being X the number of the coordinate. Numbering must be correlative beginning from 0. * There must be a dataset called nvars with the total number of fields with data (excluding coordinates). * Every field must be in a separate dataset called varX, being X the number of the field. Numbering must be correlative beginning from 0. The size of the fields must match dimensionality. For instance in a 2D with first dimension having 400 values and second dimension having 250 values, every field must have 400x250 values in a 2D dataset.
Scope
Any section (Inside math tags). It also can be used in initial conditions or finalization conditions.
Infix
$fcff
Usage
The number of parameters are variable, depending on the number of coordinates and variables to get, findCoordFromFile(X)D(FileName, NCoords, NVars, OutputCoordIndex, CoordInputValues, ..., Var, VarIndex):
- FileName: name of the file to read from (without the .h5 extension).
- NCoords: number of coordinates in file.
- NVars: number of fields to read.
- OutputCoordIndex: index of the coordinate to return.
- CoordInputValues (Multiple): values for each coordinate to get position including an initial guess of the coordinate to obtain (number of arguments must be NCoords).
- Var: known value of the field.
- VarIndex: index of the given field.
Go to Simml reference.
Go to Simml context tags.
Go to Simml control tags.
Go to Simml data type tags.
Updated