Flow123d  3.9.0-960b954f9
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 
80  // TODO: seems that duplicities are set only at one place and never used
81  // probable meaning is : how many times this intersecion can be reused.
82  // not clear how we can use this, probably can REMOVE
83  unsigned int duplicities() const;
84  void set_duplicities(unsigned int n_duplicities);
85 
86 
87  void set_ips_in_face(unsigned int face_idx);
88 
89  /// Friend output operator.
90  template<unsigned int dimAA, unsigned int dimBB>
91  friend std::ostream& operator<<(std::ostream& os, const IntersectionAux<dimAA,dimBB>& intersection);
92 
93  template<unsigned int, unsigned int>
94  friend class ComputeIntersection;
95 };
96 
97 /********************************************* IMPLEMENTATION ***********************************************/
98 
99 template<unsigned int dimA, unsigned int dimB>
101 { return i_points_; }
102 
103 template<unsigned int dimA, unsigned int dimB>
105 { return i_points_; }
106 
107 template<unsigned int dimA, unsigned int dimB>
109 { ASSERT(index < i_points_.size());
110  return i_points_[index]; }
111 
112 
113 template<unsigned int dimA, unsigned int dimB>
114 inline unsigned int IntersectionAux<dimA,dimB>::size() const
115 { return i_points_.size(); }
116 
117 template<unsigned int dimA, unsigned int dimB>
119 { return component_element_idx_; }
120 
121 template<unsigned int dimA, unsigned int dimB>
122 inline unsigned int IntersectionAux<dimA,dimB>::bulk_ele_idx() const
123 { return bulk_element_idx_; }
124 
125 template<unsigned int dimA, unsigned int dimB>
126 inline unsigned int IntersectionAux<dimA,dimB>::ips_in_face() const
127 { return ips_in_face_;}
128 
129 template<unsigned int dimA, unsigned int dimB>
130 inline unsigned int IntersectionAux<dimA,dimB>::duplicities() const
131 { return n_duplicities_;}
132 
133 template<unsigned int dimA, unsigned int dimB>
134 inline void IntersectionAux<dimA,dimB>::set_duplicities(unsigned int n_duplicities)
135 { n_duplicities_ = n_duplicities; }
136 
137 template<unsigned int dimA, unsigned int dimB>
138 inline void IntersectionAux<dimA,dimB>::set_ips_in_face(unsigned int face_idx)
139 { ips_in_face_ = face_idx; }
140 
141 #endif /* INTERSECTIONAUX_H_ */
IntersectionAux::operator[]
const IntersectionPointAux< dimA, dimB > & operator[](unsigned int index) const
Returns intersection point of given index.
Definition: intersection_aux.hh:108
IntersectionAux::component_ele_idx
unsigned int component_ele_idx() const
Returns index of component element.
Definition: intersection_aux.hh:118
IntersectionAux::IntersectionAux
IntersectionAux()
Default constructor.
Definition: intersection_aux.cc:21
IntersectionAux::i_points_
std::vector< IntersectionPointAux< dimA, dimB > > i_points_
Vector of internal intersection points.
Definition: intersection_aux.hh:39
ASSERT
#define ASSERT(expr)
Definition: asserts.hh:351
IntersectionAux::operator<<
friend std::ostream & operator<<(std::ostream &os, const IntersectionAux< dimAA, dimBB > &intersection)
Friend output operator.
std::vector
Definition: doxy_dummy_defs.hh:7
system.hh
IntersectionAux::set_ips_in_face
void set_ips_in_face(unsigned int face_idx)
Definition: intersection_aux.hh:138
IntersectionAux::points
std::vector< IntersectionPointAux< dimA, dimB > > & points()
Returns intersection points by a reference.
Definition: intersection_aux.hh:100
IntersectionAux::bulk_element_idx_
unsigned int bulk_element_idx_
Index of intersecting element in the bulk.
Definition: intersection_aux.hh:44
IntersectionAux::bulk_ele_idx
unsigned int bulk_ele_idx() const
Returns index of bulk element.
Definition: intersection_aux.hh:122
IntersectionAux::set_duplicities
void set_duplicities(unsigned int n_duplicities)
Definition: intersection_aux.hh:134
IntersectionPointAux
Internal auxiliary class represents an intersection point of simplex<N> and simplex<M>.
Definition: compute_intersection.hh:48
IntersectionAux::ips_in_face_
unsigned int ips_in_face_
Local index of face/side in which all IPs lie.
Definition: intersection_aux.hh:46
IntersectionAux::component_element_idx_
unsigned int component_element_idx_
Index of intersecting element in the component.
Definition: intersection_aux.hh:42
IntersectionAux::~IntersectionAux
virtual ~IntersectionAux()
Destructor.
Definition: intersection_aux.cc:27
IntersectionAux::ips_in_face
unsigned int ips_in_face() const
Returns idx of face when all IPs lie on it; -1 otherwise.
Definition: intersection_aux.hh:126
IntersectionAux::size
unsigned int size() const
Returns number of intersection points.
Definition: intersection_aux.hh:114
IntersectionAux
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
Definition: compute_intersection.hh:47
IntersectionAux::n_duplicities_
unsigned int n_duplicities_
Number of duplicit intersections.
Definition: intersection_aux.hh:48
IntersectionAux::compute_measure
double compute_measure()
IntersectionAux::duplicities
unsigned int duplicities() const
Definition: intersection_aux.hh:130
ComputeIntersection
Definition: compute_intersection.hh:45