#pragma once #include #include #include #include #include namespace AMDiS { // Evaluate DiscreteFunction in global coordinates template typename DiscreteFunction::Range DiscreteFunction:: operator()(Domain const& x) const { using Grid = typename GlobalBasis::GridView::Grid; using IS = typename GlobalBasis::GridView::IndexSet; auto const& gv = this->basis().gridView(); Dune::HierarchicSearch hsearch{gv.grid(), gv.indexSet()}; auto element = hsearch.findEntity(x); auto geometry = element.geometry(); auto localFct = localFunction(*this); localFct.bind(element); return localFct(geometry.local(x)); } // Interpolation of GridFunction to DOFVector template template void DiscreteFunction:: interpolate_noalias(Expr&& expr, Tag strategy) { auto const& basis = this->basis(); auto const& treePath = this->treePath(); auto&& gf = makeGridFunction(FWD(expr), basis.gridView()); if (std::is_same_v) { VectorType_t counter(basis); AMDiS::interpolate(basis, coefficients(), gf, treePath, counter); coefficients().forEach([&counter](auto dof, auto& coeff) { coeff /= std::max(double(counter.at(dof)), 1.0); }); } else { AMDiS::interpolate(basis, coefficients(), gf, treePath); } } // Interpolation of GridFunction to DOFVector template template void DiscreteFunction:: interpolate(Expr&& expr, Tag strategy) { // create temporary copy of data Coefficients tmp(coefficients()); Self tmpView{tmp, this->basis(), this->treePath()}; tmpView.interpolate_noalias(FWD(expr), strategy); // move data from temporary vector into stored DOFVector coefficients() = std::move(tmp); } } // end namespace AMDiS