dune-localfunctions
2.6-git
|
Go to the documentation of this file.
3 #ifndef DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS_RAVIARTTHOMASSIMPLEX_RAVIARTTHOMASSIMPLEXINTERPOLATION_HH
4 #define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS_RAVIARTTHOMASSIMPLEX_RAVIARTTHOMASSIMPLEXINTERPOLATION_HH
9 #include <dune/common/exceptions.hh>
11 #include <dune/geometry/topologyfactory.hh>
12 #include <dune/geometry/quadraturerules.hh>
13 #include <dune/geometry/referenceelements.hh>
14 #include <dune/geometry/type.hh>
27 template <
unsigned int dim >
30 template <
unsigned int dim,
class Field >
43 template <
class Setter>
46 setter.setLocalKeys(localKey_);
52 return localKey_[ i ];
57 return localKey_.size();
61 std::vector< LocalKey > localKey_;
69 template <
unsigned int dim >
74 typedef unsigned int Key;
83 template <
unsigned int dim >
85 :
public TopologyFactory< RaviartThomasCoefficientsFactoryTraits< dim > >
89 template<
class Topology >
93 if( !supports< Topology >( key ) )
95 typename InterpolationFactory::Object *interpolation = InterpolationFactory::template create< Topology >( key );
97 InterpolationFactory::release( interpolation );
101 template<
class Topology >
119 template<
unsigned int dim,
class Field >
127 typedef FieldVector< Field, dimension >
Normal;
136 TestBasisFactory::release( testBasis_ );
137 for( FaceStructure &f : faceStructure_ )
138 TestFaceBasisFactory::release( f.basis_ );
145 unsigned int order ()
const {
return order_; }
147 unsigned int faceSize ()
const {
return faceSize_; }
152 const Normal &
normal (
unsigned int f )
const { assert( f <
faceSize() );
return *(faceStructure_[ f ].normal_); }
154 template<
class Topology >
158 topologyId_ = Topology::id;
160 testBasis_ = (
order > 0 ? TestBasisFactory::template create< Topology >(
order-1 ) :
nullptr);
162 const auto &refElement = ReferenceElements< Field, dimension >::general(
type() );
163 faceSize_ = refElement.size( 1 );
164 faceStructure_.reserve( faceSize_ );
165 for(
unsigned int face = 0; face < faceSize_; ++face )
167 TestFaceBasis *faceBasis = Impl::IfTopology< CreateFaceBasis, dimension-1 >::apply( refElement.type( face, 1 ).id(),
order );
168 faceStructure_.emplace_back( faceBasis, refElement.integrationOuterNormal( face ) );
170 assert( faceStructure_.size() == faceSize_ );
177 : basis_( tfb ), normal_( &n )
181 const Dune::FieldVector< Field, dimension > *normal_;
184 template<
class FaceTopology >
185 struct CreateFaceBasis
187 static TestFaceBasis *apply (
unsigned int order ) {
return TestFaceBasisFactory::template create< FaceTopology >(
order ); }
190 std::vector< FaceStructure > faceStructure_;
192 unsigned int topologyId_, order_, faceSize_;
205 template<
unsigned int dimension,
class F>
220 template<
class Function,
class Fy >
221 void interpolate (
const Function &
function, std::vector< Fy > &coefficients )
const
223 coefficients.resize(
size());
227 template<
class Basis,
class Matrix >
230 matrix.resize(
size(), basis.size() );
243 template <
class Topology>
248 builder_.template build<Topology>(order_);
250 size_ += dimension*builder_.
testBasis()->size();
251 for (
unsigned int f=0; f<builder_.
faceSize(); ++f )
259 unsigned int row = 0;
260 for (
unsigned int f=0; f<builder_.
faceSize(); ++f)
267 for (
unsigned int i=0; i<builder_.
testBasis()->
size()*dimension; ++i,++row)
269 assert( row ==
size() );
273 template<
class Func,
class Container,
bool type >
276 const Dune::GeometryType geoType( builder_.
topologyId(), dimension );
278 std::vector< Field > testBasisVal;
280 for (
unsigned int i=0; i<
size(); ++i)
281 for (
unsigned int j=0; j<func.size(); ++j)
284 unsigned int row = 0;
287 typedef Dune::QuadratureRule<
Field, dimension-1> FaceQuadrature;
288 typedef Dune::QuadratureRules<
Field, dimension-1> FaceQuadratureRules;
290 const auto &refElement = Dune::ReferenceElements< Field, dimension >::general( geoType );
292 for (
unsigned int f=0; f<builder_.
faceSize(); ++f)
298 const auto &geometry = refElement.template geometry< 1 >( f );
299 const Dune::GeometryType subGeoType( geometry.type().id(), dimension-1 );
300 const FaceQuadrature &faceQuad = FaceQuadratureRules::rule( subGeoType, 2*order_+2 );
302 const unsigned int quadratureSize = faceQuad.size();
303 for(
unsigned int qi = 0; qi < quadratureSize; ++qi )
306 builder_.
testFaceBasis(f)->template evaluate<0>(faceQuad[qi].position(),testBasisVal);
308 testBasisVal[0] = 1.;
309 fillBnd( row, testBasisVal,
310 func.evaluate( geometry.global( faceQuad[qi].position() ) ),
311 builder_.
normal(f), faceQuad[qi].weight(),
320 testBasisVal.resize(builder_.
testBasis()->size());
322 typedef Dune::QuadratureRule<Field, dimension> Quadrature;
323 typedef Dune::QuadratureRules<Field, dimension> QuadratureRules;
324 const Quadrature &elemQuad = QuadratureRules::rule( geoType, 2*order_+1 );
326 const unsigned int quadratureSize = elemQuad.size();
327 for(
unsigned int qi = 0; qi < quadratureSize; ++qi )
329 builder_.
testBasis()->template evaluate<0>(elemQuad[qi].position(),testBasisVal);
330 fillInterior( row, testBasisVal,
331 func.evaluate(elemQuad[qi].position()),
332 elemQuad[qi].weight(),
336 row += builder_.
testBasis()->size()*dimension;
343 template <
class MVal,
class RTVal,
class Matrix>
344 void fillBnd (
unsigned int startRow,
347 const FieldVector<Field,dimension> &normal,
349 Matrix &matrix)
const
351 const unsigned int endRow = startRow+mVal.size();
352 typename RTVal::const_iterator rtiter = rtVal.begin();
353 for (
unsigned int col = 0; col < rtVal.size() ; ++rtiter,++col)
355 Field cFactor = (*rtiter)*normal;
356 typename MVal::const_iterator miter = mVal.begin();
357 for (
unsigned int row = startRow;
358 row!=endRow; ++miter, ++row )
360 matrix.add(row,col, (weight*cFactor)*(*miter) );
362 assert( miter == mVal.end() );
365 template <
class MVal,
class RTVal,
class Matrix>
366 void fillInterior (
unsigned int startRow,
370 Matrix &matrix)
const
372 const unsigned int endRow = startRow+mVal.size()*dimension;
373 typename RTVal::const_iterator rtiter = rtVal.begin();
374 for (
unsigned int col = 0; col < rtVal.size() ; ++rtiter,++col)
376 typename MVal::const_iterator miter = mVal.begin();
377 for (
unsigned int row = startRow;
378 row!=endRow; ++miter,row+=dimension )
380 for (
unsigned int i=0; i<dimension; ++i)
382 matrix.add(row+i,col, (weight*(*miter))*(*rtiter)[i] );
385 assert( miter == mVal.end() );
394 template <
unsigned int dim,
class F >
402 template <
unsigned int dim,
class Field >
404 public TopologyFactory< RaviartThomasL2InterpolationFactoryTraits<dim,Field> >
410 template <
class Topology>
413 if ( !supports<Topology>(key) )
416 interpol->template build<Topology>(key);
419 template<
class Topology >
428 #endif // #ifndef DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS_RAVIARTTHOMASSIMPLEX_RAVIARTTHOMASSIMPLEXINTERPOLATION_HH
static Traits::Object * createObject(const typename Traits::Key &key)
Definition: raviartthomassimplexinterpolation.hh:411
void build(unsigned int order)
Definition: raviartthomassimplexinterpolation.hh:244
RTL2InterpolationBuilder< dimension, Field > Builder
Definition: raviartthomassimplexinterpolation.hh:214
Definition: interpolationhelper.hh:73
OrthonormalBasisFactory< dimension, Field > TestBasisFactory
Definition: raviartthomassimplexinterpolation.hh:123
~RTL2InterpolationBuilder()
Definition: raviartthomassimplexinterpolation.hh:134
RaviartThomasL2InterpolationFactoryTraits< dim, Field > Traits
Definition: raviartthomassimplexinterpolation.hh:406
Definition: interpolationhelper.hh:17
@ value
Definition: tensor.hh:165
TestFaceBasisFactory::Object TestFaceBasis
Definition: raviartthomassimplexinterpolation.hh:126
static const unsigned int dimension
Definition: raviartthomassimplexinterpolation.hh:122
unsigned int Key
Definition: raviartthomassimplexinterpolation.hh:398
static Traits::Object * createObject(const typename Traits::Key &key)
Definition: raviartthomassimplexinterpolation.hh:90
unsigned int order() const
Definition: raviartthomassimplexinterpolation.hh:145
void build(unsigned int order)
Definition: raviartthomassimplexinterpolation.hh:155
Definition: raviartthomassimplexinterpolation.hh:28
void interpolate(typename Base::template Helper< Func, Container, type > &func) const
Definition: raviartthomassimplexinterpolation.hh:274
Definition: orthonormalbasis.hh:19
TestFaceBasis * testFaceBasis(unsigned int f) const
Definition: raviartthomassimplexinterpolation.hh:150
Definition: raviartthomassimplexinterpolation.hh:38
unsigned int faceSize() const
Definition: raviartthomassimplexinterpolation.hh:147
unsigned int size() const
Definition: raviartthomassimplexinterpolation.hh:239
RaviartThomasL2Interpolation()
Definition: raviartthomassimplexinterpolation.hh:215
Definition: raviartthomassimplexinterpolation.hh:395
unsigned int size() const
Definition: raviartthomassimplexinterpolation.hh:55
void interpolate(const Function &function, std::vector< Fy > &coefficients) const
Definition: raviartthomassimplexinterpolation.hh:221
TestBasisFactory::Object TestBasis
Definition: raviartthomassimplexinterpolation.hh:124
FieldVector< Field, dimension > Normal
Definition: raviartthomassimplexinterpolation.hh:127
GeometryType type() const
Definition: raviartthomassimplexinterpolation.hh:143
std::remove_const< Object >::type NonConstObject
Definition: raviartthomassimplexinterpolation.hh:409
RaviartThomasCoefficientsFactory< dim > Factory
Definition: raviartthomassimplexinterpolation.hh:75
void interpolate(const Basis &basis, Matrix &matrix) const
Definition: raviartthomassimplexinterpolation.hh:228
static bool supports(const typename Traits::Key &key)
Definition: raviartthomassimplexinterpolation.hh:102
RaviartThomasCoefficientsFactoryTraits< dim > Traits
Definition: raviartthomassimplexinterpolation.hh:87
Traits::Object Object
Definition: raviartthomassimplexinterpolation.hh:408
void setLocalKeys(std::vector< LocalKey > &keys) const
Definition: raviartthomassimplexinterpolation.hh:256
Definition: raviartthomassimplexinterpolation.hh:120
Definition: raviartthomassimplexinterpolation.hh:31
TestBasis * testBasis() const
Definition: raviartthomassimplexinterpolation.hh:149
RTL2InterpolationBuilder()=default
RTL2InterpolationBuilder< dim, Field > Builder
Definition: raviartthomassimplexinterpolation.hh:407
static bool supports(const typename Traits::Key &key)
Definition: raviartthomassimplexinterpolation.hh:420
const typedef RaviartThomasL2Interpolation< dim, F > Object
Definition: raviartthomassimplexinterpolation.hh:399
Definition: raviartthomassimplexinterpolation.hh:70
static const unsigned int dimension
Definition: raviartthomassimplexinterpolation.hh:72
Definition: interpolationhelper.hh:20
RaviartThomasL2InterpolationFactory< dim, F > Factory
Definition: raviartthomassimplexinterpolation.hh:400
const LocalKey & localKey(const unsigned int i) const
Definition: raviartthomassimplexinterpolation.hh:49
unsigned int order() const
Definition: raviartthomassimplexinterpolation.hh:235
unsigned int topologyId() const
Definition: raviartthomassimplexinterpolation.hh:141
const typedef LocalCoefficientsContainer Object
Definition: raviartthomassimplexinterpolation.hh:73
Traits::Object Object
Definition: orthonormalbasis.hh:45
Describe position of one degree of freedom.
Definition: localkey.hh:20
const Normal & normal(unsigned int f) const
Definition: raviartthomassimplexinterpolation.hh:152
LocalCoefficientsContainer(const Setter &setter)
Definition: raviartthomassimplexinterpolation.hh:44
unsigned int Key
Definition: raviartthomassimplexinterpolation.hh:74
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:15
static const unsigned int dimension
Definition: raviartthomassimplexinterpolation.hh:397
OrthonormalBasisFactory< dimension-1, Field > TestFaceBasisFactory
Definition: raviartthomassimplexinterpolation.hh:125
An L2-based interpolation for Raviart Thomas.
Definition: raviartthomassimplexinterpolation.hh:206
F Field
Definition: raviartthomassimplexinterpolation.hh:213