Reference documentation for deal.II version 9.0.0
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 #include <deal.II/base/std_cxx14/memory.h>
24 
25 
26 DEAL_II_NAMESPACE_OPEN
27 
28 
29 template <int dim>
31  const unsigned int n_face_support_points) :
34  FiniteElementData<dim>(this->get_dpo_vector(),
35  1,
36  2,
37  FiniteElementData<dim>::L2),
38  std::vector<bool>(4, false), // restriction not implemented
39  std::vector<ComponentMask>(4, std::vector<bool>(1, true))),
40  order(order),
41  n_face_support_points(n_face_support_points)
42 {
43  Assert(dim == 2, ExcNotImplemented());
46 }
47 
48 
49 
50 template <int dim>
51 std::vector<unsigned int> FE_RannacherTurek<dim>::get_dpo_vector()
52 {
53  std::vector<unsigned int> dpo(dim + 1, 0);
54  dpo[dim - 1] = 1;
55 
56  return dpo;
57 }
58 
59 
60 
61 template <int dim>
63 {
64  std::ostringstream namebuf;
65  namebuf << "FE_RannacherTurek"
66  << "<" << dim << ">"
67  << "(" << this->order << ", " << this->n_face_support_points << ")";
68  return namebuf.str();
69 }
70 
71 
72 
73 template <int dim>
74 std::unique_ptr<FiniteElement<dim,dim> >
76 {
77  return std_cxx14::make_unique<FE_RannacherTurek<dim>>(this->order, this->n_face_support_points);
78 }
79 
80 
81 
82 template <int dim>
84 {
85  Assert(dim == 2, ExcNotImplemented());
86  ::QGauss<dim-1> face_quadrature(this->n_face_support_points);
87  this->weights = face_quadrature.get_weights();
88  this->generalized_support_points.resize(4*face_quadrature.size());
89  for (unsigned int q = 0;
90  q < face_quadrature.size();
91  ++q)
92  {
93  this->generalized_support_points[0*face_quadrature.size() + q] =
94  ::Point<dim>(0, 1 - face_quadrature.point(q)(0));
95  this->generalized_support_points[1*face_quadrature.size() + q] =
96  ::Point<dim>(1, 1 - face_quadrature.point(q)(0));
97  this->generalized_support_points[2*face_quadrature.size() + q] =
98  ::Point<dim>(face_quadrature.point(q)(0), 0);
99  this->generalized_support_points[3*face_quadrature.size() + q] =
100  ::Point<dim>(face_quadrature.point(q)(0), 1);
101  }
102 }
103 
104 
105 
106 template <int dim>
107 void
110  std::vector<double> &nodal_values) const
111 {
112  AssertDimension(support_point_values.size(), this->generalized_support_points.size());
113  AssertDimension(nodal_values.size(), this->dofs_per_cell);
114 
115  const unsigned int q_points_per_face = this->weights.size();
116  std::fill(nodal_values.begin(), nodal_values.end(), 0.0);
117 
118  std::vector<Vector<double> >::const_iterator value = support_point_values.begin();
119  for (unsigned int face = 0;
120  face < ::GeometryInfo<dim>::faces_per_cell;
121  ++face)
122  {
123  for (unsigned int q = 0;
124  q < q_points_per_face;
125  ++q)
126  {
127  nodal_values[face] += (*value)[0] * this->weights[q];
128  ++value;
129  }
130  }
131 }
132 
133 
134 
135 // explicit instantiations
136 #include "fe_rannacher_turek.inst"
137 
138 DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1248
FE_RannacherTurek(const unsigned int order=0, const unsigned int n_face_support_points=2)
STL namespace.
virtual std::unique_ptr< FiniteElement< dim, dim > > clone() const
const unsigned int order
#define Assert(cond, exc)
Definition: exceptions.h:1142
virtual void convert_generalized_support_point_values_to_dof_values(const std::vector< Vector< double > > &support_point_values, std::vector< double > &nodal_values) const
virtual std::string get_name() const
static ::ExceptionBase & ExcNotImplemented()
std::vector< unsigned int > get_dpo_vector()