Skip to content
Snippets Groups Projects
Commit 5a169a85 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

added helper utility to wrap Dune::FunctionFromCallable constructors

parent fb5c14f2
No related branches found
No related tags found
No related merge requests found
...@@ -17,10 +17,9 @@ ...@@ -17,10 +17,9 @@
#include <dune/grid/common/geometry.hh> #include <dune/grid/common/geometry.hh>
#include <dune/grid/common/rangegenerators.hh> #include <dune/grid/common/rangegenerators.hh>
#include <dune/functions/common/functionfromcallable.hh>
#include <amdis/Output.hpp> #include <amdis/Output.hpp>
#include <amdis/common/ConcurrentCache.hpp> #include <amdis/common/ConcurrentCache.hpp>
#include <amdis/functions/FunctionFromCallable.hpp>
#include <amdis/typetree/Traversal.hpp> #include <amdis/typetree/Traversal.hpp>
namespace AMDiS { namespace AMDiS {
...@@ -373,9 +372,8 @@ bool NodeDataTransfer<N,C,B>:: ...@@ -373,9 +372,8 @@ bool NodeDataTransfer<N,C,B>::
return fatherDOFsTemp_[currentDOF++]; return fatherDOFsTemp_[currentDOF++];
}; };
using FFC auto evalLeafFct = functionFromCallable<LIRangeType(LIDomainType)>(evalLeaf);
= Dune::Functions::FunctionFromCallable<LIRangeType(LIDomainType), decltype(evalLeaf)>; fatherFE.localInterpolation().interpolate(evalLeafFct, fatherDOFs);
fatherFE.localInterpolation().interpolate(FFC(evalLeaf), fatherDOFs);
// Return true if all father DOFs have been evaluated // Return true if all father DOFs have been evaluated
return std::accumulate(finishedDOFs_.begin(), finishedDOFs_.end(), true, return std::accumulate(finishedDOFs_.begin(), finishedDOFs_.end(), true,
...@@ -413,9 +411,8 @@ void NodeDataTransfer<N,C,B>:: ...@@ -413,9 +411,8 @@ void NodeDataTransfer<N,C,B>::
auto const& childFE = childNode.finiteElement(); auto const& childFE = childNode.finiteElement();
thread_local std::vector<T> childDOFs; thread_local std::vector<T> childDOFs;
using FFC = Dune::Functions auto evalFatherFct = functionFromCallable<LIRangeType(LIDomainType)>(evalFather);
::FunctionFromCallable<LIRangeType(LIDomainType), decltype(evalFather)>; childFE.localInterpolation().interpolate(evalFatherFct, childDOFs);
childFE.localInterpolation().interpolate(FFC(evalFather), childDOFs);
for (std::size_t i = 0; i < childDOFs.size(); ++i) for (std::size_t i = 0; i < childDOFs.size(); ++i)
(*coeff_)[lv_->index(childNode.localIndex(i))] = childDOFs[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 ...@@ -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; std::array<std::vector<typename RangeType::field_type>, D::dimension> coeffs;
for (int d = 0; d < D::dimension; ++d) { for (int d = 0; d < D::dimension; ++d) {
auto evalCoord = [&](DomainType const& local) -> RangeType { return geometry.global(local)[d]; }; auto evalCoord = functionFromCallable<RangeType(DomainType)>([&](DomainType const& local) -> RangeType { return geometry.global(local)[d]; });
using FFC = Dune::Functions::FunctionFromCallable<RangeType(DomainType), decltype(evalCoord)>; localInterpol.interpolate(evalCoord, coeffs[d]);
localInterpol.interpolate(FFC(evalCoord), coeffs[d]);
} }
for (std::size_t j = 0; j < localIndices.size(); ++j) { for (std::size_t j = 0; j < localIndices.size(); ++j) {
......
#install headers #install headers
install(FILES install(FILES
FunctionFromCallable.hpp
GlobalIdSet.hpp GlobalIdSet.hpp
HierarchicNodeToRangeMap.hpp HierarchicNodeToRangeMap.hpp
Interpolate.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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment