Flow123d  JS_before_hm-1621-g63a12c7
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 private:
114  /// Subobject holds evaluation points data of one dimension (0,1,2,3)
116  public:
117  /// Constructor
118  DimEvalPoints(unsigned int dim);
119 
120  /// Return size of evaluation points object (number of points).
121  inline unsigned int size() const {
122  if (dim_==0) return n_subsets_;
123  else return local_points_.size();
124  }
125 
126  /// Return local coordinates of given local point.
127  template<unsigned int dim>
128  inline arma::vec::fixed<dim> local_point(unsigned int local_point_idx) const {
129  ASSERT_LT_DBG(local_point_idx, this->size());
130  return local_points_.vec<dim>(local_point_idx);
131  }
132 
133  /// Return begin index of appropriate subset data.
134  inline int subset_begin(unsigned int idx) const {
135  ASSERT_LT_DBG(idx, n_subsets());
136  return subset_starts_[idx];
137  }
138 
139  /// Return end index of appropriate subset data.
140  inline int subset_end(unsigned int idx) const {
141  ASSERT_LT_DBG(idx, n_subsets());
142  return subset_starts_[idx+1];
143  }
144 
145  /// Return number of local points corresponding to subset.
146  inline int subset_size(unsigned int idx) const {
147  ASSERT_LT_DBG(idx, n_subsets());
148  return subset_starts_[idx+1] - subset_starts_[idx];
149  }
150 
151  /// Return number of subsets.
152  inline unsigned int n_subsets() const {
153  return n_subsets_;
154  }
155 
156  /// Adds set of local point to local_points_ (bulk or side of given permutation).
157  template <unsigned int dim>
158  void add_local_points(const Armor::Array<double> & quad_points);
159 
160  /// Find position of local point (coords) in subvector of local points given by limits <data_begin, ... data_end)
161  template <unsigned int dim>
162  unsigned int find_permute_point(arma::vec coords, unsigned int data_begin, unsigned int data_end);
163 
164  /// Adds new subset and its end size to subset_starts_ array.
165  void add_subset();
166  private:
167  Armor::Array<double> local_points_; ///< Local coords of points vector
168  std::array<int, EvalPoints::max_subsets+1> subset_starts_; ///< Indices of subsets data in local_points_ vector, used size is n_subsets_ + 1
169  unsigned int n_subsets_; ///< Number of subset
170  unsigned int dim_; ///< Dimension of local points
171  };
172 
173  inline void set_max_size() {
174  max_size_ = std::max( std::max( size(0), size(1) ), std::max( size(2), size(3) ) );
175  }
176 
177  /// Sub objects of dimensions 0,1,2,3
178  std::array<DimEvalPoints, 4> dim_eval_points_;
179 
180  /// Maximal number of used EvalPoints.
181  unsigned int max_size_;
182 
183 };
184 
185 
186 #endif /* EVAL_POINTS_HH_ */
static constexpr unsigned int max_subsets
Maximal number of hold subsets.
Definition: eval_points.hh:49
std::shared_ptr< BulkIntegral > add_bulk(const Quadrature &)
Definition: eval_points.cc:33
int subset_end(unsigned int dim, unsigned int idx) const
Return end index of appropriate subset data.
Definition: eval_points.hh:75
int subset_end(unsigned int idx) const
Return end index of appropriate subset data.
Definition: eval_points.hh:140
Armor::Array< double > local_points_
Local coords of points vector.
Definition: eval_points.hh:167
unsigned int size() const
Definition: armor.hh:728
ArmaVec< double, N > vec
Definition: armor.hh:885
unsigned int n_subsets_
Number of subset.
Definition: eval_points.hh:169
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
unsigned int max_size() const
Return maximal size of evaluation points objects.
Definition: eval_points.hh:109
unsigned int n_subsets() const
Return number of subsets.
Definition: eval_points.hh:152
#define ASSERT_GT(a, b)
Definition of comparative assert macro (Greater Than)
Definition: asserts.hh:312
Definitions of ASSERTS.
static const unsigned int max_subset_points
Maximal average number of points hold in subset.
Definition: eval_points.hh:52
DimEvalPoints(unsigned int dim)
Constructor.
Definition: eval_points.cc:111
Subobject holds evaluation points data of one dimension (0,1,2,3)
Definition: eval_points.hh:115
ArmaVec< Type, nr > vec(uint mat_index) const
Definition: armor.hh:821
static const unsigned int undefined_dim
Undefined dimension of new (empty) object.
Definition: eval_points.hh:46
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
unsigned int max_size_
Maximal number of used EvalPoints.
Definition: eval_points.hh:181
void set_max_size()
Definition: eval_points.hh:173
arma::vec::fixed< dim > local_point(unsigned int local_point_idx) const
Return local coordinates of given local point.
Definition: eval_points.hh:128
std::shared_ptr< EdgeIntegral > add_edge(const Quadrature &)
The same as add_bulk but for edge points on sides.
Definition: eval_points.cc:54
int subset_size(unsigned int dim, unsigned int idx) const
Return number of local points corresponding to subset.
Definition: eval_points.hh:80
std::array< DimEvalPoints, 4 > dim_eval_points_
Sub objects of dimensions 0,1,2,3.
Definition: eval_points.hh:178
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:95
unsigned int find_permute_point(arma::vec coords, unsigned int data_begin, unsigned int data_end)
Find position of local point (coords) in subvector of local points given by limits <data_begin...
Definition: eval_points.cc:129
EvalPoints()
Constructor.
Definition: eval_points.cc:28
int subset_begin(unsigned int idx) const
Return begin index of appropriate subset data.
Definition: eval_points.hh:134
unsigned int size() const
Return size of evaluation points object (number of points).
Definition: eval_points.hh:121
unsigned int size(unsigned int dim) const
Return size of evaluation points object (number of points).
Definition: eval_points.hh:58
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 add_local_points(const Armor::Array< double > &quad_points)
Adds set of local point to local_points_ (bulk or side of given permutation).
Definition: eval_points.cc:119
int subset_size(unsigned int idx) const
Return number of local points corresponding to subset.
Definition: eval_points.hh:146
std::shared_ptr< BoundaryIntegral > add_boundary(const Quadrature &)
The same as add_bulk but for edge points on boundary sides.
Definition: eval_points.cc:104
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:168
void add_subset()
Adds new subset and its end size to subset_starts_ array.
Definition: eval_points.cc:140
Implementation of range helper class.
unsigned int n_subsets(unsigned int dim) const
Return number of subsets.
Definition: eval_points.hh:85
unsigned int dim_
Dimension of local points.
Definition: eval_points.hh:170
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:300