3 #ifndef DUNE_RAVIARTTHOMASINTERPOLATION_HH
4 #define DUNE_RAVIARTTHOMASINTERPOLATION_HH
9 #include <dune/common/exceptions.hh>
10 #include <dune/common/forloop.hh>
12 #include <dune/geometry/topologyfactory.hh>
13 #include <dune/geometry/referenceelements.hh>
14 #include <dune/geometry/quadraturerules.hh>
26 template <
unsigned int dim >
28 template <
unsigned int dim,
class Field >
36 template <
class Setter>
39 setter.setLocalKeys(localKey_);
45 return localKey_[ i ];
50 return localKey_.size();
54 std::vector< LocalKey > localKey_;
57 template <
unsigned int dim >
62 typedef unsigned int Key;
65 template <
unsigned int dim >
67 public TopologyFactory< RaviartThomasCoefficientsFactoryTraits<dim> >
70 template <
class Topology>
74 if (! supports<Topology>(key) )
76 typename InterpolationFactory::Object *interpol
77 = InterpolationFactory::template create<Topology>(key);
79 InterpolationFactory::release(interpol);
82 template<
class Topology >
101 template <
unsigned int dim,
class Field>
109 typedef FieldVector<Field,dimension>
Normal;
116 TestBasisFactory::release(testBasis_);
117 for (
unsigned int i=0; i<faceStructure_.size(); ++i)
118 TestFaceBasisFactory::release(faceStructure_[i].basis_);
140 return faceStructure_[f].basis_;
144 return *(faceStructure_[f].normal_);
147 template <
class Topology>
151 topologyId_ = Topology::id;
153 testBasis_ = TestBasisFactory::template create<Topology>(order-1);
158 faceStructure_.reserve( faceSize_ );
159 ForLoop< Creator<Topology>::template GetCodim,0,size-1>::apply(order, faceStructure_ );
160 assert( faceStructure_.size() == faceSize_ );
168 : basis_(tfb), normal_(&n)
171 const Dune::FieldVector<Field,dimension> *normal_;
173 template <
class Topology >
176 template <
int face >
179 typedef typename GenericGeometry::SubTopology<Topology,1,face>::type
FaceTopology;
181 std::vector<FaceStructure> &faceStructure )
183 static const int dimTopo = Topology::dimension;
184 faceStructure.push_back(
186 TestFaceBasisFactory::template create<FaceTopology>(order),
187 ReferenceElements<Field,dimTopo>::general(GeometryType( Topology() )).integrationOuterNormal(face)
193 std::vector<FaceStructure> faceStructure_;
195 unsigned int topologyId_, order_, faceSize_;
200 template<
unsigned int dimension,
class F>
215 template<
class Function,
class Fy >
216 void interpolate (
const Function &
function, std::vector< Fy > &coefficients )
const
218 coefficients.resize(
size());
222 template<
class Basis,
class Matrix >
225 matrix.resize(
size(), basis.size() );
238 template <
class Topology>
243 builder_.template build<Topology>(order_);
246 for (
unsigned int f=0; f<builder_.
faceSize(); ++f )
254 unsigned int row = 0;
255 for (
unsigned int f=0; f<builder_.
faceSize(); ++f)
262 for (
unsigned int i=0; i<builder_.
testBasis()->
size()*dimension; ++i,++row)
264 assert( row ==
size() );
268 template<
class Func,
class Container,
bool type >
271 const Dune::GeometryType geoType( builder_.
topologyId(), dimension );
273 std::vector< Field > testBasisVal;
275 for (
unsigned int i=0; i<
size(); ++i)
276 for (
unsigned int j=0; j<func.size(); ++j)
279 unsigned int row = 0;
282 typedef Dune::QuadratureRule<
Field, dimension-1> FaceQuadrature;
283 typedef Dune::QuadratureRules<
Field, dimension-1> FaceQuadratureRules;
285 typedef Dune::ReferenceElements< Field, dimension > RefElements;
286 typedef Dune::ReferenceElement< Field, dimension > RefElement;
287 typedef typename RefElement::template Codim< 1 >::Geometry Geometry;
289 const RefElement &refElement = RefElements::general( geoType );
291 for (
unsigned int f=0; f<builder_.
faceSize(); ++f)
297 const Geometry &geometry = refElement.template geometry< 1 >( f );
298 const Dune::GeometryType subGeoType( geometry.type().id(), dimension-1 );
299 const FaceQuadrature &faceQuad = FaceQuadratureRules::rule( subGeoType, 2*order_+2 );
301 const unsigned int quadratureSize = faceQuad.size();
302 for(
unsigned int qi = 0; qi < quadratureSize; ++qi )
305 builder_.
testFaceBasis(f)->template evaluate<0>(faceQuad[qi].position(),testBasisVal);
307 testBasisVal[0] = 1.;
308 fillBnd( row, testBasisVal,
309 func.evaluate( geometry.global( faceQuad[qi].position() ) ),
310 builder_.
normal(f), faceQuad[qi].weight(),
321 typedef Dune::QuadratureRule<Field, dimension> Quadrature;
322 typedef Dune::QuadratureRules<Field, dimension> QuadratureRules;
323 const Quadrature &elemQuad = QuadratureRules::rule( geoType, 2*order_+1 );
325 const unsigned int quadratureSize = elemQuad.size();
326 for(
unsigned int qi = 0; qi < quadratureSize; ++qi )
328 builder_.
testBasis()->template evaluate<0>(elemQuad[qi].position(),testBasisVal);
329 fillInterior( row, testBasisVal,
330 func.evaluate(elemQuad[qi].position()),
331 elemQuad[qi].weight(),
342 template <
class MVal,
class RTVal,
class Matrix>
343 void fillBnd (
unsigned int startRow,
346 const FieldVector<Field,dimension> &normal,
348 Matrix &matrix)
const
350 const unsigned int endRow = startRow+mVal.size();
351 typename RTVal::const_iterator rtiter = rtVal.begin();
352 for (
unsigned int col = 0; col < rtVal.size() ; ++rtiter,++col)
354 Field cFactor = (*rtiter)*normal;
355 typename MVal::const_iterator miter = mVal.begin();
356 for (
unsigned int row = startRow;
357 row!=endRow; ++miter, ++row )
359 matrix.add(row,col, (weight*cFactor)*(*miter) );
361 assert( miter == mVal.end() );
364 template <
class MVal,
class RTVal,
class Matrix>
365 void fillInterior (
unsigned int startRow,
369 Matrix &matrix)
const
371 const unsigned int endRow = startRow+mVal.size()*dimension;
372 typename RTVal::const_iterator rtiter = rtVal.begin();
373 for (
unsigned int col = 0; col < rtVal.size() ; ++rtiter,++col)
375 typename MVal::const_iterator miter = mVal.begin();
376 for (
unsigned int row = startRow;
377 row!=endRow; ++miter,row+=dimension )
379 for (
unsigned int i=0; i<dimension; ++i)
381 matrix.add(row+i,col, (weight*(*miter))*(*rtiter)[i] );
384 assert( miter == mVal.end() );
393 template <
unsigned int dim,
class F >
396 static const unsigned int dimension = dim;
401 template <
unsigned int dim,
class Field >
403 public TopologyFactory< RaviartThomasL2InterpolationFactoryTraits<dim,Field> >
409 template <
class Topology>
412 if ( !supports<Topology>(key) )
415 interpol->template build<Topology>(key);
418 template<
class Topology >
425 #endif // DUNE_RAVIARTTHOMASINTERPOLATION_HH
unsigned int topologyId() const
Definition: raviartthomassimplexinterpolation.hh:121
unsigned int order() const
Definition: raviartthomassimplexinterpolation.hh:125
const unsigned int size() const
Definition: polynomialbasis.hh:107
TestFaceBasisFactory::Object TestFaceBasis
Definition: raviartthomassimplexinterpolation.hh:108
unsigned int faceSize() const
Definition: raviartthomassimplexinterpolation.hh:129
void interpolate(typename Base::template Helper< Func, Container, type > &func) const
Definition: raviartthomassimplexinterpolation.hh:269
Definition: raviartthomassimplexinterpolation.hh:394
Definition: raviartthomassimplexinterpolation.hh:27
unsigned int Key
Definition: raviartthomassimplexinterpolation.hh:62
RaviartThomasCoefficientsFactoryTraits< dim > Traits
Definition: raviartthomassimplexinterpolation.hh:69
Definition: raviartthomassimplexinterpolation.hh:31
static bool supports(const typename Traits::Key &key)
Definition: raviartthomassimplexinterpolation.hh:83
FieldVector< Field, dimension > Normal
Definition: raviartthomassimplexinterpolation.hh:109
void build(unsigned int order)
Definition: raviartthomassimplexinterpolation.hh:148
void interpolate(const Function &function, std::vector< Fy > &coefficients) const
Definition: raviartthomassimplexinterpolation.hh:216
RTL2InterpolationBuilder< dimension, Field > Builder
Definition: raviartthomassimplexinterpolation.hh:209
const Normal & normal(unsigned int f) const
Definition: raviartthomassimplexinterpolation.hh:142
TestFaceBasis * testFaceBasis(unsigned int f) const
Definition: raviartthomassimplexinterpolation.hh:137
void build(unsigned int order)
Definition: raviartthomassimplexinterpolation.hh:239
static Traits::Object * createObject(const typename Traits::Key &key)
Definition: raviartthomassimplexinterpolation.hh:410
RTL2InterpolationBuilder()
Definition: raviartthomassimplexinterpolation.hh:111
RaviartThomasL2InterpolationFactory< dim, F > Factory
Definition: raviartthomassimplexinterpolation.hh:399
Definition: interpolationhelper.hh:20
RaviartThomasL2InterpolationFactoryTraits< dim, Field > Traits
Definition: raviartthomassimplexinterpolation.hh:405
F Field
Definition: raviartthomassimplexinterpolation.hh:208
TestBasisFactory::Object TestBasis
Definition: raviartthomassimplexinterpolation.hh:106
TestBasis * testBasis() const
Definition: raviartthomassimplexinterpolation.hh:133
~RTL2InterpolationBuilder()
Definition: raviartthomassimplexinterpolation.hh:114
const LocalCoefficientsContainer Object
Definition: raviartthomassimplexinterpolation.hh:61
const LocalKey & localKey(const unsigned int i) const
Definition: raviartthomassimplexinterpolation.hh:42
Definition: raviartthomassimplexinterpolation.hh:29
Definition: orthonormalbasis.hh:19
Traits::Object Object
Definition: raviartthomassimplexinterpolation.hh:407
static void apply(const unsigned int order, std::vector< FaceStructure > &faceStructure)
Definition: raviartthomassimplexinterpolation.hh:180
unsigned int size() const
Definition: raviartthomassimplexinterpolation.hh:234
remove_const< Object >::type NonConstObject
Definition: raviartthomassimplexinterpolation.hh:408
Definition: raviartthomassimplexinterpolation.hh:177
static const unsigned int dimension
Definition: raviartthomassimplexinterpolation.hh:60
unsigned int order() const
Definition: raviartthomassimplexinterpolation.hh:230
OrthonormalBasisFactory< dimension-1, Field > TestFaceBasisFactory
Definition: raviartthomassimplexinterpolation.hh:107
LocalCoefficientsContainer(const Setter &setter)
Definition: raviartthomassimplexinterpolation.hh:37
RTL2InterpolationBuilder< dim, Field > Builder
Definition: raviartthomassimplexinterpolation.hh:406
RaviartThomasL2Interpolation()
Definition: raviartthomassimplexinterpolation.hh:210
Definition: tensor.hh:165
Definition: raviartthomassimplexinterpolation.hh:201
unsigned int size() const
Definition: raviartthomassimplexinterpolation.hh:48
Definition: raviartthomassimplexinterpolation.hh:102
RaviartThomasCoefficientsFactory< dim > Factory
Definition: raviartthomassimplexinterpolation.hh:63
void setLocalKeys(std::vector< LocalKey > &keys) const
Definition: raviartthomassimplexinterpolation.hh:251
unsigned int Key
Definition: raviartthomassimplexinterpolation.hh:397
OrthonormalBasisFactory< dimension, Field > TestBasisFactory
Definition: raviartthomassimplexinterpolation.hh:105
Definition: interpolationhelper.hh:17
static Traits::Object * createObject(const typename Traits::Key &key)
Definition: raviartthomassimplexinterpolation.hh:71
Definition: polynomialbasis.hh:61
const RaviartThomasL2Interpolation< dim, F > Object
Definition: raviartthomassimplexinterpolation.hh:398
Definition: raviartthomassimplexinterpolation.hh:58
static const unsigned int dimension
Definition: raviartthomassimplexinterpolation.hh:104
void interpolate(const Basis &basis, Matrix &matrix) const
Definition: raviartthomassimplexinterpolation.hh:223
static bool supports(const typename Traits::Key &key)
Definition: raviartthomassimplexinterpolation.hh:419
Describe position of one degree of freedom.
Definition: localkey.hh:21
GenericGeometry::SubTopology< Topology, 1, face >::type FaceTopology
Definition: raviartthomassimplexinterpolation.hh:179
Definition: interpolationhelper.hh:73