| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2009 - 2024 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_adini_h |
| 17 |
#define dealii_polynomials_adini_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/table.h> |
| 24 |
#include <deal.II/base/tensor.h> |
| 25 |
|
| 26 |
DEAL_II_NAMESPACE_OPEN |
| 27 |
|
| 28 |
/** |
| 29 |
* The cubic polynomial space for the Adini element |
| 30 |
* |
| 31 |
* This space consists of the cubic space <i>P<sub>3</sub></i> augmented by |
| 32 |
* the functions <i>xy<sup>3</sup></i> and <i>x<sup>3</sup>y</i>. |
| 33 |
* |
| 34 |
* The basis of the space is chosen to match the node functionals of the Adini |
| 35 |
* element. |
| 36 |
* |
| 37 |
* @todo This polynomial space is implemented in 2d only and does not compute |
| 38 |
* derivatives of order 3 or higher. |
| 39 |
* |
| 40 |
* @ingroup Polynomials |
| 41 |
*/ |
| 42 |
template <int dim> |
| 43 |
class PolynomialsAdini : public ScalarPolynomialsBase<dim> |
| 44 |
{ |
| 45 |
public: |
| 46 |
/** |
| 47 |
* Constructor for the polynomials of the described space |
| 48 |
*/ |
| 49 |
PolynomialsAdini(); |
| 50 |
|
| 51 |
/** |
| 52 |
* Compute the value and the first and second derivatives of each |
| 53 |
* polynomial at <tt>unit_point</tt>. |
| 54 |
* |
| 55 |
* The size of the vectors must either be equal 0 or equal n(). In the first |
| 56 |
* case, the function will not compute these values, i.e. you indicate what |
| 57 |
* you want to have computed by resizing those vectors which you want |
| 58 |
* filled. |
| 59 |
* |
| 60 |
* If you need values or derivatives of all polynomials then use this |
| 61 |
* function, rather than using any of the compute_value(), compute_grad() or |
| 62 |
* compute_grad_grad() functions, see below, in a loop over all polynomials. |
| 63 |
*/ |
| 64 |
void |
| 65 |
evaluate(const Point<dim> &unit_point, |
| 66 |
std::vector<double> &values, |
| 67 |
std::vector<Tensor<1, dim>> &grads, |
| 68 |
std::vector<Tensor<2, dim>> &grad_grads, |
| 69 |
std::vector<Tensor<3, dim>> &third_derivatives, |
| 70 |
std::vector<Tensor<4, dim>> &fourth_derivatives) const override; |
| 71 |
|
| 72 |
/** |
| 73 |
* Compute the value of the <tt>i</tt>th polynomial at <tt>unit_point</tt>. |
| 74 |
* |
| 75 |
* Consider using evaluate() instead. |
| 76 |
*/ |
| 77 |
double |
| 78 |
compute_value(const unsigned int i, const Point<dim> &p) const override; |
| 79 |
|
| 80 |
/** |
| 81 |
* @copydoc ScalarPolynomialsBase::compute_1st_derivative() |
| 82 |
*/ |
| 83 |
virtual Tensor<1, dim> |
| 84 |
compute_1st_derivative(const unsigned int i, |
| 85 |
const Point<dim> &p) const override; |
| 86 |
|
| 87 |
/** |
| 88 |
* @copydoc ScalarPolynomialsBase::compute_2nd_derivative() |
| 89 |
*/ |
| 90 |
virtual Tensor<2, dim> |
| 91 |
compute_2nd_derivative(const unsigned int i, |
| 92 |
const Point<dim> &p) const override; |
| 93 |
|
| 94 |
/** |
| 95 |
* @copydoc ScalarPolynomialsBase::compute_3rd_derivative() |
| 96 |
*/ |
| 97 |
virtual Tensor<3, dim> |
| 98 |
compute_3rd_derivative(const unsigned int i, |
| 99 |
const Point<dim> &p) const override; |
| 100 |
|
| 101 |
/** |
| 102 |
* @copydoc ScalarPolynomialsBase::compute_4th_derivative() |
| 103 |
*/ |
| 104 |
virtual Tensor<4, dim> |
| 105 |
compute_4th_derivative(const unsigned int i, |
| 106 |
const Point<dim> &p) const override; |
| 107 |
|
| 108 |
/** |
| 109 |
* Compute the gradient of the <tt>i</tt>th polynomial at |
| 110 |
* <tt>unit_point</tt>. |
| 111 |
* |
| 112 |
* Consider using evaluate() instead. |
| 113 |
*/ |
| 114 |
Tensor<1, dim> |
| 115 |
compute_grad(const unsigned int i, const Point<dim> &p) const override; |
| 116 |
|
| 117 |
/** |
| 118 |
* Compute the second derivative (grad_grad) of the <tt>i</tt>th polynomial |
| 119 |
* at <tt>unit_point</tt>. |
| 120 |
* |
| 121 |
* Consider using evaluate() instead. |
| 122 |
*/ |
| 123 |
Tensor<2, dim> |
| 124 |
compute_grad_grad(const unsigned int i, const Point<dim> &p) const override; |
| 125 |
|
| 126 |
/** |
| 127 |
* Return the name of the space, which is <tt>PolynomialsAdini</tt>. |
| 128 |
*/ |
| 129 |
std::string |
| 130 |
name() const override; |
| 131 |
|
| 132 |
/** |
| 133 |
* @copydoc ScalarPolynomialsBase::clone() |
| 134 |
*/ |
| 135 |
virtual std::unique_ptr<ScalarPolynomialsBase<dim>> |
| 136 |
clone() const override; |
| 137 |
|
| 138 |
private: |
| 139 |
/** |
| 140 |
* Store the coefficients of the polynomials in the order |
| 141 |
* $1,x,y,x^2,y^2,xy,x^3,y^3,xy^2,x^2y,x^3y,xy^3$ |
| 142 |
*/ |
| 143 |
Table<2, double> coef; |
| 144 |
|
| 145 |
/** |
| 146 |
* Store the coefficients of the x-derivative of the polynomials in the |
| 147 |
* order $1,x,y,x^2,y^2,xy,x^3,y^3,xy^2,x^2y,x^3y,xy^3$ |
| 148 |
*/ |
| 149 |
Table<2, double> dx; |
| 150 |
|
| 151 |
/** |
| 152 |
* Store the coefficients of the y-derivative of the polynomials in the |
| 153 |
* order $1,x,y,x^2,y^2,xy,x^3,y^3,xy^2,x^2y,x^3y,xy^3$ |
| 154 |
*/ |
| 155 |
Table<2, double> dy; |
| 156 |
|
| 157 |
/** |
| 158 |
* Store the coefficients of the second x-derivative of the polynomials in |
| 159 |
* the order $1,x,y,x^2,y^2,xy,x^3,y^3,xy^2,x^2y,x^3y,xy^3$ |
| 160 |
*/ |
| 161 |
Table<2, double> dxx; |
| 162 |
|
| 163 |
/** |
| 164 |
* Store the coefficients of the second y-derivative of the polynomials in |
| 165 |
* the order $1,x,y,x^2,y^2,xy,x^3,y^3,xy^2,x^2y,x^3y,xy^3$ |
| 166 |
*/ |
| 167 |
Table<2, double> dyy; |
| 168 |
|
| 169 |
/** |
| 170 |
* Store the coefficients of the second mixed derivative of the polynomials |
| 171 |
* in the order $1,x,y,x^2,y^2,xy,x^3,y^3,xy^2,x^2y,x^3y,xy^3$ |
| 172 |
*/ |
| 173 |
Table<2, double> dxy; |
| 174 |
}; |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
template <int dim> |
| 179 |
inline Tensor<1, dim> |
| 180 |
PolynomialsAdini<dim>::compute_1st_derivative(const unsigned int /*i*/, |
| 181 |
const Point<dim> & /*p*/) const |
| 182 |
{ |
| 183 |
DEAL_II_NOT_IMPLEMENTED(); |
| 184 |
return {}; |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
template <int dim> |
| 190 |
inline Tensor<2, dim> |
| 191 |
PolynomialsAdini<dim>::compute_2nd_derivative(const unsigned int /*i*/, |
| 192 |
const Point<dim> & /*p*/) const |
| 193 |
{ |
| 194 |
DEAL_II_NOT_IMPLEMENTED(); |
| 195 |
return {}; |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
template <int dim> |
| 201 |
inline Tensor<3, dim> |
| 202 |
PolynomialsAdini<dim>::compute_3rd_derivative(const unsigned int /*i*/, |
| 203 |
const Point<dim> & /*p*/) const |
| 204 |
{ |
| 205 |
DEAL_II_NOT_IMPLEMENTED(); |
| 206 |
return {}; |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
template <int dim> |
| 212 |
inline Tensor<4, dim> |
| 213 |
PolynomialsAdini<dim>::compute_4th_derivative(const unsigned int /*i*/, |
| 214 |
const Point<dim> & /*p*/) const |
| 215 |
{ |
| 216 |
DEAL_II_NOT_IMPLEMENTED(); |
| 217 |
return {}; |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
template <int dim> |
| 223 |
inline std::string |
| 224 |
PolynomialsAdini<dim>::name() const |
| 225 |
{ |
| 226 |
return "PolynomialsAdini"; |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
DEAL_II_NAMESPACE_CLOSE |
| 232 |
|
| 233 |
#endif |