When performing preparatory operations for e.g. CFD or FEM analyses, it is often necessary to specify vector parameters. Vector constants are easy to handle:

1 2 3 | DIR="1 0 0" myMesh --direction "$DIR" |

However, it quickly becomes complicated if the vectors have to be manipulated, e.g. multiplied by scalars or rotated.

A powerful solution is to use the Matlab Octave clone to perform the operations. Two features of octave are useful in this context:

- the command line option “–eval” to specify the expression to handle
- the function “disp” to output the results in plain format in a single line

An example:

1 2 3 4 5 | DIR="1 0 0" VELOCITY=$(octave --eval "disp( 11.*[$DIR] )") myMesh --direction "$DIR" mySolver --velocity "$VELOCITY" |

More complicated operation are possible. Though one needs to take care to produce line vectors as results. Rotation as an example:

1 2 3 4 5 6 | DIR="1 0 0" ANG=45 DIR_ROT=$(octave --eval "pkg load linear-algebra; disp( (rotv([0 0 1], $ANG*pi/180)*[$DIR]')' )") myMesh --direction "$DIR_ROT" |