Flow123d  JS_before_hm-1008-g3dab983
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-1].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  return dim_eval_points_[dim-1].local_point<dim>(local_point_idx);
66  }
67 
68  /// Return begin index of appropriate subset data.
69  inline int subset_begin(unsigned int dim, unsigned int idx) const {
70  return dim_eval_points_[dim-1].subset_begin(idx);
71  }
72 
73  /// Return end index of appropriate subset data.
74  inline int subset_end(unsigned int dim, unsigned int idx) const {
75  return dim_eval_points_[dim-1].subset_end(idx);
76  }
77 
78  /// Return number of local points corresponding to subset.
79  inline int subset_size(unsigned int dim, unsigned int idx) const {
80  return dim_eval_points_[dim-1].subset_size(idx);
81  }
82 
83  /// Return number of subsets.
84  inline unsigned int n_subsets(unsigned int dim) const {
85  return dim_eval_points_[dim-1].n_subsets();
86  }
87 
88  /**
89  * Registers point set from quadrature.
90  * Returns an object referencing to the EvalPoints and list of its points.
91  */
92  template <unsigned int dim>
93  std::shared_ptr<BulkIntegral> add_bulk(const Quadrature &);
94 
95  /// The same as add_bulk but for edge points on sides.
96  template <unsigned int dim>
97  std::shared_ptr<EdgeIntegral> add_edge(const Quadrature &);
98 
99  /// The same as add_bulk but for points between side points of element of dim and bulk points of element of dim-1.
100  template <unsigned int dim>
101  std::shared_ptr<CouplingIntegral> add_coupling(const Quadrature &);
102 
103  /// The same as add_bulk but for edge points on boundary sides.
104  template <unsigned int dim>
105  std::shared_ptr<BoundaryIntegral> add_boundary(const Quadrature &);
106 
107  /// Return maximal size of evaluation points objects .
108  inline unsigned int max_size() const {
109  return std::max( size(1), std::max( size(2), size(3) ) );
110  }
111 
112 private:
114  public:
115  /// Constructor
116  DimEvalPoints(unsigned int dim);
117 
118  /// Return size of evaluation points object (number of points).
119  inline unsigned int size() const {
120  return local_points_.size();
121  }
122 
123  /// Return local coordinates of given local point.
124  template<unsigned int dim>
125  inline arma::vec::fixed<dim> local_point(unsigned int local_point_idx) const {
126  ASSERT_LT_DBG(local_point_idx, this->size());
127  return local_points_.vec<dim>(local_point_idx);
128  }
129 
130  /// Return begin index of appropriate subset data.
131  inline int subset_begin(unsigned int idx) const {
132  ASSERT_LT_DBG(idx, n_subsets());
133  return subset_starts_[idx];
134  }
135 
136  /// Return end index of appropriate subset data.
137  inline int subset_end(unsigned int idx) const {
138  ASSERT_LT_DBG(idx, n_subsets());
139  return subset_starts_[idx+1];
140  }
141 
142  /// Return number of local points corresponding to subset.
143  inline int subset_size(unsigned int idx) const {
144  ASSERT_LT_DBG(idx, n_subsets());
145  return subset_starts_[idx+1] - subset_starts_[idx];
146  }
147 
148  /// Return number of subsets.
149  inline unsigned int n_subsets() const {
150  return n_subsets_;
151  }
152 
153  /// Adds set of local point to local_points_ (bulk or side of given permutation).
154  template <unsigned int dim>
155  void add_local_points(const Armor::Array<double> & quad_points);
156 
157  /// Find position of local point (coords) in subvector of local points given by limits <data_begin, ... data_end)
158  template <unsigned int dim>
159  unsigned int find_permute_point(arma::vec coords, unsigned int data_begin, unsigned int data_end);
160 
161  /// Adds new subset and its end size to subset_starts_ array.
162  void add_subset();
163  private:
164  Armor::Array<double> local_points_; ///< Local coords of points vector
165  std::array<int, EvalPoints::max_subsets+1> subset_starts_; ///< Indices of subsets data in local_points_ vector, used size is n_subsets_ + 1
166  unsigned int n_subsets_; ///< Number of subset
167  unsigned int dim_; ///< Dimension of local points
168  };
169 
170  /// Sub objects of dimensions 1,2,3
171  std::array<DimEvalPoints, 3> dim_eval_points_;
172 
173  friend class EvalSubSet;
174 };
175 
176 
177 #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:74
int subset_end(unsigned int idx) const
Return end index of appropriate subset data.
Definition: eval_points.hh:137
Armor::Array< double > local_points_
Local coords of points vector.
Definition: eval_points.hh:164
unsigned int size() const
Definition: armor.hh:718
ArmaVec< double, N > vec
Definition: armor.hh:861
unsigned int n_subsets_
Number of subset.
Definition: eval_points.hh:166
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:108
unsigned int n_subsets() const
Return number of subsets.
Definition: eval_points.hh:149
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:97
ArmaVec< Type, nr > vec(uint mat_index) const
Definition: armor.hh:807
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
arma::vec::fixed< dim > local_point(unsigned int local_point_idx) const
Return local coordinates of given local point.
Definition: eval_points.hh:125
std::shared_ptr< EdgeIntegral > add_edge(const Quadrature &)
The same as add_bulk but for edge points on sides.
Definition: eval_points.cc:43
int subset_size(unsigned int dim, unsigned int idx) const
Return number of local points corresponding to subset.
Definition: eval_points.hh:79
std::array< DimEvalPoints, 3 > dim_eval_points_
Sub objects of dimensions 1,2,3.
Definition: eval_points.hh:171
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:83
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:114
friend class EvalSubSet
Definition: eval_points.hh:173
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:131
unsigned int size() const
Return size of evaluation points object (number of points).
Definition: eval_points.hh:119
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:69
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:105
int subset_size(unsigned int idx) const
Return number of local points corresponding to subset.
Definition: eval_points.hh:143
std::shared_ptr< BoundaryIntegral > add_boundary(const Quadrature &)
The same as add_bulk but for edge points on boundary sides.
Definition: eval_points.cc:92
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:165
void add_subset()
Adds new subset and its end size to subset_starts_ array.
Definition: eval_points.cc:124
Implementation of range helper class.
unsigned int n_subsets(unsigned int dim) const
Return number of subsets.
Definition: eval_points.hh:84
unsigned int dim_
Dimension of local points.
Definition: eval_points.hh:167
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:300