Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
fe_rannacher_turek.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2015 - 2018 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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #include <deal.II/base/quadrature_lib.h>
18 #include <deal.II/base/std_cxx14/memory.h>
19 
20 #include <deal.II/fe/fe_rannacher_turek.h>
21 
22 #include <deal.II/lac/vector.h>
23 
24 #include <algorithm>
25 #include <sstream>
26 
27 
28 DEAL_II_NAMESPACE_OPEN
29 
30 
31 template <int dim>
33  const unsigned int order,
34  const unsigned int n_face_support_points)
37  FiniteElementData<dim>(this->get_dpo_vector(),
38  1,
39  2,
40  FiniteElementData<dim>::L2),
41  std::vector<bool>(4, false), // restriction not implemented
42  std::vector<ComponentMask>(4, std::vector<bool>(1, true)))
43  , order(order)
44  , n_face_support_points(n_face_support_points)
45 {
46  Assert(dim == 2, ExcNotImplemented());
49 }
50 
51 
52 
53 template <int dim>
54 std::vector<unsigned int>
56 {
57  std::vector<unsigned int> dpo(dim + 1, 0);
58  dpo[dim - 1] = 1;
59 
60  return dpo;
61 }
62 
63 
64 
65 template <int dim>
66 std::string
68 {
69  std::ostringstream namebuf;
70  namebuf << "FE_RannacherTurek"
71  << "<" << dim << ">"
72  << "(" << this->order << ", " << this->n_face_support_points << ")";
73  return namebuf.str();
74 }
75 
76 
77 
78 template <int dim>
79 std::unique_ptr<FiniteElement<dim, dim>>
81 {
82  return std_cxx14::make_unique<FE_RannacherTurek<dim>>(
83  this->order, this->n_face_support_points);
84 }
85 
86 
87 
88 template <int dim>
89 void
91 {
92  Assert(dim == 2, ExcNotImplemented());
93  ::QGauss<dim - 1> face_quadrature(this->n_face_support_points);
94  this->weights = face_quadrature.get_weights();
95  this->generalized_support_points.resize(4 * face_quadrature.size());
96  for (unsigned int q = 0; q < face_quadrature.size(); ++q)
97  {
98  this->generalized_support_points[0 * face_quadrature.size() + q] =
99  ::Point<dim>(0, 1 - face_quadrature.point(q)(0));
100  this->generalized_support_points[1 * face_quadrature.size() + q] =
101  ::Point<dim>(1, 1 - face_quadrature.point(q)(0));
102  this->generalized_support_points[2 * face_quadrature.size() + q] =
103  ::Point<dim>(face_quadrature.point(q)(0), 0);
104  this->generalized_support_points[3 * face_quadrature.size() + q] =
105  ::Point<dim>(face_quadrature.point(q)(0), 1);
106  }
107 }
108 
109 
110 
111 template <int dim>
112 void
114  const std::vector<Vector<double>> &support_point_values,
115  std::vector<double> & nodal_values) const
116 {
117  AssertDimension(support_point_values.size(),
118  this->generalized_support_points.size());
119  AssertDimension(nodal_values.size(), this->dofs_per_cell);
120 
121  const unsigned int q_points_per_face = this->weights.size();
122  std::fill(nodal_values.begin(), nodal_values.end(), 0.0);
123 
124  std::vector<Vector<double>>::const_iterator value =
125  support_point_values.begin();
126  for (unsigned int face = 0; face < ::GeometryInfo<dim>::faces_per_cell;
127  ++face)
128  {
129  for (unsigned int q = 0; q < q_points_per_face; ++q)
130  {
131  nodal_values[face] += (*value)[0] * this->weights[q];
132  ++value;
133  }
134  }
135 }
136 
137 
138 
139 // explicit instantiations
140 #include "fe_rannacher_turek.inst"
141 
142 DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1567
FE_RannacherTurek(const unsigned int order=0, const unsigned int n_face_support_points=2)
STL namespace.
virtual std::string get_name() const override
const unsigned int order
#define Assert(cond, exc)
Definition: exceptions.h:1407
static ::ExceptionBase & ExcNotImplemented()
std::vector< unsigned int > get_dpo_vector()
virtual std::unique_ptr< FiniteElement< dim, dim > > clone() const override
virtual void convert_generalized_support_point_values_to_dof_values(const std::vector< Vector< double >> &support_point_values, std::vector< double > &nodal_values) const override