Creating a Model

In order to create a FLAME GPU 2 simulation, you must first describe the model.

What is a Model?

In FLAME GPU 2, a model is represented by a ModelDescription object, this contains information specifying the agents, messages and environment properties within the model and how they interact.

Once the ModelDescription has been completely described, it is used to construct either a CUDASimulation or CUDAEnsemble to execute simulations of the model.

Creating a ModelDescription Object

ModelDescription objects can be initialised directly, requiring only a single argument specifying the model’s name. Currently this name is only used to generate the default window title within the visualiser.

#include "flamegpu/flamegpu.h"

int main(int argc, const char **argv) {
    // Define a new FLAME GPU model
    flamegpu::ModelDescription model("My Model");
}

The ModelDescription class has various methods for specifying components of the model, these are used to fully describe a model to be simulated.

Method

Returns

Environment()

EnvironmentDescription&

newAgent()

AgentDescription&

newMessage()

Specialised message description type, e.g. MessageBruteForce::Description&, MessageSpatial2D::Description&, etc

newSubModel()

SubModelDescription&

addInitFunction()

n/a

addStepFunction()

n/a

addExitFunction()

n/a

addExitCondition()

n/a

newLayer()

LayerDescription&

Note

newMessage() take a template argument, so it is called in the format newMessage<flamegpu::MessageBruteForce>(). As the Python API lacks templates, they are instead called in the format newMessageBruteForce().

Note

The host function methods e.g. addInitFunction(), addExitCondition() etc are named slightly different in the Python API. Instead they are called addInitFunctionCallback(), addExitConditionCallback() etc.

The subsequent chapters of this guide explore their usage in greater detail.