Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Utopia::TriangularGrid< Space > Class Template Reference

A grid discretization using triangular cells. More...

#include <triangular.hh>

Inheritance diagram for Utopia::TriangularGrid< Space >:
Inheritance graph
[legend]
Collaboration diagram for Utopia::TriangularGrid< Space >:
Collaboration graph
[legend]

Public Types

using Base = Grid< Space >
 Base class type.
 
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 Types inherited from Utopia::Grid< Space >
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

 TriangularGrid (std::shared_ptr< Space > space, const Config &cfg)
 Construct a triangular grid discretization.
 
IndexType num_cells () const override
 Number of triangular cells required to fill the physical space.
 
SpaceVec effective_resolution () const override
 The effective cell resolution into each physical space dimension.
 
MultiIndex shape () const override
 Get shape of the triangular grid.
 
GridStructure structure () const override
 Structure of the grid.
 
MultiIndex midx_of (const IndexType) const override
 Returns the multi index of the cell with the given ID.
 
SpaceVec barycenter_of (const IndexType) const override
 Returns the barycenter of the cell with the given ID.
 
SpaceVec extent_of (const IndexType) const override
 Returns the extent of the cell with the given ID.
 
std::vector< SpaceVecvertices_of (const IndexType) const override
 Returns the vertices of the cell with the given ID.
 
IndexType cell_at (const SpaceVec &) const override
 Return the ID of the cell covering the given point in physical space.
 
std::set< IndexTypeboundary_cells (std::string={}) const override
 Retrieve a set of cell indices that are at a specified boundary.
 
- Public Member Functions inherited from Utopia::Grid< Space >
 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 NBModenb_mode () const
 Const reference to the currently selected neighborhood mode.
 
const Confignb_params () const
 The neighborhood parameters of the currently selected neighborhood.
 
auto nb_size () const
 Maximum size of the currently selected neighborhood.
 
auto resolution () const
 Get scalar resolution value of this 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)
 
- Static Public Attributes inherited from Utopia::Grid< Space >
static constexpr DimType dim = Space::dim
 The dimensionality of the space to be discretized (for easier access)
 

Protected Member Functions

NBFuncID< Baseget_nb_func (NBMode nb_mode, const Config &) override
 Retrieve the neighborhood function depending on the mode.
 
DistType expected_num_neighbors (const NBMode &nb_mode, const Config &) const override
 Computes the expected number of neighbors for a neighborhood mode.
 

Additional Inherited Members

- Protected Attributes inherited from Utopia::Grid< Space >
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.
 

Detailed Description

template<class Space>
class Utopia::TriangularGrid< Space >

A grid discretization using triangular cells.

Member Typedef Documentation

◆ Base

Base class type.

◆ Config

The configuration type.

◆ MultiIndex

The type of multi-index like arrays, e.g. the grid shape.

◆ SpaceVec

The type of vectors that have a relation to physical space.

Constructor & Destructor Documentation

◆ TriangularGrid()

template<class Space >
Utopia::TriangularGrid< Space >::TriangularGrid ( std::shared_ptr< Space space,
const Config cfg 
)
inline

Construct a triangular grid discretization.

Parameters
spaceThe space to construct the discretization for
cfgFurther configuration parameters
45 :
46 Base(space, cfg)
47 {}
const std::shared_ptr< Space > & space() const
Const reference to the space this grid maps to.
Definition base.hh:299
Grid< Space > Base
Base class type.
Definition triangular.hh:19

Member Function Documentation

◆ barycenter_of()

template<class Space >
SpaceVec Utopia::TriangularGrid< Space >::barycenter_of ( const IndexType  ) const
inlineoverridevirtual

Returns the barycenter of the cell with the given ID.

Note
This method does not perform bounds checking of the given ID!

Implements Utopia::Grid< Space >.

94 {
95 throw std::runtime_error("The TriangularGrid::barycenter_of method "
96 "is not yet implemented!");
97 return {};
98 }

◆ boundary_cells()

template<class Space >
std::set< IndexType > Utopia::TriangularGrid< Space >::boundary_cells ( std::string  = {}) const
inlineoverridevirtual

Retrieve a set of cell indices that are at a specified boundary.

Note
For a periodic space, an empty container is returned; no error or warning is emitted.
Parameters
selectWhich 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

Implements Utopia::Grid< Space >.

150 {}) const override {
151 throw std::runtime_error("The TriangularGrid::boundary_cells method "
152 "is not yet implemented!");
153 return {};
154 }

◆ cell_at()

template<class Space >
IndexType Utopia::TriangularGrid< Space >::cell_at ( const SpaceVec ) const
inlineoverridevirtual

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.

