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(); }
56 const LocalGeometryType &localGeo_;
57 const LocalFunctionType &lfFather_;
59 template<
class BasisFunctionSet,
class LF>
62 typedef std::remove_reference_t< LF > LocalFunctionType;
63 typedef std::remove_reference_t< BasisFunctionSet > BasisFunctionSetType;
66 typedef typename LocalFunctionType::DomainType DomainType;
67 typedef typename LocalFunctionType::RangeType RangeType;
70 typedef typename LocalFunctionType::DomainType DomainType;
71 typedef typename LocalFunctionType::RangeType RangeType;
72 typedef typename LocalFunctionType::JacobianRangeType JacobianRangeType;
73 typedef typename LocalFunctionType::HessianRangeType HessianRangeType;
74 typedef typename LocalFunctionType::EntityType EntityType;
75 typedef typename EntityType::LocalGeometry LocalGeometryType;
77 template <
class LFFather>
78 SonsWrapper (
const LFFather &father,
79 const std::vector< EntityType >& childEntities,
80 const std::vector< BasisFunctionSetType >& childBasisSets,
81 const std::vector< std::vector<double> >& childDofs )
82 : father_(father.entity())
83 , order_(father.order())
84 , childEntities_(childEntities), childBasisSets_(childBasisSets), childDofs_(childDofs)
86 template <
class Po
int>
87 void evaluate (
const Point &x, RangeType &val )
const
92 for (
unsigned int i=0; i<childEntities_.size();++i)
96 auto y = childEntities_[i].geometryInFather().local(coordinate(x));
97 if( refSon.checkInside( y ) )
99 childBasisSets_[i].evaluateAll( y, childDofs_[i], tmp );
107 template <
class Quadrature,
class RangeArray>
108 void evaluateQuadrature(
const Quadrature& quadrature, RangeArray& values )
const
110 const unsigned int nop = quadrature.nop();
111 values.resize( nop );
112 for(
unsigned int qp=0; qp<nop; ++qp)
113 evaluate( quadrature[ qp ], values[ qp ]);
115 const EntityType& entity ()
const {
return father_; }
116 unsigned int order ()
const {
return order_; }
119 const EntityType &father_;
121 const std::vector< EntityType >& childEntities_;
122 const std::vector< BasisFunctionSetType >& childBasisSets_;
123 const std::vector< std::vector<double> >& childDofs_;
128 template<
class LFESpace >
129 struct DefaultLocalRestrictProlongLFE
131 typedef LFESpace DiscreteFunctionSpaceType;
132 typedef DefaultLocalRestrictProlongLFE< DiscreteFunctionSpaceType > ThisType;
134 typedef typename DiscreteFunctionSpaceType::DomainFieldType DomainFieldType;
135 typedef typename DiscreteFunctionSpaceType::BasisFunctionSetType BasisFunctionSetType;
136 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
137 typedef typename EntityType::LocalGeometry LocalGeometryType;
138 typedef typename EntityType::EntitySeed EntitySeedType;
140 DefaultLocalRestrictProlongLFE (
const DiscreteFunctionSpaceType &space)
142 interpolation_( space_ ),
143 childSeeds_(0), childDofs_(0)
152 void setFatherChildWeight (
const DomainFieldType &weight )
157 template<
class LFFather,
class LFSon,
class LocalGeometry >
158 void restrictLocal ( LFFather &lfFather,
const LFSon &lfSon,
159 const LocalGeometry &geometryInFather,
bool initialize )
const
161 assert( lfFather.numDofs() == lfSon.numDofs() );
165 childSeeds_.resize(0);
166 childDofs_.resize(0);
169 childSeeds_.push_back(lfSon.entity().seed());
170 childDofs_.push_back(std::vector<double>(lfSon.size()));
171 std::vector<double>& chDofs = childDofs_.back();
172 const unsigned int numDofs = lfSon.size();
173 for (
unsigned int i=0;i<numDofs; ++i )
174 chDofs[i] = lfSon[i];
177 template <
class LFFather>
178 void restrictFinalize( LFFather &lfFather )
const
180 std::vector< EntityType > childEntities(childSeeds_.size());
181 std::vector< BasisFunctionSetType > childBasisSets(childSeeds_.size());
182 const unsigned int cSize = childSeeds_.size();
183 for (
unsigned int i=0; i<cSize; ++i)
185 childEntities[i] = space_.gridPart().entity( childSeeds_[i] );
186 childBasisSets[i] = space_.basisFunctionSet( childEntities[i] );
191 auto guard = bindGuard( interpolation_, lfFather.entity() );
193 typedef Impl::SonsWrapper<BasisFunctionSetType, LFFather> SonsWrapperType;
194 SonsWrapperType sonsWrapper( lfFather, childEntities, childBasisSets, childDofs_ );
197 interpolation_( sonsWrapper, lfFather );
201 template<
class LFFather,
class LFSon,
class LocalGeometry >
202 void prolongLocal (
const LFFather &lfFather, LFSon &lfSon,
203 const LocalGeometry &geometryInFather,
bool initialize )
const
205 assert( lfFather.numDofs() == lfSon.numDofs() );
207 typedef Impl::FatherWrapper<LocalGeometry,LFFather> FatherWrapperType;
208 FatherWrapperType fatherWrapper(geometryInFather,lfFather);
211 auto guard = bindGuard( interpolation_, lfSon.entity() );
214 interpolation_( fatherWrapper, lfSon );
218 bool needCommunication ()
const {
return true; }
221 template<
class Entity >
222 static DomainFieldType calcWeight (
const Entity &father,
const Entity &son )
224 return son.geometry().volume() / father.geometry().volume();
226 const DiscreteFunctionSpaceType &space_;
227 mutable LocalInterpolation< DiscreteFunctionSpaceType > interpolation_;
229 mutable std::vector< EntitySeedType > childSeeds_;
230 mutable std::vector< std::vector<double> > childDofs_;
232 mutable std::vector< double > tmpDofs_;
236 template<
class LFEMap,
class FunctionSpace,
class Storage >
237 class DefaultLocalRestrictProlong< LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
238 :
public Impl::DefaultLocalRestrictProlongLFE
239 < LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
242 typedef Impl::DefaultLocalRestrictProlongLFE
243 < LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > > BaseType;
244 using BaseType::BaseType;
246 template<
class LFEMap,
class FunctionSpace,
class Storage >
247 class DefaultLocalRestrictProlong< DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
248 :
public Impl::DefaultLocalRestrictProlongLFE
249 < DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
253 typedef Impl::DefaultLocalRestrictProlongLFE
254 < DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > > BaseType;
255 using BaseType::BaseType;
A vector valued function space.
Definition: functionspace.hh:60
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