Flow123d  DF_patch_fe_data_tables-4eb41dd
eval_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 eval_points.hh
15  * @brief
16  * @author David Flanderka
17  */
18 
19 #ifndef EVAL_POINTS_HH_
20 #define EVAL_POINTS_HH_
21 
22 
23 #include <vector>
24 #include <memory>
25 #include <armadillo>
26 #include "mesh/range_wrapper.hh"
27 #include "system/asserts.hh"
28 #include "system/armor.hh"
29 
30 class Side;
31 class Quadrature;
32 class BulkIntegral;
33 class EdgeIntegral;
34 class CouplingIntegral;
35 class BoundaryIntegral;
36 template <int spacedim> class ElementAccessor;
37 
38 
39 /**
40  * @brief Class holds local coordinations of evaluating points (bulk and sides)
41  * specified by element dimension.
42  */
43 class EvalPoints : public std::enable_shared_from_this<EvalPoints> {
44 public:
45  /// Undefined dimension of new (empty) object
46  static const unsigned int undefined_dim;
47 
48  /// Maximal number of hold subsets.
49  static constexpr unsigned int max_subsets = 10;
50 
51  /// Maximal average number of points hold in subset.
52  static const unsigned int max_subset_points = 30;
53 
54  /// Constructor
55  EvalPoints();
56 
57  /// Return size of evaluation points object (number of points).
58  inline unsigned int size(unsigned int dim) const {
59  return dim_eval_points_[dim].size();
60  }
61 
62  /// Return local coordinates of given local point and appropriate dim.
63  template<unsigned int dim>
64  inline arma::vec::fixed<dim> local_point(unsigned int local_point_idx) const {
65  ASSERT_GT(dim, 0).error("Dimension 0 not supported!\n");
66  return dim_eval_points_[dim].local_point<dim>(local_point_idx);
67  }
68 
69  /// Return begin index of appropriate subset data.
70  inline int subset_begin(unsigned int dim, unsigned int idx) const {
71  return dim_eval_points_[dim].subset_begin(idx);
72  }
73 
74  /// Return end index of appropriate subset data.
75  inline int subset_end(unsigned int dim, unsigned int idx) const {
76  return dim_eval_points_[dim].subset_end(idx);
77  }
78 
79  /// Return number of local points corresponding to subset.
80  inline int subset_size(unsigned int dim, unsigned int idx) const {
81  return dim_eval_points_[dim].subset_size(idx);
82  }
83 
84  /// Return number of subsets.
85  inline unsigned int n_subsets(unsigned int dim) const {
86  return dim_eval_points_[dim].n_subsets();
87  }
88 
89  /**
90  * Registers point set from quadrature.
91  * Returns an object referencing to the EvalPoints and list of its points.
92  */
93  template <unsigned int dim>
94  std::shared_ptr<BulkIntegral> add_bulk(const Quadrature &);
95 
96  /// The same as add_bulk but for edge points on sides.
97  template <unsigned int dim>
98  std::shared_ptr<EdgeIntegral> add_edge(const Quadrature &);
99 
100  /// The same as add_bulk but for points between side points of element of dim and bulk points of element of dim-1.
101  template <unsigned int dim>
102  std::shared_ptr<CouplingIntegral> add_coupling(const Quadrature &);
103 
104  /// The same as add_bulk but for edge points on boundary sides.
105  template <unsigned int dim>
106  std::shared_ptr<BoundaryIntegral> add_boundary(const Quadrature &);
107 
108  /// Return maximal size of evaluation points objects.
109  inline unsigned int max_size() const {
110  return max_size_;
111  }
112 
113  inline void clear() {
114  for (uint i=0; i<4; ++i)
115  dim_eval_points_[i].clear();
116  }
117 
118 private:
119  /// Subobject holds evaluation points data of one dimension (0,1,2,3)
121  public:
122  /// Constructor
123  DimEvalPoints(unsigned int dim);
124 
125  /// Return size of evaluation points object (number of points).
126  inline unsigned int size() const {
127  if (dim_==0) return n_subsets_;
128  else return local_points_.size();
129  }
130 
131  /// Return local coordinates of given local point.
132  template<unsigned int dim>
133  inline arma::vec::fixed<dim> local_point(unsigned int local_point_idx) const {
134  ASSERT_LT(local_point_idx, this->size());
135  return local_points_.vec<dim>(local_point_idx);
136  }
137 
138  /// Return begin index of appropriate subset data.
139  inline int subset_begin(unsigned int idx) const {
140  ASSERT_LT(idx, n_subsets());
141  return subset_starts_[idx];
142  }
143 
144  /// Return end index of appropriate subset data.
145  inline int subset_end(unsigned int idx) const {
146  ASSERT_LT(idx, n_subsets());
147  return subset_starts_[idx+1];
148  }
149 
150  /// Return number of local points corresponding to subset.
151  inline int subset_size(unsigned int idx) const {
152  ASSERT_LT(idx, n_subsets());
153  return subset_starts_[idx+1] - subset_starts_[idx];
154  }
155 
156  /// Return number of subsets.
157  inline unsigned int n_subsets() const {
158  return n_subsets_;
159  }
160 
161  /// Adds set of local point to local_points_ (bulk or side).
162  template <unsigned int dim>
163  void add_local_points(const Armor::Array<double> & quad_points);
164 
165  /// Adds new subset and its end size to subset_starts_ array.
166  uint add_subset();
167 
168  inline void clear() {
170  n_subsets_ = 0;
171  }
172  private:
173  Armor::Array<double> local_points_; ///< Local coords of points vector
174  std::array<int, EvalPoints::max_subsets+1> subset_starts_; ///< Indices of subsets data in local_points_ vector, used size is n_subsets_ + 1
175  unsigned int n_subsets_; ///< Number of subset
176  unsigned int dim_; ///< Dimension of local points
177  };
178 
179  inline void set_max_size() {
180  max_size_ = std::max( std::max( size(0), size(1) ), std::max( size(2), size(3) ) );
181  }
182 
183  /// Sub objects of dimensions 0,1,2,3
184  std::array<DimEvalPoints, 4> dim_eval_points_;
185 
186  /// Maximal number of used EvalPoints.
187  unsigned int max_size_;
188 
189 };
190 
191 
192 #endif /* EVAL_POINTS_HH_ */
Definitions of ASSERTS.
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:301
#define ASSERT_GT(a, b)
Definition of comparative assert macro (Greater Than) only for debug mode.
Definition: asserts.hh:317
void resize(uint size)
Definition: armor.hh:758
ArmaVec< Type, nr > vec(uint mat_index) const
Definition: armor.hh:869
unsigned int size() const
Definition: armor.hh:776
Subobject holds evaluation points data of one dimension (0,1,2,3)
Definition: eval_points.hh:120
unsigned int n_subsets_
Number of subset.
Definition: eval_points.hh:175
int subset_begin(unsigned int idx) const
Return begin index of appropriate subset data.
Definition: eval_points.hh:139
std::array< int, EvalPoints::max_subsets+1 > subset_starts_
Indices of subsets data in local_points_ vector, used size is n_subsets_ + 1.
Definition: eval_points.hh:174
unsigned int size() const
Return size of evaluation points object (number of points).
Definition: eval_points.hh:126
arma::vec::fixed< dim > local_point(unsigned int local_point_idx) const
Return local coordinates of given local point.
Definition: eval_points.hh:133
DimEvalPoints(unsigned int dim)
Constructor.
Definition: eval_points.cc:93
unsigned int n_subsets() const
Return number of subsets.
Definition: eval_points.hh:157
uint add_subset()
Adds new subset and its end size to subset_starts_ array.
Definition: eval_points.cc:113
unsigned int dim_
Dimension of local points.
Definition: eval_points.hh:176
int subset_end(unsigned int idx) const
Return end index of appropriate subset data.
Definition: eval_points.hh:145
Armor::Array< double > local_points_
Local coords of points vector.
Definition: eval_points.hh:173
void add_local_points(const Armor::Array< double > &quad_points)
Adds set of local point to local_points_ (bulk or side).
Definition: eval_points.cc:101
int subset_size(unsigned int idx) const
Return number of local points corresponding to subset.
Definition: eval_points.hh:151
Class holds local coordinations of evaluating points (bulk and sides) specified by element dimension.
Definition: eval_points.hh:43
int subset_begin(unsigned int dim, unsigned int idx) const
Return begin index of appropriate subset data.
Definition: eval_points.hh:70
void set_max_size()
Definition: eval_points.hh:179
std::shared_ptr< CouplingIntegral > add_coupling(const Quadrature &)
The same as add_bulk but for points between side points of element of dim and bulk points of element ...
Definition: eval_points.cc:71
static const unsigned int undefined_dim
Undefined dimension of new (empty) object.
Definition: eval_points.hh:46
unsigned int n_subsets(unsigned int dim) const
Return number of subsets.
Definition: eval_points.hh:85
unsigned int size(unsigned int dim) const
Return size of evaluation points object (number of points).
Definition: eval_points.hh:58
std::shared_ptr< BoundaryIntegral > add_boundary(const Quadrature &)
The same as add_bulk but for edge points on boundary sides.
Definition: eval_points.cc:82
unsigned int max_size() const
Return maximal size of evaluation points objects.
Definition: eval_points.hh:109
int subset_end(unsigned int dim, unsigned int idx) const
Return end index of appropriate subset data.
Definition: eval_points.hh:75
unsigned int max_size_
Maximal number of used EvalPoints.
Definition: eval_points.hh:187
static const unsigned int max_subset_points
Maximal average number of points hold in subset.
Definition: eval_points.hh:52
void clear()
Definition: eval_points.hh:113
int subset_size(unsigned int dim, unsigned int idx) const
Return number of local points corresponding to subset.
Definition: eval_points.hh:80
std::shared_ptr< BulkIntegral > add_bulk(const Quadrature &)
Definition: eval_points.cc:33
std::shared_ptr< EdgeIntegral > add_edge(const Quadrature &)
The same as add_bulk but for edge points on sides.
Definition: eval_points.cc:55
std::array< DimEvalPoints, 4 > dim_eval_points_
Sub objects of dimensions 0,1,2,3.
Definition: eval_points.hh:184
static constexpr unsigned int max_subsets
Maximal number of hold subsets.
Definition: eval_points.hh:49
arma::vec::fixed< dim > local_point(unsigned int local_point_idx) const
Return local coordinates of given local point and appropriate dim.
Definition: eval_points.hh:64
EvalPoints()
Constructor.
Definition: eval_points.cc:28
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
unsigned int uint
Implementation of range helper class.