Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
polynomials_p.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 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/polynomials_p.h>
18 
19 DEAL_II_NAMESPACE_OPEN
20 
21 
22 template <int dim>
23 PolynomialsP<dim>::PolynomialsP(const unsigned int p)
24  : PolynomialSpace<dim>(
25  Polynomials::Monomial<double>::generate_complete_basis(p))
26  , p(p)
27 {
28  std::vector<unsigned int> index_map(this->n());
29  create_polynomial_ordering(index_map);
30  this->set_numbering(index_map);
31 }
32 
33 
34 template <>
35 void
37  std::vector<unsigned int> &index_map) const
38 {
39  Assert(index_map.size() == this->n(),
40  ExcDimensionMismatch(index_map.size(), this->n()));
41 
42  // identity
43  for (unsigned int i = 0; i < this->n(); ++i)
44  index_map[i] = i;
45 }
46 
47 
48 namespace
49 {
50  const unsigned int imap2[6][21] = {
51  {0},
52  {0, 1, 2},
53  {0, 1, 3, 4, 2, 5},
54  {0, 1, 4, 5, 2, 7, 6, 8, 3, 9},
55  {0, 1, 5, 6, 2, 9, 7, 10, 3, 12, 11, 8, 13, 4, 14},
56  {0, 1, 6, 7, 2, 11, 8, 12, 3, 15, 13, 9, 16, 4, 18, 14, 17, 10, 19, 5, 20}};
57 }
58 
59 template <>
60 void
62  std::vector<unsigned int> &index_map) const
63 {
64  Assert(index_map.size() == this->n(),
65  ExcDimensionMismatch(index_map.size(), this->n()));
66  Assert(p <= 5, ExcNotImplemented());
67 
68  // Given the number i of the
69  // polynomial in
70  // @f$1,x,y,xy,x2,y2,...@f$,
71  // index_map[i] gives the number of
72  // the polynomial in
73  // PolynomialSpace.
74  for (unsigned int i = 0; i < this->n(); ++i)
75  index_map[i] = imap2[p][i];
76 }
77 
78 
79 namespace
80 {
81  const unsigned int imap3[4][20] = {{0},
82  {0, 1, 2, 3},
83  {0, 1, 3, 6, 4, 7, 8, 2, 5, 9},
84  {0, 1, 4, 10, 5, 11, 13, 2, 7, 16,
85  14, 6, 12, 8, 15, 17, 18, 3, 9, 19}};
86 }
87 
88 template <>
89 void
91  std::vector<unsigned int> &index_map) const
92 {
93  Assert(index_map.size() == this->n(),
94  ExcDimensionMismatch(index_map.size(), this->n()));
95  Assert(p <= 3, ExcNotImplemented());
96 
97  // Given the number i of the
98  // polynomial in
99  // @f$1,x,y,xy,x2,y2,...@f$,
100  // index_map[i] gives the number of
101  // the polynomial in
102  // PolynomialSpace.
103  for (unsigned int i = 0; i < this->n(); ++i)
104  index_map[i] = imap3[p][i];
105 }
106 
107 
108 
109 template class PolynomialsP<1>;
110 template class PolynomialsP<2>;
111 template class PolynomialsP<3>;
112 
113 DEAL_II_NAMESPACE_CLOSE
void create_polynomial_ordering(std::vector< unsigned int > &index_map) const
void set_numbering(const std::vector< unsigned int > &renumber)
#define Assert(cond, exc)
Definition: exceptions.h:1407
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
unsigned int n() const
static ::ExceptionBase & ExcNotImplemented()
std::vector< unsigned int > index_map
PolynomialsP(const unsigned int p)