HyperHDG
hy_data_container.hxx
Go to the documentation of this file.
1 #pragma once // Ensure that file is included only once in a single compilation.
2 
3 #include <HyperHDG/hy_assert.hxx>
4 
5 /*!*************************************************************************************************
6  * \brief Class for saving some (abstract) data per hyperedge.
7  *
8  * For parabolic PDEs, for example, it might be necessary to save some data of the old time step.
9  * This data might be related to hypernodes and therefore be saved in a global vector that is
10  * administrated by the HypernodeFactory, or it might be related to hypernodes and therefore be
11  * administrated by the HyDataContainer.
12  *
13  * \tparam data_t The class name of the data which is saved per hyperedge.
14  * \tparam vectorT Data structure in which the datas are stored. Defaults to std::vector.
15  * \tparam hyEdge_index_t Index type which is used to identify entries in this data structure.
16  *
17  * \authors Guido Kanschat, Heidelberg University, 2019--2020.
18  * \authors Andreas Rupp, Heidelberg University, 2019--2020.
19  **************************************************************************************************/
20 template <typename data_t,
21  typename vectorT = std::vector<data_t>,
22  typename hyEdge_index_t = decltype(std::declval<vectorT>().size())>
24 {
25  private:
26  /*!***********************************************************************************************
27  * \brief The internal overall data container which holds all data of a hypergraph's hyperedges.
28  ************************************************************************************************/
29  vectorT data_container;
30 
31  public:
32  /*!***********************************************************************************************
33  * \brief Defines the return value of the class.
34  ************************************************************************************************/
35  typedef data_t value_type;
36  /*!***********************************************************************************************
37  * \brief Defines the value type of input argument for standard constructor.
38  ************************************************************************************************/
39  typedef decltype(std::declval<vectorT>().size()) constructor_value_type;
40  /*!***********************************************************************************************
41  * \brief Construct a topology from a given filename.
42  *
43  * \param n_hyEdges Number of hyperedges.
44  ************************************************************************************************/
46 
47  /*!***********************************************************************************************
48  * \brief Get data of hyperedge of given index.
49  *
50  * \param index The index of the hyperedge whose data is to be returned.
51  * \retval data The data of the selected hyperedge.
52  ************************************************************************************************/
53  value_type& operator[](const hyEdge_index_t index) { return get_hyEdge(index); }
54  /*!***********************************************************************************************
55  * \brief Get data of hyperedge of given index.
56  *
57  * \param index The index of the hyperedge whose data is to be returned.
58  * \retval data The data of the selected hyperedge.
59  ************************************************************************************************/
60  value_type& get_hyEdge(const hyEdge_index_t index)
61  {
62  hy_assert(index < data_container.size() && index >= 0,
63  "Index must be non-negative and smaller than "
64  << data_container.size() << " (which is the amount of hyperedges). It was " << index
65  << "!");
66  return data_container[index];
67  }
68 }; // end of class File
HyDataContainer::operator[]
value_type & operator[](const hyEdge_index_t index)
Get data of hyperedge of given index.
Definition: hy_data_container.hxx:53
hy_assert.hxx
This file provides the function hy_assert.
check_push_test.index
index
Definition: check_push_test.py:10
HyDataContainer::constructor_value_type
decltype(std::declval< vectorT >().size()) typedef constructor_value_type
Defines the value type of input argument for standard constructor.
Definition: hy_data_container.hxx:39
HyDataContainer::data_container
vectorT data_container
The internal overall data container which holds all data of a hypergraph's hyperedges.
Definition: hy_data_container.hxx:29
HyDataContainer::value_type
data_t value_type
Defines the return value of the class.
Definition: hy_data_container.hxx:35
HyDataContainer
Class for saving some (abstract) data per hyperedge.
Definition: hy_data_container.hxx:23
hy_assert
#define hy_assert(Expr, Msg)
The assertion to be used within HyperHDG — deactivate using -DNDEBUG compile flag.
Definition: hy_assert.hxx:38
HyDataContainer::get_hyEdge
value_type & get_hyEdge(const hyEdge_index_t index)
Get data of hyperedge of given index.
Definition: hy_data_container.hxx:60
diffusion_uniform.const
const
Definition: diffusion_uniform.py:15