Commit 792d38c6 authored by Praetorius, Simon's avatar Praetorius, Simon

Merge branch 'feature/function_From_callable' into 'master'

added helper utility to wrap Dune::FunctionFromCallable constructors

See merge request !84
parents fb5c14f2 5a169a85
Pipeline #2656 passed with stage
in 42 minutes and 48 seconds
......@@ -17,10 +17,9 @@
#include <dune/grid/common/geometry.hh>
#include <dune/grid/common/rangegenerators.hh>
#include <dune/functions/common/functionfromcallable.hh>
#include <amdis/Output.hpp>
#include <amdis/common/ConcurrentCache.hpp>
#include <amdis/functions/FunctionFromCallable.hpp>
#include <amdis/typetree/Traversal.hpp>
namespace AMDiS {
......@@ -373,9 +372,8 @@ bool NodeDataTransfer<N,C,B>::
return fatherDOFsTemp_[currentDOF++];
};
using FFC
= Dune::Functions::FunctionFromCallable<LIRangeType(LIDomainType), decltype(evalLeaf)>;
fatherFE.localInterpolation().interpolate(FFC(evalLeaf), fatherDOFs);
auto evalLeafFct = functionFromCallable<LIRangeType(LIDomainType)>(evalLeaf);
fatherFE.localInterpolation().interpolate(evalLeafFct, fatherDOFs);
// Return true if all father DOFs have been evaluated
return std::accumulate(finishedDOFs_.begin(), finishedDOFs_.end(), true,
......@@ -413,9 +411,8 @@ void NodeDataTransfer<N,C,B>::
auto const& childFE = childNode.finiteElement();
thread_local std::vector<T> childDOFs;
using FFC = Dune::Functions
::FunctionFromCallable<LIRangeType(LIDomainType), decltype(evalFather)>;
childFE.localInterpolation().interpolate(FFC(evalFather), childDOFs);
auto evalFatherFct = functionFromCallable<LIRangeType(LIDomainType)>(evalFather);
childFE.localInterpolation().interpolate(evalFatherFct, childDOFs);
for (std::size_t i = 0; i < childDOFs.size(); ++i)
(*coeff_)[lv_->index(childNode.localIndex(i))] = childDOFs[i];
......
......@@ -211,9 +211,8 @@ coords(Node const& tree, std::vector<std::size_t> const& localIndices) const
std::array<std::vector<typename RangeType::field_type>, D::dimension> coeffs;
for (int d = 0; d < D::dimension; ++d) {
auto evalCoord = [&](DomainType const& local) -> RangeType { return geometry.global(local)[d]; };
using FFC = Dune::Functions::FunctionFromCallable<RangeType(DomainType), decltype(evalCoord)>;
localInterpol.interpolate(FFC(evalCoord), coeffs[d]);
auto evalCoord = functionFromCallable<RangeType(DomainType)>([&](DomainType const& local) -> RangeType { return geometry.global(local)[d]; });
localInterpol.interpolate(evalCoord, coeffs[d]);
}
for (std::size_t j = 0; j < localIndices.size(); ++j) {
......
#install headers
install(FILES
FunctionFromCallable.hpp
GlobalIdSet.hpp
HierarchicNodeToRangeMap.hpp
Interpolate.hpp
......
#pragma once
#include <dune/common/typeutilities.hh>
#include <dune/functions/common/functionfromcallable.hh>
namespace AMDiS
{
namespace Impl
{
template <class Traits, class F,
class Range = typename Traits::RangeType,
class Domain = typename Traits::DomainType>
auto functionFromCallableImpl(F const& f, Dune::PriorityTag<2>)
{
return Dune::Functions::FunctionFromCallable<Range(Domain), F>(f);
}
template <class Signature, class F>
auto functionFromCallableImpl(F const& f, Dune::PriorityTag<1>)
{
return Dune::Functions::FunctionFromCallable<Signature, F>(f);
}
}
template <class SigTraits, class F>
auto functionFromCallable(F const& f)
{
return Impl::functionFromCallableImpl<SigTraits>(f, Dune::PriorityTag<10>{});
}
} // end namespace AMDiS
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment