Flow123d  release_3.0.0-968-gc87a28e79
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.
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_ */
FEValueHandler::~FEValueHandler
~FEValueHandler()
Destructor.
Definition: fe_value_handler.cc:226
FEValueHandler< 0, spacedim, Value >::r_value_
Value::return_type r_value_
Definition: fe_value_handler.hh:159
FEValueHandler::Point
Space< spacedim >::Point Point
Definition: fe_value_handler.hh:54
FEValueHandler< 0, spacedim, Value >::value_
Value value_
Last value, prevents passing large values (vectors) by value.
Definition: fe_value_handler.hh:158
FEValueHandler::initialize
void initialize(FEValueInitData init_data)
Initialize data members.
Definition: fe_value_handler.cc:94
FEValueHandler< 0, spacedim, Value >::Point
Space< spacedim >::Point Point
Definition: fe_value_handler.hh:116
point.hh
FEValueHandler::comp_index_
unsigned int comp_index_
Index of component (of vector_value/tensor_value)
Definition: fe_value_handler.hh:98
std::vector
Definition: doxy_dummy_defs.hh:7
ElementAccessor
Definition: fe_value_handler.hh:29
FEValueHandler::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
Definition: fe_value_handler.hh:87
FEValueHandler< 0, spacedim, Value >::data_vec_
VectorMPI data_vec_
Store data of Field.
Definition: fe_value_handler.hh:154
Space::Point
arma::vec::fixed< spacedim > Point
Definition: point.hh:42
FEValueInitData::dh
std::shared_ptr< DOFHandlerMultiDim > dh
DOF handler object.
Definition: fe_value_handler.hh:36
FEValueHandler::dof_indices
std::vector< LongIdx > dof_indices
Array of indexes to data_vec_, used for get/set values.
Definition: fe_value_handler.hh:91
FEValueHandler< 0, spacedim, Value >::boundary_dofs_
std::shared_ptr< std::vector< LongIdx > > boundary_dofs_
Definition: fe_value_handler.hh:166
finite_element.hh
Abstract class for description of finite elements.
FEValueHandler::map_
MappingP1< elemdim, 3 > * map_
Mapping object.
Definition: fe_value_handler.hh:96
FEValueHandler::r_value_
Value::return_type r_value_
Definition: fe_value_handler.hh:94
field_values.hh
FEValueHandler< 0, spacedim, Value >::value
const Value::return_type & value(const Point &p, const ElementAccessor< spacedim > &elm)
Returns one value in one given point.
Definition: fe_value_handler.hh:125
FEValueHandler::boundary_dofs_
std::shared_ptr< std::vector< LongIdx > > boundary_dofs_
Definition: fe_value_handler.hh:105
FEValueInitData::ndofs
unsigned int ndofs
number of dofs
Definition: fe_value_handler.hh:40
FEValueHandler::data_vec_
VectorMPI data_vec_
Store data of Field.
Definition: fe_value_handler.hh:89
FEValueHandler::value_
Value value_
Last value, prevents passing large values (vectors) by value.
Definition: fe_value_handler.hh:93
FEValueHandler::compute_quadrature
unsigned int compute_quadrature(std::vector< arma::vec::fixed< 3 >> &q_points, std::vector< double > &q_weights, const ElementAccessor< spacedim > &elm, unsigned int order=3)
Compute real coordinates and weights (use QGauss) for given element.
Definition: fe_value_handler.cc:153
FEValueHandler< 0, spacedim, Value >::dof_indices
std::vector< LongIdx > dof_indices
Array of indexes to data_vec_, used for get/set values.
Definition: fe_value_handler.hh:156
FEValueInitData
Initialization structure of FEValueHandler class.
Definition: fe_value_handler.hh:33
Value
@ Value
Definition: finite_element.hh:47
FEValueHandler::get_mapping
MappingP1< elemdim, 3 > * get_mapping()
Return mapping object.
Definition: fe_value_handler.hh:62
FEValueHandler::FEValueHandler
FEValueHandler()
Constructor.
Definition: fe_value_handler.cc:87
FEValueHandler< 0, spacedim, Value >::FEValueHandler
FEValueHandler()
Constructor.
Definition: fe_value_handler.hh:119
FEValueHandler::set_boundary_dofs_vector
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....
Definition: fe_value_handler.hh:79
FEValueHandler::value_list
void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
Returns std::vector of scalar values in several points at once.
Definition: fe_value_handler.cc:124
FEValueHandler
Definition: fe_value_handler.hh:51
FEValueHandler< 0, spacedim, Value >::~FEValueHandler
~FEValueHandler()
Destructor.
Definition: fe_value_handler.hh:140
FEValueHandler::value
const Value::return_type & value(const Point &p, const ElementAccessor< spacedim > &elm)
Returns one value in one given point.
Definition: fe_value_handler.cc:111
MappingP1< elemdim, 3 >
FEValueInitData::data_vec
VectorMPI data_vec
Store data of Field.
Definition: fe_value_handler.hh:38
long_idx.hh
mapping_p1.hh
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell.
FEValueInitData::comp_index
unsigned int comp_index
index of component (of vector_value/tensor_value)
Definition: fe_value_handler.hh:44
FEValueHandler< 0, spacedim, Value >::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
Definition: fe_value_handler.hh:152
VectorMPI
Definition: vector_mpi.hh:42
ASSERT_PTR
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
Definition: asserts.hh:335
FEValueHandler::get_dof_indices
unsigned int get_dof_indices(const ElementAccessor< 3 > &cell, std::vector< LongIdx > &indices) const
TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh....
Definition: fe_value_handler.cc:171
FEValueHandler< 0, spacedim, Value >::set_boundary_dofs_vector
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....
Definition: fe_value_handler.hh:143
FEValueInitData::n_comp
unsigned int n_comp
number of components
Definition: fe_value_handler.hh:42