The FMUFunction class should not exist. Only the FMUPointToFieldFunction class needs to exist. This is because, provided we can access to the whole trajectory of the output depending on the time, then we can always access the last value of the time series. To do this, the user can implement a new FinalValueFMUFunction an OpenTURNSPythonFunction which takes the FMUPointToFieldFunction model as input:
model = otfmi.FMUPointToFieldFunction()
fmuFunction = FinalValueFMUFunction(model)
In the exec() method, we evaluate the underlying function, then extracts the last value of the time series and returns it.
We could, however, make this much easier if a new ot.VertexFunction class is created in OpenTURNS. This function would have the constructor:
function = ot.VertexFunction(pointToFieldFunction, indices)
where pointToFieldFunction is a PointToFieldFunction and indices is:
either a single int if the output dimension of the Field is greater or equal to 1,
or a list of several integers if the output dimension of the Field is equal to 1.
These indices must be in the integer interval $[0, n - 1]$ where $n$ is the number of vertices. This new VertexFunction would return the value of the output Field corresponding to the indices at the vertices corresponding to the given indices.
To make things clearer, I consider the SIR epidemiological model as an example. This is a PointToField function with input dimension 2 corresponding to $\beta$ and $\gamma$ and output the Field corresponding to the time series.
Example 1. Suppose the model only returns the output $S$, i.e. the output Field has dimension equal to 1. Then indices can be a list of arbitrary indices in the integer $[0, n-1]$ where $n$ is the number of time steps. Then the function returns the value of $S$ at the given time points.
Example 2. Suppose the model returns the 3 outputs $S$, $I$ and $R$, i.e. the output Field has dimension equal to 3. Then indices can be a single integer. Then the function returns the value of the vector $(S, I, R)$ at that particular time point. If indices = -1, this corresponds to the last time value.
The
FMUFunction
class should not exist. Only theFMUPointToFieldFunction
class needs to exist. This is because, provided we can access to the whole trajectory of the output depending on the time, then we can always access the last value of the time series. To do this, the user can implement a newFinalValueFMUFunction
anOpenTURNSPythonFunction
which takes theFMUPointToFieldFunction
model as input:In the
exec()
method, we evaluate the underlying function, then extracts the last value of the time series and returns it.We could, however, make this much easier if a new
ot.VertexFunction
class is created in OpenTURNS. This function would have the constructor:where
pointToFieldFunction
is aPointToFieldFunction
andindices
is:int
if the output dimension of the Field is greater or equal to 1,These indices must be in the integer interval $[0, n - 1]$ where $n$ is the number of vertices. This new
VertexFunction
would return the value of the outputField
corresponding to the indices at the vertices corresponding to the given indices.To make things clearer, I consider the SIR epidemiological model as an example. This is a
PointToField
function with input dimension 2 corresponding to $\beta$ and $\gamma$ and output theField
corresponding to the time series.Field
has dimension equal to 1. Thenindices
can be a list of arbitrary indices in the integer $[0, n-1]$ where $n$ is the number of time steps. Then the function returns the value of $S$ at the given time points.Field
has dimension equal to 3. Thenindices
can be a single integer. Then the function returns the value of the vector $(S, I, R)$ at that particular time point. Ifindices = -1
, this corresponds to the last time value.