Flow123d  release_2.2.0-914-gf1a3a4f
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 "fem/fe_rt.hh"
20 #include "fem/fe_values.hh"
21 #include "mesh/ref_element.hh"
23 
24 
25 RT0_space::RT0_space(unsigned int dim)
26  : FunctionSpace(dim, dim)
27 {}
28 
29 
30 const double RT0_space::basis_value(unsigned int basis_index,
31  const arma::vec &point,
32  unsigned int comp_index) const
33 {
34  OLD_ASSERT(basis_index < this->dim(), "Index of basis function is out of range.");
35  OLD_ASSERT(comp_index < this->n_components_, "Index of component is out of range.");
36 
37  if (basis_index>0 && comp_index==basis_index-1)
38  return point[comp_index]-1;
39  else
40  return point[comp_index];
41 }
42 
43 
44 const arma::vec RT0_space::basis_grad(unsigned int basis_index,
45  const arma::vec &point,
46  unsigned int comp_index) const
47 {
48  OLD_ASSERT(basis_index < this->dim(), "Index of basis function is out of range.");
49  OLD_ASSERT(comp_index < this->n_components_, "Index of component is out of range.");
50 
51  arma::vec g(this->space_dim_);
52  g.zeros();
53  g[comp_index] = 1;
54 
55  return g;
56 }
57 
58 
59 
60 
61 
62 template<unsigned int dim, unsigned int spacedim>
64 {
65  arma::vec::fixed<dim> sp;
66 
67  this->init(false, FEVectorPiola);
68  this->function_space_ = new RT0_space(dim);
69 
70  for (unsigned int sid=0; sid<RefElement<dim>::n_sides; ++sid)
71  {
72  sp.fill(0);
73  for (unsigned int i=0; i<RefElement<dim>::n_nodes_per_side; ++i)
76  // barycentric coordinates
77  arma::vec::fixed<dim+1> bsp;
78  bsp.subvec(0,dim-1) = sp;
79  bsp[dim] = 1. - arma::sum(sp);
80  // The dof (flux through side) is computed as scalar product of the value with normal vector times side measure.
81  this->dofs_.push_back(Dof(dim, 0, bsp, RefElement<dim>::normal_vector(sid)*RefElement<dim>::side_measure(sid), Value));
82  }
83  this->component_indices_.clear();
84  this->nonzero_components_.resize(this->dofs_.size(), std::vector<bool>(this->n_components(), true));
85 
86  this->compute_node_matrix();
87 }
88 
89 
90 
91 
92 
93 template class FE_RT0<1,3>;
94 template class FE_RT0<2,3>;
95 template class FE_RT0<3,3>;
96 
RT0_space(unsigned int dim)
Definition: fe_rt.cc:25
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
FE_RT0()
Constructor.
Definition: fe_rt.cc:63
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:44
#define OLD_ASSERT(...)
Definition: global_defs.h:131
Raviart-Thomas element of order 0.
Definition: fe_rt.hh:60
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:30
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.