Skip to content
Snippets Groups Projects
Commit 4b42dba7 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[operators.projections.l2] add L2ProjectionOperator

parent 45ad3e5a
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,15 @@ public:
}; // class L2ProjectionLocalizableOperatorTraits
template <class GridViewType, class FieldImp = double>
class L2ProjectionOperatorTraits
{
public:
typedef L2ProjectionOperator<GridViewType, FieldImp> derived_type;
typedef FieldImp FieldType;
};
} // namespace internal
......@@ -86,6 +95,122 @@ make_l2_projection_localizable_operator(const SourceType& source, DiscreteFuncti
} // ... make_l2_projection_localizable_operator(...)
template <class GridViewImp, class FieldImp>
class L2ProjectionOperator : public OperatorInterface<internal::L2ProjectionOperatorTraits<GridViewImp, FieldImp>>
{
typedef OperatorInterface<internal::L2ProjectionOperatorTraits<GridViewImp, FieldImp>> BaseType;
public:
typedef internal::L2ProjectionOperatorTraits<GridViewImp, FieldImp> Traits;
typedef GridViewImp GridViewType;
using typename BaseType::FieldType;
private:
typedef typename Stuff::Grid::Entity<GridViewType>::Type E;
typedef typename GridViewType::ctype D;
static const size_t d = GridViewType::dimension;
public:
L2ProjectionOperator(const size_t over_integrate, GridViewType grid_view)
: grid_view_(grid_view)
, over_integrate_(over_integrate)
{
}
L2ProjectionOperator(GridViewType grid_view)
: grid_view_(grid_view)
, over_integrate_(0)
{
}
template <class R, size_t r, size_t rC, class S, class V>
void apply(const Stuff::LocalizableFunctionInterface<E, D, d, R, r, rC>& source, DiscreteFunction<S, V>& range) const
{
redirect<S::continuous>::apply(grid_view_, source, range, over_integrate_);
}
template <class RangeType, class SourceType>
FieldType apply2(const RangeType& /*range*/, const SourceType& /*source*/) const
{
DUNE_THROW(NotImplemented, "Go ahead if you think this makes sense!");
}
template <class RangeType, class SourceType>
void apply_inverse(const RangeType& /*range*/, SourceType& /*source*/,
const Stuff::Common::Configuration& /*opts*/) const
{
DUNE_THROW(NotImplemented, "Go ahead if you think this makes sense!");
}
std::vector<std::string> invert_options() const
{
DUNE_THROW(NotImplemented, "Go ahead if you think this makes sense!");
}
Stuff::Common::Configuration invert_options(const std::string& /*type*/) const
{
DUNE_THROW(NotImplemented, "Go ahead if you think this makes sense!");
}
private:
template <bool continuous = true, bool anything = true>
struct redirect
{
template <class SourceType, class RangeType>
static void apply(const GridViewType& grd_vw, const SourceType& src, RangeType& rng, const size_t over_integrate)
{
L2GlobalProjectionLocalizableOperator<GridViewType, SourceType, RangeType>(over_integrate, grd_vw, src, rng)
.apply();
}
};
template <bool anything>
struct redirect<false, anything>
{
template <class SourceType, class RangeType>
static void apply(const GridViewType& grd_vw, const SourceType& src, RangeType& rng, const size_t over_integrate)
{
L2LocalProjectionLocalizableOperator<GridViewType, SourceType, RangeType>(over_integrate, grd_vw, src, rng)
.apply();
}
};
GridViewType grid_view_;
const size_t over_integrate_;
}; // class L2ProjectionOperator
template <class GridViewType>
typename std::enable_if<Stuff::Grid::is_grid_layer<GridViewType>::value,
std::unique_ptr<L2ProjectionOperator<GridViewType>>>::type
make_l2_projection_operator(const GridViewType& grid_view, const size_t over_integrate = 0)
{
return DSC::make_unique<L2ProjectionOperator<GridViewType>>(over_integrate, grid_view);
}
template <class GridViewType, class SourceType, class SpaceType, class VectorType>
typename std::enable_if<Stuff::Grid::is_grid_layer<GridViewType>::value
&& Stuff::is_localizable_function<SourceType>::value && is_space<SpaceType>::value
&& Stuff::LA::is_vector<VectorType>::value,
void>::type
project_l2(const GridViewType& grid_view, const SourceType& source, DiscreteFunction<SpaceType, VectorType>& range,
const size_t over_integrate = 0)
{
make_l2_projection_operator(grid_view, over_integrate)->apply(source, range);
}
template <class SourceType, class SpaceType, class VectorType>
typename std::enable_if<Stuff::is_localizable_function<SourceType>::value && is_space<SpaceType>::value
&& Stuff::LA::is_vector<VectorType>::value,
void>::type
project_l2(const SourceType& source, DiscreteFunction<SpaceType, VectorType>& range, const size_t over_integrate = 0)
{
make_l2_projection_operator(range.space().grid_view(), over_integrate)->apply(source, range);
}
} // namespace GDT
} // namespace Dune
......
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