| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2021 - 2025 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 |
|
| 16 |
#ifndef dealii_polynomials_pyramid_h |
| 17 |
#define dealii_polynomials_pyramid_h |
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/base/point.h> |
| 22 |
#include <deal.II/base/scalar_polynomials_base.h> |
| 23 |
#include <deal.II/base/tensor.h> |
| 24 |
|
| 25 |
DEAL_II_NAMESPACE_OPEN |
| 26 |
|
| 27 |
/** |
| 28 |
* Polynomials defined on pyramid entities. This class is basis of |
| 29 |
* FE_PyramidP. |
| 30 |
*/ |
| 31 |
template <int dim> |
| 32 |
class ScalarLagrangePolynomialPyramid : public ScalarPolynomialsBase<dim> |
| 33 |
{ |
| 34 |
public: |
| 35 |
/** |
| 36 |
* Make the dimension available to the outside. |
| 37 |
*/ |
| 38 |
static constexpr unsigned int dimension = dim; |
| 39 |
|
| 40 |
/* |
| 41 |
* Constructor taking the polynomial @p degree as input. |
| 42 |
* |
| 43 |
* @note Currently, only linear polynomials (degree=1) are implemented. |
| 44 |
*/ |
| 45 |
ScalarLagrangePolynomialPyramid(const unsigned int degree); |
| 46 |
|
| 47 |
/** |
| 48 |
* @copydoc ScalarPolynomialsBase::evaluate() |
| 49 |
* |
| 50 |
* @note Currently, only the vectors @p values and @p grads are filled. |
| 51 |
*/ |
| 52 |
void |
| 53 |
evaluate(const Point<dim> &unit_point, |
| 54 |
std::vector<double> &values, |
| 55 |
std::vector<Tensor<1, dim>> &grads, |
| 56 |
std::vector<Tensor<2, dim>> &grad_grads, |
| 57 |
std::vector<Tensor<3, dim>> &third_derivatives, |
| 58 |
std::vector<Tensor<4, dim>> &fourth_derivatives) const override; |
| 59 |
|
| 60 |
double |
| 61 |
compute_value(const unsigned int i, const Point<dim> &p) const override; |
| 62 |
|
| 63 |
/** |
| 64 |
* @copydoc ScalarPolynomialsBase::compute_derivative() |
| 65 |
* |
| 66 |
* @note Currently, only implemented for first derivative. |
| 67 |
*/ |
| 68 |
template <int order> |
| 69 |
Tensor<order, dim> |
| 70 |
compute_derivative(const unsigned int i, const Point<dim> &p) const; |
| 71 |
|
| 72 |
Tensor<1, dim> |
| 73 |
compute_1st_derivative(const unsigned int i, |
| 74 |
const Point<dim> &p) const override; |
| 75 |
|
| 76 |
Tensor<2, dim> |
| 77 |
compute_2nd_derivative(const unsigned int i, |
| 78 |
const Point<dim> &p) const override; |
| 79 |
|
| 80 |
/** |
| 81 |
* @copydoc ScalarPolynomialsBase::compute_3rd_derivative() |
| 82 |
* |
| 83 |
* @note Not implemented yet. |
| 84 |
*/ |
| 85 |
Tensor<3, dim> |
| 86 |
compute_3rd_derivative(const unsigned int i, |
| 87 |
const Point<dim> &p) const override; |
| 88 |
|
| 89 |
/** |
| 90 |
* @copydoc ScalarPolynomialsBase::compute_4th_derivative() |
| 91 |
* |
| 92 |
* @note Not implemented yet. |
| 93 |
*/ |
| 94 |
Tensor<4, dim> |
| 95 |
compute_4th_derivative(const unsigned int i, |
| 96 |
const Point<dim> &p) const override; |
| 97 |
|
| 98 |
/** |
| 99 |
* @copydoc ScalarPolynomialsBase::compute_grad() |
| 100 |
* |
| 101 |
* @note Not implemented yet. |
| 102 |
*/ |
| 103 |
Tensor<1, dim> |
| 104 |
compute_grad(const unsigned int i, const Point<dim> &p) const override; |
| 105 |
|
| 106 |
/** |
| 107 |
* @copydoc ScalarPolynomialsBase::compute_grad_grad() |
| 108 |
* |
| 109 |
* @note Not implemented yet. |
| 110 |
*/ |
| 111 |
Tensor<2, dim> |
| 112 |
compute_grad_grad(const unsigned int i, const Point<dim> &p) const override; |
| 113 |
|
| 114 |
std::string |
| 115 |
name() const override; |
| 116 |
|
| 117 |
virtual std::unique_ptr<ScalarPolynomialsBase<dim>> |
| 118 |
clone() const override; |
| 119 |
}; |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
template <int dim> |
| 124 |
template <int order> |
| 125 |
Tensor<order, dim> |
| 126 |
ScalarLagrangePolynomialPyramid<dim>::compute_derivative( |
| 127 |
const unsigned int i, |
| 128 |
const Point<dim> &p) const |
| 129 |
{ |
| 130 |
Tensor<order, dim> der; |
| 131 |
|
| 132 |
Assert(order == 1, ExcNotImplemented()); |
| 133 |
const auto grad = compute_grad(i, p); |
| 134 |
|
| 135 |
for (unsigned int i = 0; i < dim; ++i) |
| 136 |
der[i] = grad[i]; |
| 137 |
|
| 138 |
return der; |
| 139 |
} |
| 140 |
|
| 141 |
DEAL_II_NAMESPACE_CLOSE |
| 142 |
|
| 143 |
#endif |