Flow123d  JS_before_hm-1728-g5d7ebd453
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_ */
EvalPoints::subset_end
int subset_end(unsigned int dim, unsigned int idx) const
Return end index of appropriate subset data.
Definition: eval_points.hh:75
EvalPoints::DimEvalPoints::local_point
arma::vec::fixed< dim > local_point(unsigned int local_point_idx) const
Return local coordinates of given local point.
Definition: eval_points.hh:128
ASSERT_GT
#define ASSERT_GT(a, b)
Definition of comparative assert macro (Greater Than)
Definition: asserts.hh:312
armor.hh
Armor::vec
ArmaVec< double, N > vec
Definition: armor.hh:885
EvalPoints::DimEvalPoints::add_local_points
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
EvalPoints::local_point
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::DimEvalPoints::subset_size
int subset_size(unsigned int idx) const
Return number of local points corresponding to subset.
Definition: eval_points.hh:146
EvalPoints::set_max_size
void set_max_size()
Definition: eval_points.hh:173
EvalPoints::DimEvalPoints::subset_starts_
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
EvalPoints::DimEvalPoints::n_subsets
unsigned int n_subsets() const
Return number of subsets.
Definition: eval_points.hh:152
Armor::Array::vec
ArmaVec< Type, nr > vec(uint mat_index) const
Definition: armor.hh:821
asserts.hh
Definitions of ASSERTS.
EvalPoints::subset_begin
int subset_begin(unsigned int dim, unsigned int idx) const
Return begin index of appropriate subset data.
Definition: eval_points.hh:70
EvalPoints::undefined_dim
static const unsigned int undefined_dim
Undefined dimension of new (empty) object.
Definition: eval_points.hh:46
EvalPoints::DimEvalPoints
Subobject holds evaluation points data of one dimension (0,1,2,3)
Definition: eval_points.hh:115
ElementAccessor
Definition: dh_cell_accessor.hh:32
EvalPoints::max_size_
unsigned int max_size_
Maximal number of used EvalPoints.
Definition: eval_points.hh:181
EvalPoints::EvalPoints
EvalPoints()
Constructor.
Definition: eval_points.cc:28
EvalPoints::DimEvalPoints::subset_begin
int subset_begin(unsigned int idx) const
Return begin index of appropriate subset data.
Definition: eval_points.hh:134
EvalPoints::max_subset_points
static const unsigned int max_subset_points
Maximal average number of points hold in subset.
Definition: eval_points.hh:52
EdgeIntegral
Definition: eval_subset.hh:307
EvalPoints::add_coupling
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
EvalPoints::max_size
unsigned int max_size() const
Return maximal size of evaluation points objects.
Definition: eval_points.hh:109
CouplingIntegral
Definition: eval_subset.hh:362
EvalPoints::add_boundary
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
BoundaryIntegral
Definition: eval_subset.hh:405
Side
Definition: accessors.hh:361
EvalPoints::add_edge
std::shared_ptr< EdgeIntegral > add_edge(const Quadrature &)
The same as add_bulk but for edge points on sides.
Definition: eval_points.cc:54
EvalPoints::dim_eval_points_
std::array< DimEvalPoints, 4 > dim_eval_points_
Sub objects of dimensions 0,1,2,3.
Definition: eval_points.hh:178
Armor::Array::size
unsigned int size() const
Definition: armor.hh:728
EvalPoints::DimEvalPoints::subset_end
int subset_end(unsigned int idx) const
Return end index of appropriate subset data.
Definition: eval_points.hh:140
EvalPoints::DimEvalPoints::add_subset
void add_subset()
Adds new subset and its end size to subset_starts_ array.
Definition: eval_points.cc:140
EvalPoints::DimEvalPoints::dim_
unsigned int dim_
Dimension of local points.
Definition: eval_points.hh:170
EvalPoints::DimEvalPoints::size
unsigned int size() const
Return size of evaluation points object (number of points).
Definition: eval_points.hh:121
EvalPoints::n_subsets
unsigned int n_subsets(unsigned int dim) const
Return number of subsets.
Definition: eval_points.hh:85
EvalPoints::max_subsets
static constexpr unsigned int max_subsets
Maximal number of hold subsets.
Definition: eval_points.hh:49
EvalPoints::subset_size
int subset_size(unsigned int dim, unsigned int idx) const
Return number of local points corresponding to subset.
Definition: eval_points.hh:80
ASSERT_LT_DBG
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:300
Armor::Array< double >
EvalPoints::DimEvalPoints::find_permute_point
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
Quadrature
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
EvalPoints::DimEvalPoints::local_points_
Armor::Array< double > local_points_
Local coords of points vector.
Definition: eval_points.hh:167
BulkIntegral
Definition: eval_subset.hh:275
EvalPoints::size
unsigned int size(unsigned int dim) const
Return size of evaluation points object (number of points).
Definition: eval_points.hh:58
EvalPoints::DimEvalPoints::DimEvalPoints
DimEvalPoints(unsigned int dim)
Constructor.
Definition: eval_points.cc:111
EvalPoints::DimEvalPoints::n_subsets_
unsigned int n_subsets_
Number of subset.
Definition: eval_points.hh:169
range_wrapper.hh
Implementation of range helper class.
EvalPoints::add_bulk
std::shared_ptr< BulkIntegral > add_bulk(const Quadrature &)
Definition: eval_points.cc:33
EvalPoints
Class holds local coordinations of evaluating points (bulk and sides) specified by element dimension.
Definition: eval_points.hh:43