17 #include <deal.II/base/geometry_info.h> 18 #include <deal.II/base/polynomial_space.h> 19 #include <deal.II/base/polynomials_bdm.h> 20 #include <deal.II/base/quadrature_lib.h> 25 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)
63 Assert(values.size() == n_pols || values.size() == 0,
65 Assert(grads.size() == n_pols || grads.size() == 0,
67 Assert(grad_grads.size() == n_pols || grad_grads.size() == 0,
69 Assert(third_derivatives.size() == n_pols || third_derivatives.size() == 0,
71 Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.size() == 0,
75 (void)third_derivatives;
77 (void)fourth_derivatives;
80 const unsigned int n_sub = polynomial_space.n();
88 std::lock_guard<std::mutex> lock(mutex);
90 p_values.resize((values.size() == 0) ? 0 : n_sub);
91 p_grads.resize((grads.size() == 0) ? 0 : n_sub);
92 p_grad_grads.resize((grad_grads.size() == 0) ? 0 : n_sub);
99 polynomial_space.compute(unit_point,
104 p_fourth_derivatives);
107 for (
unsigned int i = 0; i < p_values.size(); ++i)
108 for (
unsigned int j = 0; j < dim; ++j)
109 values[i + j * n_sub][j] = p_values[i];
112 for (
unsigned int i = 0; i < p_grads.size(); ++i)
113 for (
unsigned int j = 0; j < dim; ++j)
114 grads[i + j * n_sub][j] = p_grads[i];
116 std::fill(grad_grads.begin(), grad_grads.end(),
Tensor<3, dim>());
117 for (
unsigned int i = 0; i < p_grad_grads.size(); ++i)
118 for (
unsigned int j = 0; j < dim; ++j)
119 grad_grads[i + j * n_sub][j] = p_grad_grads[i];
124 unsigned int start = dim * n_sub;
129 std::vector<std::vector<double>> monovali(dim, std::vector<double>(4));
130 std::vector<std::vector<double>> monovalk(dim, std::vector<double>(4));
134 for (
unsigned int d = 0; d < dim; ++d)
135 monomials[0].value(unit_point(d), monovali[d]);
136 if (values.size() != 0)
138 values[start][0] = monovali[0][0];
139 values[start][1] = -unit_point(1) * monovali[0][1];
140 values[start + 1][0] = unit_point(0) * monovali[1][1];
141 values[start + 1][1] = -monovali[1][0];
143 if (grads.size() != 0)
145 grads[start][0][0] = monovali[0][1];
146 grads[start][0][1] = 0.;
147 grads[start][1][0] = -unit_point(1) * monovali[0][2];
148 grads[start][1][1] = -monovali[0][1];
149 grads[start + 1][0][0] = monovali[1][1];
150 grads[start + 1][0][1] = unit_point(0) * monovali[1][2];
151 grads[start + 1][1][0] = 0.;
152 grads[start + 1][1][1] = -monovali[1][1];
154 if (grad_grads.size() != 0)
156 grad_grads[start][0][0][0] = monovali[0][2];
157 grad_grads[start][0][0][1] = 0.;
158 grad_grads[start][0][1][0] = 0.;
159 grad_grads[start][0][1][1] = 0.;
160 grad_grads[start][1][0][0] = -unit_point(1) * monovali[0][3];
161 grad_grads[start][1][0][1] = -monovali[0][2];
162 grad_grads[start][1][1][0] = -monovali[0][2];
163 grad_grads[start][1][1][1] = 0.;
164 grad_grads[start + 1][0][0][0] = 0;
165 grad_grads[start + 1][0][0][1] = monovali[1][2];
166 grad_grads[start + 1][0][1][0] = monovali[1][2];
167 grad_grads[start + 1][0][1][1] = unit_point(0) * monovali[1][3];
168 grad_grads[start + 1][1][0][0] = 0.;
169 grad_grads[start + 1][1][0][1] = 0.;
170 grad_grads[start + 1][1][1][0] = 0.;
171 grad_grads[start + 1][1][1][1] = -monovali[1][2];
186 const unsigned int n_curls = monomials.size() - 1;
187 for (
unsigned int i = 0; i < n_curls; ++i, start += dim)
189 for (
unsigned int d = 0; d < dim; ++d)
192 monomials[i + 1].value(unit_point(d), monovali[d]);
194 monomials[degree() - i].value(unit_point(d), monovalk[d]);
196 if (values.size() != 0)
200 unit_point(0) * monovali[1][1] * monovalk[2][0];
202 values[start][1] = -monovali[1][0] * monovalk[2][0];
203 values[start][2] = 0.;
206 values[start + 1][1] =
207 unit_point(1) * monovali[2][1] * monovalk[0][0];
209 values[start + 1][2] = -monovali[2][0] * monovalk[0][0];
210 values[start + 1][0] = 0.;
213 values[start + 2][2] =
214 unit_point(2) * monovali[0][1] * monovalk[1][0];
216 values[start + 2][0] = -monovali[0][0] * monovalk[1][0];
217 values[start + 2][1] = 0.;
219 if (grads.size() != 0)
221 grads[start][0][0] = monovali[1][1] * monovalk[2][0];
223 unit_point(0) * monovali[1][2] * monovalk[2][0];
225 unit_point(0) * monovali[1][1] * monovalk[2][1];
226 grads[start][1][0] = 0.;
227 grads[start][1][1] = -monovali[1][1] * monovalk[2][0];
228 grads[start][1][2] = -monovali[1][0] * monovalk[2][1];
229 grads[start][2][0] = 0.;
230 grads[start][2][1] = 0.;
231 grads[start][2][2] = 0.;
233 grads[start + 1][1][1] = monovali[2][1] * monovalk[0][0];
234 grads[start + 1][1][2] =
235 unit_point(1) * monovali[2][2] * monovalk[0][0];
236 grads[start + 1][1][0] =
237 unit_point(1) * monovali[2][1] * monovalk[0][1];
238 grads[start + 1][2][1] = 0.;
239 grads[start + 1][2][2] = -monovali[2][1] * monovalk[0][0];
240 grads[start + 1][2][0] = -monovali[2][0] * monovalk[0][1];
241 grads[start + 1][0][1] = 0.;
242 grads[start + 1][0][2] = 0.;
243 grads[start + 1][0][0] = 0.;
245 grads[start + 2][2][2] = monovali[0][1] * monovalk[1][0];
246 grads[start + 2][2][0] =
247 unit_point(2) * monovali[0][2] * monovalk[1][0];
248 grads[start + 2][2][1] =
249 unit_point(2) * monovali[0][1] * monovalk[1][1];
250 grads[start + 2][0][2] = 0.;
251 grads[start + 2][0][0] = -monovali[0][1] * monovalk[1][0];
252 grads[start + 2][0][1] = -monovali[0][0] * monovalk[1][1];
253 grads[start + 2][1][2] = 0.;
254 grads[start + 2][1][0] = 0.;
255 grads[start + 2][1][1] = 0.;
257 if (grad_grads.size() != 0)
259 grad_grads[start][0][0][0] = 0.;
260 grad_grads[start][0][0][1] = monovali[1][2] * monovalk[2][0];
261 grad_grads[start][0][0][2] = monovali[1][1] * monovalk[2][1];
262 grad_grads[start][0][1][0] = monovali[1][2] * monovalk[2][0];
263 grad_grads[start][0][1][1] =
264 unit_point(0) * monovali[1][3] * monovalk[2][0];
265 grad_grads[start][0][1][2] =
266 unit_point(0) * monovali[1][2] * monovalk[2][1];
267 grad_grads[start][0][2][0] = monovali[1][1] * monovalk[2][1];
268 grad_grads[start][0][2][1] =
269 unit_point(0) * monovali[1][2] * monovalk[2][1];
270 grad_grads[start][0][2][2] =
271 unit_point(0) * monovali[1][1] * monovalk[2][2];
272 grad_grads[start][1][0][0] = 0.;
273 grad_grads[start][1][0][1] = 0.;
274 grad_grads[start][1][0][2] = 0.;
275 grad_grads[start][1][1][0] = 0.;
276 grad_grads[start][1][1][1] = -monovali[1][2] * monovalk[2][0];
277 grad_grads[start][1][1][2] = -monovali[1][1] * monovalk[2][1];
278 grad_grads[start][1][2][0] = 0.;
279 grad_grads[start][1][2][1] = -monovali[1][1] * monovalk[2][1];
280 grad_grads[start][1][2][2] = -monovali[1][0] * monovalk[2][2];
281 grad_grads[start][2][0][0] = 0.;
282 grad_grads[start][2][0][1] = 0.;
283 grad_grads[start][2][0][2] = 0.;
284 grad_grads[start][2][1][0] = 0.;
285 grad_grads[start][2][1][1] = 0.;
286 grad_grads[start][2][1][2] = 0.;
287 grad_grads[start][2][2][0] = 0.;
288 grad_grads[start][2][2][1] = 0.;
289 grad_grads[start][2][2][2] = 0.;
291 grad_grads[start + 1][0][0][0] = 0.;
292 grad_grads[start + 1][0][0][1] = 0.;
293 grad_grads[start + 1][0][0][2] = 0.;
294 grad_grads[start + 1][0][1][0] = 0.;
295 grad_grads[start + 1][0][1][1] = 0.;
296 grad_grads[start + 1][0][1][2] = 0.;
297 grad_grads[start + 1][0][2][0] = 0.;
298 grad_grads[start + 1][0][2][1] = 0.;
299 grad_grads[start + 1][0][2][2] = 0.;
300 grad_grads[start + 1][1][0][0] =
301 unit_point(1) * monovali[2][1] * monovalk[0][2];
302 grad_grads[start + 1][1][0][1] = monovali[2][1] * monovalk[0][1];
303 grad_grads[start + 1][1][0][2] =
304 unit_point(1) * monovali[2][2] * monovalk[0][1];
305 grad_grads[start + 1][1][1][0] = monovalk[0][1] * monovali[2][1];
306 grad_grads[start + 1][1][1][1] = 0.;
307 grad_grads[start + 1][1][1][2] = monovalk[0][0] * monovali[2][2];
308 grad_grads[start + 1][1][2][0] =
309 unit_point(1) * monovalk[0][1] * monovali[2][2];
310 grad_grads[start + 1][1][2][1] = monovalk[0][0] * monovali[2][2];
311 grad_grads[start + 1][1][2][2] =
312 unit_point(1) * monovalk[0][0] * monovali[2][3];
313 grad_grads[start + 1][2][0][0] = -monovalk[0][2] * monovali[2][0];
314 grad_grads[start + 1][2][0][1] = 0.;
315 grad_grads[start + 1][2][0][2] = -monovalk[0][1] * monovali[2][1];
316 grad_grads[start + 1][2][1][0] = 0.;
317 grad_grads[start + 1][2][1][1] = 0.;
318 grad_grads[start + 1][2][1][2] = 0.;
319 grad_grads[start + 1][2][2][0] = -monovalk[0][1] * monovali[2][1];
320 grad_grads[start + 1][2][2][1] = 0.;
321 grad_grads[start + 1][2][2][2] = -monovalk[0][0] * monovali[2][2];
323 grad_grads[start + 2][0][0][0] = -monovali[0][2] * monovalk[1][0];
324 grad_grads[start + 2][0][0][1] = -monovali[0][1] * monovalk[1][1];
325 grad_grads[start + 2][0][0][2] = 0.;
326 grad_grads[start + 2][0][1][0] = -monovali[0][1] * monovalk[1][1];
327 grad_grads[start + 2][0][1][1] = -monovali[0][0] * monovalk[1][2];
328 grad_grads[start + 2][0][1][2] = 0.;
329 grad_grads[start + 2][0][2][0] = 0.;
330 grad_grads[start + 2][0][2][1] = 0.;
331 grad_grads[start + 2][0][2][2] = 0.;
332 grad_grads[start + 2][1][0][0] = 0.;
333 grad_grads[start + 2][1][0][1] = 0.;
334 grad_grads[start + 2][1][0][2] = 0.;
335 grad_grads[start + 2][1][1][0] = 0.;
336 grad_grads[start + 2][1][1][1] = 0.;
337 grad_grads[start + 2][1][1][2] = 0.;
338 grad_grads[start + 2][1][2][0] = 0.;
339 grad_grads[start + 2][1][2][1] = 0.;
340 grad_grads[start + 2][1][2][2] = 0.;
341 grad_grads[start + 2][2][0][0] =
342 unit_point(2) * monovali[0][3] * monovalk[1][0];
343 grad_grads[start + 2][2][0][1] =
344 unit_point(2) * monovali[0][2] * monovalk[1][1];
345 grad_grads[start + 2][2][0][2] = monovali[0][2] * monovalk[1][0];
346 grad_grads[start + 2][2][1][0] =
347 unit_point(2) * monovali[0][2] * monovalk[1][1];
348 grad_grads[start + 2][2][1][1] =
349 unit_point(2) * monovali[0][1] * monovalk[1][2];
350 grad_grads[start + 2][2][1][2] = monovali[0][1] * monovalk[1][1];
351 grad_grads[start + 2][2][2][0] = monovali[0][2] * monovalk[1][0];
352 grad_grads[start + 2][2][2][1] = monovali[0][1] * monovalk[1][1];
353 grad_grads[start + 2][2][2][2] = 0.;
435 return (k + 1) * (k + 2) + 2;
437 return ((k + 1) * (k + 2) * (k + 3)) / 2 + 3 * (k + 1);
448 DEAL_II_NAMESPACE_CLOSE
PolynomialsBDM(const unsigned int k)
std::vector< Polynomials::Polynomial< double > > monomials
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
#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()