17 #include <deal.II/base/geometry_info.h> 18 #include <deal.II/base/polynomials_bdm.h> 19 #include <deal.II/base/polynomial_space.h> 20 #include <deal.II/base/quadrature_lib.h> 24 DEAL_II_NAMESPACE_OPEN
30 polynomial_space (
Polynomials::Legendre::generate_complete_basis(k)),
31 monomials((dim==2) ? (1) : (k+2)),
32 n_pols(compute_n_pols(k)),
33 p_values(polynomial_space.n()),
34 p_grads(polynomial_space.n()),
35 p_grad_grads(polynomial_space.n())
43 for (
unsigned int i=0; i<
monomials.size(); ++i)
62 Assert(values.size()==n_pols || values.size()==0,
64 Assert(grads.size()==n_pols|| grads.size()==0,
66 Assert(grad_grads.size()==n_pols|| grad_grads.size()==0,
68 Assert(third_derivatives.size()==n_pols|| third_derivatives.size()==0,
70 Assert(fourth_derivatives.size()==n_pols|| fourth_derivatives.size()==0,
74 (void)third_derivatives;
75 Assert(third_derivatives.size()==0,
77 (void)fourth_derivatives;
78 Assert(fourth_derivatives.size()==0,
81 const unsigned int n_sub = polynomial_space.n();
91 p_values.resize((values.size() == 0) ? 0 : n_sub);
92 p_grads.resize((grads.size() == 0) ? 0 : n_sub);
93 p_grad_grads.resize((grad_grads.size() == 0) ? 0 : n_sub);
100 polynomial_space.compute (unit_point, p_values, p_grads, p_grad_grads,
101 p_third_derivatives, p_fourth_derivatives);
104 for (
unsigned int i=0; i<p_values.size(); ++i)
105 for (
unsigned int j=0; j<dim; ++j)
106 values[i+j*n_sub][j] = p_values[i];
109 for (
unsigned int i=0; i<p_grads.size(); ++i)
110 for (
unsigned int j=0; j<dim; ++j)
111 grads[i+j*n_sub][j] = p_grads[i];
113 std::fill(grad_grads.begin(), grad_grads.end(),
Tensor<3,dim>());
114 for (
unsigned int i=0; i<p_grad_grads.size(); ++i)
115 for (
unsigned int j=0; j<dim; ++j)
116 grad_grads[i+j*n_sub][j] = p_grad_grads[i];
121 unsigned int start = dim*n_sub;
126 std::vector<std::vector<double> > monovali(dim, std::vector<double>(4));
127 std::vector<std::vector<double> > monovalk(dim, std::vector<double>(4));
131 for (
unsigned int d=0; d<dim; ++d)
132 monomials[0].value(unit_point(d), monovali[d]);
133 if (values.size() != 0)
135 values[start][0] = monovali[0][0];
136 values[start][1] = -unit_point(1) * monovali[0][1];
137 values[start+1][0] = unit_point(0) * monovali[1][1];
138 values[start+1][1] = -monovali[1][0];
140 if (grads.size() != 0)
142 grads[start][0][0] = monovali[0][1];
143 grads[start][0][1] = 0.;
144 grads[start][1][0] = -unit_point(1) * monovali[0][2];
145 grads[start][1][1] = -monovali[0][1];
146 grads[start+1][0][0] = monovali[1][1];
147 grads[start+1][0][1] = unit_point(0) * monovali[1][2];
148 grads[start+1][1][0] = 0.;
149 grads[start+1][1][1] = -monovali[1][1];
151 if (grad_grads.size() != 0)
153 grad_grads[start][0][0][0] = monovali[0][2];
154 grad_grads[start][0][0][1] = 0.;
155 grad_grads[start][0][1][0] = 0.;
156 grad_grads[start][0][1][1] = 0.;
157 grad_grads[start][1][0][0] = -unit_point(1) * monovali[0][3];
158 grad_grads[start][1][0][1] = -monovali[0][2];
159 grad_grads[start][1][1][0] = -monovali[0][2];
160 grad_grads[start][1][1][1] = 0.;
161 grad_grads[start+1][0][0][0] = 0;
162 grad_grads[start+1][0][0][1] = monovali[1][2];
163 grad_grads[start+1][0][1][0] = monovali[1][2];
164 grad_grads[start+1][0][1][1] = unit_point(0) * monovali[1][3];
165 grad_grads[start+1][1][0][0] = 0.;
166 grad_grads[start+1][1][0][1] = 0.;
167 grad_grads[start+1][1][1][0] = 0.;
168 grad_grads[start+1][1][1][1] = -monovali[1][2];
183 const unsigned int n_curls = monomials.size() - 1;
184 for (
unsigned int i=0; i<n_curls; ++i, start+=dim)
186 for (
unsigned int d=0; d<dim; ++d)
189 monomials[i+1].value(unit_point(d), monovali[d]);
191 monomials[degree()-i].value(unit_point(d), monovalk[d]);
193 if (values.size() != 0)
196 values[start][0] = unit_point(0) * monovali[1][1] * monovalk[2][0];
198 values[start][1] = -monovali[1][0] * monovalk[2][0];
199 values[start][2] = 0.;
202 values[start+1][1] = unit_point(1) * monovali[2][1] * monovalk[0][0];
204 values[start+1][2] = -monovali[2][0] * monovalk[0][0];
205 values[start+1][0] = 0.;
208 values[start+2][2] = unit_point(2) * monovali[0][1] * monovalk[1][0];
210 values[start+2][0] = -monovali[0][0] * monovalk[1][0];
211 values[start+2][1] = 0.;
213 if (grads.size() != 0)
215 grads[start][0][0] = monovali[1][1] * monovalk[2][0];
216 grads[start][0][1] = unit_point(0) * monovali[1][2] * monovalk[2][0];
217 grads[start][0][2] = unit_point(0) * monovali[1][1] * monovalk[2][1];
218 grads[start][1][0] = 0.;
219 grads[start][1][1] = -monovali[1][1] * monovalk[2][0];
220 grads[start][1][2] = -monovali[1][0] * monovalk[2][1];
221 grads[start][2][0] = 0.;
222 grads[start][2][1] = 0.;
223 grads[start][2][2] = 0.;
225 grads[start+1][1][1] = monovali[2][1] * monovalk[0][0];
226 grads[start+1][1][2] = unit_point(1) * monovali[2][2] * monovalk[0][0];
227 grads[start+1][1][0] = unit_point(1) * monovali[2][1] * monovalk[0][1];
228 grads[start+1][2][1] = 0.;
229 grads[start+1][2][2] = -monovali[2][1] * monovalk[0][0];
230 grads[start+1][2][0] = -monovali[2][0] * monovalk[0][1];
231 grads[start+1][0][1] = 0.;
232 grads[start+1][0][2] = 0.;
233 grads[start+1][0][0] = 0.;
235 grads[start+2][2][2] = monovali[0][1] * monovalk[1][0];
236 grads[start+2][2][0] = unit_point(2) * monovali[0][2] * monovalk[1][0];
237 grads[start+2][2][1] = unit_point(2) * monovali[0][1] * monovalk[1][1];
238 grads[start+2][0][2] = 0.;
239 grads[start+2][0][0] = -monovali[0][1] * monovalk[1][0];
240 grads[start+2][0][1] = -monovali[0][0] * monovalk[1][1];
241 grads[start+2][1][2] = 0.;
242 grads[start+2][1][0] = 0.;
243 grads[start+2][1][1] = 0.;
245 if (grad_grads.size() != 0)
247 grad_grads[start][0][0][0] = 0.;
248 grad_grads[start][0][0][1] = monovali[1][2]*monovalk[2][0];
249 grad_grads[start][0][0][2] = monovali[1][1]*monovalk[2][1];
250 grad_grads[start][0][1][0] = monovali[1][2]*monovalk[2][0];
251 grad_grads[start][0][1][1] = unit_point(0)*monovali[1][3]*monovalk[2][0];
252 grad_grads[start][0][1][2] = unit_point(0)*monovali[1][2]*monovalk[2][1];
253 grad_grads[start][0][2][0] = monovali[1][1]*monovalk[2][1];
254 grad_grads[start][0][2][1] = unit_point(0)*monovali[1][2]*monovalk[2][1];
255 grad_grads[start][0][2][2] = unit_point(0)*monovali[1][1]*monovalk[2][2];
256 grad_grads[start][1][0][0] = 0.;
257 grad_grads[start][1][0][1] = 0.;
258 grad_grads[start][1][0][2] = 0.;
259 grad_grads[start][1][1][0] = 0.;
260 grad_grads[start][1][1][1] = -monovali[1][2]*monovalk[2][0];
261 grad_grads[start][1][1][2] = -monovali[1][1]*monovalk[2][1];
262 grad_grads[start][1][2][0] = 0.;
263 grad_grads[start][1][2][1] = -monovali[1][1]*monovalk[2][1];
264 grad_grads[start][1][2][2] = -monovali[1][0]*monovalk[2][2];
265 grad_grads[start][2][0][0] = 0.;
266 grad_grads[start][2][0][1] = 0.;
267 grad_grads[start][2][0][2] = 0.;
268 grad_grads[start][2][1][0] = 0.;
269 grad_grads[start][2][1][1] = 0.;
270 grad_grads[start][2][1][2] = 0.;
271 grad_grads[start][2][2][0] = 0.;
272 grad_grads[start][2][2][1] = 0.;
273 grad_grads[start][2][2][2] = 0.;
275 grad_grads[start+1][0][0][0] = 0.;
276 grad_grads[start+1][0][0][1] = 0.;
277 grad_grads[start+1][0][0][2] = 0.;
278 grad_grads[start+1][0][1][0] = 0.;
279 grad_grads[start+1][0][1][1] = 0.;
280 grad_grads[start+1][0][1][2] = 0.;
281 grad_grads[start+1][0][2][0] = 0.;
282 grad_grads[start+1][0][2][1] = 0.;
283 grad_grads[start+1][0][2][2] = 0.;
284 grad_grads[start+1][1][0][0] = unit_point(1)*monovali[2][1]*monovalk[0][2];
285 grad_grads[start+1][1][0][1] = monovali[2][1]*monovalk[0][1];
286 grad_grads[start+1][1][0][2] = unit_point(1)*monovali[2][2]*monovalk[0][1];
287 grad_grads[start+1][1][1][0] = monovalk[0][1]*monovali[2][1];
288 grad_grads[start+1][1][1][1] = 0.;
289 grad_grads[start+1][1][1][2] = monovalk[0][0]*monovali[2][2];
290 grad_grads[start+1][1][2][0] = unit_point(1)*monovalk[0][1]*monovali[2][2];
291 grad_grads[start+1][1][2][1] = monovalk[0][0]*monovali[2][2];
292 grad_grads[start+1][1][2][2] = unit_point(1)*monovalk[0][0]*monovali[2][3];
293 grad_grads[start+1][2][0][0] = -monovalk[0][2]*monovali[2][0];
294 grad_grads[start+1][2][0][1] = 0.;
295 grad_grads[start+1][2][0][2] = -monovalk[0][1]*monovali[2][1];
296 grad_grads[start+1][2][1][0] = 0.;
297 grad_grads[start+1][2][1][1] = 0.;
298 grad_grads[start+1][2][1][2] = 0.;
299 grad_grads[start+1][2][2][0] = -monovalk[0][1]*monovali[2][1];
300 grad_grads[start+1][2][2][1] = 0.;
301 grad_grads[start+1][2][2][2] = -monovalk[0][0]*monovali[2][2];
303 grad_grads[start+2][0][0][0] = -monovali[0][2]*monovalk[1][0];
304 grad_grads[start+2][0][0][1] = -monovali[0][1]*monovalk[1][1];
305 grad_grads[start+2][0][0][2] = 0.;
306 grad_grads[start+2][0][1][0] = -monovali[0][1]*monovalk[1][1];
307 grad_grads[start+2][0][1][1] = -monovali[0][0]*monovalk[1][2];
308 grad_grads[start+2][0][1][2] = 0.;
309 grad_grads[start+2][0][2][0] = 0.;
310 grad_grads[start+2][0][2][1] = 0.;
311 grad_grads[start+2][0][2][2] = 0.;
312 grad_grads[start+2][1][0][0] = 0.;
313 grad_grads[start+2][1][0][1] = 0.;
314 grad_grads[start+2][1][0][2] = 0.;
315 grad_grads[start+2][1][1][0] = 0.;
316 grad_grads[start+2][1][1][1] = 0.;
317 grad_grads[start+2][1][1][2] = 0.;
318 grad_grads[start+2][1][2][0] = 0.;
319 grad_grads[start+2][1][2][1] = 0.;
320 grad_grads[start+2][1][2][2] = 0.;
321 grad_grads[start+2][2][0][0] = unit_point(2)*monovali[0][3]*monovalk[1][0];
322 grad_grads[start+2][2][0][1] = unit_point(2)*monovali[0][2]*monovalk[1][1];
323 grad_grads[start+2][2][0][2] = monovali[0][2]*monovalk[1][0];
324 grad_grads[start+2][2][1][0] = unit_point(2)*monovali[0][2]*monovalk[1][1];
325 grad_grads[start+2][2][1][1] = unit_point(2)*monovali[0][1]*monovalk[1][2];
326 grad_grads[start+2][2][1][2] = monovali[0][1]*monovalk[1][1];
327 grad_grads[start+2][2][2][0] = monovali[0][2]*monovalk[1][0];
328 grad_grads[start+2][2][2][1] = monovali[0][1]*monovalk[1][1];
329 grad_grads[start+2][2][2][2] = 0.;
410 if (dim == 1)
return k+1;
411 if (dim == 2)
return (k+1)*(k+2)+2;
412 if (dim == 3)
return ((k+1)*(k+2)*(k+3))/2+3*(k+1);
423 DEAL_II_NAMESPACE_CLOSE
PolynomialsBDM(const unsigned int k)
void compute(const Point< dim > &unit_point, std::vector< Tensor< 1, dim > > &values, std::vector< Tensor< 2, dim > > &grads, std::vector< Tensor< 3, dim > > &grad_grads, std::vector< Tensor< 4, dim > > &third_derivatives, std::vector< Tensor< 5, dim > > &fourth_derivatives) const
std::vector< Polynomials::Polynomial< double > > monomials
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static unsigned int compute_n_pols(unsigned int degree)
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcInternalError()