Flow123d  DF_patch_fe_darcy_complete-579fe1e
integral_points.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 integral_points.hh
15  * @brief
16  * @author David Flanderka
17  *
18  * TODO (readability, optimization):
19  * - EdgePoint::point_on is too general, can fail for non-matching sides,
20  * depends on a map;
21  * Iterator over edge sides should know index of side on the edge or
22  * we should directly iterate over pairs of sides and iterate points over both sides
23  * without mapping.
24  * - similarly for Coupling and boundary points
25  * - Points should just hold necessary indices, without reference to complex classes,
26  * these points only can be used as indices to fields to get appropriate value in the field cache
27  */
28 
29 #ifndef INTEGRAL_POINTS_HH_
30 #define INTEGRAL_POINTS_HH_
31 
32 #include <memory>
33 #include <armadillo>
34 #include "fem/eval_points.hh"
35 #include "fem/element_cache_map.hh"
36 #include "mesh/accessors.hh"
37 #include "fem/dh_cell_accessor.hh"
38 
39 
40 class Side;
41 class EdgeIntegral;
42 class CouplingIntegral;
43 class BoundaryIntegral;
44 
45 
46 /**
47  * @brief Base point accessor class.
48  */
49 /**
50  * @brief Point accessor allow iterate over bulk quadrature points defined in local element coordinates.
51  */
52 
53 class BulkPoint {
54 public:
55  /// Default constructor
57  {}
58 
59  /// Constructor
60  BulkPoint(const ElementCacheMap *elm_cache_map, uint elem_idx, uint loc_point_idx)
61  : elm_cache_map_(elm_cache_map), elem_patch_idx_(elem_idx), local_point_idx_(loc_point_idx)
62  {}
63 
64  /// Getter of EvalPoints object.
65  inline std::shared_ptr<EvalPoints> eval_points() const {
66  ASSERT_PTR(elm_cache_map_).error("Invalid point.\n");
67  return elm_cache_map_->eval_points();
68  }
69 
70  // Getter of ElementCacheMap object.
71  inline const ElementCacheMap *elm_cache_map() const {
72  return elm_cache_map_;
73  }
74 
75 
76  // Getter of element patch index.
77  inline unsigned int elem_patch_idx() const {
78  return elem_patch_idx_;
79  }
80 
81  /// Return index in EvalPoints object
82  inline unsigned int eval_point_idx() const {
83  return local_point_idx_;
84  }
85 
86  /// Return index in ElementCacheMap
87  inline unsigned int value_cache_idx() const {
89  }
90 
91  /// Iterates to next point.
92  void inc() {
93  this->local_point_idx_++;
94  }
95 
96  /// Comparison of accessors.
97  bool operator==(const BulkPoint& other) {
99  return (local_point_idx_ == other.local_point_idx_);
100  }
101 
102 
103 protected:
105  /// Index of element in the patch.
106  unsigned int elem_patch_idx_;
107  /// Index of the local point in the integral object.
108  unsigned int local_point_idx_;
109 };
110 
111 
112 
113 
114 /**
115  * @brief General point a+ side_begin_ + ccessor allow iterate over quadrature points of given side defined in local element coordinates.
116  *
117  * Common ancestor of all side points classes (Edge-, Coupling-, BoundaryPoint)
118  */
119 class SidePoint : public BulkPoint {
120 public:
121  /// Default constructor
123  : BulkPoint() {}
124 
125  /// Constructor
126  SidePoint(BulkPoint bulk, uint side_begin)
127  : BulkPoint(bulk), side_begin_(side_begin)
128  {
129  //DebugOut().fmt("begin: {} sidx: {}", side_begin_, local_point_idx_);
130  }
131 
132 
133  /// Constructor
135  const EdgeIntegral *edge_integral, unsigned int local_point_idx);
136 
137  /// Return local index in quadrature. Temporary method - intermediate step in implementation of PatcFEValues.
138  inline unsigned int local_point_idx() const {
139  return local_point_idx_;
140  }
141 
142  /// Return index in EvalPoints object
143  inline unsigned int eval_point_idx() const {
144  return side_begin_ + local_point_idx_;
145  }
146 
147  /// Return index in ElementCacheMap
148  inline unsigned int value_cache_idx() const {
150  }
151 
152  /// Comparison of accessors.
153  bool operator==(const SidePoint& other) {
156  return (local_point_idx_ == other.local_point_idx_);
157  }
158 
159 
160 protected:
161  //// local_point_idx_ here have meaning of index within the side.
162 
163  /// Index of side in element
164  unsigned int side_begin_;
165 
166 };
167 
168 
169 /**
170  * @brief Point accessor allow iterate over quadrature points of given side defined in local element coordinates.
171  */
172 class EdgePoint : public SidePoint {
173 public:
174  /// Default constructor
176  : SidePoint() {}
177 
178  /// Constructor
179  inline EdgePoint(BulkPoint bulk, std::shared_ptr<internal_integrals::Edge> edge_integral, uint side_begin)
180  : SidePoint(bulk, side_begin),
181  integral_(edge_integral)
182  {}
183 
184  /// Return corresponds EdgePoint of neighbour side of same dimension (computing of side integrals).
185  EdgePoint point_on(const DHCellSide &edg_side) const;
186 
187  /// Comparison of accessors.
188  bool operator==(const EdgePoint& other) {
189  return (elem_patch_idx_ == other.elem_patch_idx_) && (local_point_idx_ == other.local_point_idx_);
190  }
191 private:
192  std::shared_ptr<internal_integrals::Edge> integral_;
193 };
194 
195 
196 /**
197  * @brief Point accessor allow iterate over quadrature points of given side defined in local element coordinates.
198  */
199 class CouplingPoint : public SidePoint {
200 public:
201  /// Default constructor
203  : SidePoint() {}
204 
205  /// Constructor
206  inline CouplingPoint(BulkPoint bulk, std::shared_ptr<internal_integrals::Bulk> integral, uint side_begin)
207  : SidePoint(bulk, side_begin),
208  integral_(integral)
209  {}
210 
211  /// Return corresponds EdgePoint of neighbour side of same dimension (computing of side integrals).
212  BulkPoint lower_dim(DHCellAccessor cell_lower) const;
213 
214  /// Comparison of accessors.
215  bool operator==(const CouplingPoint& other) {
216  return (elem_patch_idx_ == other.elem_patch_idx_) && (local_point_idx_ == other.local_point_idx_);
217  }
218 
219 private:
220  /// Pointer to internal bulk integral
221  std::shared_ptr<internal_integrals::Bulk> integral_;
222 };
223 
224 /**
225  * @brief Point accessor allow iterate over quadrature points of given side defined in local element coordinates.
226  */
227 class BoundaryPoint : public SidePoint {
228 public:
229  /// Default constructor
231  : SidePoint() {}
232 
233  /// Constructor
234  inline BoundaryPoint(BulkPoint bulk, std::shared_ptr<internal_integrals::Bulk> integral, uint side_begin)
235  : SidePoint(bulk, side_begin),
236  integral_(integral)
237  {}
238 
239  /// Return corresponds BulkPoint on boundary element.
240  BulkPoint point_bdr(ElementAccessor<3> bdr_elm) const;
241 
242  /// Comparison of accessors.
243  bool operator==(const BoundaryPoint& other) {
244  return (elem_patch_idx_ == other.elem_patch_idx_) && (local_point_idx_ == other.local_point_idx_);
245  }
246 
247 private:
248  /// Pointer to internal bulk integral
249  std::shared_ptr<internal_integrals::Bulk> integral_;
250 };
251 
252 
253 #endif /* INTEGRAL_POINTS_HH_ */
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
Definition: asserts.hh:333
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR) only for debug mode.
Definition: asserts.hh:341
Point accessor allow iterate over quadrature points of given side defined in local element coordinate...
BoundaryPoint(BulkPoint bulk, std::shared_ptr< internal_integrals::Bulk > integral, uint side_begin)
Constructor.
BulkPoint point_bdr(ElementAccessor< 3 > bdr_elm) const
Return corresponds BulkPoint on boundary element.
std::shared_ptr< internal_integrals::Bulk > integral_
Pointer to internal bulk integral.
bool operator==(const BoundaryPoint &other)
Comparison of accessors.
BoundaryPoint()
Default constructor.
Base point accessor class.
const ElementCacheMap * elm_cache_map_
unsigned int elem_patch_idx_
Index of element in the patch.
BulkPoint(const ElementCacheMap *elm_cache_map, uint elem_idx, uint loc_point_idx)
Constructor.
BulkPoint()
Default constructor.
unsigned int value_cache_idx() const
Return index in ElementCacheMap.
std::shared_ptr< EvalPoints > eval_points() const
Getter of EvalPoints object.
bool operator==(const BulkPoint &other)
Comparison of accessors.
const ElementCacheMap * elm_cache_map() const
unsigned int elem_patch_idx() const
unsigned int local_point_idx_
Index of the local point in the integral object.
void inc()
Iterates to next point.
unsigned int eval_point_idx() const
Return index in EvalPoints object.
Point accessor allow iterate over quadrature points of given side defined in local element coordinate...
CouplingPoint(BulkPoint bulk, std::shared_ptr< internal_integrals::Bulk > integral, uint side_begin)
Constructor.
CouplingPoint()
Default constructor.
bool operator==(const CouplingPoint &other)
Comparison of accessors.
std::shared_ptr< internal_integrals::Bulk > integral_
Pointer to internal bulk integral.
BulkPoint lower_dim(DHCellAccessor cell_lower) const
Return corresponds EdgePoint of neighbour side of same dimension (computing of side integrals).
Cell accessor allow iterate over DOF handler cells.
Side accessor allows to iterate over sides of DOF handler cell.
Point accessor allow iterate over quadrature points of given side defined in local element coordinate...
bool operator==(const EdgePoint &other)
Comparison of accessors.
EdgePoint()
Default constructor.
EdgePoint point_on(const DHCellSide &edg_side) const
Return corresponds EdgePoint of neighbour side of same dimension (computing of side integrals).
std::shared_ptr< internal_integrals::Edge > integral_
EdgePoint(BulkPoint bulk, std::shared_ptr< internal_integrals::Edge > edge_integral, uint side_begin)
Constructor.
Directing class of FieldValueCache.
int element_eval_point(unsigned int i_elem_in_cache, unsigned int i_eval_point) const
std::shared_ptr< EvalPoints > eval_points() const
Getter of eval_points object.
General point a+ side_begin_ + ccessor allow iterate over quadrature points of given side defined in ...
SidePoint(BulkPoint bulk, uint side_begin)
Constructor.
SidePoint()
Default constructor.
unsigned int side_begin_
Index of side in element.
bool operator==(const SidePoint &other)
Comparison of accessors.
SidePoint(DHCellSide cell_side, const ElementCacheMap *elm_cache_map, const EdgeIntegral *edge_integral, unsigned int local_point_idx)
Constructor.
unsigned int value_cache_idx() const
Return index in ElementCacheMap.
unsigned int eval_point_idx() const
Return index in EvalPoints object.
unsigned int local_point_idx() const
Return local index in quadrature. Temporary method - intermediate step in implementation of PatcFEVal...
unsigned int uint