Reference documentation for deal.II version 8.1.0
tensor_product_polynomials.h
1 // ---------------------------------------------------------------------
2 // @f$Id: tensor_product_polynomials.h 31772 2013-11-23 08:02:51Z kanschat @f$
3 //
4 // Copyright (C) 2000 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__tensor_product_polynomials_h
18 #define __deal2__tensor_product_polynomials_h
19 
20 
21 #include <deal.II/base/config.h>
23 #include <deal.II/base/tensor.h>
24 #include <deal.II/base/point.h>
25 #include <deal.II/base/polynomial.h>
26 #include <deal.II/base/utilities.h>
27 
28 #include <vector>
29 
31 
66 template <int dim, typename POLY=Polynomials::Polynomial<double> >
68 {
69 public:
74  static const unsigned int dimension = dim;
75 
82  template <class Pol>
83  TensorProductPolynomials (const std::vector<Pol> &pols);
84 
88  void output_indices(std::ostream &out) const;
89 
94  void set_numbering(const std::vector<unsigned int> &renumber);
95 
99  const std::vector<unsigned int> &get_numbering() const;
100 
104  const std::vector<unsigned int> &get_numbering_inverse() const;
105 
118  void compute (const Point<dim> &unit_point,
119  std::vector<double> &values,
120  std::vector<Tensor<1,dim> > &grads,
121  std::vector<Tensor<2,dim> > &grad_grads) const;
122 
135  double compute_value (const unsigned int i,
136  const Point<dim> &p) const;
137 
150  Tensor<1,dim> compute_grad (const unsigned int i,
151  const Point<dim> &p) const;
152 
165  Tensor<2,dim> compute_grad_grad (const unsigned int i,
166  const Point<dim> &p) const;
167 
172  unsigned int n () const;
173 
174 
175 protected:
179  std::vector<POLY> polynomials;
180 
184  unsigned int n_tensor_pols;
185 
189  std::vector<unsigned int> index_map;
190 
194  std::vector<unsigned int> index_map_inverse;
195 
202  // fix to avoid compiler warnings about zero length arrays
203  void compute_index (const unsigned int i,
204  unsigned int (&indices)[(dim>0?dim:1)]) const;
205 };
206 
207 
208 
228 template <int dim>
230 {
231 public:
239  AnisotropicPolynomials (const std::vector<std::vector<Polynomials::Polynomial<double> > > &pols);
240 
254  void compute (const Point<dim> &unit_point,
255  std::vector<double> &values,
256  std::vector<Tensor<1,dim> > &grads,
257  std::vector<Tensor<2,dim> > &grad_grads) const;
258 
271  double compute_value (const unsigned int i,
272  const Point<dim> &p) const;
273 
286  Tensor<1,dim> compute_grad (const unsigned int i,
287  const Point<dim> &p) const;
288 
301  Tensor<2,dim> compute_grad_grad (const unsigned int i,
302  const Point<dim> &p) const;
303 
308  unsigned int n () const;
309 
310 private:
314  std::vector<std::vector<Polynomials::Polynomial<double> > > polynomials;
315 
320  unsigned int n_tensor_pols;
321 
328  void compute_index (const unsigned int i,
329  unsigned int (&indices)[dim]) const;
330 
334  static
335  unsigned int
336  get_n_tensor_pols (const std::vector<std::vector<Polynomials::Polynomial<double> > > &pols);
337 };
338 
341 #ifndef DOXYGEN
342 
343 
344 /* ---------------- template and inline functions ---------- */
345 
346 
347 template <int dim, typename POLY>
348 template <class Pol>
349 inline
351 TensorProductPolynomials(const std::vector<Pol> &pols)
352  :
353  polynomials (pols.begin(), pols.end()),
354  n_tensor_pols(Utilities::fixed_power<dim>(pols.size())),
355  index_map(n_tensor_pols),
356  index_map_inverse(n_tensor_pols)
357 {
358  // per default set this index map to identity. This map can be changed by
359  // the user through the set_numbering() function
360  for (unsigned int i=0; i<n_tensor_pols; ++i)
361  {
362  index_map[i]=i;
363  index_map_inverse[i]=i;
364  }
365 }
366 
367 
368 
369 template <int dim, typename POLY>
370 inline
371 unsigned int
373 {
374  if (dim == 0)
376  else
377  return n_tensor_pols;
378 }
379 
380 
381 
382 template <int dim, typename POLY>
383 inline
384 const std::vector<unsigned int> &
386 {
387  return index_map;
388 }
389 
390 
391 template <int dim, typename POLY>
392 inline
393 const std::vector<unsigned int> &
395 {
396  return index_map_inverse;
397 }
398 
399 
400 
401 #endif // DOXYGEN
402 DEAL_II_NAMESPACE_CLOSE
403 
404 #endif
double compute_value(const unsigned int i, const Point< dim > &p) const
AnisotropicPolynomials(const std::vector< std::vector< Polynomials::Polynomial< double > > > &pols)
void compute_index(const unsigned int i, unsigned int(&indices)[(dim >0?dim:1)]) const
static const unsigned int invalid_unsigned_int
Definition: types.h:191
static const unsigned int dimension
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
std::vector< std::vector< Polynomials::Polynomial< double > > > polynomials
void compute(const Point< dim > &unit_point, std::vector< double > &values, std::vector< Tensor< 1, dim > > &grads, std::vector< Tensor< 2, dim > > &grad_grads) const
void output_indices(std::ostream &out) const
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const
std::vector< unsigned int > index_map_inverse
void set_numbering(const std::vector< unsigned int > &renumber)
unsigned int n() const
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const
static unsigned int get_n_tensor_pols(const std::vector< std::vector< Polynomials::Polynomial< double > > > &pols)
unsigned int n() const
const std::vector< unsigned int > & get_numbering_inverse() const
Definition: mpi.h:54
void compute(const Point< dim > &unit_point, std::vector< double > &values, std::vector< Tensor< 1, dim > > &grads, std::vector< Tensor< 2, dim > > &grad_grads) const
const std::vector< unsigned int > & get_numbering() const
TensorProductPolynomials(const std::vector< Pol > &pols)
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const
void compute_index(const unsigned int i, unsigned int(&indices)[dim]) const
std::vector< unsigned int > index_map
double compute_value(const unsigned int i, const Point< dim > &p) const