Reference documentation for deal.II version 9.0.0
polynomials_adini.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 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_adini.h>
18 
19 #define ENTER_COEFFICIENTS(koefs,z,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
20  koefs(0, z)= a0; koefs(1, z)=a1; koefs(2, z)=a2; koefs(3, z)=a3; koefs( 4, z)=a4 ; koefs( 5, z)=a5 ; \
21  koefs(6, z)= a6; koefs(7, z)=a7; koefs(8, z)=a8; koefs(9, z)=a9; koefs(10, z)=a10; koefs(11, z)=a11;
22 
23 
24 DEAL_II_NAMESPACE_OPEN
25 
26 
28  coef(12,12),
29  dx(12,12),
30  dy(12,12),
31  dxx(12,12),
32  dyy(12,12),
33  dxy(12,12)
34 {
35  // 1 x y xx yy xy 3x 3y xyy xxy 3xy x3y
36  // 0 1 2 3 4 5 6 7 8 9 10 11
37  ENTER_COEFFICIENTS(coef, 0, 1, 0, 0,-3,-3,-1, 2, 2, 3, 3,-2,-2);
38  ENTER_COEFFICIENTS(coef, 1, 0, 1, 0,-2, 0,-1, 1, 0, 0, 2,-1, 0);
39  ENTER_COEFFICIENTS(coef, 2, 0, 0, 1, 0,-2,-1, 0, 1, 2, 0, 0,-1);
40  ENTER_COEFFICIENTS(coef, 3, 0, 0, 0, 3, 0, 1,-2, 0,-3,-3, 2, 2);
41  ENTER_COEFFICIENTS(coef, 4, 0, 0, 0,-1, 0, 0, 1, 0, 0, 1,-1, 0);
42  ENTER_COEFFICIENTS(coef, 5, 0, 0, 0, 0, 0, 1, 0, 0,-2, 0, 0, 1);
43  ENTER_COEFFICIENTS(coef, 6, 0, 0, 0, 0, 3, 1, 0,-2,-3,-3, 2, 2);
44  ENTER_COEFFICIENTS(coef, 7, 0, 0, 0, 0, 0, 1, 0, 0, 0,-2, 1, 0);
45  ENTER_COEFFICIENTS(coef, 8, 0, 0, 0, 0,-1, 0, 0, 1, 1, 0, 0,-1);
46  ENTER_COEFFICIENTS(coef, 9, 0, 0, 0, 0, 0,-1, 0, 0, 3, 3,-2,-2);
47  ENTER_COEFFICIENTS(coef, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0,-1, 1, 0);
48  ENTER_COEFFICIENTS(coef, 11, 0, 0, 0, 0, 0, 0, 0, 0,-1, 0, 0, 1);
49 
50  ENTER_COEFFICIENTS( dx, 0, 0,-6,-1, 6, 3, 6, 0,-2, 0,-6, 0, 0);
51  ENTER_COEFFICIENTS( dx, 1, 1,-4,-1, 3, 0, 4, 0, 0, 0,-3, 0, 0);
52  ENTER_COEFFICIENTS( dx, 2, 0, 0,-1, 0, 2, 0, 0,-1, 0, 0, 0, 0);
53  ENTER_COEFFICIENTS( dx, 3, 0, 6, 1,-6,-3,-6, 0, 2, 0, 6, 0, 0);
54  ENTER_COEFFICIENTS( dx, 4, 0,-2, 0, 3, 0, 2, 0, 0, 0,-3, 0, 0);
55  ENTER_COEFFICIENTS( dx, 5, 0, 0, 1, 0,-2, 0, 0, 1, 0, 0, 0, 0);
56  ENTER_COEFFICIENTS( dx, 6, 0, 0, 1, 0,-3,-6, 0, 2, 0, 6, 0, 0);
57  ENTER_COEFFICIENTS( dx, 7, 0, 0, 1, 0, 0,-4, 0, 0, 0, 3, 0, 0);
58  ENTER_COEFFICIENTS( dx, 8, 0, 0, 0, 0, 1, 0, 0,-1, 0, 0, 0, 0);
59  ENTER_COEFFICIENTS( dx, 9, 0, 0,-1, 0, 3, 6, 0,-2, 0,-6, 0, 0);
60  ENTER_COEFFICIENTS( dx, 10, 0, 0, 0, 0, 0,-2, 0, 0, 0, 3, 0, 0);
61  ENTER_COEFFICIENTS( dx, 11, 0, 0, 0, 0,-1, 0, 0, 1, 0, 0, 0, 0);
62 
63  ENTER_COEFFICIENTS( dy, 0, 0,-1,-6, 3, 6, 6,-2, 0,-6, 0, 0, 0);
64  ENTER_COEFFICIENTS( dy, 1, 0,-1, 0, 2, 0, 0,-1, 0, 0, 0, 0, 0);
65  ENTER_COEFFICIENTS( dy, 2, 1,-1,-4, 0, 3, 4, 0, 0,-3, 0, 0, 0);
66  ENTER_COEFFICIENTS( dy, 3, 0, 1, 0,-3, 0,-6, 2, 0, 6, 0, 0, 0);
67  ENTER_COEFFICIENTS( dy, 4, 0, 0, 0, 1, 0, 0,-1, 0, 0, 0, 0, 0);
68  ENTER_COEFFICIENTS( dy, 5, 0, 1, 0, 0, 0,-4, 0, 0, 3, 0, 0, 0);
69  ENTER_COEFFICIENTS( dy, 6, 0, 1, 6,-3,-6,-6, 2, 0, 6, 0, 0, 0);
70  ENTER_COEFFICIENTS( dy, 7, 0, 1, 0,-2, 0, 0, 1, 0, 0, 0, 0, 0);
71  ENTER_COEFFICIENTS( dy, 8, 0, 0,-2, 0, 3, 2, 0, 0,-3, 0, 0, 0);
72  ENTER_COEFFICIENTS( dy, 9, 0,-1, 0, 3, 0, 6,-2, 0,-6, 0, 0, 0);
73  ENTER_COEFFICIENTS( dy, 10, 0, 0, 0,-1, 0, 0, 1, 0, 0, 0, 0, 0);
74  ENTER_COEFFICIENTS( dy, 11, 0, 0, 0, 0, 0,-2, 0, 0, 3, 0, 0, 0);
75 
76  // 0 1 2 3 4 5 6 7 8 9 10 11
77  ENTER_COEFFICIENTS( dxx, 0,-6, 12, 6, 0, 0,-12, 0, 0, 0, 0, 0, 0);
78  ENTER_COEFFICIENTS( dxx, 1,-4, 6, 4, 0, 0, -6, 0, 0, 0, 0, 0, 0);
79  ENTER_COEFFICIENTS( dxx, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
80  ENTER_COEFFICIENTS( dxx, 3, 6,-12,-6, 0, 0, 12, 0, 0, 0, 0, 0, 0);
81  ENTER_COEFFICIENTS( dxx, 4,-2, 6, 2, 0, 0, -6, 0, 0, 0, 0, 0, 0);
82  ENTER_COEFFICIENTS( dxx, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
83  ENTER_COEFFICIENTS( dxx, 6, 0, 0,-6, 0, 0, 12, 0, 0, 0, 0, 0, 0);
84  ENTER_COEFFICIENTS( dxx, 7, 0, 0,-4, 0, 0, 6, 0, 0, 0, 0, 0, 0);
85  ENTER_COEFFICIENTS( dxx, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
86  ENTER_COEFFICIENTS( dxx, 9, 0, 0, 6, 0, 0,-12, 0, 0, 0, 0, 0, 0);
87  ENTER_COEFFICIENTS( dxx, 10, 0, 0,-2, 0, 0, 6, 0, 0, 0, 0, 0, 0);
88  ENTER_COEFFICIENTS( dxx, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
89 
90  ENTER_COEFFICIENTS( dyy, 0,-6, 6, 12, 0, 0,-12, 0, 0, 0, 0, 0, 0);
91  ENTER_COEFFICIENTS( dyy, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
92  ENTER_COEFFICIENTS( dyy, 2,-4, 4, 6, 0, 0, -6, 0, 0, 0, 0, 0, 0);
93  ENTER_COEFFICIENTS( dyy, 3, 0,-6, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0);
94  ENTER_COEFFICIENTS( dyy, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
95  ENTER_COEFFICIENTS( dyy, 5, 0,-4, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0);
96  ENTER_COEFFICIENTS( dyy, 6, 6,-6,-12, 0, 0, 12, 0, 0, 0, 0, 0, 0);
97  ENTER_COEFFICIENTS( dyy, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
98  ENTER_COEFFICIENTS( dyy, 8,-2, 2, 6, 0, 0, -6, 0,-0, 0, 0, 0, 0);
99  ENTER_COEFFICIENTS( dyy, 9, 0, 6, 0, 0, 0,-12, 0, 0, 0, 0, 0, 0);
100  ENTER_COEFFICIENTS( dyy, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
101  ENTER_COEFFICIENTS( dyy, 11, 0,-2, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0);
102 
103  ENTER_COEFFICIENTS( dxy, 0,-1, 6, 6,-6,-6, 0, 0, 0, 0, 0, 0, 0);
104  ENTER_COEFFICIENTS( dxy, 1,-1, 4, 0,-3, 0, 0, 0, 0, 0, 0, 0, 0);
105  ENTER_COEFFICIENTS( dxy, 2,-1, 0, 4, 0,-3, 0, 0, 0, 0, 0, 0, 0);
106  ENTER_COEFFICIENTS( dxy, 3, 1,-6,-6, 6, 6, 0, 0, 0, 0, 0, 0, 0);
107  ENTER_COEFFICIENTS( dxy, 4, 0, 2, 0,-3, 0, 0, 0, 0, 0, 0, 0, 0);
108  ENTER_COEFFICIENTS( dxy, 5, 1, 0,-4, 0, 3, 0, 0, 0, 0, 0, 0, 0);
109  ENTER_COEFFICIENTS( dxy, 6, 1,-6,-6, 6, 6, 0, 0, 0, 0, 0, 0, 0);
110  ENTER_COEFFICIENTS( dxy, 7, 1,-4, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0);
111  ENTER_COEFFICIENTS( dxy, 8, 0, 0, 2, 0,-3, 0, 0, 0, 0, 0, 0, 0);
112  ENTER_COEFFICIENTS( dxy, 9,-1, 6, 6,-6,-6, 0, 0, 0, 0, 0, 0, 0);
113  ENTER_COEFFICIENTS( dxy, 10, 0,-2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0);
114  ENTER_COEFFICIENTS( dxy, 11, 0, 0,-2, 0, 3, 0, 0, 0, 0, 0, 0, 0);
115 }
116 
117 void
119  std::vector<double> &values,
120  std::vector<Tensor<1,2> > &grads,
121  std::vector< Tensor<2,2> > &grad_grads) const
122 {
123  if (values.empty() == false) // do not bother if empty
124  {
125  for (unsigned int i=0; i<values.size(); ++i)
126  {
127  values[i] = compute_value(i, unit_point);
128  }
129  }
130 
131  if (grads.empty() == false) // do not bother if empty
132  {
133  for (unsigned int i=0; i<grads.size(); ++i)
134  {
135  grads[i] = compute_grad(i, unit_point);
136  }
137  }
138 
139  if (grad_grads.empty() == false) // do not bother if empty
140  {
141  for (unsigned int i=0; i<grad_grads.size(); ++i)
142  {
143  grad_grads[i] = compute_grad_grad(i, unit_point);
144  }
145  }
146  return;
147 }
148 
149 double PolynomialsAdini::compute_value (const unsigned int i, const Point<2> &p) const
150 {
151  const double x = p(0);
152  const double y = p(1);
153  return coef( 0,i) +
154  coef( 1,i)*x +
155  coef( 2,i)*y +
156  coef( 3,i)*x*x +
157  coef( 4,i)*y*y +
158  coef( 5,i)*x*y +
159  coef( 6,i)*x*x*x +
160  coef( 7,i)*y*y*y +
161  coef( 8,i)*x*y*y +
162  coef( 9,i)*x*x*y +
163  coef(10,i)*x*x*x*y +
164  coef(11,i)*x*y*y*y;
165 }
166 
167 Tensor<1,2> PolynomialsAdini::compute_grad (const unsigned int i, const Point<2> &p) const
168 {
169  const double x = p(0);
170  const double y = p(1);
171  Tensor<1,2> tensor;
172  tensor[0]= dx( 0,i) +
173  dx( 1,i)*x +
174  dx( 2,i)*y +
175  dx( 3,i)*x*x +
176  dx( 4,i)*y*y +
177  dx( 5,i)*x*y +
178  dx( 6,i)*x*x*x +
179  dx( 7,i)*y*y*y +
180  dx( 8,i)*x*y*y +
181  dx( 9,i)*x*x*y +
182  dx(10,i)*x*x*x*y +
183  dx(11,i)*x*y*y*y;
184 
185  tensor[1]= dy( 0,i) +
186  dy( 1,i)*x +
187  dy( 2,i)*y +
188  dy( 3,i)*x*x +
189  dy( 4,i)*y*y +
190  dy( 5,i)*x*y +
191  dy( 6,i)*x*x*x +
192  dy( 7,i)*y*y*y +
193  dy( 8,i)*x*y*y +
194  dy( 9,i)*x*x*y +
195  dy(10,i)*x*x*x*y +
196  dy(11,i)*x*y*y*y;
197  return tensor;
198 }
199 
200 Tensor<2,2> PolynomialsAdini::compute_grad_grad (const unsigned int i, const Point<2> &p) const
201 {
202  const double x = p(0);
203  const double y = p(1);
204  Tensor<2,2> tensor;
205  tensor[0][0]= dxx( 0,i) +
206  dxx( 1,i)*x +
207  dxx( 2,i)*y +
208  dxx( 3,i)*x*x +
209  dxx( 4,i)*y*y +
210  dxx( 5,i)*x*y +
211  dxx( 6,i)*x*x*x +
212  dxx( 7,i)*y*y*y +
213  dxx( 8,i)*x*y*y +
214  dxx( 9,i)*x*x*y +
215  dxx(10,i)*x*x*x*y +
216  dxx(11,i)*x*y*y*y;
217  tensor[0][1]= dxy( 0,i) +
218  dxy( 1,i)*x +
219  dxy( 2,i)*y +
220  dxy( 3,i)*x*x +
221  dxy( 4,i)*y*y +
222  dxy( 5,i)*x*y +
223  dxy( 6,i)*x*x*x +
224  dxy( 7,i)*y*y*y +
225  dxy( 8,i)*x*y*y +
226  dxy( 9,i)*x*x*y +
227  dxy(10,i)*x*x*x*y +
228  dxy(11,i)*x*y*y*y;
229  tensor[1][0]= tensor[0][1];
230  tensor[1][1]= dyy( 0,i) +
231  dyy( 1,i)*x +
232  dyy( 2,i)*y +
233  dyy( 3,i)*x*x +
234  dyy( 4,i)*y*y +
235  dyy( 5,i)*x*y +
236  dyy( 6,i)*x*x*x +
237  dyy( 7,i)*y*y*y +
238  dyy( 8,i)*x*y*y +
239  dyy( 9,i)*x*x*y +
240  dyy(10,i)*x*x*x*y +
241  dyy(11,i)*x*y*y*y;
242  return tensor;
243 }
244 
245 
246 DEAL_II_NAMESPACE_CLOSE
Table< 2, double > dyy
double compute_value(const unsigned int i, const Point< 2 > &p) const
Table< 2, double > dxy
Table< 2, double > coef
Tensor< 2, 2 > compute_grad_grad(const unsigned int i, const Point< 2 > &p) const
void compute(const Point< 2 > &unit_point, std::vector< double > &values, std::vector< Tensor< 1, 2 > > &grads, std::vector< Tensor< 2, 2 > > &grad_grads) const
Tensor< 1, 2 > compute_grad(const unsigned int i, const Point< 2 > &p) const
Table< 2, double > dxx
Table< 2, double > dx
Definition: mpi.h:53
Table< 2, double > dy