parallel-cellular-automata
Framework for building parallel cellular automata.
|
Parallel Cellular Automaton using OpenMP. More...
#include <omp_automaton.hpp>
Public Member Functions | |
CellularAutomaton (ca::Grid< T > &grid, std::function< T(T, T, T, T, T, T, T, T, T)> update_function, unsigned workers=0) | |
Construct a new Cellular Automaton object. More... | |
CellularAutomaton (CellularAutomaton &&other) | |
Construct a new Cellular Automaton object from another one using move semantic. More... | |
CellularAutomaton (const CellularAutomaton &other)=delete | |
Deleted copy constructor. More... | |
virtual void | simulate (unsigned steps=1) |
Run the simulation for a given number of steps. More... | |
size_t | get_generation () const |
Get the generation of the simulation. More... | |
Protected Member Functions | |
virtual std::tuple< T, T, T, T, T, T, T, T > | get_neighborhood (int row, int col) const |
Get the neighborhood of a cell. More... | |
Protected Attributes | |
Grid< T > & | grid |
Grid of the C.A. | |
size_t | generation |
Current generation of the grid. | |
std::function< T(T, T, T, T, T, T, T, T, T)> | update_function |
Function used to compute the next state of the cell. More... | |
unsigned | nw |
Number of worker threads. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const CellularAutomaton &ca) |
Overload of the << operator. More... | |
Parallel Cellular Automaton using OpenMP.
This class implements a toroidal Cellular Automaton parallelized using OpenMP.
T | type of the cells. |
|
inline |
Construct a new Cellular Automaton object.
grid | Grid of the simulation. |
update_function | Function used to update the state of the grid. |
workers | Number of threads. If 0 the default value is chosen by OpenMP. |
|
inline |
Construct a new Cellular Automaton object from another one using move semantic.
other | CellularAutomaton to move. |
|
delete |
Deleted copy constructor.
|
inline |
Get the generation of the simulation.
|
inlineprotectedvirtual |
Get the neighborhood of a cell.
row | row of the center cell. |
col | column of the center cell. |
|
inlinevirtual |
Run the simulation for a given number of steps.
steps | number of simulation steps to run (default 1). |
|
friend |
Overload of the << operator.
Print the grid on a output stream.
os | output stream |
ca | CellularAutomaton |
|
protected |
Function used to compute the next state of the cell.
The function takes nine arguments. It will be called by passing the central cell as first argument and its eight neighbors as the remaining arguments. Their order is the one returned by the get_neighborhood function.