version 0.4
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
11namespace Ikarus::utils {
23 template <int size, typename LocalView>
24 void obtainLagrangeNodePositions(const LocalView& localView,
25 std::vector<Dune::FieldVector<double, size>>& lagrangeNodeCoords) {
26 static_assert(Concepts::LagrangeNode<std::remove_cvref_t<decltype(localView.tree().child(0))>>,
27 "This function is only supported for Lagrange basis");
28 assert(localView.bound() && "The local view must be bound to an element");
29 const auto& localFE = localView.tree().child(0).finiteElement();
30 lagrangeNodeCoords.resize(localFE.size());
31 std::vector<double> out;
32 for (int i = 0; i < size; i++) {
33 auto ithCoord = [&i](const Dune::FieldVector<double, size>& x) { return x[i]; };
34 localFE.localInterpolation().interpolate(ithCoord, out);
35 for (std::size_t j = 0; j < out.size(); j++)
36 lagrangeNodeCoords[j][i] = out[j];
37 }
38 for (auto& nCoord : lagrangeNodeCoords)
39 nCoord = localView.element().geometry().global(nCoord);
40 }
41
42} // namespace Ikarus::utils
void obtainLagrangeNodePositions(const LocalView &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:24
Definition: algorithms.hh:17
Definition: resultevaluators.hh:20
Concept to check if a node in a basis tree is a Lagrangian node.
Definition: concepts.hh:69