Flow123d  release_3.0.0-965-gb0c8897
fe_rt.cc
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_rt.cc
15  * @brief Definitions of Raviart-Thomas finite elements.
16  * @author Jan Stebel
17  */
18 
19 #include "mesh/side_impl.hh"
20 #include "fem/fe_rt.hh"
21 #include "fem/fe_values.hh"
22 #include "mesh/ref_element.hh"
24 
25 
26 RT0_space::RT0_space(unsigned int dim)
27  : FunctionSpace(dim, dim)
28 {}
29 
30 
31 const double RT0_space::basis_value(unsigned int basis_index,
32  const arma::vec &point,
33  unsigned int comp_index) const
34 {
35  OLD_ASSERT(basis_index < this->dim(), "Index of basis function is out of range.");
36  OLD_ASSERT(comp_index < this->n_components_, "Index of component is out of range.");
37 
38  if (basis_index>0 && comp_index==basis_index-1)
39  return point[comp_index]-1;
40  else
41  return point[comp_index];
42 }
43 
44 
45 const arma::vec RT0_space::basis_grad(unsigned int basis_index,
46  const arma::vec &point,
47  unsigned int comp_index) const
48 {
49  OLD_ASSERT(basis_index < this->dim(), "Index of basis function is out of range.");
50  OLD_ASSERT(comp_index < this->n_components_, "Index of component is out of range.");
51 
52  arma::vec g(this->space_dim_);
53  g.zeros();
54  g[comp_index] = 1;
55 
56  return g;
57 }
58 
59 
60 template<> FE_RT0<0>::FE_RT0()
61 {
62 }
63 
64 
65 
66 template<unsigned int dim>
68 {
69  arma::vec::fixed<dim> sp;
70 
71  this->init(false, FEVectorPiola);
72  this->function_space_ = make_shared<RT0_space>(dim);
73 
74  for (unsigned int sid=0; sid<RefElement<dim>::n_sides; ++sid)
75  {
76  sp.fill(0);
77  for (unsigned int i=0; i<RefElement<dim>::n_nodes_per_side; ++i)
80  // barycentric coordinates
81  arma::vec::fixed<dim+1> bsp;
82  bsp.subvec(1,dim) = sp;
83  bsp[0] = 1. - arma::sum(sp);
84  // The dof (flux through side) is computed as scalar product of the value with normal vector times side measure.
85  this->dofs_.push_back(Dof(dim-1, sid, bsp, RefElement<dim>::normal_vector(sid)*RefElement<dim>::side_measure(sid), Value));
86  }
87  this->component_indices_.clear();
88  this->nonzero_components_.resize(this->dofs_.size(), std::vector<bool>(this->n_components(), true));
89 
90  this->compute_node_matrix();
91 }
92 
93 
94 
95 
96 template class FE_RT0<0>;
97 template class FE_RT0<1>;
98 template class FE_RT0<2>;
99 template class FE_RT0<3>;
100 
101 
103 {
104 }
105 
106 
107 template<unsigned int dim>
109 {
110  arma::vec::fixed<dim> sp;
111 
112  this->init(false, FEVectorPiola);
113  this->function_space_ = make_shared<RT0_space>(dim);
114 
115  for (unsigned int sid=0; sid<RefElement<dim>::n_sides; ++sid)
116  {
117  sp.fill(0);
118  for (unsigned int i=0; i<RefElement<dim>::n_nodes_per_side; ++i)
121  // barycentric coordinates
122  arma::vec::fixed<dim+1> bsp;
123  bsp.subvec(1,dim) = sp;
124  bsp[0] = 1. - arma::sum(sp);
125  // The dof (flux through side) is computed as scalar product of the value with normal vector times side measure.
126  this->dofs_.push_back(Dof(dim, 0, bsp, RefElement<dim>::normal_vector(sid)*RefElement<dim>::side_measure(sid), Value));
127  }
128  this->component_indices_.clear();
129  this->nonzero_components_.resize(this->dofs_.size(), std::vector<bool>(this->n_components(), true));
130 
131  this->compute_node_matrix();
132 }
133 
134 
135 
136 
137 template class FE_RT0_disc<0>;
138 template class FE_RT0_disc<1>;
139 template class FE_RT0_disc<2>;
140 template class FE_RT0_disc<3>;
141 
FE_RT0_disc()
Constructor.
Definition: fe_rt.cc:108
RT0_space(unsigned int dim)
Definition: fe_rt.cc:26
unsigned int n_components_
Number of components of function values.
Class FEValues calculates finite element data on the actual cells such as shape function values...
const unsigned int dim() const override
Dimension of function space (number of basis functions).
Definition: fe_rt.hh:49
const arma::vec basis_grad(unsigned int basis_index, const arma::vec &point, unsigned int comp_index) const override
Gradient of the i th basis function at point point.
Definition: fe_rt.cc:45
#define OLD_ASSERT(...)
Definition: global_defs.h:131
Raviart-Thomas element of order 0.
Definition: fe_rt.hh:60
FE_RT0()
Constructor.
Definition: fe_rt.cc:67
const double basis_value(unsigned int basis_index, const arma::vec &point, unsigned int comp_index) const override
Value of the i th basis function at point point.
Definition: fe_rt.cc:31
Discontinuous Raviart-Thomas element of order 0.
Definition: fe_rt.hh:81
const unsigned int n_components() const
Getter for number of components.
Definitions of particular quadrature rules on simplices.
Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc...
unsigned int space_dim_
Space dimension of function arguments (i.e. 1, 2 or 3).
Definitions of Raviart-Thomas finite elements.