1#ifndef DUNE_FEM_LFESPACE_LOCALRESTRICTPROLONG_HH
2#define DUNE_FEM_LFESPACE_LOCALRESTRICTPROLONG_HH
5#include <dune/geometry/referenceelements.hh>
6#include <dune/fem/function/localfunction/localfunction.hh>
7#include <dune/fem/space/localfiniteelement/space.hh>
8#include <dune/fem/space/common/localinterpolation.hh>
9#include <dune/fem/space/common/localrestrictprolong.hh>
19 template<
class LocalGeometry,
class LF>
22 typedef std::remove_reference_t< LF > LocalFunctionType;
23 typedef std::remove_reference_t< LocalGeometry > LocalGeometryType;
26 typedef typename LocalFunctionType::DomainType DomainType;
27 typedef typename LocalFunctionType::RangeType RangeType;
29 typedef typename LocalFunctionType::EntityType EntityType;
31 typedef typename LocalFunctionType::DomainType DomainType;
32 typedef typename LocalFunctionType::RangeType RangeType;
33 typedef typename LocalFunctionType::JacobianRangeType JacobianRangeType;
34 typedef typename LocalFunctionType::HessianRangeType HessianRangeType;
36 FatherWrapper (
const LocalGeometryType &localGeo,
const LocalFunctionType &lfFather)
37 : localGeo_(localGeo), lfFather_(lfFather) {}
38 template <
class Po
int>
39 void evaluate (
const Point &x, RangeType &y )
const
41 lfFather_.evaluate( localGeo_.global(coordinate(x)), y);
43 template <
class Quadrature,
class RangeArray>
44 void evaluateQuadrature(
const Quadrature& quadrature, RangeArray& values )
const
46 const unsigned int nop = quadrature.nop();
48 for(
unsigned int qp=0; qp<nop; ++qp)
49 evaluate( quadrature[ qp ], values[ qp ]);
52 const EntityType& entity ()
const {
return lfFather_.entity(); }
53 unsigned int order ()
const {
return lfFather_.order(); }
55 bool valid ()
const {
return lfFather_.valid(); }
58 const LocalGeometryType &localGeo_;
59 const LocalFunctionType &lfFather_;
61 template<
class BasisFunctionSet,
class LF>
64 typedef std::remove_reference_t< LF > LocalFunctionType;
65 typedef std::remove_reference_t< BasisFunctionSet > BasisFunctionSetType;
68 typedef typename LocalFunctionType::DomainType DomainType;
69 typedef typename LocalFunctionType::RangeType RangeType;
72 typedef typename LocalFunctionType::DomainType DomainType;
73 typedef typename LocalFunctionType::RangeType RangeType;
74 typedef typename LocalFunctionType::JacobianRangeType JacobianRangeType;
75 typedef typename LocalFunctionType::HessianRangeType HessianRangeType;
76 typedef typename LocalFunctionType::EntityType EntityType;
77 typedef typename EntityType::LocalGeometry LocalGeometryType;
79 template <
class LFFather>
80 SonsWrapper (
const LFFather &father,
81 const std::vector< EntityType >& childEntities,
82 const std::vector< BasisFunctionSetType >& childBasisSets,
83 const std::vector< std::vector<double> >& childDofs )
84 : father_(father.entity())
85 , order_(father.order())
86 , childEntities_(childEntities), childBasisSets_(childBasisSets), childDofs_(childDofs)
88 template <
class Po
int>
89 void evaluate (
const Point &x, RangeType &val )
const
94 for (
unsigned int i=0; i<childEntities_.size();++i)
98 auto y = childEntities_[i].geometryInFather().local(coordinate(x));
99 if( refSon.checkInside( y ) )
101 childBasisSets_[i].evaluateAll( y, childDofs_[i], tmp );
109 template <
class Quadrature,
class RangeArray>
110 void evaluateQuadrature(
const Quadrature& quadrature, RangeArray& values )
const
112 const unsigned int nop = quadrature.nop();
113 values.resize( nop );
114 for(
unsigned int qp=0; qp<nop; ++qp)
115 evaluate( quadrature[ qp ], values[ qp ]);
117 const EntityType& entity ()
const {
return father_; }
118 unsigned int order ()
const {
return order_; }
120 bool valid()
const {
return true; }
123 const EntityType &father_;
125 const std::vector< EntityType >& childEntities_;
126 const std::vector< BasisFunctionSetType >& childBasisSets_;
127 const std::vector< std::vector<double> >& childDofs_;
132 template<
class LFESpace >
133 struct DefaultLocalRestrictProlongLFE
135 typedef LFESpace DiscreteFunctionSpaceType;
136 typedef DefaultLocalRestrictProlongLFE< DiscreteFunctionSpaceType > ThisType;
138 typedef typename DiscreteFunctionSpaceType::DomainFieldType DomainFieldType;
139 typedef typename DiscreteFunctionSpaceType::BasisFunctionSetType BasisFunctionSetType;
140 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
141 typedef typename EntityType::LocalGeometry LocalGeometryType;
142 typedef typename EntityType::EntitySeed EntitySeedType;
144 DefaultLocalRestrictProlongLFE (
const DiscreteFunctionSpaceType &space)
146 interpolation_( space_ ),
147 childSeeds_(0), childDofs_(0)
156 void setFatherChildWeight (
const DomainFieldType &weight )
161 template<
class LFFather,
class LFSon,
class LocalGeometry >
162 void restrictLocal ( LFFather &lfFather,
const LFSon &lfSon,
163 const LocalGeometry &geometryInFather,
bool initialize )
const
165 assert( lfFather.numDofs() == lfSon.numDofs() );
169 childSeeds_.resize(0);
170 childDofs_.resize(0);
173 childSeeds_.push_back(lfSon.entity().seed());
174 childDofs_.push_back(std::vector<double>(lfSon.size()));
175 std::vector<double>& chDofs = childDofs_.back();
176 const unsigned int numDofs = lfSon.size();
177 for (
unsigned int i=0;i<numDofs; ++i )
178 chDofs[i] = lfSon[i];
181 template <
class LFFather>
182 void restrictFinalize( LFFather &lfFather )
const
184 std::vector< EntityType > childEntities(childSeeds_.size());
185 std::vector< BasisFunctionSetType > childBasisSets(childSeeds_.size());
186 const unsigned int cSize = childSeeds_.size();
187 for (
unsigned int i=0; i<cSize; ++i)
189 childEntities[i] = space_.gridPart().entity( childSeeds_[i] );
190 childBasisSets[i] = space_.basisFunctionSet( childEntities[i] );
195 auto guard = bindGuard( interpolation_, lfFather.entity() );
197 typedef Impl::SonsWrapper<BasisFunctionSetType, LFFather> SonsWrapperType;
198 SonsWrapperType sonsWrapper( lfFather, childEntities, childBasisSets, childDofs_ );
201 interpolation_( sonsWrapper, lfFather );
205 template<
class LFFather,
class LFSon,
class LocalGeometry >
206 void prolongLocal (
const LFFather &lfFather, LFSon &lfSon,
207 const LocalGeometry &geometryInFather,
bool initialize )
const
209 assert( lfFather.numDofs() == lfSon.numDofs() );
211 typedef Impl::FatherWrapper<LocalGeometry,LFFather> FatherWrapperType;
212 FatherWrapperType fatherWrapper(geometryInFather,lfFather);
215 auto guard = bindGuard( interpolation_, lfSon.entity() );
218 interpolation_( fatherWrapper, lfSon );
222 bool needCommunication ()
const {
return true; }
225 template<
class Entity >
226 static DomainFieldType calcWeight (
const Entity &father,
const Entity &son )
228 return son.geometry().volume() / father.geometry().volume();
230 const DiscreteFunctionSpaceType &space_;
231 mutable LocalInterpolation< DiscreteFunctionSpaceType > interpolation_;
233 mutable std::vector< EntitySeedType > childSeeds_;
234 mutable std::vector< std::vector<double> > childDofs_;
236 mutable std::vector< double > tmpDofs_;
240 template<
class LFEMap,
class FunctionSpace,
class Storage >
241 class DefaultLocalRestrictProlong< LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
242 :
public Impl::DefaultLocalRestrictProlongLFE
243 < LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
246 typedef Impl::DefaultLocalRestrictProlongLFE
247 < LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > > BaseType;
248 using BaseType::BaseType;
250 template<
class LFEMap,
class FunctionSpace,
class Storage >
251 class DefaultLocalRestrictProlong< DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
252 :
public Impl::DefaultLocalRestrictProlongLFE
253 < DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
257 typedef Impl::DefaultLocalRestrictProlongLFE
258 < DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > > BaseType;
259 using BaseType::BaseType;
A vector valued function space.
Definition: functionspace.hh:60
actual interface class for quadratures
This file implements a dense matrix with dynamic numbers of rows and columns.
Dune namespace.
Definition: alignedallocator.hh:13
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:156