Flow123d  release_3.0.0-879-gd0f69e9
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  /// index of component (of vector_value/tensor_value)
44  unsigned int comp_index;
45 };
46 
47 /**
48  * Helper class that allows compute finite element values specified by element dimension.
49  */
50 template <int elemdim, int spacedim, class Value>
52 {
53 public:
54  typedef typename Space<spacedim>::Point Point;
55 
56  /// Constructor.
58 
59  /// Initialize data members
60  void initialize(FEValueInitData init_data);
61  /// Return mapping object
63  ASSERT_PTR(map_).error("Uninitialized FEValueHandler!\n");
64  return map_;
65  }
66  /// Returns one value in one given point.
67  typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm);
68  /// Returns std::vector of scalar values in several points at once.
69  void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
71  /// Compute real coordinates and weights (use QGauss) for given element
72  unsigned int compute_quadrature(std::vector<arma::vec::fixed<3>> & q_points, std::vector<double> & q_weights,
73  const ElementAccessor<spacedim> &elm, unsigned int order=3);
74 
75  /// Destructor.
76  ~FEValueHandler();
77 
78  /// TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
79  inline void set_boundary_dofs_vector(std::shared_ptr< std::vector<LongIdx> > boundary_dofs) {
80  this->boundary_dofs_ = boundary_dofs;
81  }
82 
83  /// TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
84  unsigned int get_dof_indices(const ElementAccessor<3> &cell, std::vector<LongIdx> &indices) const;
85 private:
86  /// DOF handler object
87  std::shared_ptr<DOFHandlerMultiDim> dh_;
88  /// Store data of Field
90  /// Array of indexes to data_vec_, used for get/set values
92  /// Last value, prevents passing large values (vectors) by value.
94  typename Value::return_type r_value_;
95  /// Mapping object.
97  /// Index of component (of vector_value/tensor_value)
98  unsigned int comp_index_;
99 
100  /**
101  * Hold dofs of boundary elements.
102  *
103  * TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
104  */
105  std::shared_ptr< std::vector<LongIdx> > boundary_dofs_;
106 };
107 
108 
109 /**
110  * Specialization for elements with dim==0.
111  */
112 template <int spacedim, class Value>
113 class FEValueHandler<0, spacedim, Value>
114 {
115 public:
116  typedef typename Space<spacedim>::Point Point;
117 
118  /// Constructor.
120  : value_(r_value_) {}
121 
122  /// Initialize data members
123  void initialize(FEValueInitData init_data);
124  /// Returns one value in one given point.
125  typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm) {
126  std::vector<Point> point_list;
127  point_list.push_back(p);
129  v_list.push_back(r_value_);
130  this->value_list(point_list, elm, v_list);
131  this->r_value_ = v_list[0];
132  return this->r_value_;
133  }
134 
135  /// Returns std::vector of scalar values in several points at once.
136  void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
138 
139  /// Destructor.
141 
142  /// TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
143  inline void set_boundary_dofs_vector(std::shared_ptr< std::vector<LongIdx> > boundary_dofs) {
144  this->boundary_dofs_ = boundary_dofs;
145  }
146 
147  /// TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
148  unsigned int get_dof_indices(const ElementAccessor<3> &cell, std::vector<LongIdx> &indices) const;
149 
150 private:
151  /// DOF handler object
152  std::shared_ptr<DOFHandlerMultiDim> dh_;
153  /// Store data of Field
155  /// Array of indexes to data_vec_, used for get/set values
157  /// Last value, prevents passing large values (vectors) by value.
159  typename Value::return_type r_value_;
160 
161  /**
162  * Hold dofs of boundary elements.
163  *
164  * TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
165  */
166  std::shared_ptr< std::vector<LongIdx> > boundary_dofs_;
167 };
168 
169 
170 
171 #endif /* FE_VALUE_HANDLER_HH_ */
unsigned int comp_index
index of component (of vector_value/tensor_value)
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell...
VectorMPI data_vec_
Store data of Field.
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.
unsigned int comp_index_
Index of component (of vector_value/tensor_value)
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.
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.
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
Definition: asserts.hh:335
std::shared_ptr< std::vector< LongIdx > > boundary_dofs_
VectorMPI data_vec_
Store data of Field.
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.
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.