Reference documentation for deal.II version 8.5.1
fe_q.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 2016 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 namespace
27 {
28  std::vector<Point<1> >
29  get_QGaussLobatto_points (const unsigned int degree)
30  {
31  if (degree > 0)
32  return QGaussLobatto<1>(degree+1).get_points();
33  else
34  {
35  typedef FE_Q_Base<TensorProductPolynomials<1>, 1, 1> FEQ;
36  AssertThrow(false, FEQ::ExcFEQCannotHaveDegree0());
37  }
38  return std::vector<Point<1> >();
39  }
40 }
41 
42 
43 
44 template <int dim, int spacedim>
45 FE_Q<dim,spacedim>::FE_Q (const unsigned int degree)
46  :
47  FE_Q_Base<TensorProductPolynomials<dim>, dim, spacedim>
48  (TensorProductPolynomials<dim>(Polynomials::generate_complete_Lagrange_basis(get_QGaussLobatto_points(degree))),
49  FiniteElementData<dim>(this->get_dpo_vector(degree),
50  1, degree,
51  FiniteElementData<dim>::H1),
52  std::vector<bool> (1, false))
53 {
54  this->initialize(get_QGaussLobatto_points(degree));
55 }
56 
57 
58 
59 template <int dim, int spacedim>
61  :
62  FE_Q_Base<TensorProductPolynomials<dim>, dim, spacedim> (
63  TensorProductPolynomials<dim>(Polynomials::generate_complete_Lagrange_basis(points.get_points())),
64  FiniteElementData<dim>(this->get_dpo_vector(points.size()-1),
65  1, points.size()-1,
66  FiniteElementData<dim>::H1),
67  std::vector<bool> (1, false))
68 {
69  this->initialize(points.get_points());
70 }
71 
72 
73 
74 template <int dim, int spacedim>
75 std::string
77 {
78  // note that the FETools::get_fe_by_name function depends on the
79  // particular format of the string this function returns, so they have to be
80  // kept in synch
81 
82  std::ostringstream namebuf;
83  bool equidistant = true;
84  std::vector<double> points(this->degree+1);
85 
86  // Decode the support points in one coordinate direction.
87  std::vector<unsigned int> lexicographic = this->poly_space.get_numbering_inverse();
88  for (unsigned int j=0; j<=this->degree; j++)
89  points[j] = this->unit_support_points[lexicographic[j]][0];
90 
91  // Check whether the support points are equidistant.
92  for (unsigned int j=0; j<=this->degree; j++)
93  if (std::fabs(points[j] - (double)j/this->degree) > 1e-15)
94  {
95  equidistant = false;
96  break;
97  }
98 
99  if (equidistant == true)
100  {
101  if (this->degree > 2)
102  namebuf << "FE_Q<"
103  << Utilities::dim_string(dim,spacedim)
104  << ">(QIterated(QTrapez()," << this->degree << "))";
105  else
106  namebuf << "FE_Q<"
107  << Utilities::dim_string(dim,spacedim)
108  << ">(" << this->degree << ")";
109  }
110  else
111  {
112  // Check whether the support points come from QGaussLobatto.
113  const QGaussLobatto<1> points_gl(this->degree+1);
114  bool gauss_lobatto = true;
115  for (unsigned int j=0; j<=this->degree; j++)
116  if (points[j] != points_gl.point(j)(0))
117  {
118  gauss_lobatto = false;
119  break;
120  }
121  if (gauss_lobatto == true)
122  namebuf << "FE_Q<"
123  << Utilities::dim_string(dim,spacedim)
124  << ">(" << this->degree << ")";
125  else
126  namebuf << "FE_Q<"
127  << Utilities::dim_string(dim,spacedim)
128  << ">(QUnknownNodes(" << this->degree << "))";
129  }
130  return namebuf.str();
131 }
132 
133 
134 
135 template <int dim, int spacedim>
138 {
139  return new FE_Q<dim,spacedim>(*this);
140 }
141 
142 
143 // explicit instantiations
144 #include "fe_q.inst"
145 
146 DEAL_II_NAMESPACE_CLOSE
FE_Q(const unsigned int p)
Definition: fe_q.cc:45
const std::vector< Point< dim > > & get_points() const
const unsigned int degree
Definition: fe_base.h:311
const Point< dim > & point(const unsigned int i) const
STL namespace.
#define AssertThrow(cond, exc)
Definition: exceptions.h:369
virtual FiniteElement< dim, spacedim > * clone() const
Definition: fe_q.cc:137
Definition: fe_q.h:552
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:161
virtual std::string get_name() const
Definition: fe_q.cc:76
void initialize(const std::vector< Point< 1 > > &support_points_1d)
Definition: fe_q_base.cc:430