Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
triangular.hh
Go to the documentation of this file.
1#ifndef UTOPIA_CORE_GRIDS_TRIANGULAR_HH
2#define UTOPIA_CORE_GRIDS_TRIANGULAR_HH
3
4#include "base.hh"
5
6namespace Utopia {
13template<class Space>
15 : public Grid<Space>
16{
17public:
20
22 static constexpr DimType dim = Space::dim;
23
25 using SpaceVec = typename Space::SpaceVec;
26
29
32
33
34private:
35 // -- TriagonalGrid-specific members --------------------------------------
36
37
38public:
39 // -- Constructors --------------------------------------------------------
41
44 TriangularGrid (std::shared_ptr<Space> space, const Config& cfg)
45 :
46 Base(space, cfg)
47 {}
48
49
50 // -- Implementations of virtual base class functions ---------------------
51 // .. Number of cells & shape .............................................
52
54 IndexType num_cells() const override {
55 // TODO Implement properly!
56 return 0;
57 };
58
60 SpaceVec effective_resolution() const override {
61 // TODO Implement properly!
63 res_eff.fill(0.);
64 return res_eff;
65 }
66
68 MultiIndex shape() const override {
69 //TODO Implement properly!
71 shape.fill(0);
72 return shape;
73 }
74
76 GridStructure structure() const override {
78 }
79
80
81 // .. Position-related methods ............................................
83
85 MultiIndex midx_of(const IndexType) const override {
86 throw std::runtime_error("The TriangularGrid::midx_of method is not "
87 "yet implemented!");
88 return {};
89 }
90
92
94 SpaceVec barycenter_of(const IndexType) const override {
95 throw std::runtime_error("The TriangularGrid::barycenter_of method "
96 "is not yet implemented!");
97 return {};
98 }
99
101
103 SpaceVec extent_of(const IndexType) const override {
104 throw std::runtime_error("The TriangularGrid::extent_of method is not "
105 "yet implemented!");
106 return {};
107 }
108
110
114 std::vector<SpaceVec> vertices_of(const IndexType) const override {
115 throw std::runtime_error("The TriangularGrid::vertices_of method is "
116 "not yet implemented!");
117 return {};
118 }
119
121
133 IndexType cell_at(const SpaceVec&) const override {
134 throw std::runtime_error("The TriangularGrid::cell_at method is not "
135 "yet implemented!");
136 return {};
137 }
138
140
150 std::set<IndexType> boundary_cells(std::string={}) const override {
151 throw std::runtime_error("The TriangularGrid::boundary_cells method "
152 "is not yet implemented!");
153 return {};
154 }
155
156
157protected:
158 // -- Neighborhood interface ----------------------------------------------
161 {
162 if (nb_mode == NBMode::empty) {
163 return this->_nb_empty;
164 }
165 else {
166 throw std::invalid_argument("No '" + nb_mode_to_string(nb_mode)
167 + "' neighborhood available for TriangularGrid!");
168 }
169 }
170
173 const Config&) const override
174 {
175 if (nb_mode == NBMode::empty) {
176 return 0;
177 }
178 else {
179 throw std::invalid_argument("No '" + nb_mode_to_string(nb_mode)
180 + "' neighborhood available for TriangularGrid!");
181 }
182 }
183
184
185
186 // .. Neighborhood implementations ........................................
187 // ...
188};
189
190
191// end group CellManager
196} // namespace Utopia
197
198#endif // UTOPIA_CORE_GRIDS_TRIANGULAR_HH
The base class for all grid discretizations used by the CellManager.
Definition base.hh:99
NBFuncID< Self > _nb_empty
A neighborhood function for empty neighborhood.
Definition base.hh:323
const std::shared_ptr< Space > & space() const
Const reference to the space this grid maps to.
Definition base.hh:299
const NBMode & nb_mode() const
Const reference to the currently selected neighborhood mode.
Definition base.hh:198
A grid discretization using triangular cells.
Definition triangular.hh:16
SpaceVec extent_of(const IndexType) const override
Returns the extent of the cell with the given ID.
Definition triangular.hh:103
DataIO::Config Config
The configuration type.
Definition triangular.hh:31
MultiIndex midx_of(const IndexType) const override
Returns the multi index of the cell with the given ID.
Definition triangular.hh:85
GridStructure structure() const override
Structure of the grid.
Definition triangular.hh:76
SpaceVec barycenter_of(const IndexType) const override
Returns the barycenter of the cell with the given ID.
Definition triangular.hh:94
TriangularGrid(std::shared_ptr< Space > space, const Config &cfg)
Construct a triangular grid discretization.
Definition triangular.hh:44
SpaceVec effective_resolution() const override
The effective cell resolution into each physical space dimension.
Definition triangular.hh:60
MultiIndexType< dim > MultiIndex
The type of multi-index like arrays, e.g. the grid shape.
Definition triangular.hh:28
MultiIndex shape() const override
Get shape of the triangular grid.
Definition triangular.hh:68
IndexType cell_at(const SpaceVec &) const override
Return the ID of the cell covering the given point in physical space.
Definition triangular.hh:133
NBFuncID< Base > get_nb_func(NBMode nb_mode, const Config &) override
Retrieve the neighborhood function depending on the mode.
Definition triangular.hh:160
std::vector< SpaceVec > vertices_of(const IndexType) const override
Returns the vertices of the cell with the given ID.
Definition triangular.hh:114
IndexType num_cells() const override
Number of triangular cells required to fill the physical space.
Definition triangular.hh:54
DistType expected_num_neighbors(const NBMode &nb_mode, const Config &) const override
Computes the expected number of neighbors for a neighborhood mode.
Definition triangular.hh:172
typename Space::SpaceVec SpaceVec
The type of vectors that have a relation to physical space.
Definition triangular.hh:25
std::set< IndexType > boundary_cells(std::string={}) const override
Retrieve a set of cell indices that are at a specified boundary.
Definition triangular.hh:150
static constexpr DimType dim
The dimensionality of the space to be discretized (for easier access)
Definition triangular.hh:22
NBMode
Possible neighborhood types; availability depends on choice of grid.
Definition base.hh:52
std::string nb_mode_to_string(const NBMode &nb_mode)
Given an NBMode enum value, return the corresponding string key.
Definition base.hh:78
GridStructure
Available grid implementations.
Definition base.hh:13
std::function< IndexContainer(const IndexType)> NBFuncID
Type of the neighborhood calculating function.
Definition base.hh:92
@ empty
Every entity is utterly alone in the world.
@ triangular
A triangular lattice grid.
YAML::Node Config
Type of a variadic dictionary-like data structure used throughout Utopia.
Definition types.hh:71
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
Definition agent.hh:11
arma::Col< IndexType >::fixed< dim > MultiIndexType
Type for index type vectors that are associated with a physical space.
Definition types.hh:53
unsigned short DimType
Type for dimensions, i.e. very small unsigned integers.
Definition types.hh:34
unsigned int DistType
Type for distancens, i.e. intermediately long unsigned integers.
Definition types.hh:37
std::size_t IndexType
Type for indices, i.e. values used for container indexing, agent IDs, ...
Definition types.hh:40
SpaceVecType< dim > SpaceVec
The type for vectors relating to physical space.
Definition space.hh:33
static constexpr std::size_t dim
The dimensionality of the space.
Definition space.hh:30