AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
DiscreteFunction.inc.hpp
1#pragma once
2
3#include <type_traits>
4
5#include <dune/grid/utility/hierarchicsearch.hh>
6
7#include <amdis/algorithm/Transform.hpp>
8#include <amdis/gridfunctions/GridFunction.hpp>
9#include <amdis/linearalgebra/VectorFacade.hpp>
10
11namespace AMDiS {
12
13// Evaluate DiscreteFunction in global coordinates
14template <class C, class GB, class TP, class R>
15typename DiscreteFunction<C const,GB,TP,R>::Range DiscreteFunction<C const,GB,TP,R>::
16 operator()(Domain const& x) const
17{
18 using Grid = typename GlobalBasis::GridView::Grid;
19 using IS = typename GlobalBasis::GridView::IndexSet;
20
21 auto const& gv = this->basis().gridView();
22 Dune::HierarchicSearch<Grid,IS> hsearch{gv.grid(), gv.indexSet()};
23
24 auto element = hsearch.findEntity(x);
25 auto geometry = element.geometry();
26 auto localFct = localFunction(*this);
27 localFct.bind(element);
28 return localFct(geometry.local(x));
29}
30
31
32// Interpolation of GridFunction to DOFVector
33template <class C, class GB, class TP, class R>
34 template <class Expr, class Tag>
36 interpolate_noalias(Expr&& expr, Tag strategy)
37{
38 auto const& basis = this->basis();
39 auto const& treePath = this->treePath();
40
41 auto&& gf = makeGridFunction(FWD(expr), basis.gridView());
42
43 auto interpolate = InterpolatorFactory<Tag>::create(basis, treePath);
44 interpolate(this->coefficients(), gf);
45}
46
47
48// Interpolation of GridFunction to DOFVector
49template <class C, class GB, class TP, class R>
50 template <class Expr, class Tag>
52 interpolate(Expr&& expr, Tag strategy)
53{
54 // create temporary copy of data
55 Coefficients tmp(coefficients());
56
57 Self tmpView{tmp, this->basis(), this->treePath()};
58 tmpView.interpolate_noalias(FWD(expr), strategy);
59
60 // move data from temporary vector into stored DOFVector
61 coefficients() = std::move(tmp);
62}
63
64} // end namespace AMDiS
A mutable view on the subspace of a DOFVector,.
Definition: DiscreteFunction.hpp:45
void interpolate(Expr &&expr, Tag strategy={})
Interpolation of GridFunction to DOFVector.
Definition: DiscreteFunction.inc.hpp:52
void interpolate_noalias(Expr &&expr, Tag strategy={})
Interpolation of GridFunction to DOFVector, assuming that there is no reference to this DOFVector in ...
Definition: DiscreteFunction.inc.hpp:36
decltype(auto) makeGridFunction(PreGridFct const &preGridFct, GridView const &gridView)
Generator for Gridfunctions from Expressions (PreGridfunctions)
Definition: GridFunction.hpp:168
Definition: SimpleInterpolator.hpp:80