diff --git a/dune/gdt/assembler/local/codim0.hh b/dune/gdt/assembler/local/codim0.hh index f44e4cb325a05271cfe3f03b18ab0cc2b0b70158..da2658ddabb11ff0a7271bf5a8b11ff767bafa69 100644 --- a/dune/gdt/assembler/local/codim0.hh +++ b/dune/gdt/assembler/local/codim0.hh @@ -20,6 +20,7 @@ #include <dune/stuff/grid/walker/wrapper.hh> #include <dune/stuff/la/container/interfaces.hh> +#include <dune/gdt/discretefunction/default.hh> #include <dune/gdt/localoperator/interface.hh> #include <dune/gdt/localoperator/interfaces.hh> #include <dune/gdt/localfunctional/interface.hh> @@ -169,6 +170,49 @@ private: }; // class LocalVolumeTwoFormAccumulator +template <class GridViewType, class LocalOperatorType, class SourceType, class RangeType> +class LocalOperatorApplicator : public Stuff::Grid::internal::Codim0Object<GridViewType> +{ + static_assert(is_local_operator<LocalOperatorType>::value, + "LocalOperatorType has to be derived from LocalOperatorInterface!"); + static_assert(Stuff::is_localizable_function<SourceType>::value, + "SourceType has to be derived from Stuff::LocalizableFunctionInterface!"); + static_assert(is_discrete_function<RangeType>::value, "RangeType has to be a DiscreteFunctionDefault!"); + typedef Stuff::Grid::internal::Codim0Object<GridViewType> BaseType; + +public: + using typename BaseType::EntityType; + + LocalOperatorApplicator(const GridViewType& grid_view, const LocalOperatorType& local_operator, + const SourceType& source, RangeType& range, + const Stuff::Grid::ApplyOn::WhichEntity<GridViewType>& where) + : grid_view_(grid_view) + , local_operator_(local_operator) + , source_(source) + , range_(range) + , where_(where) + { + } + + virtual bool apply_on(const GridViewType& grid_view, const EntityType& entity) const + { + return where_.apply_on(grid_view, entity); + } + + virtual void apply_local(const EntityType& entity) + { + local_operator_.apply(source_, *range_.local_discrete_function(entity)); + } + +private: + const GridViewType& grid_view_; + const LocalOperatorType& local_operator_; + const SourceType& source_; + RangeType& range_; + const Stuff::Grid::ApplyOn::WhichEntity<GridViewType>& where_; +}; // class LocalOperatorApplicator + + namespace LocalAssembler {