13#include <dune/common/float_cmp.hh>
14#include <dune/grid/utility/hierarchicsearch.hh>
29template <
int size,
typename LV>
33 lagrangeNodeGlobalCoords.emplace_back(localView.element().geometry().global(localCoordinate));
49template <
int worldDim,
typename Basis>
52 "globalIndexFromGlobalPosition is only supported for Lagrange basis");
53 constexpr double tol = 1e-8;
54 using LocalView = std::remove_cvref_t<
decltype(
basis.localView())>;
55 using MultiIndex =
typename LocalView::MultiIndex;
56 using Element =
typename LocalView::Element;
57 constexpr int myDim = Element::mydimension;
58 Dune::HierarchicSearch hSearch(
basis.gridView().grid(),
basis.gridView().indexSet());
59 const auto& ele = hSearch.findEntity(pos);
60 auto localView =
basis.localView();
62 const auto geo = localView.element().geometry();
63 const auto& node = localView.tree();
64 std::optional<std::array<MultiIndex, worldDim>>
globalIndices;
67 if (Dune::FloatCmp::eq(geo.global(localCoordinate), pos, tol)) {
69 for (
int j = 0; j < worldDim; j++)
70 globalIndices.value()[j] = localView.index(node.child(j).localIndex(nodeNumber));
77 DUNE_THROW(Dune::InvalidStateException,
"No Lagrange node found at the given position in the grid.");
93 const auto& referenceElement = Dune::referenceElement<double, dim>(element.type());
94 const int numberOfVertices = referenceElement.size(codim);
96 auto getPosition = [=](
const int i) {
return referenceElement.position(i, codim); };
97 return std::views::transform(std::views::iota(0, numberOfVertices), getPosition);
107template <
typename FE>
136 auto& dv = assembler->dirichletValues();
137 auto newInc = Eigen::VectorXd::Zero(dv.size()).eval();
138 dv.evaluateInhomogeneousBoundaryConditionDerivative(newInc, 1.0);
140 Eigen::VectorXd F_dirichlet;
141 F_dirichlet = K * newInc;
144 assembler->dirichletValues().setZeroAtConstrainedDofs(F_dirichlet);
146 F_dirichlet = assembler->createReducedVector(F_dirichlet);
Contains functions to traverse through a tree to its different nodes.
auto referenceElementSubEntityPositions(FE &fe, int codim)
A function to obtain the local coordinates of subentities of an FiniteElement.
Definition: functionhelper.hh:90
auto referenceElementVertexPositions(FE &fe)
A function to obtain the local coordinates the vertices of an FiniteElement.
Definition: functionhelper.hh:108
auto globalIndexFromGlobalPosition(const Basis &basis, const Dune::FieldVector< double, worldDim > &pos)
A helper function to obtain the global index from the global positions for a Lagrange node.
Definition: functionhelper.hh:50
void obtainLagrangeGlobalNodePositions(const LV &localView, std::vector< Dune::FieldVector< double, size > > &lagrangeNodeGlobalCoords)
A function to obtain the global positions of the nodes of an element with Lagrangian basis.
Definition: functionhelper.hh:30
void globalIndices(const FiniteElement &fe, std::vector< typename FiniteElement::LocalView::MultiIndex > &globalIndices)
Get the global indices for the provided finite element.
Definition: fehelper.hh:127
Definition: algorithms.hh:17
auto obtainForcesDueToIDBC(const A &assembler)
A helper function to compute the forces due to inhomogeneous Dirichlet BCs.
Definition: functionhelper.hh:134
void forEachLagrangeNodePosition(const LV &localView, F &&f)
A helper function that helps in traversing over the local coordinates of an element and call a user-d...
Definition: traversal.hh:65
decltype(auto) maybeDeref(T &t)
if T is a pointer type, return the dereferenced value, otherwise return the value itself.
Definition: functionhelper.hh:120
def basis(gv, tree)
Definition: basis.py:10
FE class is a base class for all finite elements.
Definition: febase.hh:79
const GridElement & gridElement() const
Get the grid element associated with the local view.
Definition: febase.hh:128
static constexpr int mydim
Dimension of the geometry.
Definition: fetraits.hh:63
Definition: utils/dirichletvalues.hh:34
Type trait to check if a type is a isSharedPtr.
Definition: traits.hh:136
Concept to check if a node in a basis tree is a Lagrangian node.
Definition: utils/concepts.hh:92
Definition: utils/concepts.hh:641