|
bool | checkArguments (const std::vector< CustomResultArgument > &arguments) const |
| Checks arguments and returns false if check failed. More...
|
|
bool | computeCustomArguments (const DataSource *dataSource, const std::vector< CustomResultArgument > &arguments, DataState *state) const |
| Computes custom arguments for given dataSource and state. More...
|
|
bool | gatherInputDataResults (const DataResultGroup *resultGroup, const std::vector< CustomResultArgument > &arguments, size_t partCount, InputDataResults *inputDataResults) const |
| Gathers input data results for given resultGroup. More...
|
|
bool | gatherInputValuePointers (const std::vector< CustomResultArgument > &arguments, size_t partIndex, const InputDataResults &inputDataResults, InputValueData *inputValueData) const |
| Gathers input value pointers. More...
|
|
bool | getOuputDataResult (DataResultGroup *resultGroup, const ResultInfo &result, OutputDataResult *outputDataResult) const |
| Gets output data result. More...
|
|
bool | getOutputValuePointer (size_t partIndex, const OutputDataResult &outputDataResult, const InputValueData &inputValueData, size_t outputItemCount, OutputValueData *outputValueData) const |
| Gets output value pointer. More...
|
|
A class to generate custom results.
In order to add a custom result, first implement a derived CustomResultFunction that provides the custom result values given a number of inputs.
Example: this custom result function provides the trace of an input tensor. There is one input, a symmetric tensor, for which the 6 values are provided in the corresponding first inputValues raw const double pointer.
The first three values are the diagonal components of the tensor, which are added to provide the output tensor trace.
class TensorTraceFunction : public CustomResultFunction
{
public:
bool computeItem(const std::vector<const double*>& inputValues, double* outputValues)
{
const double* inputTensorValues = inputValues[0];
CVF_ASSERT(inputTensorValues);
*outputValues = inputTensorValues[0] + inputTensorValues[1] + inputTensorValues[2];
return true;
}
};
To generate the custom result with this function, create a CustomResultGenerator providing the number of inputs (one, in the example) and the DataSource that will be used to get the input values, and specify the input argument types. Instantiate the function, and set it on the CustomResultGenerator.
PtrRef<TensorTraceFunction> function = new TensorTraceFunction;
generator.setFunction(function.get());
A custom result can now be added as a ResultInfo to the directory of the DataSource that contains the input argument results. If "tensorResultInfo" is the ResultInfo associated to the input tensor result, the custom result is registered like this:
std::vector<CustomResultArgument> arguments;
arguments.push_back(CustomResultArgument(tensorResultInfo));
ds->directory()->setCustomResultInfo(customInfo);
The generation of the custom result for a given DataState is performed in CustomResultGenerator::generate(). The default implementation assumes that the custom result and the arguments have the same mapping. A loop runs through all the items of this mapping and calls the CustomResultFunction on each of them. For more complex custom results, for example node-averaging of element-mapped results, CustomResultGenerator::generate() can be specialized in a derived CustomResultGenerator.