DUNE-FEM (unstable)

dense.hh
1#ifndef DUNE_FEM_OPERATOR_PROJECTION_LOCAL_RIESZ_DENSE_HH
2#define DUNE_FEM_OPERATOR_PROJECTION_LOCAL_RIESZ_DENSE_HH
3
4#include <cassert>
5#include <cstddef>
6
7#include <utility>
8#include <vector>
9
11
12#include "localrieszprojection.hh"
13
14namespace Dune
15{
16
17 namespace Fem
18 {
19
20 // DenseLocalRieszProjection
21 // -------------------------
22
23 template< class BasisFunctionSet, class Quadrature >
24 class DenseLocalRieszProjection
25 : public LocalRieszProjection< BasisFunctionSet, DenseLocalRieszProjection< BasisFunctionSet, Quadrature > >
26 {
27 typedef DenseLocalRieszProjection< BasisFunctionSet, Quadrature > ThisType;
28 typedef LocalRieszProjection< BasisFunctionSet, DenseLocalRieszProjection< BasisFunctionSet, Quadrature > > BaseType;
29
30 public:
32 typedef typename BaseType::BasisFunctionSetType BasisFunctionSetType;
33
38 explicit DenseLocalRieszProjection ( const BasisFunctionSetType &basisFunctionSet )
39 : basisFunctionSet_( basisFunctionSet ),
40 inverse_( basisFunctionSet.size(), basisFunctionSet.size() )
41 {
42 assemble( basisFunctionSet, inverse_ );
43 inverse_.invert();
44 }
45
46 explicit DenseLocalRieszProjection ( BasisFunctionSetType &&basisFunctionSet )
47 : basisFunctionSet_( std::forward< BasisFunctionSetType >( basisFunctionSet ) ),
48 inverse_( basisFunctionSet.size(), basisFunctionSet.size() )
49 {
50 assemble( basisFunctionSet, inverse_ );
51 inverse_.invert();
52 }
53
60 DenseLocalRieszProjection ( const ThisType &other ) = default;
61
62 DenseLocalRieszProjection ( ThisType &&other )
63 : basisFunctionSet_( std::move( other.basisFunctionSet_ ) ),
64 inverse_( std::move( other.inverse_ ) )
65 {}
66
67 ThisType &operator= ( const ThisType &other ) = default;
68
69 ThisType &operator= ( ThisType &&other )
70 {
71 basisFunctionSet_ = std::move( other.basisFunctionSet_ );
72 inverse_ = std::move( other.inverse_ );
73 return *this;
74 }
75
83 BasisFunctionSetType basisFunctionSet () const { return basisFunctionSet_; }
84
86 template< class F, class LocalDofVector >
87 void apply ( const F&f, LocalDofVector &dofs ) const
88 {
89 inverse_.mv( f, dofs );
90 }
91
94 private:
95 template< class DenseMatrix >
96 void assemble ( const BasisFunctionSetType &basisFunctionSet, DenseMatrix &matrix )
97 {
98 const std::size_t size = basisFunctionSet.size();
99 std::vector< typename BasisFunctionSetType::RangeType > phi( size );
100
101 matrix = static_cast< typename DenseMatrix::value_type >( 0 );
102 assert( matrix.N() == basisFunctionSet.size() );
103 assert( matrix.M() == basisFunctionSet.size() );
104
105 const auto &geometry = basisFunctionSet.geometry();
106 const Quadrature quadrature( geometry.type(), 2*basisFunctionSet.order() );
107 const std::size_t nop = quadrature.nop();
108 for( std::size_t qp = 0; qp < nop; ++qp )
109 {
110 basisFunctionSet.evaluateAll( quadrature[ qp ], phi );
111
112 const auto weight = quadrature.weight( qp )*geometry.integrationElement( quadrature.point( qp ) );
113 for( std::size_t i = 0; i < size; ++i )
114 {
115 matrix[ i ][ i ] += weight*( phi[ i ] * phi[ i ] );
116 for( std::size_t j = i+1; j < size; ++j )
117 {
118 const auto value = weight*( phi[ i ]* phi[ j ] );
119 matrix[ i ][ j ] += value;
120 matrix[ j ][ i ] += value;
121 }
122 }
123 }
124 }
125
126 BasisFunctionSetType basisFunctionSet_;
128 };
129
130 } // namespace Fem
131
132} // namepsace Dune
133
134#endif // #ifndef DUNE_FEM_OPERATOR_PROJECTION_LOCAL_RIESZ_DENSE_HH
135
Traits::value_type value_type
export the type representing the field
Definition: densematrix.hh:157
BasisFunctionSet BasisFunctionSetType
basis function set
Definition: localrieszprojection.hh:26
actual interface class for quadratures
This file implements a dense matrix with dynamic numbers of rows and columns.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 22, 23:33, 2024)