Flow123d  release_3.0.0-688-g6b683cf
fe_value_handler.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 fe_value_handler.hh
15  * @brief
16  */
17 
18 #ifndef FE_VALUE_HANDLER_HH_
19 #define FE_VALUE_HANDLER_HH_
20 
21 #include "fields/field_values.hh"
22 #include "fem/mapping_p1.hh"
23 #include "fem/finite_element.hh"
24 #include "mesh/point.hh"
25 #include "mesh/long_idx.hh"
26 #include <armadillo>
27 
28 class VectorMPI;
29 template <int spacedim> class ElementAccessor;
30 
31 
32 /// Initialization structure of FEValueHandler class.
34 {
35  /// DOF handler object
36  std::shared_ptr<DOFHandlerMultiDim> dh;
37  /// Store data of Field
39  /// number of dofs
40  unsigned int ndofs;
41  /// number of components
42  unsigned int n_comp;
43 };
44 
45 /**
46  * Helper class that allows compute finite element values specified by element dimension.
47  */
48 template <int elemdim, int spacedim, class Value>
50 {
51 public:
52  typedef typename Space<spacedim>::Point Point;
53 
54  /// Constructor.
56 
57  /// Initialize data members
58  void initialize(FEValueInitData init_data, MappingP1<elemdim,3> *map = nullptr);
59  /// Return mapping object
61  return map_;
62  }
63  /// Returns one value in one given point.
64  typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm);
65  /// Returns std::vector of scalar values in several points at once.
66  void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
68  /// Compute real coordinates and weights (use QGauss) for given element
69  unsigned int compute_quadrature(std::vector<arma::vec::fixed<3>> & q_points, std::vector<double> & q_weights,
70  const ElementAccessor<spacedim> &elm, unsigned int order=3);
71 
72  /// Destructor.
73  ~FEValueHandler();
74 
75  /// TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
76  inline void set_boundary_dofs_vector(std::shared_ptr< std::vector<LongIdx> > boundary_dofs) {
77  this->boundary_dofs_ = boundary_dofs;
78  }
79 
80  /// TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
81  unsigned int get_dof_indices(const ElementAccessor<3> &cell, std::vector<LongIdx> &indices) const;
82 private:
83  /// DOF handler object
84  std::shared_ptr<DOFHandlerMultiDim> dh_;
85  /// Store data of Field
87  /// Array of indexes to data_vec_, used for get/set values
89  /// Last value, prevents passing large values (vectors) by value.
91  typename Value::return_type r_value_;
92  /// Mapping object.
94 
95  /**
96  * Hold dofs of boundary elements.
97  *
98  * TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
99  */
100  std::shared_ptr< std::vector<LongIdx> > boundary_dofs_;
101 };
102 
103 
104 /**
105  * Specialization for elements with dim==0.
106  */
107 template <int spacedim, class Value>
108 class FEValueHandler<0, spacedim, Value>
109 {
110 public:
111  typedef typename Space<spacedim>::Point Point;
112 
113  /// Constructor.
115  : value_(r_value_) {}
116 
117  /// Initialize data members
118  void initialize(FEValueInitData init_data);
119  /// Returns one value in one given point.
120  typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm) {
121  std::vector<Point> point_list;
122  point_list.push_back(p);
124  v_list.push_back(r_value_);
125  this->value_list(point_list, elm, v_list);
126  this->r_value_ = v_list[0];
127  return this->r_value_;
128  }
129 
130  /// Returns std::vector of scalar values in several points at once.
131  void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
133 
134  /// Destructor.
136 
137  /// TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
138  inline void set_boundary_dofs_vector(std::shared_ptr< std::vector<LongIdx> > boundary_dofs) {
139  this->boundary_dofs_ = boundary_dofs;
140  }
141 
142  /// TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
143  unsigned int get_dof_indices(const ElementAccessor<3> &cell, std::vector<LongIdx> &indices) const;
144 
145 private:
146  /// DOF handler object
147  std::shared_ptr<DOFHandlerMultiDim> dh_;
148  /// Store data of Field
150  /// Array of indexes to data_vec_, used for get/set values
152  /// Last value, prevents passing large values (vectors) by value.
154  typename Value::return_type r_value_;
155 
156  /**
157  * Hold dofs of boundary elements.
158  *
159  * TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
160  */
161  std::shared_ptr< std::vector<LongIdx> > boundary_dofs_;
162 };
163 
164 
165 
166 #endif /* FE_VALUE_HANDLER_HH_ */
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell...
void set_boundary_dofs_vector(std::shared_ptr< std::vector< LongIdx > > boundary_dofs)
TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
VectorMPI * data_vec
Store data of Field.
VectorMPI * data_vec_
Store data of Field.
std::vector< LongIdx > dof_indices
Array of indexes to data_vec_, used for get/set values.
Space< spacedim >::Point Point
Value value_
Last value, prevents passing large values (vectors) by value.
Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
Returns one value in one given point.
static constexpr bool value
Definition: json.hpp:87
MappingP1< elemdim, 3 > * map_
Mapping object.
arma::vec::fixed< spacedim > Point
Definition: point.hh:42
Value::return_type r_value_
std::vector< LongIdx > dof_indices
Array of indexes to data_vec_, used for get/set values.
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
unsigned int ndofs
number of dofs
std::shared_ptr< DOFHandlerMultiDim > dh
DOF handler object.
VectorMPI * data_vec_
Store data of Field.
MappingP1< elemdim, 3 > * get_mapping()
Return mapping object.
std::shared_ptr< std::vector< LongIdx > > boundary_dofs_
Value value_
Last value, prevents passing large values (vectors) by value.
std::shared_ptr< std::vector< LongIdx > > boundary_dofs_
void set_boundary_dofs_vector(std::shared_ptr< std::vector< LongIdx > > boundary_dofs)
TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
Abstract class for description of finite elements.
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
unsigned int n_comp
number of components
Initialization structure of FEValueHandler class.