]> https://gitweb.dealii.org/ - dealii.git/blob - tests/base/polynomials_tensor.cc
Update copyright years.
[dealii.git] / tests / base / polynomials_tensor.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 2017 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 // Output function values and derivatives for vector valued
18 // polynomials returning Tensor<1,dim> for their values.
19
20 // classes: PolynomialsBDM, PolynomialsRaviartThomas
21
22 #include "../tests.h"
23 #include <deal.II/base/polynomials_bdm.h>
24 #include <deal.II/base/polynomials_raviart_thomas.h>
25
26 #include <vector>
27
28 using namespace std;
29
30 template <int dim, class PolynomialType>
31 void check_point (const Point<dim>     &x,
32                   const PolynomialType &p)
33 {
34   const unsigned int n = p.n();
35   std::vector<Tensor<1,dim> > values(n);
36   std::vector<Tensor<2,dim> > gradients(n);
37   std::vector<Tensor<3,dim> > seconds(0);
38   std::vector<Tensor<4,dim> > thirds(0);
39   std::vector<Tensor<5,dim> > fourths(0);
40
41   p.compute(x, values, gradients, seconds, thirds, fourths);
42
43   deallog << "Point " << x << std::endl;
44   for (unsigned int i=0; i<n; ++i)
45     {
46       deallog << "p[" << i << "] value ";
47       for (unsigned int d=0; d<dim; ++d)
48         deallog << (int) (values[i][d]+.5) << ' ';
49       deallog << " first ";
50       for (unsigned int d1=0; d1<dim; ++d1)
51         for (unsigned int d2=0; d2<dim; ++d2)
52           deallog << (int) (gradients[i][d1][d2]+.5) << ' ';
53       deallog << std::endl;
54     }
55 }
56
57
58 template <int dim>
59 void check_bdm ()
60 {
61   Point<dim> x;
62
63   PolynomialsBDM<dim> p1(1);
64   PolynomialsBDM<dim> p2(2);
65   PolynomialsBDM<dim> p3(3);
66   PolynomialsBDM<dim> p4(4);
67
68   x(0) = 2.;
69   x(1) = 3.;
70   if (dim>2)
71     x(2) = 4;
72
73   check_point(x, p1);
74   check_point(x, p2);
75   check_point(x, p3);
76   check_point(x, p4);
77 }
78
79 template <int dim>
80 void check_rt ()
81 {
82   Point<dim> x;
83
84   PolynomialsRaviartThomas<dim> p0(0);
85   PolynomialsRaviartThomas<dim> p1(1);
86   PolynomialsRaviartThomas<dim> p2(2);
87   PolynomialsRaviartThomas<dim> p3(3);
88
89   x(0) = 2.;
90   x(1) = 3.;
91   if (dim>2)
92     x(2) = 4;
93
94   check_point(x, p0);
95   check_point(x, p1);
96   check_point(x, p2);
97   check_point(x, p3);
98 }
99
100 int main()
101 {
102   std::ofstream logfile("output");
103   deallog << std::setprecision(0);
104   deallog.attach(logfile);
105
106   deallog.push("BDM");
107   check_bdm<2>();
108   check_bdm<3>();
109   deallog.pop();
110   deallog.push("RT");
111   check_rt<2>();
112   check_rt<3>();
113   deallog.pop();
114 }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.