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 >
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 >
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 >
118 typedef FieldVector< Field, dimension >
Normal;
128 for( FaceStructure &f : faceStructure_ )
132 GeometryType
type ()
const {
return geometry_; }
134 std::size_t
order ()
const {
return order_; }
137 unsigned int faceSize ()
const {
return faceSize_; }
148 template< GeometryType::Id geometryId >
151 constexpr GeometryType geometry = geometryId;
152 geometry_ = geometry;
155 testBasis_ = (
order > 0 ? TestBasisFactory::template create< geometry >(
order-1 ) :
nullptr);
157 const auto &refElement = ReferenceElements< Field, dimension >::general(
type() );
158 faceSize_ = refElement.size( 1 );
159 faceStructure_.reserve( faceSize_ );
160 for(
unsigned int face = 0; face < faceSize_; ++face )
173 TestFaceBasis *faceBasis = Impl::toGeometryTypeIdConstant<
dimension-1>(refElement.type( face, 1 ), [&](
auto faceGeometryTypeId) {
174 return TestFaceBasisFactory::template create< decltype(faceGeometryTypeId)::value >(
order );
176 faceStructure_.emplace_back( faceBasis, refElement.integrationOuterNormal( face ) );
178 assert( faceStructure_.size() == faceSize_ );
185 : basis_( tfb ), normal_( n )
189 const Dune::FieldVector< Field, dimension > normal_;
192 std::vector< FaceStructure > faceStructure_;
194 GeometryType geometry_;
195 unsigned int faceSize_;
209 template<
unsigned int dimension,
class F>
224 template<
class Function,
class Vector,
225 decltype(std::declval<Vector>().size(),
bool{}) =
true,
226 decltype(std::declval<Vector>().resize(0u),
bool{}) =
true>
234 template<
class Basis,
class Matrix,
235 decltype(std::declval<Matrix>().rows(),
bool{}) =
true,
236 decltype(std::declval<Matrix>().cols(),
bool{}) =
true,
237 decltype(std::declval<Matrix>().resize(0u,0u),
bool{}) =
true>
240 matrix.resize(
size(), basis.size() );
253 template <GeometryType::Id geometryId>
259 if (builder_.testBasis())
260 size_ += dimension*builder_.testBasis()->size();
261 for (
unsigned int f=0; f<builder_.faceSize(); ++f )
262 if (builder_.testFaceBasis(f))
263 size_ += builder_.testFaceBasis(f)->size();
269 unsigned int row = 0;
270 for (
unsigned int f=0; f<builder_.faceSize(); ++f)
272 if (builder_.faceSize())
273 for (
unsigned int i=0; i<builder_.testFaceBasis(f)->
size(); ++i,++row)
276 if (builder_.testBasis())
277 for (
unsigned int i=0; i<builder_.testBasis()->
size()*dimension; ++i,++row)
279 assert( row ==
size() );
283 template<
class Func,
class Container,
bool type >
286 const Dune::GeometryType geoType = builder_.type();
288 std::vector< Field > testBasisVal;
290 for (
unsigned int i=0; i<
size(); ++i)
291 for (
unsigned int j=0; j<func.size(); ++j)
294 unsigned int row = 0;
297 typedef Dune::QuadratureRule<
Field, dimension-1> FaceQuadrature;
298 typedef Dune::QuadratureRules<
Field, dimension-1> FaceQuadratureRules;
300 const auto &refElement = Dune::ReferenceElements< Field, dimension >::general( geoType );
302 for (
unsigned int f=0; f<builder_.faceSize(); ++f)
304 if (!builder_.testFaceBasis(f))
306 testBasisVal.resize(builder_.testFaceBasis(f)->size());
308 const auto &geometry = refElement.template geometry< 1 >( f );
309 const Dune::GeometryType subGeoType( geometry.type().id(), dimension-1 );
310 const FaceQuadrature &faceQuad = FaceQuadratureRules::rule( subGeoType, 2*order_+2 );
312 const unsigned int quadratureSize = faceQuad.size();
313 for(
unsigned int qi = 0; qi < quadratureSize; ++qi )
316 builder_.testFaceBasis(f)->template evaluate<0>(faceQuad[qi].position(),testBasisVal);
318 testBasisVal[0] = 1.;
319 fillBnd( row, testBasisVal,
320 func.evaluate( geometry.global( faceQuad[qi].position() ) ),
321 builder_.normal(f), faceQuad[qi].weight(),
325 row += builder_.testFaceBasis(f)->size();
328 if (builder_.testBasis())
330 testBasisVal.resize(builder_.testBasis()->size());
332 typedef Dune::QuadratureRule<Field, dimension> Quadrature;
333 typedef Dune::QuadratureRules<Field, dimension> QuadratureRules;
334 const Quadrature &elemQuad = QuadratureRules::rule( geoType, 2*order_+1 );
336 const unsigned int quadratureSize = elemQuad.size();
337 for(
unsigned int qi = 0; qi < quadratureSize; ++qi )
339 builder_.testBasis()->template evaluate<0>(elemQuad[qi].position(),testBasisVal);
340 fillInterior( row, testBasisVal,
341 func.evaluate(elemQuad[qi].position()),
342 elemQuad[qi].weight(),
346 row += builder_.testBasis()->size()*dimension;
361 template <
class MVal,
class RTVal,
class Matrix>
362 void fillBnd (
unsigned int startRow,
365 const FieldVector<Field,dimension> &normal,
367 Matrix &matrix)
const
369 const unsigned int endRow = startRow+mVal.size();
370 typename RTVal::const_iterator rtiter = rtVal.begin();
371 for (
unsigned int col = 0; col < rtVal.size() ; ++rtiter,++col)
373 Field cFactor = (*rtiter)*normal;
374 typename MVal::const_iterator miter = mVal.begin();
375 for (
unsigned int row = startRow;
376 row!=endRow; ++miter, ++row )
378 matrix.add(row,col, (weight*cFactor)*(*miter) );
380 assert( miter == mVal.end() );
391 template <
class MVal,
class RTVal,
class Matrix>
392 void fillInterior (
unsigned int startRow,
396 Matrix &matrix)
const
398 const unsigned int endRow = startRow+mVal.size()*dimension;
399 typename RTVal::const_iterator rtiter = rtVal.begin();
400 for (
unsigned int col = 0; col < rtVal.size() ; ++rtiter,++col)
402 typename MVal::const_iterator miter = mVal.begin();
403 for (
unsigned int row = startRow;
404 row!=endRow; ++miter,row+=dimension )
406 for (
unsigned int i=0; i<dimension; ++i)
408 matrix.add(row+i,col, (weight*(*miter))*(*rtiter)[i] );
411 assert( miter == mVal.end() );
420 template <
unsigned int dim,
class Field >
428 template <GeometryType::Id geometryId>
434 interpol->template build<geometryId>(key);
437 template< GeometryType::Id geometryId >
440 return GeometryType(geometryId).isSimplex();
Definition bdfmcube.hh:18
const int RannacherTurek3DLocalBasis< D, R >::coefficients[6][6]
Definition rannacherturek3dlocalbasis.hh:121
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
static void release(Object *object)
Definition orthonormalbasis.hh:59
const Basis Object
Definition orthonormalbasis.hh:41
Definition raviartthomassimplexinterpolation.hh:422
std::remove_const< Object >::type NonConstObject
Definition raviartthomassimplexinterpolation.hh:426
static void release(Object *object)
Definition raviartthomassimplexinterpolation.hh:442
static bool supports(const Key &key)
Definition raviartthomassimplexinterpolation.hh:438
static Object * create(const Key &key)
Definition raviartthomassimplexinterpolation.hh:429
RTL2InterpolationBuilder< dim, Field > Builder
Definition raviartthomassimplexinterpolation.hh:423
const RaviartThomasL2Interpolation< dim, Field > Object
Definition raviartthomassimplexinterpolation.hh:424
std::size_t Key
Definition raviartthomassimplexinterpolation.hh:425
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:140
FieldVector< Field, dimension > Normal
Definition raviartthomassimplexinterpolation.hh:118
TestBasisFactory::Object TestBasis
Definition raviartthomassimplexinterpolation.hh:111
TestFaceBasisFactory::Object TestFaceBasis
Definition raviartthomassimplexinterpolation.hh:115
const Normal normal(unsigned int f) const
Definition raviartthomassimplexinterpolation.hh:146
unsigned int faceSize() const
Definition raviartthomassimplexinterpolation.hh:137
OrthonormalBasisFactory< dimension, Field, Field, Field > TestBasisFactory
Definition raviartthomassimplexinterpolation.hh:110
void build(std::size_t order)
Definition raviartthomassimplexinterpolation.hh:149
RTL2InterpolationBuilder()=default
TestFaceBasis * testFaceBasis(unsigned int f) const
Definition raviartthomassimplexinterpolation.hh:143
GeometryType type() const
Definition raviartthomassimplexinterpolation.hh:132
RTL2InterpolationBuilder(const RTL2InterpolationBuilder &)=delete
RTL2InterpolationBuilder(RTL2InterpolationBuilder &&)=delete
std::size_t order() const
Definition raviartthomassimplexinterpolation.hh:134
OrthonormalBasisFactory< dimension-1, Field, Field, Field > TestFaceBasisFactory
Definition raviartthomassimplexinterpolation.hh:114
static const unsigned int dimension
Definition raviartthomassimplexinterpolation.hh:108
~RTL2InterpolationBuilder()
Definition raviartthomassimplexinterpolation.hh:125
An L2-based interpolation for Raviart Thomas.
Definition raviartthomassimplexinterpolation.hh:212
std::size_t order() const
Definition raviartthomassimplexinterpolation.hh:245
void interpolate(const Function &function, Vector &coefficients) const
Definition raviartthomassimplexinterpolation.hh:227
RaviartThomasL2Interpolation()
Definition raviartthomassimplexinterpolation.hh:219
void interpolate(typename Base::template Helper< Func, Container, type > &func) const
Definition raviartthomassimplexinterpolation.hh:284
RTL2InterpolationBuilder< dimension, Field > Builder
Definition raviartthomassimplexinterpolation.hh:218
F Field
Definition raviartthomassimplexinterpolation.hh:217
void build(std::size_t order)
Definition raviartthomassimplexinterpolation.hh:254
std::size_t size() const
Definition raviartthomassimplexinterpolation.hh:249
void setLocalKeys(std::vector< LocalKey > &keys) const
Definition raviartthomassimplexinterpolation.hh:266
Definition interpolationhelper.hh:21
Definition interpolationhelper.hh:23