Utopia 2
Framework for studying models of complex & adaptive systems.
|
The base class for all grid discretizations used by the CellManager. More...
#include <base.hh>
Public Types | |
using | Self = Grid< Space > |
Type of this class, i.e. the base grid class. | |
using | SpaceVec = typename Space::SpaceVec |
The type of vectors that have a relation to physical space. | |
using | MultiIndex = MultiIndexType< dim > |
The type of multi-index like arrays, e.g. the grid shape. | |
using | Config = DataIO::Config |
The configuration type. | |
Public Member Functions | |
Grid (std::shared_ptr< Space > space, const Config &cfg) | |
Construct a grid discretization. | |
virtual | ~Grid ()=default |
Virtual destructor to allow polymorphic destruction. | |
IndexContainer | neighbors_of (const IndexType id) const |
Returns the indices of the neighbors of the cell with the given ID. | |
void | select_neighborhood (NBMode nb_mode, const Config &nb_params={}) |
const NBMode & | nb_mode () const |
Const reference to the currently selected neighborhood mode. | |
const Config & | nb_params () const |
The neighborhood parameters of the currently selected neighborhood. | |
auto | nb_size () const |
Maximum size of the currently selected neighborhood. | |
virtual MultiIndex | midx_of (const IndexType) const =0 |
Returns the multi-index of the cell with the given ID. | |
virtual SpaceVec | barycenter_of (const IndexType) const =0 |
Returns the barycenter of the cell with the given ID. | |
virtual SpaceVec | extent_of (const IndexType) const =0 |
Returns the extent of the cell with the given ID. | |
virtual std::vector< SpaceVec > | vertices_of (const IndexType) const =0 |
Returns the vertices of the cell with the given ID. | |
virtual IndexType | cell_at (const SpaceVec &) const =0 |
Return the ID of the cell covering the given point in physical space. | |
virtual std::set< IndexType > | boundary_cells (std::string={}) const =0 |
Retrieve a set of cell indices that are at a specified boundary. | |
virtual IndexType | num_cells () const =0 |
Get number of cells. | |
auto | resolution () const |
Get scalar resolution value of this grid. | |
virtual SpaceVec | effective_resolution () const =0 |
Returns the effective resolution into each dimension of the grid. | |
virtual MultiIndex | shape () const =0 |
Get the shape of the grid discretization. | |
virtual GridStructure | structure () const =0 |
Structure of the grid. | |
std::string | structure_name () const |
Structure of the grid as std::string. | |
const std::shared_ptr< Space > & | space () const |
Const reference to the space this grid maps to. | |
bool | is_periodic () const |
Whether the space this grid maps to is periodic. | |
Static Public Attributes | |
static constexpr DimType | dim = Space::dim |
The dimensionality of the space to be discretized (for easier access) | |
Protected Member Functions | |
virtual NBFuncID< Self > | get_nb_func (NBMode, const Config &)=0 |
Retrieve the neighborhood function depending on the mode. | |
virtual DistType | expected_num_neighbors (const NBMode &, const Config &) const =0 |
Protected Attributes | |
const std::shared_ptr< Space > | _space |
The space that is to be discretized. | |
const DistType | _resolution |
How many cells to place per length unit of space. | |
NBMode | _nb_mode |
Neighborhood mode. | |
Config | _nb_params |
Neighborhood parameters. | |
NBFuncID< Self > | _nb_func |
Neighborhood function (working on cell IDs) | |
NBFuncID< Self > | _nb_empty |
A neighborhood function for empty neighborhood. | |
The base class for all grid discretizations used by the CellManager.
using Utopia::Grid< Space >::Config = DataIO::Config |
The configuration type.
using Utopia::Grid< Space >::MultiIndex = MultiIndexType<dim> |
The type of multi-index like arrays, e.g. the grid shape.
Type of this class, i.e. the base grid class.
using Utopia::Grid< Space >::SpaceVec = typename Space::SpaceVec |
The type of vectors that have a relation to physical space.
|
inline |
Construct a grid discretization.
space | The space to construct the discretization for |
cfg | Further configuration parameters |
Virtual destructor to allow polymorphic destruction.
Returns the barycenter of the cell with the given ID.
Implemented in Utopia::HexagonalGrid< Space >, Utopia::SquareGrid< Space >, and Utopia::TriangularGrid< Space >.
|
pure virtual |
Retrieve a set of cell indices that are at a specified boundary.
select | Which boundary to return the cell IDs of. If 'all', all boundary cells are returned. Other available values depend on the dimensionality of the grid: 1D: left, right 2D: bottom, top 3D: back, front |
Implemented in Utopia::HexagonalGrid< Space >, Utopia::SquareGrid< Space >, and Utopia::TriangularGrid< Space >.
Return the ID of the cell covering the given point in physical space.
Cells are interpreted as covering half-open intervals in space, i.e., including their low-value edges and excluding their high-value edges. The special case of points on high-value edges for non-periodic space behaves such that these points are associated with the cells at the boundary.
Implemented in Utopia::TriangularGrid< Space >, Utopia::HexagonalGrid< Space >, and Utopia::SquareGrid< Space >.
|
pure virtual |
Returns the effective resolution into each dimension of the grid.
Depending on choice of resolution and extent of physical space, the resolution given at initialization might not represent the density of cells per unit of space fully accurately. The effective resolution accounts for the scaling that was required to map an integer number of cells onto the space.
Implemented in Utopia::HexagonalGrid< Space >, Utopia::SquareGrid< Space >, and Utopia::TriangularGrid< Space >.
|
protectedpure virtual |
Computes the expected number of neighbors for a given neighborhood mode and a corresponding set of neighborhood parameters
Implemented in Utopia::HexagonalGrid< Space >, Utopia::TriangularGrid< Space >, and Utopia::SquareGrid< Space >.
Returns the extent of the cell with the given ID.
Implemented in Utopia::HexagonalGrid< Space >, Utopia::SquareGrid< Space >, and Utopia::TriangularGrid< Space >.
|
protectedpure virtual |
Retrieve the neighborhood function depending on the mode.
The configuration node that is passed along can be used to specify the neighborhood parameter members.
Implemented in Utopia::TriangularGrid< Space >, Utopia::HexagonalGrid< Space >, and Utopia::SquareGrid< Space >.
|
inline |
Whether the space this grid maps to is periodic.
|
pure virtual |
Returns the multi-index of the cell with the given ID.
Implemented in Utopia::HexagonalGrid< Space >, Utopia::SquareGrid< Space >, and Utopia::TriangularGrid< Space >.
Const reference to the currently selected neighborhood mode.
The neighborhood parameters of the currently selected neighborhood.
|
inline |
Maximum size of the currently selected neighborhood.
|
inline |
Returns the indices of the neighbors of the cell with the given ID.
Get number of cells.
This information is used by the CellManager to populate the cell container with the returned number of cells
Implemented in Utopia::HexagonalGrid< Space >, Utopia::SquareGrid< Space >, and Utopia::TriangularGrid< Space >.
|
inline |
Get scalar resolution value of this grid.
|
inline |
|
pure virtual |
Get the shape of the grid discretization.
Implemented in Utopia::HexagonalGrid< Space >, Utopia::SquareGrid< Space >, and Utopia::TriangularGrid< Space >.
|
inline |
Const reference to the space this grid maps to.
|
pure virtual |
Structure of the grid.
Implemented in Utopia::HexagonalGrid< Space >, Utopia::SquareGrid< Space >, and Utopia::TriangularGrid< Space >.
|
inline |
Structure of the grid as std::string.
|
pure virtual |
Returns the vertices of the cell with the given ID.
Consult the derived class implementation's documentation on the order of the vertices in the returned container.
Implemented in Utopia::HexagonalGrid< Space >, Utopia::SquareGrid< Space >, and Utopia::TriangularGrid< Space >.
A neighborhood function for empty neighborhood.
Neighborhood function (working on cell IDs)
|
protected |
Neighborhood mode.
|
protected |
Neighborhood parameters.
How many cells to place per length unit of space.
The space that is to be discretized.
The dimensionality of the space to be discretized (for easier access)