Flow123d  DF_patch_fe_mechanics-5faa023
patch_point_values.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 patch_point_values.hh
15  * @brief Store finite element data on the actual patch
16  * such as shape function values, gradients, Jacobian
17  * of the mapping from the reference cell etc.
18  * @author David Flanderka
19  */
20 
21 #ifndef PATCH_POINT_VALUES_HH_
22 #define PATCH_POINT_VALUES_HH_
23 
24 #include <Eigen/Dense>
25 
26 #include "fem/eigen_tools.hh"
28 #include "fem/arena_resource.hh"
29 #include "fem/arena_vec.hh"
30 #include "mesh/accessors.hh"
31 
32 
33 
34 using Scalar = double;
37 
38 
39 /// Distinguishes operations by type and size of output rows
41 {
42  elemOp, ///< operation is evaluated on elements or sides
43  pointOp, ///< operation is evaluated on quadrature points
44  fixedSizeOp ///< operation has fixed size and it is filled during initialization
45 };
46 
47 
48 
49 /**
50  * v Class for storing FE data of quadrature points on one patch.
51  *
52  * Store data of bulk or side quadrature points of one dimension.
53  */
54 template<unsigned int spacedim = 3>
56 {
57 public:
58  /**
59  * Stores shared data members between PatchFeValues and PatchPoinValues
60  */
61  struct PatchFeData {
62  public:
63  /// Constructor
64  PatchFeData(size_t buffer_size, size_t simd_alignment)
65  : asm_arena_(buffer_size, simd_alignment), patch_arena_(nullptr) {}
66 
67  /// Destructor
69  if (patch_arena_!=nullptr)
70  delete patch_arena_;
71  }
72 
73  AssemblyArena asm_arena_; ///< Assembly arena, created and filled once during initialization
74  PatchArena *patch_arena_; ///< Patch arena, reseted before patch reinit
75  ArenaVec<double> zero_vec_; ///< ArenaVec of zero values of maximal length using in zero PatchPointValues construction
76  };
77 
78  /**
79  * Constructor
80  *
81  * @param dim Set dimension
82  */
83  PatchPointValues(uint dim, uint quad_order, bool is_bulk, PatchFeData &patch_fe_data)
84  : elements_map_(300, 0), points_map_(300, 0), patch_fe_data_(patch_fe_data) {
85  reset();
86 
87  if (is_bulk) {
88  this->quad_ = new QGauss(dim, 2*quad_order);
89  this->int_sizes_ = {pointOp, pointOp, pointOp};
90  } else {
91  this->quad_ = new QGauss(dim-1, 2*quad_order);
92  this->int_sizes_ = {pointOp, pointOp, pointOp, elemOp, pointOp};
93  }
94  }
95 
96  /**
97  * Destructor.
98  */
99  virtual ~PatchPointValues() {}
100 
101  /**
102  * Initialize object, set number of columns (quantities) in tables.
103  */
104  void initialize() {
105  this->reset();
106  int_table_.resize(int_sizes_.size());
107  }
108 
109  /// Reset number of columns (points and elements)
110  inline void reset() {
111  n_points_ = 0;
112  n_elems_ = 0;
113  i_elem_ = 0;
114  elem_list_.clear();
115  side_list_.clear();
116  }
117 
118  /// Getter for n_elems_
119  inline uint n_elems() const {
120  return n_elems_;
121  }
122 
123  /// Getter for n_points_
124  inline uint n_points() const {
125  return n_points_;
126  }
127 
128  /// Getter for quadrature
130  return quad_;
131  }
132 
133  /// Resize data tables. Method is called before reinit of patch.
135  n_elems_ = n_elems;
138  for (uint i=0; i<int_table_.rows(); ++i) {
140  }
141  std::fill(elements_map_.begin(), elements_map_.end(), (uint)-1);
142  }
143 
144  /**
145  * Register bulk point, add to int_table_
146  *
147  * @param elem_table_row Index of element in temporary element table.
148  * @param value_patch_idx Index of point in ElementCacheMap.
149  * @param elem_idx Index of element in Mesh.
150  * @param i_point_on_elem Index of point on element
151  */
152  uint register_bulk_point(uint elem_table_row, uint value_patch_idx, uint elem_idx, uint i_point_on_elem) {
153  uint point_pos = i_point_on_elem * n_elems_ + elem_table_row; // index of bulk point on patch
154  int_table_(0)(point_pos) = value_patch_idx;
155  int_table_(1)(point_pos) = elem_table_row;
156  int_table_(2)(point_pos) = elem_idx;
157 
158  points_map_[value_patch_idx] = point_pos;
159  return point_pos;
160  }
161 
162  /**
163  * Register side point, add to int_table_
164  *
165  * @param elem_table_row Index of side in temporary element table.
166  * @param value_patch_idx Index of point in ElementCacheMap.
167  * @param elem_idx Index of element in Mesh.
168  * @param side_idx Index of side on element.
169  * @param i_point_on_side Index of point on side
170  */
171  uint register_side_point(uint elem_table_row, uint value_patch_idx, uint elem_idx, uint side_idx, uint i_point_on_side) {
172  uint point_pos = i_point_on_side * n_elems_ + elem_table_row; // index of side point on patch
173  int_table_(0)(point_pos) = value_patch_idx;
174  int_table_(1)(point_pos) = elem_table_row;
175  int_table_(2)(point_pos) = elem_idx;
176  int_table_(4)(point_pos) = side_idx;
177 
178  points_map_[value_patch_idx] = point_pos;
179  return point_pos;
180  }
181 
182  /// return reference to assembly arena
183  inline AssemblyArena &asm_arena() const {
184  return patch_fe_data_.asm_arena_;
185  }
186 
187  /// return reference to patch arena
188  inline PatchArena &patch_arena() const {
190  }
191 
192  template<class ElementDomain>
193  NodeAccessor<spacedim> node(unsigned int i_elm, unsigned int i_n);
194 
195 //protected:
196 
197  /**
198  * Hold integer values of quadrature points of defined operations.
199  *
200  * Table contains following rows:
201  * 0: Index of quadrature point on patch
202  * 1: Row of element/side in PatchOp::result_ table in registration step (before expansion)
203  * 2: Element idx in Mesh
204  * - last two rows are allocated only for side point table
205  * 3: Index of side in element - short vector, size of column = number of sides
206  * 4: Index of side in element - long vector, size of column = number of points
207  * Number of used rows is given by n_points_.
208  */
210 
211  /// Set size and type of rows of int_table_, value is set implicitly in constructor of descendants
213 
214 
215  uint n_points_; ///< Number of points in patch
216  uint n_elems_; ///< Number of elements in patch
217  uint i_elem_; ///< Index of registered element in table, helper value used during patch creating.
218  Quadrature *quad_; ///< Quadrature of given dimension and order passed in constructor.
219 
220  std::vector<uint> elements_map_; ///< Map of element patch indices to PatchOp::result_ and int_table_ tables
221  std::vector<uint> points_map_; ///< Map of point patch indices to PatchOp::result_ and int_table_ tables
222 
223  PatchFeData &patch_fe_data_; ///< Reference to PatchFeData structure shared with PatchFeValues
224 
225  std::vector<ElementAccessor<spacedim>> elem_list_; ///< List of elements on patch
226  std::vector<Side> side_list_; ///< List of sides on patch
227 };
228 
229 
230 
231 #endif /* PATCH_POINT_VALUES_HH_ */
PatchArena & patch_arena() const
return reference to patch arena
std::vector< ElementAccessor< spacedim > > elem_list_
List of elements on patch.
std::vector< uint > points_map_
Map of point patch indices to PatchOp::result_ and int_table_ tables.
uint register_bulk_point(uint elem_table_row, uint value_patch_idx, uint elem_idx, uint i_point_on_elem)
PatchPointValues(uint dim, uint quad_order, bool is_bulk, PatchFeData &patch_fe_data)
void resize_tables(uint n_elems, uint n_points)
Resize data tables. Method is called before reinit of patch.
Quadrature * get_quadrature() const
Getter for quadrature.
uint n_elems() const
Getter for n_elems_.
uint i_elem_
Index of registered element in table, helper value used during patch creating.
PatchFeData & patch_fe_data_
Reference to PatchFeData structure shared with PatchFeValues.
void reset()
Reset number of columns (points and elements)
uint n_points() const
Getter for n_points_.
std::vector< uint > elements_map_
Map of element patch indices to PatchOp::result_ and int_table_ tables.
AssemblyArena & asm_arena() const
return reference to assembly arena
NodeAccessor< spacedim > node(unsigned int i_elm, unsigned int i_n)
uint register_side_point(uint elem_table_row, uint value_patch_idx, uint elem_idx, uint side_idx, uint i_point_on_side)
IntTableArena int_table_
uint n_points_
Number of points in patch.
std::vector< Side > side_list_
List of sides on patch.
Quadrature * quad_
Quadrature of given dimension and order passed in constructor.
std::vector< OpSizeType > int_sizes_
Set size and type of rows of int_table_, value is set implicitly in constructor of descendants.
uint n_elems_
Number of elements in patch.
Symmetric Gauss-Legendre quadrature formulae on simplices.
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
Store finite element data on the actual patch such as shape function values, gradients,...
Eigen::Vector< ArenaVec< uint >, Eigen::Dynamic > IntTableArena
Definition: eigen_tools.hh:39
unsigned int uint
double Scalar
Definition: op_accessors.hh:25
OpSizeType
Distinguishes operations by type and size of output rows.
@ pointOp
operation is evaluated on quadrature points
@ elemOp
operation is evaluated on elements or sides
@ fixedSizeOp
operation has fixed size and it is filled during initialization
Definitions of particular quadrature rules on simplices.
AssemblyArena asm_arena_
Assembly arena, created and filled once during initialization.
ArenaVec< double > zero_vec_
ArenaVec of zero values of maximal length using in zero PatchPointValues construction.
PatchFeData(size_t buffer_size, size_t simd_alignment)
Constructor.
PatchArena * patch_arena_
Patch arena, reseted before patch reinit.