Flow123d  master-7bf36fe
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 "system/index_types.hh"
22 #include "fields/field_values.hh"
23 #include "fem/finite_element.hh"
24 #include "mesh/point.hh"
25 #include "la/vector_mpi.hh"
26 #include <armadillo>
27 #include "system/armor.hh"
28 #include "tools/mixed.hh"
29 
30 class DOFHandlerMultiDim;
31 template <int spacedim> class ElementAccessor;
32 
33 
34 /// Initialization structure of FEValueHandler class.
36 {
37  /// DOF handler object
38  std::shared_ptr<DOFHandlerMultiDim> dh;
39  /// Store data of Field
41  /// number of dofs
42  unsigned int ndofs;
43  /// number of components
44  unsigned int n_comp;
45  /// Holds begin of component range of evaluation.
46  unsigned int range_begin;
47  /// Holds end of component range of evaluation.
48  unsigned int range_end;
49  /// FiniteElement objects of all dimensions.
51 };
52 
53 /**
54  * Helper class that allows compute finite element values specified by element dimension.
55  */
56 template <int elemdim, int spacedim, class Value>
58 {
59 public:
60  typedef typename Space<spacedim>::Point Point;
61 
62  /// Constructor.
64 
65  /// Initialize data members
66  void initialize(FEValueInitData init_data);
67  /// Compute real coordinates and weights (use QGauss) for given element
68  unsigned int compute_quadrature(std::vector<arma::vec::fixed<3>> & q_points, std::vector<double> & q_weights,
69  const ElementAccessor<spacedim> &elm, unsigned int order=3);
70 
71  /// Destructor.
73 
74 private:
75  /// DOF handler object
76  std::shared_ptr<DOFHandlerMultiDim> dh_;
77  /// Store data of Field
79  /// Last value, prevents passing large values (vectors) by value.
81  typename Value::return_type r_value_;
82  /// Begin of dof range of actual component
83  unsigned int range_begin_;
84  /// End of dof range of actual component
85  unsigned int range_end_;
86  /// Pointer to FiniteElement object used to computing values
87  std::shared_ptr<FiniteElement<elemdim>> fe_;
88 };
89 
90 
91 /**
92  * Specialization for elements with dim==0.
93  */
94 template <int spacedim, class Value>
95 class FEValueHandler<0, spacedim, Value>
96 {
97 public:
98  typedef typename Space<spacedim>::Point Point;
99 
100  /// Constructor.
102  : value_(r_value_) {}
103 
104  /// Initialize data members
105  void initialize(FEValueInitData init_data);
106  /// Returns one value in one given point.
107  typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm) {
108  Armor::array point_list(spacedim, 1, 1);
109  point_list.set(0) = Armor::ArmaVec<double,spacedim>( p );
111  v_list.push_back(r_value_);
112  this->value_list(point_list, elm, v_list);
113  this->r_value_ = v_list[0];
114  return this->r_value_;
115  }
116 
117  /// Returns std::vector of scalar values in several points at once.
118  void value_list (const Armor::array &point_list, const ElementAccessor<spacedim> &elm,
120 
121  /// Destructor.
123 
124 private:
125  /// DOF handler object
126  std::shared_ptr<DOFHandlerMultiDim> dh_;
127  /// Store data of Field
129  /// Last value, prevents passing large values (vectors) by value.
131  typename Value::return_type r_value_;
132  /// Begin of dof range of actual component
133  unsigned int range_begin_;
134  /// End of dof range of actual component
135  unsigned int range_end_;
136 };
137 
138 
139 
140 #endif /* FE_VALUE_HANDLER_HH_ */
Space::Point
Armor::ArmaVec< double, spacedim > Point
Definition: point.hh:42
FEValueHandler::~FEValueHandler
~FEValueHandler()
Destructor.
Definition: fe_value_handler.cc:159
FEValueInitData::range_end
unsigned int range_end
Holds end of component range of evaluation.
Definition: fe_value_handler.hh:48
FEValueHandler< 0, spacedim, Value >::r_value_
Value::return_type r_value_
Definition: fe_value_handler.hh:131
FEValueHandler::Point
Space< spacedim >::Point Point
Definition: fe_value_handler.hh:60
armor.hh
FEValueHandler< 0, spacedim, Value >::value_
Value value_
Last value, prevents passing large values (vectors) by value.
Definition: fe_value_handler.hh:130
vector_mpi.hh
FEValueHandler::initialize
void initialize(FEValueInitData init_data)
Initialize data members.
Definition: fe_value_handler.cc:93
FEValueHandler< 0, spacedim, Value >::Point
Space< spacedim >::Point Point
Definition: fe_value_handler.hh:98
point.hh
std::vector
Definition: doxy_dummy_defs.hh:7
ElementAccessor
Definition: dh_cell_accessor.hh:32
FEValueHandler< 0, spacedim, Value >::range_begin_
unsigned int range_begin_
Begin of dof range of actual component.
Definition: fe_value_handler.hh:133
FEValueHandler< 0, spacedim, Value >::range_end_
unsigned int range_end_
End of dof range of actual component.
Definition: fe_value_handler.hh:135
index_types.hh
FEValueInitData::mixed_fe
MixedPtr< FiniteElement > mixed_fe
FiniteElement objects of all dimensions.
Definition: fe_value_handler.hh:50
FEValueHandler::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
Definition: fe_value_handler.hh:76
FEValueHandler< 0, spacedim, Value >::data_vec_
VectorMPI data_vec_
Store data of Field.
Definition: fe_value_handler.hh:128
FEValueInitData::dh
std::shared_ptr< DOFHandlerMultiDim > dh
DOF handler object.
Definition: fe_value_handler.hh:38
DOFHandlerMultiDim
Provides the numbering of the finite element degrees of freedom on the computational mesh.
Definition: dofhandler.hh:151
FEValueHandler::range_end_
unsigned int range_end_
End of dof range of actual component.
Definition: fe_value_handler.hh:85
finite_element.hh
Abstract class for description of finite elements.
FEValueHandler::r_value_
Value::return_type r_value_
Definition: fe_value_handler.hh:81
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:107
FEValueInitData::ndofs
unsigned int ndofs
number of dofs
Definition: fe_value_handler.hh:42
FEValueHandler::data_vec_
VectorMPI data_vec_
Store data of Field.
Definition: fe_value_handler.hh:78
FEValueHandler::value_
Value value_
Last value, prevents passing large values (vectors) by value.
Definition: fe_value_handler.hh:80
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:108
Armor::Array::set
ArrayMatSet set(uint index)
Definition: armor.hh:838
FEValueInitData
Initialization structure of FEValueHandler class.
Definition: fe_value_handler.hh:35
Value
@ Value
Definition: finite_element.hh:43
FEValueHandler::FEValueHandler
FEValueHandler()
Constructor.
Definition: fe_value_handler.cc:87
FEValueHandler::fe_
std::shared_ptr< FiniteElement< elemdim > > fe_
Pointer to FiniteElement object used to computing values.
Definition: fe_value_handler.hh:87
FEValueHandler< 0, spacedim, Value >::FEValueHandler
FEValueHandler()
Constructor.
Definition: fe_value_handler.hh:101
FEValueHandler
Definition: fe_value_handler.hh:57
FEValueHandler< 0, spacedim, Value >::~FEValueHandler
~FEValueHandler()
Destructor.
Definition: fe_value_handler.hh:122
FEValueHandler::range_begin_
unsigned int range_begin_
Begin of dof range of actual component.
Definition: fe_value_handler.hh:83
MixedPtr< FiniteElement >
Armor::Array< double >
FEValueInitData::data_vec
VectorMPI data_vec
Store data of Field.
Definition: fe_value_handler.hh:40
FEValueInitData::range_begin
unsigned int range_begin
Holds begin of component range of evaluation.
Definition: fe_value_handler.hh:46
FEValueHandler< 0, spacedim, Value >::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
Definition: fe_value_handler.hh:126
VectorMPI
Definition: vector_mpi.hh:43
Armor::ArmaVec
typename arma::Col< Type >::template fixed< nr > ArmaVec
Definition: armor.hh:505
mixed.hh
FEValueInitData::n_comp
unsigned int n_comp
number of components
Definition: fe_value_handler.hh:44