9#include <dune/localfefunctions/manifolds/realTuple.hh>
27template <
typename Traits,
typename Vector,
typename ST>
29 const Vector& x,
const typename Traits::LocalView& localView,
30 const std::optional<std::reference_wrapper<
const Eigen::VectorX<ST>>>& dx = std::nullopt) {
31 constexpr int worldDim = Traits::worlddim;
32 const auto& fe = localView.tree().child(0).finiteElement();
33 Dune::BlockVector<Dune::RealTuple<ST, worldDim>> localX(fe.size());
35 for (
auto i = 0U; i < localX.size(); ++i)
36 for (
auto j = 0U; j < worldDim; ++j)
38 dx.value().get()[i * worldDim + j] + x[localView.index(localView.tree().child(j).localIndex(i))[0]];
40 for (
auto i = 0U; i < localX.size(); ++i)
41 for (
auto j = 0U; j < worldDim; ++j)
42 localX[i][j] = x[localView.index(localView.tree().child(j).localIndex(i))[0]];
61template <
typename Traits,
typename Vector,
typename ST>
63 const Vector& x,
const typename Traits::LocalView& localView,
auto&& treePath,
64 const std::optional<std::reference_wrapper<
const Eigen::VectorX<ST>>>& dx = std::nullopt) {
65 constexpr int worldDim = Traits::worlddim;
66 const auto& fe = localView.tree().child(treePath).finiteElement();
67 Dune::BlockVector<Dune::RealTuple<ST, 1>> localX(fe.size());
69 for (
auto i = 0U; i < localX.size(); ++i) {
70 auto iIdx = localView.index(localView.tree().child(treePath).localIndex(i))[0];
71 localX[i][0] = dx.value().get()[iIdx] + x[iIdx];
74 for (
auto i = 0U; i < localX.size(); ++i)
75 localX[i][0] = x[localView.index(localView.tree().child(treePath).localIndex(i))[0]];
94template <
typename Traits,
typename Vector,
typename ST>
96 const Vector& x,
const typename Traits::LocalView& localView,
auto&& treePath,
97 const std::optional<std::reference_wrapper<
const Eigen::VectorX<ST>>>& dx = std::nullopt) {
98 constexpr int worldDim = Traits::worlddim;
99 const auto& fe = localView.tree().child(treePath).child(0).finiteElement();
100 Dune::BlockVector<Dune::RealTuple<ST, worldDim>> localX(fe.size());
102 for (
auto i = 0U; i < localX.size(); ++i)
103 for (
auto j = 0U; j < worldDim; ++j) {
104 auto ijIndx = localView.index(localView.tree().child(treePath).child(j).localIndex(i))[0];
105 localX[i][j] = dx.value().get()[ijIndx] + x[ijIndx];
108 for (
auto i = 0U; i < localX.size(); ++i)
109 for (
auto j = 0U; j < worldDim; ++j)
110 localX[i][j] = x[localView.index(localView.tree().child(treePath).child(j).localIndex(i))[0]];
127 template <
typename LocalView,
typename Node>
128 void leafNodeIndices(
const LocalView& localView,
const Node& node,
129 std::vector<typename LocalView::MultiIndex>&
globalIndices) {
130 const auto& fe = node.finiteElement();
131 for (
size_t i = 0; i < fe.size(); ++i)
132 globalIndices.push_back(localView.index(node.localIndex(i)));
145 template <
typename LocalView,
typename Node>
146 void powerNodeIndices(
const LocalView& localView,
const Node& node,
147 std::vector<typename LocalView::MultiIndex>&
globalIndices) {
148 const auto& fe = node.child(0).finiteElement();
149 const int childrenSize = node.degree();
150 for (
size_t i = 0; i < fe.size(); ++i)
151 for (
int j = 0; j < childrenSize; ++j)
152 globalIndices.push_back(localView.index(node.child(j).localIndex(i)));
164template <
typename LocalView>
166 std::vector<typename LocalView::MultiIndex>&
globalIndices) {
167 assert(localView.bound());
169 using namespace Dune::Indices;
170 using namespace FEHelper::Impl;
172 auto leafOpFunc = [&](
auto&& node, [[maybe_unused]]
auto&& treePath) {
176 auto powerOpFunc = [&](
auto&& node, [[maybe_unused]]
auto&& treePath) {
194template <
typename FiniteElement>
Contains functions to traverse through a tree to its different nodes.
Definition: fehelper.hh:13
auto localSolutionBlockVectorComposite(const Vector &x, const typename Traits::LocalView &localView, auto &&treePath, const std::optional< std::reference_wrapper< const Eigen::VectorX< ST > > > &dx=std::nullopt)
Gets the local solution Dune block vector for a particular power node child of a composite basis.
Definition: fehelper.hh:95
void globalIndicesFromLocalView(const LocalView &localView, std::vector< typename LocalView::MultiIndex > &globalIndices)
Get the global indices for the provided local view of an element.
Definition: fehelper.hh:165
void globalIndices(const FiniteElement &fe, std::vector< typename FiniteElement::LocalView::MultiIndex > &globalIndices)
Get the global indices for the provided finite element.
Definition: fehelper.hh:195
auto localSolutionBlockVector(const Vector &x, const typename Traits::LocalView &localView, const std::optional< std::reference_wrapper< const Eigen::VectorX< ST > > > &dx=std::nullopt)
Gets the local solution Dune block vector for a power basis.
Definition: fehelper.hh:28
auto localSolutionBlockVectorScalar(const Vector &x, const typename Traits::LocalView &localView, auto &&treePath, const std::optional< std::reference_wrapper< const Eigen::VectorX< ST > > > &dx=std::nullopt)
Gets the local solution Dune block vector for a scalar (or leaf) node of a power basis.
Definition: fehelper.hh:62
void forEachLeafOrPowerLeafNode(T &&tree, TreePath &&treePath, PowerFunc &&powerFunc, LeafFunc &&leafFunc)
A function which loops over all the nodes of a tree and performs different actions for a power node (...
Definition: traversal.hh:31