Reference documentation for deal.II version 8.4.2
fe_rannacher_turek.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2015 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #include <deal.II/fe/fe_rannacher_turek.h>
18 #include <deal.II/base/quadrature_lib.h>
19 #include <deal.II/lac/vector.h>
20 #include <algorithm>
21 
22 #include <sstream>
23 
24 
25 DEAL_II_NAMESPACE_OPEN
26 
27 
28 template <int dim>
30  const unsigned int n_face_support_points) :
33  FiniteElementData<dim>(this->get_dpo_vector(),
34  1,
35  2,
36  FiniteElementData<dim>::L2),
37  std::vector<bool>(4, false), // restriction not implemented
38  std::vector<ComponentMask>(4, std::vector<bool>(1, true))),
39  degree(degree),
40  n_face_support_points(n_face_support_points)
41 {
42  Assert(dim == 2, ExcNotImplemented());
43  Assert(degree == 0, ExcNotImplemented());
45 }
46 
47 
48 
49 template <int dim>
50 std::vector<unsigned int> FE_RannacherTurek<dim>::get_dpo_vector()
51 {
52  std::vector<unsigned int> dpo(dim + 1, 0);
53  dpo[dim - 1] = 1;
54 
55  return dpo;
56 }
57 
58 
59 
60 template <int dim>
62 {
63  std::ostringstream namebuf;
64  namebuf << "FE_RannacherTurek"
65  << "<" << dim << ">"
66  << "(" << this->degree << ", " << this->n_face_support_points << ")";
67  return namebuf.str();
68 }
69 
70 
71 
72 template <int dim>
74 {
75  return new FE_RannacherTurek<dim>(this->degree, this->n_face_support_points);
76 }
77 
78 
79 
80 template <int dim>
82 {
83  Assert(dim == 2, ExcNotImplemented());
84  ::QGauss<dim-1> face_quadrature(this->n_face_support_points);
85  this->weights = face_quadrature.get_weights();
86  this->generalized_support_points.resize(4*face_quadrature.size());
87  for (unsigned int q = 0;
88  q < face_quadrature.size();
89  ++q)
90  {
91  this->generalized_support_points[0*face_quadrature.size() + q] =
92  ::Point<dim>(0, 1 - face_quadrature.point(q)(0));
93  this->generalized_support_points[1*face_quadrature.size() + q] =
94  ::Point<dim>(1, 1 - face_quadrature.point(q)(0));
95  this->generalized_support_points[2*face_quadrature.size() + q] =
96  ::Point<dim>(face_quadrature.point(q)(0), 0);
97  this->generalized_support_points[3*face_quadrature.size() + q] =
98  ::Point<dim>(face_quadrature.point(q)(0), 1);
99  }
100 }
101 
102 
103 
104 template <int dim>
106  std::vector<double> &local_dofs,
107  const std::vector<double> &values) const
108 {
109  AssertDimension(values.size(), this->generalized_support_points.size());
110  AssertDimension(local_dofs.size(), this->dofs_per_cell);
111 
112  const unsigned int q_points_per_face = this->weights.size();
113  std::fill(local_dofs.begin(), local_dofs.end(), 0.0);
114 
115  std::vector<double>::const_iterator value = values.begin();
116  for (unsigned int face = 0;
117  face < ::GeometryInfo<dim>::faces_per_cell;
118  ++face)
119  {
120  for (unsigned int q = 0;
121  q < q_points_per_face;
122  ++q)
123  {
124  local_dofs[face] += (*value) * this->weights[q];
125  ++value;
126  }
127  }
128 }
129 
130 
131 
132 template <int dim>
134  std::vector<double> &local_dofs,
135  const std::vector<Vector<double> > &values,
136  unsigned int offset) const
137 {
138  AssertDimension(values.size(), this->generalized_support_points.size());
139  AssertDimension(local_dofs.size(), this->dofs_per_cell);
140 
141  // extract component at offset and call scalar version of this function
142  std::vector<double> scalar_values(values.size());
143  for (unsigned int q = 0; q < values.size(); ++q)
144  {
145  scalar_values[q] = values[q][offset];
146  }
147  this->interpolate(local_dofs, scalar_values);
148 }
149 
150 
151 
152 template <int dim>
154  std::vector<double> &local_dofs,
155  const VectorSlice<const std::vector<std::vector<double> > > &values) const
156 {
157  AssertDimension(values.size(), 1);
158  AssertDimension(values[0].size(), this->generalized_support_points.size());
159  AssertDimension(local_dofs.size(), this->dofs_per_cell);
160 
161  // convert data structure to use scalar version of this function
162  std::vector<double> scalar_values(values[0].size());
163  for (unsigned int q = 0; q < values[0].size(); ++q)
164  {
165  scalar_values[q] = values[0][q];
166  }
167  this->interpolate(local_dofs, scalar_values);
168 }
169 
170 
171 
172 // explicit instantiations
173 #include "fe_rannacher_turek.inst"
174 
175 DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1052
std::vector< Point< dim > > generalized_support_points
Definition: fe.h:2157
const unsigned int n_face_support_points
STL namespace.
const unsigned int degree
FE_RannacherTurek(const unsigned int degree=0, const unsigned int n_face_support_points=2)
virtual FiniteElement< dim > * clone() const
#define Assert(cond, exc)
Definition: exceptions.h:294
virtual std::string get_name() const
std::vector< double > weights
const unsigned int dofs_per_cell
Definition: fe_base.h:283
virtual void interpolate(std::vector< double > &local_dofs, const std::vector< double > &values) const
std::vector< unsigned int > get_dpo_vector()