Reference documentation for deal.II version 8.4.2
fe_q.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 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/base/quadrature_lib.h>
18 #include <deal.II/fe/fe_q.h>
19 
20 #include <vector>
21 #include <sstream>
22 
23 DEAL_II_NAMESPACE_OPEN
24 
25 
26 
27 template <int dim, int spacedim>
28 FE_Q<dim,spacedim>::FE_Q (const unsigned int degree)
29  :
30  FE_Q_Base<TensorProductPolynomials<dim>, dim, spacedim> (
31  TensorProductPolynomials<dim>(Polynomials::LagrangeEquidistant::generate_complete_basis(degree)),
32  FiniteElementData<dim>(this->get_dpo_vector(degree),
33  1, degree,
34  FiniteElementData<dim>::H1),
35  std::vector<bool> (1, false))
36 {
37  Assert (degree > 0,
38  ExcMessage ("This element can only be used for polynomial degrees "
39  "greater than zero. If you want an element of polynomial "
40  "degree zero, then it cannot be continuous and you "
41  "will want to use FE_DGQ<dim>(0)."));
42  std::vector<Point<1> > support_points_1d(degree+1);
43  for (unsigned int i=0; i<=degree; ++i)
44  support_points_1d[i][0] = static_cast<double>(i)/degree;
45 
46  this->initialize(support_points_1d);
47 }
48 
49 
50 
51 template <int dim, int spacedim>
53  :
54  FE_Q_Base<TensorProductPolynomials<dim>, dim, spacedim> (
55  TensorProductPolynomials<dim>(Polynomials::generate_complete_Lagrange_basis(points.get_points())),
56  FiniteElementData<dim>(this->get_dpo_vector(points.size()-1),
57  1, points.size()-1,
58  FiniteElementData<dim>::H1),
59  std::vector<bool> (1, false))
60 {
61  const unsigned int degree = points.size()-1;
62  (void)degree;
63  Assert (degree > 0,
64  ExcMessage ("This element can only be used for polynomial degrees "
65  "at least zero"));
66 
67  this->initialize(points.get_points());
68 }
69 
70 
71 
72 template <int dim, int spacedim>
73 std::string
75 {
76  // note that the FETools::get_fe_from_name function depends on the
77  // particular format of the string this function returns, so they have to be
78  // kept in synch
79 
80  std::ostringstream namebuf;
81  bool equidistant = true;
82  std::vector<double> points(this->degree+1);
83 
84  // Decode the support points in one coordinate direction.
85  std::vector<unsigned int> lexicographic = this->poly_space.get_numbering_inverse();
86  for (unsigned int j=0; j<=this->degree; j++)
87  points[j] = this->unit_support_points[lexicographic[j]][0];
88 
89  // Check whether the support points are equidistant.
90  for (unsigned int j=0; j<=this->degree; j++)
91  if (std::fabs(points[j] - (double)j/this->degree) > 1e-15)
92  {
93  equidistant = false;
94  break;
95  }
96 
97  if (equidistant == true)
98  namebuf << "FE_Q<"
99  << Utilities::dim_string(dim,spacedim)
100  << ">(" << this->degree << ")";
101  else
102  {
103  // Check whether the support points come from QGaussLobatto.
104  const QGaussLobatto<1> points_gl(this->degree+1);
105  bool gauss_lobatto = true;
106  for (unsigned int j=0; j<=this->degree; j++)
107  if (points[j] != points_gl.point(j)(0))
108  {
109  gauss_lobatto = false;
110  break;
111  }
112  if (gauss_lobatto == true)
113  namebuf << "FE_Q<"
114  << Utilities::dim_string(dim,spacedim)
115  << ">(QGaussLobatto(" << this->degree+1 << "))";
116  else
117  namebuf << "FE_Q<"
118  << Utilities::dim_string(dim,spacedim)
119  << ">(QUnknownNodes(" << this->degree << "))";
120  }
121  return namebuf.str();
122 }
123 
124 
125 
126 template <int dim, int spacedim>
129 {
130  return new FE_Q<dim,spacedim>(*this);
131 }
132 
133 
134 // explicit instantiations
135 #include "fe_q.inst"
136 
137 DEAL_II_NAMESPACE_CLOSE
static std::vector< unsigned int > get_dpo_vector(const unsigned int degree)
Definition: fe_q_base.cc:1121
FE_Q(const unsigned int p)
Definition: fe_q.cc:28
const std::vector< Point< dim > > & get_points() const
::ExceptionBase & ExcMessage(std::string arg1)
const unsigned int degree
Definition: fe_base.h:299
const Point< dim > & point(const unsigned int i) const
STL namespace.
virtual FiniteElement< dim, spacedim > * clone() const
Definition: fe_q.cc:128
std::vector< Point< dim > > unit_support_points
Definition: fe.h:2144
Definition: fe_q.h:522
#define Assert(cond, exc)
Definition: exceptions.h:294
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:158
unsigned int size() const
virtual std::string get_name() const
Definition: fe_q.cc:74
void initialize(const std::vector< Point< 1 > > &support_points_1d)
Definition: fe_q_base.cc:428
const std::vector< unsigned int > & get_numbering_inverse() const