File: polynomials.h

package info (click to toggle)
fenics-basix 0.10.0.post0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,156 kB
  • sloc: cpp: 23,435; python: 10,829; makefile: 43; sh: 26
file content (52 lines) | stat: -rw-r--r-- 1,627 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2021 Matthew Scroggs
// FEniCS Project
// SPDX-License-Identifier:    MIT

#pragma once

#include "cell.h"
#include "mdspan.hpp"
#include "types.h"
#include <array>
#include <concepts>
#include <utility>
#include <vector>

/// Polynomials
namespace basix::polynomials
{
/// @brief Polynomial types that can be created.
enum class type
{
  /// Legendre polynomials: polynomials that span the full space on a cell
  legendre = 0,
  /// Lagrange polynomials: polynomials that span the Lagrange space on a cell.
  /// Note that these will be equal to the Legendre polynomials on all cells
  /// except pyramids
  lagrange = 1,
  /// Bernstein polynomials
  bernstein = 2,
};

/// @brief Tabulate a set of polynomials.
/// @param[in] polytype Polynomial type
/// @param[in] celltype Cell type
/// @param[in] d Polynomial degree
/// @param[in] x Points at which to evaluate the basis. The shape is
/// (number of points, geometric dimension).
/// @return Polynomial sets, for each derivative, tabulated at points.
/// The shape is `(basis index, number of points)`.
template <std::floating_point T>
std::pair<std::vector<T>, std::array<std::size_t, 2>>
tabulate(polynomials::type polytype, cell::type celltype, int d,
         md::mdspan<const T, md::dextents<std::size_t, 2>> x);

/// @brief Dimension of a polynomial space.
/// @param[in] polytype Polynomial type
/// @param[in] cell Cell type
/// @param[in] d Polynomial degree
/// @return The number terms in the basis spanning a space of
/// polynomial degree `d`.
int dim(polynomials::type polytype, cell::type cell, int d);

} // namespace basix::polynomials