HyperHDG
file.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>
5 
6 #include <string>
7 
8 namespace NodeDescriptor
9 {
10 /*!*************************************************************************************************
11  * \brief Hypergraph topology based on an input file.
12  *
13  * The node descriptor class of a hypergraph which is read from a file. Thus, this class uses the
14  * file's information on hypernode types and returns them.
15  *
16  * \authors Guido Kanschat, Heidelberg University, 2019--2020.
17  * \authors Andreas Rupp, Heidelberg University, 2019--2020.
18  **************************************************************************************************/
19 template <unsigned int hyEdge_dimT,
20  unsigned int space_dimT,
21  template <typename...> typename vectorT = std::vector,
22  typename pointT = Point<space_dimT, float>,
23  typename hyEdge_index_t = unsigned int,
24  typename hyNode_index_t = hyEdge_index_t,
25  typename pt_index_t = hyNode_index_t>
26 class File
27 {
28  /*!***********************************************************************************************
29  * \brief Definition of the node types of a hypergraph's edges.
30  ************************************************************************************************/
31  class hyEdge
32  {
33  public:
34  static constexpr unsigned int n_hyNodes() { return 2 * hyEdge_dimT; }
35  /*!*********************************************************************************************
36  * \brief Return dimension of the hyperedge.
37  **********************************************************************************************/
38  static constexpr unsigned int hyEdge_dim() { return hyEdge_dimT; }
39  /*!*********************************************************************************************
40  * \brief Return dimension of the surrounding space.
41  **********************************************************************************************/
42  static constexpr unsigned int space_dim() { return space_dimT; }
43 
44  private:
45  /*!*********************************************************************************************
46  * \brief Reference to parent hypergraph.
47  **********************************************************************************************/
49  /*!*********************************************************************************************
50  * \brief Index of the hyperedge within the hypergraph
51  **********************************************************************************************/
52  const hyEdge_index_t index_;
53 
54  /*!*********************************************************************************************
55  * \brief Indices of the hypernodes adjacent to the hyperedge.
56  **********************************************************************************************/
57  std::array<hyNode_index_t, 2 * hyEdge_dimT> hyFace_types_;
58 
59  public:
60  /*!*********************************************************************************************
61  * \brief Construct hyperedge from hypergraph and index.
62  **********************************************************************************************/
63  hyEdge(const File& node_desc, const hyEdge_index_t index)
64  : hyGraph_topology_(node_desc), index_(index)
65  {
66  hyFace_types_ = node_desc.domain_info_
67  .hyFaces_hyEdge[index / Wrapper::n_elements(node_desc.tpcc_ref_elem_)];
68 
70  node_desc.tpcc_ref_elem_, index % Wrapper::n_elements(node_desc.tpcc_ref_elem_));
71  for (unsigned int i = 0; i < hyFace_types_.size(); ++i)
72  {
73  Wrapper::tpcc_elem_t<hyEdge_dimT - 1, hyEdge_dimT> face = Wrapper::get_face(ref_elem, i);
74  if (Wrapper::exterior_coordinate(face, 0) != 0 &&
75  Wrapper::exterior_coordinate(face, 0) != node_desc.n_subintervals_)
76  hyFace_types_[i] = 0;
77  }
78  }
79  /*!*********************************************************************************************
80  * \brief Return hypernode types of the \c hyEdge.
81  **********************************************************************************************/
82  const auto& get_hyFaces_types() const { return hyFace_types_; }
83  /*!*********************************************************************************************
84  * \brief Return hypernode type of given index.
85  **********************************************************************************************/
86  unsigned int operator[](const unsigned int index) const { return hyFace_types_[index]; }
87  }; // end of class hyEdge
88 
89  public:
90  /*!***********************************************************************************************
91  * \brief Return local dimension of the hypergraph's hyperedges.
92  ************************************************************************************************/
93  static constexpr unsigned int hyEdge_dim() { return hyEdge_dimT; }
94  /*!***********************************************************************************************
95  * \brief Return dimension of the surrounding space.
96  ************************************************************************************************/
97  static constexpr unsigned int space_dim() { return space_dimT; }
98 
99  private:
100  /*!***********************************************************************************************
101  * \brief Domain Info containing all the information of the hypergraph (cf. ReadDomain.hxx).
102  ************************************************************************************************/
103  const DomainInfo<hyEdge_dimT,
104  space_dimT,
105  vectorT,
106  pointT,
107  hyEdge_index_t,
108  hyNode_index_t,
109  pt_index_t>& domain_info_;
110 
111  /*!***********************************************************************************************
112  * \brief Refinment level corresponds to number of subintervals per dimension.
113  ************************************************************************************************/
114  unsigned int n_subintervals_;
115  /*!***********************************************************************************************
116  * \brief Tensor product chain complex for refined elements of hypergedge.
117  ************************************************************************************************/
119  /*!***********************************************************************************************
120  * \brief Total amount of hyperedges in hypergraph.
121  ************************************************************************************************/
122  hyEdge_index_t n_hyEdges_;
123 
124  public:
125  /*!***********************************************************************************************
126  * \brief Define the return value of the class.
127  ************************************************************************************************/
129  /*!***********************************************************************************************
130  * \brief Defines the value type of input argument for standard constructor.
131  ************************************************************************************************/
132  typedef Topology::
133  File<hyEdge_dimT, space_dimT, vectorT, pointT, hyEdge_index_t, hyNode_index_t, pt_index_t>
135  /*!***********************************************************************************************
136  * \brief Construct a node descriptor from a file topology.
137  ************************************************************************************************/
139  : domain_info_(topology.domain_info()),
141  tpcc_ref_elem_(topology.tpcc_ref_elem()),
142  n_hyEdges_(topology.n_hyEdges())
143  {
144  }
145  /*!***********************************************************************************************
146  * \brief Copy constructor.
147  ************************************************************************************************/
148  File(const File<hyEdge_dimT,
149  space_dimT,
150  vectorT,
151  pointT,
152  hyEdge_index_t,
153  hyNode_index_t,
154  pt_index_t>& other)
155  : domain_info_(other.domain_info),
156  n_subintervals_(1),
158  Wrapper::create_tpcc<hyEdge_dimT, hyEdge_dimT, TPCC::boundaries::both, hyEdge_index_t>(
159  SmallVec<hyEdge_dimT, unsigned int>(n_subintervals_))),
160  n_hyEdges_(domain_info_.n_hyEdges)
161  {
162  }
163 
164  /*!***********************************************************************************************
165  * \brief Return hyperegde of given index.
166  ************************************************************************************************/
167  value_type operator[](const hyEdge_index_t index) const { return get_hyEdge(index); }
168  /*!***********************************************************************************************
169  * \brief Return hyperedge of given index.
170  ************************************************************************************************/
171  value_type get_hyEdge(const hyEdge_index_t index) const
172  {
174  "Index must be non-negative and smaller than "
175  << domain_info_.n_hyEdges << " (which is the amount of hyperedges). It was "
176  << index << "!");
177  return hyEdge(*this, index);
178  }
179  /*!***********************************************************************************************
180  * \brief Return the refinement level (equal to number of subintervals).
181  ************************************************************************************************/
182  unsigned int get_refinement() const { return n_subintervals_; }
183  /*!***********************************************************************************************
184  * \brief Set the refinement level (equal to number of subintervals).
185  ************************************************************************************************/
186  void set_refinement(unsigned int level)
187  {
188  n_subintervals_ = level;
190  Wrapper::create_tpcc<hyEdge_dimT, hyEdge_dimT, TPCC::boundaries::both, hyEdge_index_t>(
193  }
194 }; // end of class File
195 
196 } // namespace NodeDescriptor
TPCC::Element
Tensor coordinates for a facet of dimension k in the complex of dimension n.
Definition: element.h:38
NodeDescriptor::File::hyEdge::hyEdge_dim
static constexpr unsigned int hyEdge_dim()
Return dimension of the hyperedge.
Definition: file.hxx:38
hy_assert.hxx
This file provides the function hy_assert.
NodeDescriptor::File::File
File(const File< hyEdge_dimT, space_dimT, vectorT, pointT, hyEdge_index_t, hyNode_index_t, pt_index_t > &other)
Copy constructor.
Definition: file.hxx:148
Wrapper
A namespace containing the different wrapper functions.
Definition: lapack.hxx:20
NodeDescriptor::File::hyEdge::index_
const hyEdge_index_t index_
Index of the hyperedge within the hypergraph.
Definition: file.hxx:52
check_push_test.index
index
Definition: check_push_test.py:10
TPCC::both
@ both
Definition: lexicographic.h:11
NodeDescriptor::File::hyEdge::hyEdge
hyEdge(const File &node_desc, const hyEdge_index_t index)
Construct hyperedge from hypergraph and index.
Definition: file.hxx:63
NodeDescriptor::File::hyEdge::space_dim
static constexpr unsigned int space_dim()
Return dimension of the surrounding space.
Definition: file.hxx:42
NodeDescriptor::File::n_hyEdges_
hyEdge_index_t n_hyEdges_
Total amount of hyperedges in hypergraph.
Definition: file.hxx:122
Topology::File
Hypergraph topology based on an input file.
Definition: file.hxx:43
NodeDescriptor::File::tpcc_ref_elem_
Wrapper::tpcc_t< hyEdge_dimT, hyEdge_dimT, TPCC::boundaries::both, hyNode_index_t > tpcc_ref_elem_
Tensor product chain complex for refined elements of hypergedge.
Definition: file.hxx:118
TPCC::boundaries
boundaries
Definition: lexicographic.h:9
NodeDescriptor::File::domain_info_
const DomainInfo< hyEdge_dimT, space_dimT, vectorT, pointT, hyEdge_index_t, hyNode_index_t, pt_index_t > & domain_info_
Domain Info containing all the information of the hypergraph (cf. ReadDomain.hxx).
Definition: file.hxx:109
NodeDescriptor::File::hyEdge::n_hyNodes
static constexpr unsigned int n_hyNodes()
Definition: file.hxx:34
Wrapper::exterior_coordinate
unsigned int exterior_coordinate(const auto &elem, const unsigned int index)
Return coordinate value with respect to index-th orthonormal direction on element.
Definition: tpcc.hxx:150
NodeDescriptor::File::hyEdge::hyFace_types_
std::array< hyNode_index_t, 2 *hyEdge_dimT > hyFace_types_
Indices of the hypernodes adjacent to the hyperedge.
Definition: file.hxx:57
Wrapper::get_face
auto get_face(const auto &elem, const unsigned int index)
Return i-th element facet.
Definition: tpcc.hxx:121
file.hxx
Wrapper::get_element
auto get_element(const auto &tpcc, const auto index)
Return the element of given index the TPCC.
Definition: tpcc.hxx:92
NodeDescriptor::File
Hypergraph topology based on an input file.
Definition: file.hxx:26
TPCC
Definition: combinations.h:8
Wrapper::n_elements
index_t n_elements(const auto &tpcc)
Return the element of given index the TPCC.
Definition: tpcc.hxx:80
TPCC::Lexicographic
Lexicographic enumeration of the k-dimensional faces in a tensor product chain complex of dimension n...
Definition: lexicographic.h:44
NodeDescriptor::File::hyEdge_dim
static constexpr unsigned int hyEdge_dim()
Return local dimension of the hypergraph's hyperedges.
Definition: file.hxx:93
NodeDescriptor::File::hyEdge::hyGraph_topology_
const File & hyGraph_topology_
Reference to parent hypergraph.
Definition: file.hxx:48
NodeDescriptor::File::n_subintervals_
unsigned int n_subintervals_
Refinment level corresponds to number of subintervals per dimension.
Definition: file.hxx:114
NodeDescriptor::File::value_type
hyEdge value_type
Define the return value of the class.
Definition: file.hxx:128
NodeDescriptor::File::operator[]
value_type operator[](const hyEdge_index_t index) const
Return hyperegde of given index.
Definition: file.hxx:167
NodeDescriptor::File::File
File(const constructor_value_type &topology)
Construct a node descriptor from a file topology.
Definition: file.hxx:138
NodeDescriptor::File::hyEdge::get_hyFaces_types
const auto & get_hyFaces_types() const
Return hypernode types of the hyEdge.
Definition: file.hxx:82
NodeDescriptor::File::space_dim
static constexpr unsigned int space_dim()
Return dimension of the surrounding space.
Definition: file.hxx:97
NodeDescriptor::File::get_refinement
unsigned int get_refinement() const
Return the refinement level (equal to number of subintervals).
Definition: file.hxx:182
hy_assert
#define hy_assert(Expr, Msg)
The assertion to be used within HyperHDG — deactivate using -DNDEBUG compile flag.
Definition: hy_assert.hxx:38
NodeDescriptor::File::hyEdge
Definition of the node types of a hypergraph's edges.
Definition: file.hxx:31
NodeDescriptor
A namespace containing different classes describing the types of hypernodes.
Definition: cubic.hxx:7
diffusion_uniform.topology
topology
Definition: diffusion_uniform.py:18
NodeDescriptor::File::hyEdge::operator[]
unsigned int operator[](const unsigned int index) const
Return hypernode type of given index.
Definition: file.hxx:86
Wrapper::create_tpcc
tpcc_t< hyEdge_dim, space_dim, bndT, index_t > create_tpcc(const SmallVec< space_dim, index_t > &vec)
Create a tensor product chain complex.
Definition: tpcc.hxx:62
NodeDescriptor::File::get_hyEdge
value_type get_hyEdge(const hyEdge_index_t index) const
Return hyperedge of given index.
Definition: file.hxx:171
DomainInfo
Hold all topological and geometrical information of a hypergraph.
Definition: read_domain.hxx:59
NodeDescriptor::File::constructor_value_type
Topology::File< hyEdge_dimT, space_dimT, vectorT, pointT, hyEdge_index_t, hyNode_index_t, pt_index_t > constructor_value_type
Defines the value type of input argument for standard constructor.
Definition: file.hxx:134
SmallMat
This class implements a small/dense matrix.
Definition: dense_la.hxx:34
NodeDescriptor::File::set_refinement
void set_refinement(unsigned int level)
Set the refinement level (equal to number of subintervals).
Definition: file.hxx:186