Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
fe_lagrange_tensor.hpp
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2//
3// Copyright (C) 2024 - 2026 by the Vulpes authors.
4// This file is part of Vulpes.
5//
6// Vulpes is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Vulpes is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Vulpes. If not, see <http://www.gnu.org/licenses/>.
18//
19// ----------------------------------------------------------------------
20
21// Author: Matteo Caldana <matteo.caldana@polimi.it>
22
23#ifndef VULPES_FE_FE_SPACES_FE_LAGRANGE_TENSOR_HPP_
24#define VULPES_FE_FE_SPACES_FE_LAGRANGE_TENSOR_HPP_
25
26#include <vector>
27
30
31namespace vulpes {
32namespace fe {
33
38template <std::size_t Dim, typename DofPolicy, typename Poly1DPolicy>
40 Dim,
41 internal::real_t,
42 DofPolicy,
43 FeSpaceLagrangeQ<Dim, DofPolicy, Poly1DPolicy>> {
44 public:
46 explicit FeSpaceLagrangeQ(std::size_t order)
48 Dim,
50 DofPolicy,
51 FeSpaceLagrangeQ<Dim, DofPolicy, Poly1DPolicy>>(order) {
52 const auto nodes_1d = Poly1DPolicy::computeNodes(order + 1);
53 const auto coef_1d = internal::computeLagrangianPolyCoef<1>(nodes_1d);
54 const auto size = order + 1;
55 const auto size_nd = vmath::pow(size, Dim);
56 m_nodes.resize(size_nd);
57 // loop on each basis function, that is each element of the cartesian
58 // product of 1d polynomials
59 for (std::size_t i = 0; i < size_nd; ++i) {
60 // this is like writing `i` in radix
61 std::size_t idx = i;
62 m_polys.emplace_back(size);
63 std::fill(m_polys.back().data().begin(), m_polys.back().data().end(), 1);
64 for (std::size_t d = 0; d < Dim; ++d) {
65 const auto basis_id_cart_d = idx % size;
66 const auto node_d = nodes_1d[basis_id_cart_d][0];
67 idx /= size;
68 // loop on each coef of the nd-polynomial
69 for (std::size_t j = 0; j < size_nd; ++j) {
70 std::array<std::size_t, Dim> coef_id_cart;
71 std::size_t coef_id = j;
72 for (std::size_t d2 = 0; d2 < Dim; ++d2) {
73 coef_id_cart[d2] = coef_id % size;
74 coef_id /= size;
75 }
76 // multiply by the 1d coef
77 std::apply(
78 [&](auto... args) {
79 m_polys.back().coef(args...) *=
80 coef_1d(coef_id_cart[d], basis_id_cart_d);
81 },
82 coef_id_cart);
83 }
84 m_nodes[i][d] = node_d;
85 }
86 }
87 }
88
89 const auto& getNodes() const { return m_nodes; }
90 const auto& getBasis() const { return m_polys; }
91 inline static constexpr FeType elemType() { return FeType::Tensor; };
92
93 protected:
94 std::vector<Polynomial> m_polys;
95 std::vector<Point<internal::real_t, Dim>> m_nodes;
96};
97
101template <std::size_t Dim>
103 Dim,
106
110template <std::size_t Dim>
112 Dim,
115
119template <std::size_t Dim>
121 Dim,
124
128template <std::size_t Dim>
130 Dim,
133
134} // namespace fe
135} // namespace vulpes
136
137#endif // VULPES_FE_FE_SPACES_FE_LAGRANGE_TENSOR_HPP_
General finite element space on a tensor product cell with (nodal) Lagrangian basis function,...
Definition fe_lagrange_tensor.hpp:43
static constexpr FeType elemType()
Definition fe_lagrange_tensor.hpp:91
polynomial::NdPolynomial< internal::real_t, Dim, false > Polynomial
Definition fe_lagrange_tensor.hpp:45
std::vector< Point< internal::real_t, Dim > > m_nodes
Definition fe_lagrange_tensor.hpp:95
FeSpaceLagrangeQ(std::size_t order)
Definition fe_lagrange_tensor.hpp:46
const auto & getNodes() const
Definition fe_lagrange_tensor.hpp:89
const auto & getBasis() const
Definition fe_lagrange_tensor.hpp:90
Definition fe_expr_base.hpp:58
Eigen::Matrix< FloatType, -1, -1 > computeLagrangianPolyCoef(const std::vector< Point< FloatType, Dim > > &points)
: Compute the coefficients of interpolatory lagrangian polynomials of a set of points
Definition fe_space.hpp:245
Definition dof_policy.hpp:45
FeType
Definition fe_space.hpp:48
@ Tensor
Definition fe_space.hpp:48
FeSpaceLagrangeQ< Dim, DofPolicyFeSpaceCQ< Dim >, internal::LagrangianNodesPolicy< 1 > > FeSpaceLagrangeCQ
Continuous lagrangian finite element space with equi-spaced nodes.
Definition fe_lagrange_tensor.hpp:102
FeSpaceLagrangeQ< Dim, DofPolicyFeSpaceDQ< Dim >, internal::WarpAndBlendNodesPolicy< 1 > > FeSpaceSpectralDQ
Discontinuous spectral finite element space.
Definition fe_lagrange_tensor.hpp:129
FeSpaceLagrangeQ< Dim, DofPolicyFeSpaceCQ< Dim >, internal::WarpAndBlendNodesPolicy< 1 > > FeSpaceSpectralCQ
Continuous spectral finite element space.
Definition fe_lagrange_tensor.hpp:120
FeSpaceLagrangeQ< Dim, DofPolicyFeSpaceDQ< Dim >, internal::LagrangianNodesPolicy< 1 > > FeSpaceLagrangeDQ
Discontinuous lagrangian finite element space with equi-spaced nodes.
Definition fe_lagrange_tensor.hpp:111
std::conditional_t< Dim==1, Polynomial< T >, std::conditional_t< Dim==2, Polynomial2D< T, IsSpaceP >, Polynomial3D< T, IsSpaceP > > > NdPolynomial
wrapper for dense polynomials in 1D, 2D and 3D
Definition ndpolynomial.hpp:41
constexpr U pow(U base, V exp, U result=U(1))
Computes the power of a number.
Definition vmath.hpp:171
Definition cell_manager.hpp:38
Definition dof_policy.hpp:100
Definition dof_policy.hpp:629
Compute the equi-spaced nodes on a simplex in Dim dimensions.
Definition fe_lagrange_simplex.hpp:46
Compute the warp&blend nodes on a simplex in Dim dimensions See: Warburton, Tim. "An explicit constru...
Definition fe_lagrange_simplex.hpp:96