Flow123d  release_3.0.0-1124-g41e620f
intersection_aux.hh
Go to the documentation of this file.
1 /*!
2  *
3 * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file intersection_aux.hh
15  * @brief Internal class representing intersection object.
16  * @author Pavel Exner
17  *
18  */
19 
20 #ifndef INTERSECTIONAUX_H_
21 #define INTERSECTIONAUX_H_
22 
23 #include "system/system.hh"
24 
25 
26 //forward declare
27 template<unsigned int, unsigned int> class IntersectionPointAux;
28 template<unsigned int, unsigned int> class ComputeIntersection;
29 
30 /** @brief Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
31  *
32  * It contains topology information and auxiliary intersection points.
33  * Used in ComputeIntersection classes.
34  */
35 template<unsigned int dimA, unsigned int dimB>
36 class IntersectionAux{
37 
38  /// Vector of internal intersection points.
40 
41  /// Index of intersecting element in the component.
42  unsigned int component_element_idx_;
43  /// Index of intersecting element in the bulk.
44  unsigned int bulk_element_idx_;
45  /// Local index of face/side in which all IPs lie.
46  unsigned int ips_in_face_;
47  /// Number of duplicit intersections.
48  unsigned int n_duplicities_;
49 
50 public:
51 
52  /// Default constructor.
54  /// Constructor taking in element indices.
55  IntersectionAux(unsigned int component_element_idx,
56  unsigned int bulk_element_idx);
57  /// Destructor.
58  virtual ~IntersectionAux();
59 
60  /// Returns intersection points by a reference.
62 
63  /// Returns intersection points by a constant reference.
65 
66  /// Returns intersection point of given @p index.
67  const IntersectionPointAux<dimA,dimB> &operator[](unsigned int index) const;
68 
69  unsigned int size() const; ///< Returns number of intersection points.
70  unsigned int component_ele_idx() const; ///< Returns index of component element.
71  unsigned int bulk_ele_idx() const; ///< Returns index of bulk element.
72 
73  /// Computes the relative measure of intersection object.
74  /// TODO: unifiy implementation with IntersectionLocalb
75  double compute_measure();
76 
77  /// Returns idx of face when all IPs lie on it; -1 otherwise.
78  unsigned int ips_in_face() const;
79  unsigned int duplicities() const;
80  void set_duplicities(unsigned int n_duplicities);
81  void set_ips_in_face(unsigned int face_idx);
82 
83  /// Friend output operator.
84  template<unsigned int dimAA, unsigned int dimBB>
85  friend std::ostream& operator<<(std::ostream& os, const IntersectionAux<dimAA,dimBB>& intersection);
86 
87  template<unsigned int, unsigned int>
88  friend class ComputeIntersection;
89 };
90 
91 /********************************************* IMPLEMENTATION ***********************************************/
92 
93 template<unsigned int dimA, unsigned int dimB>
95 { return i_points_; }
96 
97 template<unsigned int dimA, unsigned int dimB>
99 { return i_points_; }
100 
101 template<unsigned int dimA, unsigned int dimB>
103 { ASSERT_DBG(index < i_points_.size());
104  return i_points_[index]; }
105 
106 
107 template<unsigned int dimA, unsigned int dimB>
108 inline unsigned int IntersectionAux<dimA,dimB>::size() const
109 { return i_points_.size(); }
110 
111 template<unsigned int dimA, unsigned int dimB>
113 { return component_element_idx_; }
114 
115 template<unsigned int dimA, unsigned int dimB>
116 inline unsigned int IntersectionAux<dimA,dimB>::bulk_ele_idx() const
117 { return bulk_element_idx_; }
118 
119 template<unsigned int dimA, unsigned int dimB>
120 inline unsigned int IntersectionAux<dimA,dimB>::ips_in_face() const
121 { return ips_in_face_;}
122 
123 template<unsigned int dimA, unsigned int dimB>
124 inline unsigned int IntersectionAux<dimA,dimB>::duplicities() const
125 { return n_duplicities_;}
126 
127 template<unsigned int dimA, unsigned int dimB>
128 inline void IntersectionAux<dimA,dimB>::set_duplicities(unsigned int n_duplicities)
129 { n_duplicities_ = n_duplicities; }
130 
131 template<unsigned int dimA, unsigned int dimB>
132 inline void IntersectionAux<dimA,dimB>::set_ips_in_face(unsigned int face_idx)
133 { ips_in_face_ = face_idx; }
134 
135 #endif /* INTERSECTIONAUX_H_ */
std::vector< IntersectionPointAux< dimA, dimB > > i_points_
Vector of internal intersection points.
unsigned int component_ele_idx() const
Returns index of component element.
unsigned int component_element_idx_
Index of intersecting element in the component.
virtual ~IntersectionAux()
Destructor.
const IntersectionPointAux< dimA, dimB > & operator[](unsigned int index) const
Returns intersection point of given index.
unsigned int size() const
Returns number of intersection points.
unsigned int bulk_ele_idx() const
Returns index of bulk element.
unsigned int n_duplicities_
Number of duplicit intersections.
void set_duplicities(unsigned int n_duplicities)
std::vector< IntersectionPointAux< dimA, dimB > > & points()
Returns intersection points by a reference.
IntersectionAux()
Default constructor.
unsigned int duplicities() const
unsigned int bulk_element_idx_
Index of intersecting element in the bulk.
#define ASSERT_DBG(expr)
Definition: asserts.hh:349
void set_ips_in_face(unsigned int face_idx)
Internal auxiliary class represents an intersection point of simplex<N> and simplex<M>.
unsigned int ips_in_face_
Local index of face/side in which all IPs lie.
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
double compute_measure()
unsigned int ips_in_face() const
Returns idx of face when all IPs lie on it; -1 otherwise.