Flow123d  release_3.0.0-506-g34af125
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/vec_seq_double.hh"
22 #include "fields/field_values.hh"
23 #include "fem/mapping_p1.hh"
24 #include "fem/finite_element.hh"
25 #include "mesh/point.hh"
26 #include "mesh/long_idx.hh"
27 #include <armadillo>
28 
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 
69  /// Destructor.
70  ~FEValueHandler();
71 private:
72  /// DOF handler object
73  std::shared_ptr<DOFHandlerMultiDim> dh_;
74  /// Store data of Field
76  /// Array of indexes to data_vec_, used for get/set values
78  /// Last value, prevents passing large values (vectors) by value.
80  typename Value::return_type r_value_;
81  /// Mapping object.
83 };
84 
85 
86 /**
87  * Specialization for elements with dim==0.
88  */
89 template <int spacedim, class Value>
90 class FEValueHandler<0, spacedim, Value>
91 {
92 public:
93  typedef typename Space<spacedim>::Point Point;
94 
95  /// Constructor.
97  : value_(r_value_) {}
98 
99  /// Initialize data members
100  void initialize(FEValueInitData init_data);
101  /// Returns one value in one given point.
102  typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm) {
103  std::vector<Point> point_list;
104  point_list.push_back(p);
106  v_list.push_back(r_value_);
107  this->value_list(point_list, elm, v_list);
108  this->r_value_ = v_list[0];
109  return this->r_value_;
110  }
111 
112  /// Returns std::vector of scalar values in several points at once.
113  void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
115 
116  /// Destructor.
118 private:
119  /// DOF handler object
120  std::shared_ptr<DOFHandlerMultiDim> dh_;
121  /// Store data of Field
123  /// Array of indexes to data_vec_, used for get/set values
125  /// Last value, prevents passing large values (vectors) by value.
127  typename Value::return_type r_value_;
128 };
129 
130 
131 
132 #endif /* FE_VALUE_HANDLER_HH_ */
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell...
VectorSeqDouble * 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_
VectorSeqDouble * data_vec
Store data of Field.
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
VectorSeqDouble * data_vec_
Store data of Field.
std::shared_ptr< DOFHandlerMultiDim > dh
DOF handler object.
MappingP1< elemdim, 3 > * get_mapping()
Return mapping object.
Value value_
Last value, prevents passing large values (vectors) by value.
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.