Note
This function always returns IDs of cells that are inside physical space. For non-periodic space, a check is performed whether the given point is inside the physical space associated with this grid. For periodic space, the given position is mapped back into the physical space.

Implements Utopia::Grid< Space >.

133 {
134 throw std::runtime_error("The TriangularGrid::cell_at method is not "
135 "yet implemented!");
136 return {};
137 }

◆ effective_resolution()

template<class Space >
SpaceVec Utopia::TriangularGrid< Space >::effective_resolution ( ) const
inlineoverridevirtual

The effective cell resolution into each physical space dimension.

Implements Utopia::Grid< Space >.

60 {
61 // TODO Implement properly!
63 res_eff.fill(0.);
64 return res_eff;
65 }
typename Space::SpaceVec SpaceVec
The type of vectors that have a relation to physical space.
Definition triangular.hh:25
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213

◆ expected_num_neighbors()

template<class Space >
DistType Utopia::TriangularGrid< Space >::expected_num_neighbors ( const NBMode nb_mode,
const Config  
) const
inlineoverrideprotectedvirtual

Computes the expected number of neighbors for a neighborhood mode.

Implements Utopia::Grid< Space >.

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 }
const NBMode & nb_mode() const
Const reference to the currently selected neighborhood mode.
Definition base.hh:198
std::string nb_mode_to_string(const NBMode &nb_mode)
Given an NBMode enum value, return the corresponding string key.
Definition base.hh:78
@ empty
Every entity is utterly alone in the world.

◆ extent_of()

template<class Space >
SpaceVec Utopia::TriangularGrid< Space >::extent_of ( const IndexType  ) const
inlineoverridevirtual

Returns the extent of the cell with the given ID.

Note
This method does not perform bounds checking of the given ID!

Implements Utopia::Grid< Space >.

103 {
104 throw std::runtime_error("The TriangularGrid::extent_of method is not "
105 "yet implemented!");
106 return {};
107 }

◆ get_nb_func()

template<class Space >
NBFuncID< Base > Utopia::TriangularGrid< Space >::get_nb_func ( NBMode  nb_mode,
const Config  
)
inlineoverrideprotectedvirtual

Retrieve the neighborhood function depending on the mode.

Implements Utopia::Grid< Space >.

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 }
NBFuncID< Self > _nb_empty
A neighborhood function for empty neighborhood.
Definition base.hh:323

◆ midx_of()

template<class Space >
MultiIndex Utopia::TriangularGrid< Space >::midx_of ( const IndexType  ) const
inlineoverridevirtual

Returns the multi index of the cell with the given ID.

Note
This method does not perform bounds checking of the given ID!

Implements Utopia::Grid< Space >.

85 {
86 throw std::runtime_error("The TriangularGrid::midx_of method is not "
87 "yet implemented!");
88 return {};
89 }

◆ num_cells()

template<class Space >
IndexType Utopia::TriangularGrid< Space >::num_cells ( ) const
inlineoverridevirtual

Number of triangular cells required to fill the physical space.

Implements Utopia::Grid< Space >.

54 {
55 // TODO Implement properly!
56 return 0;
57 };

◆ shape()

template<class Space >
MultiIndex Utopia::TriangularGrid< Space >::shape ( ) const
inlineoverridevirtual

Get shape of the triangular grid.

Implements Utopia::Grid< Space >.

68 {
69 //TODO Implement properly!
71 shape.fill(0);
72 return shape;
73 }
MultiIndex shape() const override
Get shape of the triangular grid.
Definition triangular.hh:68

◆ structure()

template<class Space >
GridStructure Utopia::TriangularGrid< Space >::structure ( ) const
inlineoverridevirtual

Structure of the grid.

Implements Utopia::Grid< Space >.

76 {
78 }
@ triangular
A triangular lattice grid.

◆ vertices_of()

template<class Space >
std::vector< SpaceVec > Utopia::TriangularGrid< Space >::vertices_of ( const IndexType  ) const
inlineoverridevirtual

Returns the vertices of the cell with the given ID.

Warning
The order of the vertices is not guaranteed.
Note
This method does not perform bounds checking of the given ID!

Implements Utopia::Grid< Space >.

114 {
115 throw std::runtime_error("The TriangularGrid::vertices_of method is "
116 "not yet implemented!");
117 return {};
118 }

Member Data Documentation

◆ dim

template<class Space >
constexpr DimType Utopia::TriangularGrid< Space >::dim = Space::dim
staticconstexpr

The dimensionality of the space to be discretized (for easier access)


The documentation for this class was generated from the following file: