3#ifndef DUNE_LAGRANGEBASIS_INTERPOLATION_HH
4#define DUNE_LAGRANGEBASIS_INTERPOLATION_HH
7#include <dune/geometry/topologyfactory.hh>
8#include <dune/localfunctions/lagrange/lagrangecoefficients.hh>
13 template<
template <
class,
unsigned int>
class LP,
14 unsigned int dim,
class F >
15 struct LagrangeInterpolationFactory;
20 template<
template <
class,
unsigned int>
class LP,
21 unsigned int dim,
class F >
22 class LocalLagrangeInterpolation
24 typedef LocalLagrangeInterpolation< LP,dim,F > This;
27 typedef LP<F,dim> LagrangePointSet;
28 typedef typename LagrangePointSet::Field Field;
30 static const unsigned int dimension = LagrangePointSet::dimension;
33 friend struct LagrangeInterpolationFactory<LP,dim,F>;
34 const LagrangePointSet &lagrangePoints_;
36 explicit LocalLagrangeInterpolation (
const LagrangePointSet &lagrangePoints )
37 : lagrangePoints_( lagrangePoints )
39 const LagrangePointSet *points ()
const
41 return &lagrangePoints_;
45 template<
class Function,
class Fy >
46 void interpolate (
const Function &function, std::vector< Fy > &coefficients )
const
48 typedef typename LagrangePointSet::iterator Iterator;
50 coefficients.resize( lagrangePoints_.size() );
52 unsigned int index = 0;
53 const Iterator end = lagrangePoints_.end();
54 for( Iterator it = lagrangePoints_.begin(); it != end; ++it )
57 function.evaluate( field_cast<typename Function::DomainType::field_type>(it->point()), val );
62 template<
class Matrix,
class Basis >
63 void interpolate (
const Basis &basis, Matrix &coefficients )
const
65 typedef typename LagrangePointSet::iterator Iterator;
67 coefficients.resize( lagrangePoints_.size(), basis.size( ) );
69 unsigned int index = 0;
70 const Iterator end = lagrangePoints_.end();
71 for( Iterator it = lagrangePoints_.begin(); it != end; ++it )
72 basis.template evaluate<0>( it->point(), coefficients.rowPtr( index++ ) );
75 const LagrangePointSet &lagrangePoints ()
const
77 return lagrangePoints_;
85 template<
template <
class,
unsigned int>
class LP,
86 unsigned int dim,
class F >
87 struct LagrangeInterpolationFactoryTraits
89 typedef LagrangeCoefficientsFactory<LP,dim,F> LagrangePointSetFactory;
90 typedef typename LagrangePointSetFactory::Object LagrangePointSet;
92 typedef typename LagrangePointSetFactory::Key Key;
93 typedef const LocalLagrangeInterpolation< LP,dim,F > Object;
94 typedef LagrangeInterpolationFactory<LP,dim,F> Factory;
96 static const unsigned int dimension = dim;
99 template<
template <
class,
unsigned int>
class LP,
100 unsigned int dim,
class F >
101 struct LagrangeInterpolationFactory :
102 public TopologyFactory< LagrangeInterpolationFactoryTraits< LP,dim,F > >
104 typedef LagrangeInterpolationFactoryTraits< LP,dim,F > Traits;
105 typedef typename Traits::Key Key;
106 typedef typename Traits::Object Object;
108 template<
class Topology >
109 static Object *createObject (
const Key &key )
111 const typename Traits::LagrangePointSet *lagrangeCoeff
112 = Traits::LagrangePointSetFactory::template create< Topology >( key );
113 if ( lagrangeCoeff == 0 )
116 return new Object( *lagrangeCoeff );
118 template<
class Topology >
119 static bool supports (
const typename Traits::Key &key )
123 static void release( Object *
object)
125 Traits::LagrangePointSetFactory::release( object->points() );
RawRangeType RangeType
Raw type of input variable with removed reference and constness.
Definition: function.hh:36
Dune namespace.
Definition: alignedallocator.hh:10
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:157
static void release(Object *object)
release the object returned by the create methods
Definition: topologyfactory.hh:60