Reference documentation for deal.II version 8.5.1
fe_rannacher_turek.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2015 - 2017 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  order(order),
40  n_face_support_points(n_face_support_points)
41 {
42  Assert(dim == 2, 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->order << ", " << 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->order, 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>
105 void
108  std::vector<double> &nodal_dofs) const
109 {
110  AssertDimension(support_point_values.size(), this->generalized_support_points.size());
111  AssertDimension(nodal_dofs.size(), this->dofs_per_cell);
112 
113  // extract component and call scalar version of this function
114  std::vector<double> scalar_values(support_point_values.size());
115  for (unsigned int q = 0; q < support_point_values.size(); ++q)
116  {
117  scalar_values[q] = support_point_values[q][0];
118  }
119  this->interpolate(nodal_dofs, scalar_values);
120 }
121 
122 
123 
124 template <int dim>
126  std::vector<double> &local_dofs,
127  const std::vector<double> &values) const
128 {
129  AssertDimension(values.size(), this->generalized_support_points.size());
130  AssertDimension(local_dofs.size(), this->dofs_per_cell);
131 
132  const unsigned int q_points_per_face = this->weights.size();
133  std::fill(local_dofs.begin(), local_dofs.end(), 0.0);
134 
135  std::vector<double>::const_iterator value = values.begin();
136  for (unsigned int face = 0;
137  face < ::GeometryInfo<dim>::faces_per_cell;
138  ++face)
139  {
140  for (unsigned int q = 0;
141  q < q_points_per_face;
142  ++q)
143  {
144  local_dofs[face] += (*value) * this->weights[q];
145  ++value;
146  }
147  }
148 }
149 
150 
151 
152 template <int dim>
154  std::vector<double> &local_dofs,
155  const std::vector<Vector<double> > &values,
156  const unsigned int offset) const
157 {
158  AssertDimension(values.size(), this->generalized_support_points.size());
159  AssertDimension(local_dofs.size(), this->dofs_per_cell);
160 
161  // extract component at offset and call scalar version of this function
162  std::vector<double> scalar_values(values.size());
163  for (unsigned int q = 0; q < values.size(); ++q)
164  {
165  scalar_values[q] = values[q][offset];
166  }
167  this->interpolate(local_dofs, scalar_values);
168 }
169 
170 
171 
172 template <int dim>
174  std::vector<double> &local_dofs,
175  const VectorSlice<const std::vector<std::vector<double> > > &values) const
176 {
177  AssertDimension(values.size(), 1);
178  AssertDimension(values[0].size(), this->generalized_support_points.size());
179  AssertDimension(local_dofs.size(), this->dofs_per_cell);
180 
181  // convert data structure to use scalar version of this function
182  std::vector<double> scalar_values(values[0].size());
183  for (unsigned int q = 0; q < values[0].size(); ++q)
184  {
185  scalar_values[q] = values[0][q];
186  }
187  this->interpolate(local_dofs, scalar_values);
188 }
189 
190 
191 
192 // explicit instantiations
193 #include "fe_rannacher_turek.inst"
194 
195 DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1146
FE_RannacherTurek(const unsigned int order=0, const unsigned int n_face_support_points=2)
virtual void interpolate(std::vector< double > &local_dofs, const std::vector< double > &values) const 1
STL namespace.
virtual FiniteElement< dim > * clone() const
const unsigned int order
#define Assert(cond, exc)
Definition: exceptions.h:313
virtual std::string get_name() const
virtual void convert_generalized_support_point_values_to_nodal_values(const std::vector< Vector< double > > &support_point_values, std::vector< double > &nodal_values) const
static ::ExceptionBase & ExcNotImplemented()
std::vector< unsigned int > get_dpo_vector()