Alsvinn  0.5.3
The fast FVM simulator with UQ support
Using the statistics

This example is meant as a minimal example of how to use only the statistics component of alsvinn::alsuq.

Prerequisites

First you need too build alsvinn, see the documentation.

Building

This should be straightforward:

mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=<path to either alsvinn/build or alsvinn-install-path> -DCMAKE_BUILD_TYPE=Release
make

Our goal

We want to compute the structure functions of "random noise". To this end, we want to use the statistics module of alsvinn.

The code

Necessary includes

// STL headers (not needed from Alsvinn, just this example)
#include <iostream>
#include <random>
// Alsvinn headers

Making an instance of the statisticsFactory

We create a separate function to create the statitics:

double p, int numberOfH, int numberOfSamples, const std::string& platform,
const alsuq::mpi::ConfigurationPtr mpiConfiguration) {

To create statistics, we need to make a new instance of the statisticsFactory

then we setup the parameter struct

boost::property_tree::ptree properties;
properties.put("p", p);
properties.put("numberOfH", numberOfH);
parameters.setNumberOfSamples(numberOfSamples);
parameters.setMpiConfiguration(mpiConfiguration);

notice how we use boost::property_tree for inserting parameters passed directly to the statistics (p and numberOfH), while we set the other parameters to the parameter struct directly

And lastly, we create and return the statistics.

auto statistics = statisticsFactory.makeStatistics(platform, "structure_cube",
return statistics;