1#ifndef DUNE_FEM_RESTRICTPROLONGFUNCTION_HH
2#define DUNE_FEM_RESTRICTPROLONGFUNCTION_HH
7#include <dune/fem/function/localfunction/const.hh>
35 template<
class CoarseFunction,
class FineFunction >
37 FineFunction &fineFunction )
const
39 typedef typename CoarseFunction::DiscreteFunctionSpaceType CoarseSpace;
41 ConstLocalFunction< CoarseFunction > coarseLocalFunction( coarseFunction );
44 const CoarseSpace &coarseSpace = coarseFunction.space();
45 for(
const auto& entity : coarseSpace )
47 auto cg = bindGuard( coarseLocalFunction, entity );
49 if( isDefinedOn( fineFunction, entity ) )
51 auto fg = bindGuard( fineLocalFunction, entity );
52 fineLocalFunction.
assign( coarseLocalFunction );
55 hierarchicProlong( coarseLocalFunction, fineLocalFunction );
60 template<
class CoarseLocalFunction,
class FineLocalFunction >
61 void hierarchicProlong (
const CoarseLocalFunction &coarseLocalFunction,
62 FineLocalFunction &fineLocalFunction )
const
64 typedef typename CoarseLocalFunction::EntityType
Entity;
65 typedef typename Entity::HierarchicIterator HierarchicIterator;
67 const Entity &parent = coarseLocalFunction.entity();
68 const int childLevel = parent.
level()+1;
70 const HierarchicIterator hend = parent.hend( childLevel );
71 for( HierarchicIterator hit = parent.hbegin( childLevel ); hit != hend; ++hit )
73 const Entity &child = *hit;
74 if( isDefinedOn( fineLocalFunction.discreteFunction(), child ) )
76 auto guard = bindGuard( fineLocalFunction, child );
77 localRestrictProlong_.prolongLocal( coarseLocalFunction, fineLocalFunction, child.geometryInFather(),
true );
84 template<
class Function >
85 static bool isDefinedOn (
const Function &function,
const typename Function::GridPartType::template Codim< 0 >::EntityType &entity )
87 typedef typename Function::GridPartType::IndexSetType IndexSet;
88 const IndexSet &indexSet = function.gridPart().indexSet();
89 return indexSet.contains( entity );
105 template<
class LRP >
119 template<
class FineFunction,
class CoarseFunction >
121 CoarseFunction &coarseFunction )
const
123 typedef typename CoarseFunction::DiscreteFunctionSpaceType CoarseSpace;
125 ConstLocalFunction< FineFunction > fineLocalFunction( fineFunction );
128 const CoarseSpace &coarseSpace = coarseFunction.space();
129 for(
const auto& entity : coarseSpace )
131 auto cg = bindGuard( coarseLocalFunction, entity );
133 if( isDefinedOn( fineFunction, entity ) )
135 auto fg = bindGuard( fineLocalFunction, entity );
136 coarseLocalFunction.
assign( fineLocalFunction );
139 hierarchicRestrict( fineLocalFunction, coarseLocalFunction );
144 template<
class FineLocalFunction,
class CoarseLocalFunction >
145 void hierarchicRestrict ( FineLocalFunction &fineLocalFunction,
146 CoarseLocalFunction &coarseLocalFunction )
const
148 typedef typename CoarseLocalFunction::EntityType
Entity;
149 typedef typename Entity::HierarchicIterator HierarchicIterator;
151 const Entity &parent = coarseLocalFunction.entity();
152 const int childLevel = parent.
level()+1;
154 bool initialize =
true;
155 const HierarchicIterator hend = parent.hend( childLevel );
156 for( HierarchicIterator hit = parent.hbegin( childLevel ); hit != hend; ++hit )
158 const Entity &child = *hit;
159 if( isDefinedOn( fineLocalFunction.discreteFunction(), child ) )
161 auto guard = bindGuard( fineLocalFunction, child );
162 localRestrictProlong_.restrictLocal( coarseLocalFunction, fineLocalFunction, child.geometryInFather(), initialize );
168 localRestrictProlong_.restrictFinalize(parent);
171 template<
class Function >
172 static bool isDefinedOn (
const Function &function,
const typename Function::GridPartType::template Codim< 0 >::EntityType &entity )
174 typedef typename Function::GridPartType::IndexSetType IndexSet;
175 const IndexSet &indexSet = function.gridPart().indexSet();
176 return indexSet.contains( entity );
Wrapper class for entities.
Definition: entity.hh:66
int level() const
The level of this entity.
Definition: entity.hh:124
void assign(const LocalFunction< BasisFunctionSet, T > &other)
assign all DoFs of this local function
Definition: localfunction.hh:192
Definition: mutable.hh:31
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:20
Different resources needed by all grid implementations.
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
prolong discrete functions between grid levels
Definition: restrictprolongfunction.hh:24
void operator()(const CoarseFunction &coarseFunction, FineFunction &fineFunction) const
prolong a discrete function to finer grid level
Definition: restrictprolongfunction.hh:36
LRP LocalRestrictProlong
type of the local restriction and prolongation operator
Definition: restrictprolongfunction.hh:26
restrict discrete functions between grid levels
Definition: restrictprolongfunction.hh:107
void operator()(const FineFunction &fineFunction, CoarseFunction &coarseFunction) const
restrict a discrete function to coarser grid level
Definition: restrictprolongfunction.hh:120
LRP LocalRestrictProlong
type of the local restriction and prolongation operator
Definition: restrictprolongfunction.hh:109