Reference documentation for deal.II version 8.5.1
polynomials_p.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 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/polynomials_p.h>
18 
19 DEAL_II_NAMESPACE_OPEN
20 
21 
22 template <int dim>
23 PolynomialsP<dim>::PolynomialsP (const unsigned int p)
24  :
25  PolynomialSpace<dim>(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 <>
36  std::vector<unsigned int> &index_map) const
37 {
38  Assert(index_map.size()==this->n(),
39  ExcDimensionMismatch(index_map.size(), this->n()));
40 
41  // identity
42  for (unsigned int i=0; i<this->n(); ++i)
43  index_map[i]=i;
44 }
45 
46 
47 namespace
48 {
49  const unsigned int imap2[6][21]=
50  {
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 
60 template <>
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]=
82  {
83  {0},
84  {0,1,2,3},
85  {0,1,3,6,4,7,8,2,5,9},
86  {0,1,4,10,5,11,13,2,7,16,14,6,12,8,15,17,18,3,9,19}
87  };
88 }
89 
90 template <>
92  std::vector<unsigned int> &index_map) const
93 {
94  Assert(index_map.size()==this->n(),
95  ExcDimensionMismatch(index_map.size(), this->n()));
96  Assert(p<=3, ExcNotImplemented());
97 
98  // Given the number i of the
99  // polynomial in
100  // @f$1,x,y,xy,x2,y2,...@f$,
101  // index_map[i] gives the number of
102  // the polynomial in
103  // PolynomialSpace.
104  for (unsigned int i=0; i<this->n(); ++i)
105  index_map[i]=imap3[p][i];
106 }
107 
108 
109 
110 template class PolynomialsP<1>;
111 template class PolynomialsP<2>;
112 template class PolynomialsP<3>;
113 
114 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:313
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)