Utopia 2
Framework for studying models of complex & adaptive systems.
|
The Space bundles properties about the physical space a model resides in. More...
#include <space.hh>
Public Types | |
using | SpaceVec = SpaceVecType< dim > |
The type for vectors relating to physical space. | |
Public Member Functions | |
Space (const Config &cfg) | |
Construct a Space using information from a config node. | |
Space () | |
Default constructor i.e. constructing a space with default parameters. | |
template<bool include_high_value_boundary = true> | |
bool | contains (const SpaceVec &pos) const |
Whether this space contains the given coordinate (without mapping it) | |
SpaceVec | map_into_space (const SpaceVec &pos) const |
Map a position (potentially outside space's extent) back into space. | |
SpaceVec | displacement (const SpaceVec &pos_0, const SpaceVec &pos_1) const |
Compute the displacement vector between two coordinates. | |
template<class NormType = std::size_t> | |
auto | distance (const SpaceVec &pos_0, const SpaceVec &pos_1, const NormType p=2) const |
The distance of two coordinates in space. | |
Public Attributes | |
const bool | periodic |
Whether the space is to be assumed periodic. | |
const SpaceVec | extent |
The physical (euclidean) extent of the space. | |
Static Public Attributes | |
static constexpr std::size_t | dim = num_dims |
The dimensionality of the space. | |
Private Member Functions | |
bool | setup_periodic (const Config &cfg) const |
Setup the member periodic from a config node. | |
SpaceVec | setup_extent () const |
Construct a default space extent vector (valued 1 in each dimension) | |
SpaceVec | setup_extent (const Config &cfg) const |
Construct a space extent vector from a config node. | |
The Space bundles properties about the physical space a model resides in.
It is, for example, used by the CellManager and its Grid discretization and by the AgentManager to properly map agent positions and movements within the spatial domain.
num_dims | The dimensionality of the space |
using Utopia::Space< num_dims >::SpaceVec = SpaceVecType<dim> |
The type for vectors relating to physical space.
|
inline |
Construct a Space using information from a config node.
cfg | The config node to read the periodic and extent entries from. |
|
inline |
Default constructor i.e. constructing a space with default parameters.
The default space is non-periodic and has default extent of 1. into each dimension.
|
inline |
Whether this space contains the given coordinate (without mapping it)
Checks whether the given coordinate is within this space's extent by computing the relative position and checking whether it is within [0, 1] or [0, 1) for all elements.
include_high_value_boundary | Whether to check the closed or the half-open interval. The latter case is useful when working with periodic grids, allowing to map values on the high-value boundary back to the low-value boundary. |
|
inline |
Compute the displacement vector between two coordinates.
Calculates vector pointing from pos_0 to pos_1. In periodic space, it calculates the shorter displacement.
|
inline |
The distance of two coordinates in space.
Calculates the distance of two coordinates using the norm implemented within Armadillo. In periodic boundary it calculates the shorter distance.
p | The norm used to compute the distance, see arma::norm. Can be either an integer >= 1 or one of: "-inf", "inf", "fro" |
|
inline |
Map a position (potentially outside space's extent) back into space.
This is intended for use with periodic space. It will also work with non-periodic space, but the input value should not have been permitted in the first place.
|
inlineprivate |
|
inlineprivate |
Construct a space extent vector from a config node.
cfg | The config node to read the extent parameter from. If that entry is missing, the default extent (1) is used. If the entry is a scalar, space will be set up to have equal extent in all dimensions. Otherwise, it is expected to be a sequence node. |
|
inlineprivate |
Setup the member periodic
from a config node.
|
staticconstexpr |
The dimensionality of the space.
const SpaceVec Utopia::Space< num_dims >::extent |
The physical (euclidean) extent of the space.
const bool Utopia::Space< num_dims >::periodic |
Whether the space is to be assumed periodic.