Flow123d  JB_transport-112d700
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  /// Returns one value in one given point.
68  typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm);
69  /// Returns std::vector of scalar values in several points at once.
70  void value_list (const Armor::array &point_list, const ElementAccessor<spacedim> &elm,
72  /// Compute real coordinates and weights (use QGauss) for given element
73  unsigned int compute_quadrature(std::vector<arma::vec::fixed<3>> & q_points, std::vector<double> & q_weights,
74  const ElementAccessor<spacedim> &elm, unsigned int order=3);
75 
76  /// Destructor.
78 
79 private:
80  /// DOF handler object
81  std::shared_ptr<DOFHandlerMultiDim> dh_;
82  /// Store data of Field
84  /// Last value, prevents passing large values (vectors) by value.
86  typename Value::return_type r_value_;
87  /// Begin of dof range of actual component
88  unsigned int range_begin_;
89  /// End of dof range of actual component
90  unsigned int range_end_;
91  /// Pointer to FiniteElement object used to computing values
92  std::shared_ptr<FiniteElement<elemdim>> fe_;
93 };
94 
95 
96 /**
97  * Specialization for elements with dim==0.
98  */
99 template <int spacedim, class Value>
100 class FEValueHandler<0, spacedim, Value>
101 {
102 public:
103  typedef typename Space<spacedim>::Point Point;
104 
105  /// Constructor.
107  : value_(r_value_) {}
108 
109  /// Initialize data members
110  void initialize(FEValueInitData init_data);
111  /// Returns one value in one given point.
112  typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm) {
113  Armor::array point_list(spacedim, 1, 1);
114  point_list.set(0) = Armor::ArmaVec<double,spacedim>( p );
116  v_list.push_back(r_value_);
117  this->value_list(point_list, elm, v_list);
118  this->r_value_ = v_list[0];
119  return this->r_value_;
120  }
121 
122  /// Returns std::vector of scalar values in several points at once.
123  void value_list (const Armor::array &point_list, const ElementAccessor<spacedim> &elm,
125 
126  /// Destructor.
128 
129 private:
130  /// DOF handler object
131  std::shared_ptr<DOFHandlerMultiDim> dh_;
132  /// Store data of Field
134  /// Last value, prevents passing large values (vectors) by value.
136  typename Value::return_type r_value_;
137  /// Begin of dof range of actual component
138  unsigned int range_begin_;
139  /// End of dof range of actual component
140  unsigned int range_end_;
141 };
142 
143 
144 
145 #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:201
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:136
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:135
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:103
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:138
FEValueHandler< 0, spacedim, Value >::range_end_
unsigned int range_end_
End of dof range of actual component.
Definition: fe_value_handler.hh:140
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:81
FEValueHandler< 0, spacedim, Value >::data_vec_
VectorMPI data_vec_
Store data of Field.
Definition: fe_value_handler.hh:133
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:90
finite_element.hh
Abstract class for description of finite elements.
FEValueHandler::r_value_
Value::return_type r_value_
Definition: fe_value_handler.hh:86
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:112
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:83
FEValueHandler::value_
Value value_
Last value, prevents passing large values (vectors) by value.
Definition: fe_value_handler.hh:85
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:150
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:92
FEValueHandler< 0, spacedim, Value >::FEValueHandler
FEValueHandler()
Constructor.
Definition: fe_value_handler.hh:106
FEValueHandler
Definition: fe_value_handler.hh:57
FEValueHandler< 0, spacedim, Value >::~FEValueHandler
~FEValueHandler()
Destructor.
Definition: fe_value_handler.hh:127
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:108
FEValueHandler::range_begin_
unsigned int range_begin_
Begin of dof range of actual component.
Definition: fe_value_handler.hh:88
MixedPtr< FiniteElement >
Armor::Array< double >
FEValueInitData::data_vec
VectorMPI data_vec
Store data of Field.
Definition: fe_value_handler.hh:40
FEValueHandler::value_list
void value_list(const Armor::array &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:121
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:131
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