5#ifndef DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS_RAVIARTTHOMASSIMPLEX_RAVIARTTHOMASSIMPLEXINTERPOLATION_HH
6#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS_RAVIARTTHOMASSIMPLEX_RAVIARTTHOMASSIMPLEXINTERPOLATION_HH
11#include <dune/common/exceptions.hh>
13#include <dune/geometry/quadraturerules.hh>
14#include <dune/geometry/referenceelements.hh>
15#include <dune/geometry/type.hh>
16#include <dune/geometry/typeindex.hh>
29 template <
unsigned int dim,
class Field >
30 struct RaviartThomasL2InterpolationFactory;
37 class LocalCoefficientsContainer
42 template <
class Setter>
45 setter.setLocalKeys(localKey_);
51 return localKey_[ i ];
56 return localKey_.size();
60 std::vector< LocalKey > localKey_;
68 template <
unsigned int dim >
71 typedef std::size_t
Key;
74 template< GeometryType::Id geometryId >
78 if( !supports< geometryId >( key ) )
80 typename InterpolationFactory::Object *interpolation = InterpolationFactory::template create< geometryId >( key );
82 InterpolationFactory::release( interpolation );
86 template< GeometryType::Id geometryId >
89 return GeometryType(geometryId).isSimplex();
105 template<
unsigned int dim,
class Field >
119 typedef FieldVector< Field, dimension >
Normal;
129 for( FaceStructure &f : faceStructure_ )
133 GeometryType
type ()
const {
return geometry_; }
135 std::size_t
order ()
const {
return order_; }
138 unsigned int faceSize ()
const {
return faceSize_; }
149 template< GeometryType::Id geometryId >
152 constexpr GeometryType geometry = geometryId;
153 geometry_ = geometry;
156 testBasis_ = (
order > 0 ? TestBasisFactory::template create< geometry >(
order-1 ) :
nullptr);
158 const auto &refElement = ReferenceElements< Field, dimension >::general(
type() );
159 faceSize_ = refElement.size( 1 );
160 faceStructure_.reserve( faceSize_ );
161 for(
unsigned int face = 0; face < faceSize_; ++face )
174 TestFaceBasis *faceBasis = Impl::toGeometryTypeIdConstant<
dimension-1>(refElement.type( face, 1 ), [&](
auto faceGeometryTypeId) {
175 return TestFaceBasisFactory::template create< decltype(faceGeometryTypeId)::value >(
order );
177 faceStructure_.emplace_back( faceBasis, refElement.integrationOuterNormal( face ) );
179 assert( faceStructure_.size() == faceSize_ );
186 : basis_( tfb ), normal_( n )
190 const Dune::FieldVector< Field, dimension > normal_;
193 std::vector< FaceStructure > faceStructure_;
195 GeometryType geometry_;
196 unsigned int faceSize_;
210 template<
unsigned int dimension,
class F>
225 template<
class Function,
class Vector,
226 decltype(std::declval<Vector>().size(),
bool{}) =
true,
227 decltype(std::declval<Vector>().resize(0u),
bool{}) =
true>
228 void interpolate (
const Function &function, Vector &coefficients )
const
230 coefficients.resize(
size());
235 template<
class Basis,
class Matrix,
236 decltype(std::declval<Matrix>().rows(),
bool{}) =
true,
237 decltype(std::declval<Matrix>().cols(),
bool{}) =
true,
238 decltype(std::declval<Matrix>().resize(0u,0u),
bool{}) =
true>
241 matrix.resize(
size(), basis.size() );
254 template <GeometryType::Id geometryId>
259 builder_.template build<geometryId>(order_);
262 for (
unsigned int f=0; f<builder_.
faceSize(); ++f )
270 unsigned int row = 0;
271 for (
unsigned int f=0; f<builder_.
faceSize(); ++f)
278 for (
unsigned int i=0; i<builder_.
testBasis()->
size()*dimension; ++i,++row)
280 assert( row ==
size() );
284 template<
class Func,
class Container,
bool type >
287 const Dune::GeometryType geoType = builder_.
type();
289 std::vector< Field > testBasisVal;
291 for (
unsigned int i=0; i<
size(); ++i)
292 for (
unsigned int j=0; j<func.size(); ++j)
295 unsigned int row = 0;
298 typedef Dune::QuadratureRule<
Field, dimension-1> FaceQuadrature;
299 typedef Dune::QuadratureRules<
Field, dimension-1> FaceQuadratureRules;
301 const auto &refElement = Dune::ReferenceElements< Field, dimension >::general( geoType );
303 for (
unsigned int f=0; f<builder_.
faceSize(); ++f)
309 const auto &geometry = refElement.template geometry< 1 >( f );
310 const Dune::GeometryType subGeoType( geometry.type().id(), dimension-1 );
311 const FaceQuadrature &faceQuad = FaceQuadratureRules::rule( subGeoType, 2*order_+2 );
313 const unsigned int quadratureSize = faceQuad.size();
314 for(
unsigned int qi = 0; qi < quadratureSize; ++qi )
317 builder_.
testFaceBasis(f)->template evaluate<0>(faceQuad[qi].position(),testBasisVal);
319 testBasisVal[0] = 1.;
320 fillBnd( row, testBasisVal,
321 func.evaluate( geometry.global( faceQuad[qi].position() ) ),
322 builder_.
normal(f), faceQuad[qi].weight(),
333 typedef Dune::QuadratureRule<Field, dimension> Quadrature;
334 typedef Dune::QuadratureRules<Field, dimension> QuadratureRules;
335 const Quadrature &elemQuad = QuadratureRules::rule( geoType, 2*order_+1 );
337 const unsigned int quadratureSize = elemQuad.size();
338 for(
unsigned int qi = 0; qi < quadratureSize; ++qi )
340 builder_.
testBasis()->template evaluate<0>(elemQuad[qi].position(),testBasisVal);
341 fillInterior( row, testBasisVal,
342 func.evaluate(elemQuad[qi].position()),
343 elemQuad[qi].weight(),
362 template <
class MVal,
class RTVal,
class Matrix>
363 void fillBnd (
unsigned int startRow,
366 const FieldVector<Field,dimension> &normal,
368 Matrix &matrix)
const
370 const unsigned int endRow = startRow+mVal.size();
371 typename RTVal::const_iterator rtiter = rtVal.begin();
372 for (
unsigned int col = 0; col < rtVal.size() ; ++rtiter,++col)
374 Field cFactor = (*rtiter)*normal;
375 typename MVal::const_iterator miter = mVal.begin();
376 for (
unsigned int row = startRow;
377 row!=endRow; ++miter, ++row )
379 matrix.add(row,col, (weight*cFactor)*(*miter) );
381 assert( miter == mVal.end() );
392 template <
class MVal,
class RTVal,
class Matrix>
393 void fillInterior (
unsigned int startRow,
397 Matrix &matrix)
const
399 const unsigned int endRow = startRow+mVal.size()*dimension;
400 typename RTVal::const_iterator rtiter = rtVal.begin();
401 for (
unsigned int col = 0; col < rtVal.size() ; ++rtiter,++col)
403 typename MVal::const_iterator miter = mVal.begin();
404 for (
unsigned int row = startRow;
405 row!=endRow; ++miter,row+=dimension )
407 for (
unsigned int i=0; i<dimension; ++i)
409 matrix.add(row+i,col, (weight*(*miter))*(*rtiter)[i] );
412 assert( miter == mVal.end() );
421 template <
unsigned int dim,
class Field >
429 template <GeometryType::Id geometryId>
432 if ( !supports<geometryId>(key) )
435 interpol->template build<geometryId>(key);
438 template< GeometryType::Id geometryId >
441 return GeometryType(geometryId).isSimplex();
Definition bdfmcube.hh:18
Describe position of one degree of freedom.
Definition localkey.hh:24
Definition nedelecsimplexinterpolation.hh:41
LocalCoefficientsContainer(const Setter &setter)
Definition nedelecsimplexinterpolation.hh:46
const LocalKey & localKey(const unsigned int i) const
Definition raviartthomassimplexinterpolation.hh:48
std::size_t size() const
Definition nedelecsimplexinterpolation.hh:57
Definition orthonormalbasis.hh:20
static void release(Object *object)
Definition orthonormalbasis.hh:57
Definition raviartthomassimplexinterpolation.hh:423
std::remove_const< Object >::type NonConstObject
Definition raviartthomassimplexinterpolation.hh:427
static void release(Object *object)
Definition raviartthomassimplexinterpolation.hh:443
static bool supports(const Key &key)
Definition raviartthomassimplexinterpolation.hh:439
static Object * create(const Key &key)
Definition raviartthomassimplexinterpolation.hh:430
RTL2InterpolationBuilder< dim, Field > Builder
Definition raviartthomassimplexinterpolation.hh:424
const RaviartThomasL2Interpolation< dim, Field > Object
Definition raviartthomassimplexinterpolation.hh:425
std::size_t Key
Definition raviartthomassimplexinterpolation.hh:426
Definition raviartthomassimplexinterpolation.hh:70
std::size_t Key
Definition raviartthomassimplexinterpolation.hh:71
static void release(Object *object)
Definition raviartthomassimplexinterpolation.hh:91
static bool supports(const Key &key)
Definition raviartthomassimplexinterpolation.hh:87
const LocalCoefficientsContainer Object
Definition raviartthomassimplexinterpolation.hh:72
static Object * create(const Key &key)
Definition raviartthomassimplexinterpolation.hh:75
Definition raviartthomassimplexinterpolation.hh:107
TestBasis * testBasis() const
Definition raviartthomassimplexinterpolation.hh:141
FieldVector< Field, dimension > Normal
Definition raviartthomassimplexinterpolation.hh:119
TestBasisFactory::Object TestBasis
Definition raviartthomassimplexinterpolation.hh:112
TestFaceBasisFactory::Object TestFaceBasis
Definition raviartthomassimplexinterpolation.hh:116
const Normal normal(unsigned int f) const
Definition raviartthomassimplexinterpolation.hh:147
unsigned int faceSize() const
Definition raviartthomassimplexinterpolation.hh:138
void build(std::size_t order)
Definition raviartthomassimplexinterpolation.hh:150
RTL2InterpolationBuilder()=default
TestFaceBasis * testFaceBasis(unsigned int f) const
Definition raviartthomassimplexinterpolation.hh:144
GeometryType type() const
Definition raviartthomassimplexinterpolation.hh:133
RTL2InterpolationBuilder(const RTL2InterpolationBuilder &)=delete
OrthonormalBasisFactory< dimension-1, Field > TestFaceBasisFactory
Definition raviartthomassimplexinterpolation.hh:115
RTL2InterpolationBuilder(RTL2InterpolationBuilder &&)=delete
OrthonormalBasisFactory< dimension, Field > TestBasisFactory
Definition raviartthomassimplexinterpolation.hh:111
std::size_t order() const
Definition raviartthomassimplexinterpolation.hh:135
static const unsigned int dimension
Definition raviartthomassimplexinterpolation.hh:108
~RTL2InterpolationBuilder()
Definition raviartthomassimplexinterpolation.hh:126
An L2-based interpolation for Raviart Thomas.
Definition raviartthomassimplexinterpolation.hh:213
std::size_t order() const
Definition raviartthomassimplexinterpolation.hh:246
void interpolate(const Function &function, Vector &coefficients) const
Definition raviartthomassimplexinterpolation.hh:228
RaviartThomasL2Interpolation()
Definition raviartthomassimplexinterpolation.hh:220
void interpolate(typename Base::template Helper< Func, Container, type > &func) const
Definition raviartthomassimplexinterpolation.hh:285
RTL2InterpolationBuilder< dimension, Field > Builder
Definition raviartthomassimplexinterpolation.hh:219
F Field
Definition raviartthomassimplexinterpolation.hh:218
void build(std::size_t order)
Definition raviartthomassimplexinterpolation.hh:255
std::size_t size() const
Definition raviartthomassimplexinterpolation.hh:250
void setLocalKeys(std::vector< LocalKey > &keys) const
Definition raviartthomassimplexinterpolation.hh:267
Definition interpolationhelper.hh:21
Definition interpolationhelper.hh:23
Definition polynomialbasis.hh:65
unsigned int size() const
Definition polynomialbasis.hh:113