deal.II version GIT relicensing-1929-g70a5450eef 2024-10-03 18:00:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
tensor_product_polynomials_const.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2013 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_tensor_product_polynomials_const_h
16#define dealii_tensor_product_polynomials_const_h
17
18
19#include <deal.II/base/config.h>
20
22#include <deal.II/base/point.h>
24#include <deal.II/base/tensor.h>
27
28#include <vector>
29
31
32
44template <int dim>
46{
47public:
52 static constexpr unsigned int dimension = dim;
53
59 template <class Pol>
60 TensorProductPolynomialsConst(const std::vector<Pol> &pols);
61
65 void
66 output_indices(std::ostream &out) const;
67
73 void
74 set_numbering(const std::vector<unsigned int> &renumber);
75
79 const std::vector<unsigned int> &
81
85 const std::vector<unsigned int> &
87
100 void
101 evaluate(const Point<dim> &unit_point,
102 std::vector<double> &values,
103 std::vector<Tensor<1, dim>> &grads,
104 std::vector<Tensor<2, dim>> &grad_grads,
105 std::vector<Tensor<3, dim>> &third_derivatives,
106 std::vector<Tensor<4, dim>> &fourth_derivatives) const override;
107
120 double
121 compute_value(const unsigned int i, const Point<dim> &p) const override;
122
137 template <int order>
139 compute_derivative(const unsigned int i, const Point<dim> &p) const;
140
144 virtual Tensor<1, dim>
145 compute_1st_derivative(const unsigned int i,
146 const Point<dim> &p) const override;
147
151 virtual Tensor<2, dim>
152 compute_2nd_derivative(const unsigned int i,
153 const Point<dim> &p) const override;
154
158 virtual Tensor<3, dim>
159 compute_3rd_derivative(const unsigned int i,
160 const Point<dim> &p) const override;
161
165 virtual Tensor<4, dim>
166 compute_4th_derivative(const unsigned int i,
167 const Point<dim> &p) const override;
168
182 compute_grad(const unsigned int i, const Point<dim> &p) const override;
183
197 compute_grad_grad(const unsigned int i, const Point<dim> &p) const override;
198
203 unsigned int
204 n() const;
205
210 std::string
211 name() const override;
212
216 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
217 clone() const override;
218
219private:
224
228 std::vector<unsigned int> index_map;
229
233 std::vector<unsigned int> index_map_inverse;
234};
235
239/* ---------------- template and inline functions ---------- */
240
241#ifndef DOXYGEN
242
243template <int dim>
244template <class Pol>
246 const std::vector<Pol> &pols)
247 : ScalarPolynomialsBase<dim>(1, Utilities::fixed_power<dim>(pols.size()) + 1)
248 , tensor_polys(pols)
249 , index_map(tensor_polys.n() + 1)
250 , index_map_inverse(tensor_polys.n() + 1)
251{}
252
253
254
255template <int dim>
256inline unsigned int
258{
259 return tensor_polys.n() + 1;
260}
261
262
263
264template <int dim>
265inline const std::vector<unsigned int> &
267{
268 return index_map;
269}
270
271
272template <int dim>
273inline const std::vector<unsigned int> &
275{
276 return index_map_inverse;
277}
278
279
280template <int dim>
281inline std::string
283{
284 return "TensorProductPolynomialsConst";
285}
286
287
288template <>
289inline unsigned int
291{
293}
294
295
296template <int dim>
297template <int order>
300 const unsigned int i,
301 const Point<dim> &p) const
302{
303 const unsigned int max_indices = tensor_polys.n();
304 Assert(i <= max_indices, ExcInternalError());
305
306 // treat the regular basis functions
307 if (i < max_indices)
308 return tensor_polys.template compute_derivative<order>(i, p);
309 else
310 // this is for the constant function
311 return Tensor<order, dim>();
312}
313
314
315
316template <int dim>
317inline Tensor<1, dim>
319 const unsigned int i,
320 const Point<dim> &p) const
321{
322 return compute_derivative<1>(i, p);
323}
324
325
326
327template <int dim>
328inline Tensor<2, dim>
330 const unsigned int i,
331 const Point<dim> &p) const
332{
333 return compute_derivative<2>(i, p);
334}
335
336
337
338template <int dim>
339inline Tensor<3, dim>
341 const unsigned int i,
342 const Point<dim> &p) const
343{
344 return compute_derivative<3>(i, p);
345}
346
347
348
349template <int dim>
350inline Tensor<4, dim>
352 const unsigned int i,
353 const Point<dim> &p) const
354{
355 return compute_derivative<4>(i, p);
356}
357
358#endif // DOXYGEN
360
361#endif
Definition point.h:111
virtual Tensor< 4, dim > compute_4th_derivative(const unsigned int i, const Point< dim > &p) const override
double compute_value(const unsigned int i, const Point< dim > &p) const override
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const override
std::string name() const override
const std::vector< unsigned int > & get_numbering() const
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const override
Tensor< order, dim > compute_derivative(const unsigned int i, const Point< dim > &p) const
void set_numbering(const std::vector< unsigned int > &renumber)
virtual Tensor< 1, dim > compute_1st_derivative(const unsigned int i, const Point< dim > &p) const override
const std::vector< unsigned int > & get_numbering_inverse() const
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const override
TensorProductPolynomials< dim > tensor_polys
TensorProductPolynomialsConst(const std::vector< Pol > &pols)
void evaluate(const Point< dim > &unit_point, std::vector< double > &values, std::vector< Tensor< 1, dim > > &grads, std::vector< Tensor< 2, dim > > &grad_grads, std::vector< Tensor< 3, dim > > &third_derivatives, std::vector< Tensor< 4, dim > > &fourth_derivatives) const override
unsigned int n() const
virtual Tensor< 3, dim > compute_3rd_derivative(const unsigned int i, const Point< dim > &p) const override
virtual Tensor< 2, dim > compute_2nd_derivative(const unsigned int i, const Point< dim > &p) const override
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static const unsigned int invalid_unsigned_int
Definition types.h:220