Flow123d  release_3.0.0-684-g928e266
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 
61 
62 
63 template<unsigned int dim>
65 {
66  arma::vec::fixed<dim> sp;
67 
68  this->init(false, FEVectorPiola);
69  this->function_space_ = make_shared<RT0_space>(dim);
70 
71  for (unsigned int sid=0; sid<RefElement<dim>::n_sides; ++sid)
72  {
73  sp.fill(0);
74  for (unsigned int i=0; i<RefElement<dim>::n_nodes_per_side; ++i)
77  // barycentric coordinates
78  arma::vec::fixed<dim+1> bsp;
79  bsp.subvec(1,dim) = sp;
80  bsp[0] = 1. - arma::sum(sp);
81  // The dof (flux through side) is computed as scalar product of the value with normal vector times side measure.
82  this->dofs_.push_back(Dof(dim, 0, bsp, RefElement<dim>::normal_vector(sid)*RefElement<dim>::side_measure(sid), Value));
83  }
84  this->component_indices_.clear();
85  this->nonzero_components_.resize(this->dofs_.size(), std::vector<bool>(this->n_components(), true));
86 
87  this->compute_node_matrix();
88 }
89 
90 
91 
92 
93 
94 template class FE_RT0<1>;
95 template class FE_RT0<2>;
96 template class FE_RT0<3>;
97 
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:64
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
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.