1 #ifndef DUNE_FEM_RESTRICTPROLONGINTERFACE_HH 2 #define DUNE_FEM_RESTRICTPROLONGINTERFACE_HH 5 #include <dune/common/bartonnackmanifcheck.hh> 6 #include <dune/grid/common/capabilities.hh> 37 template<
class Traits >
61 template<
class Entity >
62 void restrictLocal (
const Entity &father,
const Entity &son,
bool initialize )
const 64 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
restrictLocal( father, son, initialize ) );
68 template<
class Entity,
class LocalGeometry >
70 const LocalGeometry &geometryInFather,
71 bool initialize )
const 73 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
restrictLocal( father, son, geometryInFather, initialize ) );
77 template<
class Entity >
78 void prolongLocal (
const Entity &father,
const Entity &son,
bool initialize )
const 80 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
prolongLocal( father, son, initialize ) );
84 template<
class Entity,
class LocalGeometry >
86 const LocalGeometry &geometryInFather,
87 bool initialize )
const 89 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
prolongLocal( father, son, geometryInFather, initialize ) );
95 template<
class Communicator >
98 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(
asImp().
addToList( comm ) );
104 template<
class LoadBalancer >
116 template<
class Entity >
117 DomainFieldType
calcWeight (
const Entity &father,
const Entity &son )
const 119 const DomainFieldType weight = son.geometry().volume() / father.geometry().volume();
125 const RestProlImp &
asImp ()
const {
return static_cast< const RestProlImp &
>( *this ); }
126 RestProlImp &
asImp () {
return static_cast< RestProlImp &
>( *this ); }
131 template<
class Impl,
class DomainField >
141 template<
class Traits >
153 template<
class IndexSet,
class Entity >
155 const Entity &father,
const Entity &son )
const 157 return (indexSet.
index( father ) == indexSet.
index( son ));
171 template<
class DiscreteFunction >
173 :
public RestrictProlongInterfaceDefault< RestrictProlongTraits< RestrictProlongDefault< DiscreteFunction >, typename DiscreteFunction::DomainFieldType > >
190 : discreteFunction_( discreteFunction ),
191 constLf_( discreteFunction ),
192 localRP_( discreteFunction_.space() )
195 discreteFunction_.enableDofCompression();
199 using BaseType::calcWeight;
200 using BaseType::entitiesAreCopies;
211 localRP_.setFatherChildWeight( weight );
215 template<
class Entity >
216 void restrictLocal (
const Entity &father,
const Entity &son,
bool initialize )
const 218 assert( !father.isLeaf() );
221 typedef typename GridPartType::template Codim< Entity::codimension >::EntityType GridPartEntityType;
222 const GridPartType &gridPart = discreteFunction_.gridPart();
223 const GridPartEntityType &gpFather = gridPart.convert( father );
224 const GridPartEntityType &gpSon = gridPart.convert( son );
226 if( !entitiesAreCopies( gridPart.indexSet(), gpFather, gpSon ) )
227 restrictLocal( gpFather, gpSon, son.geometryInFather(), initialize );
231 template<
class Entity,
class LocalGeometry >
233 const LocalGeometry &geometryInFather,
234 bool initialize )
const 236 constLf_.init( son );
237 LocalFunctionType lfFather = discreteFunction_.localFunction( father );
239 localRP_.restrictLocal( lfFather, constLf_, geometryInFather, initialize );
243 template<
class Entity >
244 void prolongLocal (
const Entity &father,
const Entity &son,
bool initialize )
const 246 assert( !father.isLeaf() );
249 typedef typename GridPartType::template Codim< Entity::codimension >::EntityType GridPartEntityType;
250 const GridPartType &gridPart = discreteFunction_.gridPart();
251 const GridPartEntityType &gpFather = gridPart.convert( father );
252 const GridPartEntityType &gpSon = gridPart.convert( son );
254 if( !entitiesAreCopies( gridPart.indexSet(), gpFather, gpSon ) )
255 prolongLocal( gpFather, gpSon, son.geometryInFather(), initialize );
259 template<
class Entity,
class LocalGeometry >
261 const LocalGeometry &geometryInFather,
262 bool initialize )
const 264 constLf_.init( father );
265 LocalFunctionType lfSon = discreteFunction_.localFunction( son );
267 localRP_.prolongLocal( constLf_, lfSon, geometryInFather, initialize );
271 template<
class Communicator >
274 if( localRP_.needCommunication() )
275 comm.addToList( discreteFunction_ );
278 template<
class Communicator >
281 if( localRP_.needCommunication() )
282 comm.removeFromList( discreteFunction_ );
286 template<
class LoadBalancer >
303 #endif // #ifndef DUNE_FEM_RESTRICTPROLONGINTERFACE_HH RestrictProlongDefault(DiscreteFunctionType &discreteFunction)
Definition: restrictprolonginterface.hh:189
void prolongLocal(const Entity &father, const Entity &son, const LocalGeometry &geometryInFather, bool initialize) const
prolong data to children
Definition: restrictprolonginterface.hh:260
This is a wrapper for the default implemented restriction/prolongation operator, which only takes a d...
Definition: restrictprolonginterface.hh:172
void addToLoadBalancer(LoadBalancer &lb)
add discrete function to load balancer
Definition: restrictprolonginterface.hh:105
void prolongLocal(const Entity &father, const Entity &son, bool initialize) const
prolong data to children
Definition: restrictprolonginterface.hh:78
interface documentation for (grid part) index sets
Definition: common/indexset.hh:25
Traits::DomainFieldType DomainFieldType
field type of domain vector space
Definition: restrictprolonginterface.hh:47
Interface default implementation for derived classes.
Definition: restrictprolonginterface.hh:142
IndexType index(const Entity &entity) const
return index for given entity
Definition: common/indexset.hh:166
DiscreteFunctionType::GridPartType GridPartType
Definition: restrictprolonginterface.hh:185
DiscreteFunctionType & discreteFunction_
Definition: restrictprolonginterface.hh:293
DomainField DomainFieldType
Definition: restrictprolonginterface.hh:135
BaseType::DomainFieldType DomainFieldType
Definition: restrictprolonginterface.hh:149
LocalFunctionType constLf_
Definition: restrictprolonginterface.hh:294
Interface class defining the local behaviour of the restrict/prolong operation (using BN) ...
Definition: restrictprolonginterface.hh:38
Traits::RestProlImp RestProlImp
type of restrict-prolong operator implementation
Definition: restrictprolonginterface.hh:44
BaseType::DomainFieldType DomainFieldType
Definition: restrictprolonginterface.hh:181
DefaultLocalRestrictProlong< DiscreteFunctionSpaceType > LocalRestrictProlongType
Definition: restrictprolonginterface.hh:187
LocalRestrictProlongType localRP_
Definition: restrictprolonginterface.hh:295
Definition: coordinate.hh:4
DomainFieldType calcWeight(const Entity &father, const Entity &son) const
calculates the weight, i.e. (volume son)/(volume father)
Definition: restrictprolonginterface.hh:117
DiscreteFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: restrictprolonginterface.hh:183
bool entitiesAreCopies(const IndexSet &indexSet, const Entity &father, const Entity &son) const
return true if father and son have the same index
Definition: restrictprolonginterface.hh:154
void prolongLocal(const Entity &father, const Entity &son, bool initialize) const
prolong data to children
Definition: restrictprolonginterface.hh:244
Impl RestProlImp
Definition: restrictprolonginterface.hh:134
void setFatherChildWeight(const DomainFieldType &weight) const
explicit set volume ratio of son and father
Definition: restrictprolonginterface.hh:55
void restrictLocal(const Entity &father, const Entity &son, const LocalGeometry &geometryInFather, bool initialize) const
restrict data to father
Definition: restrictprolonginterface.hh:232
DiscreteFunctionType::LocalFunctionType LocalFunctionType
Definition: restrictprolonginterface.hh:184
void addToList(Communicator &comm)
add discrete function to communicator
Definition: restrictprolonginterface.hh:272
void setFatherChildWeight(const DomainFieldType &weight) const
explicit set volume ratio of son and father
Definition: restrictprolonginterface.hh:209
void prolongLocal(const Entity &father, const Entity &son, const LocalGeometry &geometryInFather, bool initialize) const
prolong data to children
Definition: restrictprolonginterface.hh:85
void restrictLocal(const Entity &father, const Entity &son, bool initialize) const
restrict data to father
Definition: restrictprolonginterface.hh:62
DiscreteFunction DiscreteFunctionType
Definition: restrictprolonginterface.hh:179
void addToLoadBalancer(DiscreteFunctionType &df)
add discrete function to data inliner/xtractor list
Definition: loadbalancer.hh:275
This class manages the adaptation process. If the method adapt is called, then the grid is adapted an...
Definition: loadbalancer.hh:69
void restrictLocal(const Entity &father, const Entity &son, const LocalGeometry &geometryInFather, bool initialize) const
restrict data to father
Definition: restrictprolonginterface.hh:69
void setFatherChildWeight(const DomainFieldType &weight) const
explicit set volume ratio of son and father
Definition: restrictprolonginterface.hh:162
void removeFromList(Communicator &comm)
remove discrete function from communicator
Definition: restrictprolonginterface.hh:279
void restrictLocal(const Entity &father, const Entity &son, bool initialize) const
restrict data to father
Definition: restrictprolonginterface.hh:216
void addToLoadBalancer(LoadBalancer &lb)
add discrete function to load balancer
Definition: restrictprolonginterface.hh:287
void addToList(Communicator &comm)
add discrete function to communicator
Definition: restrictprolonginterface.hh:96
Traits class for derivation from RestrictProlongInterface.
Definition: restrictprolonginterface.hh:132
RestProlImp & asImp()
Definition: restrictprolonginterface.hh:126
const RestProlImp & asImp() const
Definition: restrictprolonginterface.hh:125