| 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_base_polynomials_wedge_h |
| 17 |
#define dealii_base_polynomials_wedge_h |
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/base/ndarray.h> |
| 22 |
#include <deal.II/base/polynomials_barycentric.h> |
| 23 |
#include <deal.II/base/scalar_polynomials_base.h> |
| 24 |
|
| 25 |
DEAL_II_NAMESPACE_OPEN |
| 26 |
|
| 27 |
|
| 28 |
namespace internal |
| 29 |
{ |
| 30 |
/** |
| 31 |
* Decompose the shape-function index of a linear wedge into an index |
| 32 |
* to access the right shape function within the triangle and within |
| 33 |
* the line. |
| 34 |
*/ |
| 35 |
constexpr dealii::ndarray<unsigned int, 6, 2> wedge_table_1{ |
| 36 |
{{{0, 0}}, {{1, 0}}, {{2, 0}}, {{0, 1}}, {{1, 1}}, {{2, 1}}}}; |
| 37 |
|
| 38 |
/** |
| 39 |
* Decompose the shape-function index of a quadratic wedge into an index |
| 40 |
* to access the right shape function within the triangle and within |
| 41 |
* the line. |
| 42 |
*/ |
| 43 |
constexpr dealii::ndarray<unsigned int, 18, 2> wedge_table_2{{{{0, 0}}, |
| 44 |
{{1, 0}}, |
| 45 |
{{2, 0}}, |
| 46 |
{{0, 1}}, |
| 47 |
{{1, 1}}, |
| 48 |
{{2, 1}}, |
| 49 |
{{3, 0}}, |
| 50 |
{{4, 0}}, |
| 51 |
{{5, 0}}, |
| 52 |
{{3, 1}}, |
| 53 |
{{4, 1}}, |
| 54 |
{{5, 1}}, |
| 55 |
{{0, 2}}, |
| 56 |
{{1, 2}}, |
| 57 |
{{2, 2}}, |
| 58 |
{{3, 2}}, |
| 59 |
{{4, 2}}, |
| 60 |
{{5, 2}}}}; |
| 61 |
} // namespace internal |
| 62 |
|
| 63 |
|
| 64 |
/** |
| 65 |
* Polynomials defined on wedge entities. This class is basis of |
| 66 |
* FE_WedgeP. |
| 67 |
* |
| 68 |
* The polynomials are created via a tensor product of a |
| 69 |
* BarycentricPolynomials<2>::get_fe_p_basis(degree) and a |
| 70 |
* BarycentricPolynomials<1>::get_fe_p_basis(degree), however, are |
| 71 |
* re-numerated to better match the definition of FiniteElement. |
| 72 |
*/ |
| 73 |
template <int dim> |
| 74 |
class ScalarLagrangePolynomialWedge : public ScalarPolynomialsBase<dim> |
| 75 |
{ |
| 76 |
public: |
| 77 |
/** |
| 78 |
* Make the dimension available to the outside. |
| 79 |
*/ |
| 80 |
static constexpr unsigned int dimension = dim; |
| 81 |
|
| 82 |
/* |
| 83 |
* Constructor taking the polynomial @p degree as input. |
| 84 |
* |
| 85 |
* @note Currently, only linear (degree=1) and quadratic polynomials |
| 86 |
* (degree=2) are implemented. |
| 87 |
*/ |
| 88 |
ScalarLagrangePolynomialWedge(const unsigned int degree); |
| 89 |
|
| 90 |
/** |
| 91 |
* @copydoc ScalarPolynomialsBase::evaluate() |
| 92 |
* |
| 93 |
* @note Currently, only the vectors @p values and @p grads are filled. |
| 94 |
*/ |
| 95 |
void |
| 96 |
evaluate(const Point<dim> &unit_point, |
| 97 |
std::vector<double> &values, |
| 98 |
std::vector<Tensor<1, dim>> &grads, |
| 99 |
std::vector<Tensor<2, dim>> &grad_grads, |
| 100 |
std::vector<Tensor<3, dim>> &third_derivatives, |
| 101 |
std::vector<Tensor<4, dim>> &fourth_derivatives) const override; |
| 102 |
|
| 103 |
double |
| 104 |
compute_value(const unsigned int i, const Point<dim> &p) const override; |
| 105 |
|
| 106 |
/** |
| 107 |
* @copydoc ScalarPolynomialsBase::compute_derivative() |
| 108 |
* |
| 109 |
* @note Currently, only implemented for first derivative. |
| 110 |
*/ |
| 111 |
template <int order> |
| 112 |
Tensor<order, dim> |
| 113 |
compute_derivative(const unsigned int i, const Point<dim> &p) const; |
| 114 |
|
| 115 |
Tensor<1, dim> |
| 116 |
compute_1st_derivative(const unsigned int i, |
| 117 |
const Point<dim> &p) const override; |
| 118 |
|
| 119 |
/** |
| 120 |
* @copydoc ScalarPolynomialsBase::compute_2nd_derivative() |
| 121 |
* |
| 122 |
* @note Not implemented yet. |
| 123 |
*/ |
| 124 |
Tensor<2, dim> |
| 125 |
compute_2nd_derivative(const unsigned int i, |
| 126 |
const Point<dim> &p) const override; |
| 127 |
|
| 128 |
/** |
| 129 |
* @copydoc ScalarPolynomialsBase::compute_3rd_derivative() |
| 130 |
* |
| 131 |
* @note Not implemented yet. |
| 132 |
*/ |
| 133 |
Tensor<3, dim> |
| 134 |
compute_3rd_derivative(const unsigned int i, |
| 135 |
const Point<dim> &p) const override; |
| 136 |
|
| 137 |
/** |
| 138 |
* @copydoc ScalarPolynomialsBase::compute_4th_derivative() |
| 139 |
* |
| 140 |
* @note Not implemented yet. |
| 141 |
*/ |
| 142 |
Tensor<4, dim> |
| 143 |
compute_4th_derivative(const unsigned int i, |
| 144 |
const Point<dim> &p) const override; |
| 145 |
|
| 146 |
/** |
| 147 |
* @copydoc ScalarPolynomialsBase::compute_grad() |
| 148 |
* |
| 149 |
* @note Not implemented yet. |
| 150 |
*/ |
| 151 |
Tensor<1, dim> |
| 152 |
compute_grad(const unsigned int i, const Point<dim> &p) const override; |
| 153 |
|
| 154 |
/** |
| 155 |
* @copydoc ScalarPolynomialsBase::compute_grad_grad() |
| 156 |
* |
| 157 |
* @note Not implemented yet. |
| 158 |
*/ |
| 159 |
Tensor<2, dim> |
| 160 |
compute_grad_grad(const unsigned int i, const Point<dim> &p) const override; |
| 161 |
|
| 162 |
std::string |
| 163 |
name() const override; |
| 164 |
|
| 165 |
virtual std::unique_ptr<ScalarPolynomialsBase<dim>> |
| 166 |
clone() const override; |
| 167 |
|
| 168 |
private: |
| 169 |
/** |
| 170 |
* Scalar polynomials defined on a triangle. |
| 171 |
*/ |
| 172 |
const BarycentricPolynomials<2> poly_tri; |
| 173 |
|
| 174 |
/** |
| 175 |
* Scalar polynomials defined on a line. |
| 176 |
*/ |
| 177 |
const BarycentricPolynomials<1> poly_line; |
| 178 |
}; |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
template <int dim> |
| 183 |
template <int order> |
| 184 |
Tensor<order, dim> |
| 185 |
ScalarLagrangePolynomialWedge<dim>::compute_derivative( |
| 186 |
const unsigned int i, |
| 187 |
const Point<dim> &p) const |
| 188 |
{ |
| 189 |
Tensor<order, dim> der; |
| 190 |
|
| 191 |
AssertDimension(order, 1); |
| 192 |
const auto grad = compute_grad(i, p); |
| 193 |
|
| 194 |
for (unsigned int i = 0; i < dim; ++i) |
| 195 |
der[i] = grad[i]; |
| 196 |
|
| 197 |
return der; |
| 198 |
} |
| 199 |
|
| 200 |
DEAL_II_NAMESPACE_CLOSE |
| 201 |
|
| 202 |
#endif |