1#ifndef DUNE_FEM_VTXPROJECTION_HH
2#define DUNE_FEM_VTXPROJECTION_HH
11#include <dune/grid/common/rangegenerators.hh>
24 template <
class Gr
idPartType>
26 typedef typename GridPartType::template Codim<0>::EntityType
EntityType;
28 typedef FieldVector<double,GridPartType::dimension>
DomainType;
31 volume_ = en.geometry().volume();
36 auto tau =
en_.geometry().global(point);
38 return tau.two_norm() /
volume_;
47 template<
class DiscreteFunction,
class Intersection >
52 typedef typename LocalFunctionType::EntityType
EntityType;
58 typedef typename FunctionSpaceType::DomainType
DomainType;
59 typedef typename FunctionSpaceType::RangeType
RangeType;
66 static const int dimDomain = FunctionSpaceType::dimDomain;
67 static const int dimRange = FunctionSpaceType::dimRange;
75 localFunction_.init( outside );
83 int order()
const {
return order_; }
85 template<
class Po
int >
88 localFunction_.evaluate( geoOut_->global( geoIn_->local(
coordinate( x ) ) ), value );
91 template<
class Po
int >
94 DUNE_THROW( NotImplemented,
"Vertex projection weights do not provide Jacobians." );
97 template<
class Po
int >
100 DUNE_THROW( NotImplemented,
"Vertex projection weights do not provide Hessians." );
103 template<
class Quadrature,
class Values >
106 for(
const auto &qp : quadrature )
107 doEvaluate( qp, values[ qp.index() ] );
111 template<
class Po
int >
112 void doEvaluate (
const Point &x,
RangeType &value )
const
117 template<
class Po
int >
123 template<
class Po
int >
137 template<
class DiscreteFunction >
140 typedef typename DiscreteFunction::GridPartType GridPartType;
142 typedef typename GridPartType::IntersectionType IntersectionType;
143 typedef typename GridPartType::template Codim< 0 >::EntityType EntityType;
144 typedef typename DiscreteFunction::DiscreteFunctionSpaceType
145 DiscreteFunctionSpaceType;
150 const auto &blockMapper = u.space().blockMapper();
152 std::vector< typename DiscreteFunction::DofType > ldu, ldw;
153 const std::size_t localBlockSize = DiscreteFunctionSpaceType::localBlockSize;
154 const std::size_t maxNumBlocks = blockMapper.maxNumDofs();
155 ldu.reserve( maxNumBlocks * localBlockSize );
156 ldw.reserve( maxNumBlocks * localBlockSize );
158 std::vector< bool > onSubEntity;
159 onSubEntity.reserve( maxNumBlocks );
165 for(
const EntityType &inside : u.space() )
167 for(
const IntersectionType &intersection : intersections( u.gridPart(), inside ) )
169 if( intersection.conforming() || !intersection.neighbor() )
173 const EntityType outside = intersection.outside();
174 if( inside.level() <= outside.level() )
179 const auto geoIn = intersection.geometryInInside();
180 const auto geoOut = intersection.geometryInOutside();
181 uOutside.
init( outside, geoIn, geoOut );
184 const std::size_t numBlocks = blockMapper.numDofs( inside );
185 ldu.resize( numBlocks * localBlockSize );
186 ldw.resize( numBlocks * localBlockSize );
189 auto guard =
bindGuard( interpolation, inside );
190 interpolation( uOutside, ldw );
193 u.getLocalDofs( inside, ldu );
196 blockMapper.onSubEntity( inside, intersection.indexInInside(), 1, onSubEntity );
197 for( std::size_t i = 0; i < numBlocks; ++i )
199 if( !onSubEntity[ i ] )
201 for( std::size_t j = 0; j < localBlockSize; ++j )
202 ldu[ i*localBlockSize + j ] = ldw[ i*localBlockSize + j ];
206 u.setLocalDofs( inside, ldu );
211 template<
class Function,
class DiscreteFunction,
class Weight >
213 -> std::enable_if_t<std::is_void<
decltype(
interpolate(f,u,weight,u )) >::value>
216 DiscreteFunction w (
"weight", u.space() );
220 template<
class Function,
class DiscreteFunction >
237 template <
typename DType,
typename RType >
245 typedef typename Dune::FieldTraits< RangeFieldType >::real_type
RealType;
246 typedef typename RType :: DiscreteFunctionSpaceType :: GridPartType
GridPartType;
251 template <
class WeightType>
253 WeightType& weight)
const
static void interpolate(const GridFunction &u, DiscreteFunction &v)
perform native interpolation of a discrete function space
Definition: common/interpolate.hh:54
Definition: bindguard.hh:11
static const Point & coordinate(const Point &x)
Definition: coordinate.hh:14
static auto bindGuard(Object &object, Args &&... args) -> std::enable_if_t< isBindable< Object, Args... >::value, BindGuard< Object > >
Definition: bindguard.hh:67
Abstract class representing a function.
Definition: common/function.hh:50
specialize with 'false' if grid part has no underlying dune grid (default=true)
Definition: gridpart/common/capabilities.hh:18
abstract operator
Definition: operator.hh:34
Definition: vtxprojection.hh:25
double operator()(const DomainType &point)
Definition: vtxprojection.hh:34
FieldVector< double, GridPartType::dimensionworld > WorldDomainType
Definition: vtxprojection.hh:27
double volume_
Definition: vtxprojection.hh:40
GridPartType::template Codim< 0 >::EntityType EntityType
Definition: vtxprojection.hh:26
WorldDomainType baryCenter_
Definition: vtxprojection.hh:41
FieldVector< double, GridPartType::dimension > DomainType
Definition: vtxprojection.hh:28
void setEntity(const EntityType &en)
Definition: vtxprojection.hh:29
EntityType en_
Definition: vtxprojection.hh:42
Definition: vtxprojection.hh:46
static auto project(const Function &f, DiscreteFunction &u) -> std::enable_if_t< std::is_void< decltype(project(f, u, std::declval< WeightDefault< typename DiscreteFunction::GridPartType > & >())) >::value >
Definition: vtxprojection.hh:221
static auto project(const Function &f, DiscreteFunction &u, Weight &weight) -> std::enable_if_t< std::is_void< decltype(interpolate(f, u, weight, u)) >::value >
Definition: vtxprojection.hh:212
static void makeConforming(DiscreteFunction &u)
Definition: vtxprojection.hh:138
Definition: vtxprojection.hh:49
void init(const EntityType &outside, const GeometryType &geoIn, const GeometryType &geoOut)
Definition: vtxprojection.hh:73
const EntityType & entity() const
Definition: vtxprojection.hh:81
static const int dimRange
Definition: vtxprojection.hh:67
FunctionSpaceType::JacobianRangeType JacobianRangeType
Definition: vtxprojection.hh:61
void evaluate(const Point &x, RangeType &value) const
Definition: vtxprojection.hh:86
int order() const
Definition: vtxprojection.hh:83
void evaluateQuadrature(const Quadrature &quadrature, Values &values) const
Definition: vtxprojection.hh:104
FunctionSpaceType::RangeType RangeType
Definition: vtxprojection.hh:59
EntityType::Geometry::LocalCoordinate LocalCoordinateType
Definition: vtxprojection.hh:64
LocalFunctionType::FunctionSpaceType FunctionSpaceType
Definition: vtxprojection.hh:53
LocalFunctionType::EntityType EntityType
Definition: vtxprojection.hh:52
DiscreteFunction::LocalFunctionType LocalFunctionType
Definition: vtxprojection.hh:50
FunctionSpaceType::DomainFieldType DomainFieldType
Definition: vtxprojection.hh:55
Intersection::LocalGeometry GeometryType
Definition: vtxprojection.hh:69
static const int dimDomain
Definition: vtxprojection.hh:66
void jacobian(const Point &x, JacobianRangeType &jacobian) const
Definition: vtxprojection.hh:92
void hessian(const Point &x, HessianRangeType &hessian) const
Definition: vtxprojection.hh:98
FunctionSpaceType::HessianRangeType HessianRangeType
Definition: vtxprojection.hh:62
FunctionSpaceType::RangeFieldType RangeFieldType
Definition: vtxprojection.hh:56
OutsideLocalFunction(const DiscreteFunction &df)
Definition: vtxprojection.hh:71
FunctionSpaceType::DomainType DomainType
Definition: vtxprojection.hh:58
The Projection class which average discontinuous function using the interpolation of the space (e....
Definition: vtxprojection.hh:239
RType::DiscreteFunctionSpaceType::GridPartType GridPartType
Definition: vtxprojection.hh:246
RType RangeType
Definition: vtxprojection.hh:242
VtxProjection()
Constructor.
Definition: vtxprojection.hh:248
DType DomainType
Definition: vtxprojection.hh:241
RType::RangeFieldType RangeFieldType
Definition: vtxprojection.hh:244
Dune::FieldTraits< RangeFieldType >::real_type RealType
Definition: vtxprojection.hh:245
void operator()(const DomainType &f, RangeType &discFunc, WeightType &weight) const
apply projection
Definition: vtxprojection.hh:252
DomainType::RangeFieldType DomainFieldType
Definition: vtxprojection.hh:243
actual interface class for quadratures
Definition: quadrature.hh:405
Definition: common/localinterpolation.hh:22