version 0.4.1
functionhelper.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
9#pragma once
10
11#include <ranges>
12
13namespace Ikarus::utils {
24template <int size, typename LV>
25void obtainLagrangeNodePositions(const LV& localView,
26 std::vector<Dune::FieldVector<double, size>>& lagrangeNodeCoords) {
27 static_assert(Concepts::LagrangeNode<std::remove_cvref_t<decltype(localView.tree().child(0))>>,
28 "This function is only supported for Lagrange basis");
29 assert(localView.bound() && "The local view must be bound to an element");
30 const auto& localFE = localView.tree().child(0).finiteElement();
31 lagrangeNodeCoords.resize(localFE.size());
32 std::vector<double> out;
33 for (int i = 0; i < size; i++) {
34 auto ithCoord = [&i](const Dune::FieldVector<double, size>& x) { return x[i]; };
35 localFE.localInterpolation().interpolate(ithCoord, out);
36 for (std::size_t j = 0; j < out.size(); j++)
37 lagrangeNodeCoords[j][i] = out[j];
38 }
39 for (auto& nCoord : lagrangeNodeCoords)
40 nCoord = localView.element().geometry().global(nCoord);
41}
50template <typename FE>
52 constexpr int dim = FE::Traits::mydim;
53 const auto& element = fe.gridElement();
54 const auto& referenceElement = Dune::referenceElement<double, dim>(element.type());
55 const int numberOfVertices = referenceElement.size(codim);
56
57 auto getPosition = [=](const int i) { return referenceElement.position(i, codim); };
58 return std::views::transform(std::views::iota(0, numberOfVertices), getPosition);
59}
60
68template <typename FE>
71}
72
73} // namespace Ikarus::utils
auto referenceElementSubEntityPositions(FE &fe, int codim)
A function to obtain the local coordinates of subentities of an FiniteElement.
Definition: functionhelper.hh:51
auto referenceElementVertexPositions(FE &fe)
A function to obtain the local coordinates the vertices of an FiniteElement.
Definition: functionhelper.hh:69
void obtainLagrangeNodePositions(const LV &localView, std::vector< Dune::FieldVector< double, size > > &lagrangeNodeCoords)
A function to obtain the global positions of the nodes of an element with Lagrangian basis,...
Definition: functionhelper.hh:25
Definition: algorithms.hh:17
FE class is a base class for all finite elements.
Definition: febase.hh:81
const GridElement & gridElement() const
Get the grid element associated with the local view.
Definition: febase.hh:130
static constexpr int mydim
Dimension of the geometry.
Definition: fetraits.hh:67
Definition: utils/dirichletvalues.hh:30
Concept to check if a node in a basis tree is a Lagrangian node.
Definition: concepts.hh:77