3#ifndef DUNE_ORTHONORMALCOMPUTE_HH
4#define DUNE_ORTHONORMALCOMPUTE_HH
16#include <dune/localfunctions/utility/field.hh>
17#include <dune/localfunctions/utility/lfematrix.hh>
18#include <dune/localfunctions/utility/monomialbasis.hh>
19#include <dune/localfunctions/utility/multiindex.hh>
24 template<
class scalar_t >
28 for(
int j = start; j <= end; ++j )
38 template<
class Topology >
41 template<
class Base >
42 struct Integral<
Dune::Impl::Pyramid< Base > >
44 template<
int dim,
class scalar_t >
45 static int compute (
const Dune::MultiIndex< dim, scalar_t > &alpha,
46 scalar_t &p, scalar_t &q )
48 const int dimension = Base::dimension+1;
49 int i = alpha.z( Base::dimension );
50 int ord = Integral< Base >::compute( alpha, p, q );
51 p *= factorial< scalar_t >( 1, i );
52 q *= factorial< scalar_t >( dimension + ord, dimension + ord + i );
57 template<
class Base >
58 struct Integral<
Dune::Impl::Prism< Base > >
60 template<
int dim,
class scalar_t >
61 static int compute (
const Dune::MultiIndex< dim, scalar_t > &alpha,
62 scalar_t &p, scalar_t &q )
64 int i = alpha.z( Base::dimension );
65 int ord = Integral< Base >::compute( alpha, p, q );
74 struct Integral<
Dune::Impl::Point >
76 template<
int dim,
class scalar_t >
77 static int compute (
const Dune::MultiIndex< dim, scalar_t > &alpha,
78 scalar_t &p, scalar_t &q )
91 template<
class Topology,
class scalar_t >
93 :
public Dune::LFEMatrix< scalar_t >
95 typedef ONBMatrix< Topology, scalar_t > This;
96 typedef Dune::LFEMatrix< scalar_t > Base;
99 typedef std::vector< scalar_t > vec_t;
100 typedef Dune::LFEMatrix< scalar_t > mat_t;
102 explicit ONBMatrix (
unsigned int order )
105 const unsigned int dim = Topology::dimension;
106 typedef Dune::MultiIndex< dim, scalar_t > MI;
107 Dune::StandardMonomialBasis< dim, MI > basis( order );
108 const std::size_t size = basis.size();
109 std::vector< Dune::FieldVector< MI, 1 > > y( size );
111 for(
unsigned int i = 0; i < dim; ++i )
113 basis.evaluate( x, y );
116 Base::resize( size, size );
117 S.resize( size, size );
122 for( std::size_t i = 0; i < size; ++i )
124 for( std::size_t j = 0; j < size; ++j )
126 Integral< Topology >::compute( y[ i ][ 0 ] * y[ j ][ 0 ], p, q );
136 template<
class Vector >
137 void row (
unsigned int row, Vector &vec )
const
140 assert( row < Base::cols() );
141 for( std::size_t i = 0; i < Base::rows(); ++i )
146 void sprod (
int col1,
int col2, scalar_t &ret )
149 for(
int k = 0; k <= col1; ++k )
151 for(
int l = 0; l <=col2; ++l )
152 ret += Base::operator()( l, col2 ) * S( l, k ) * Base::operator()( k, col1 );
156 void vmul ( std::size_t col, std::size_t rowEnd,
const scalar_t &s )
158 for( std::size_t i = 0; i <= rowEnd; ++i )
159 Base::operator()( i, col ) *= s;
162 void vsub ( std::size_t coldest, std::size_t colsrc, std::size_t rowEnd,
const scalar_t &s )
164 for( std::size_t i = 0; i <= rowEnd; ++i )
165 Base::operator()( i, coldest ) -= s * Base::operator()( i, colsrc );
171 const std::size_t N = Base::rows();
172 for( std::size_t i = 0; i < N; ++i )
174 for( std::size_t j = 0; j < N; ++j )
175 Base::operator()( i, j ) = scalar_t( i == j ? 1 : 0 );
181 vmul( 0, 0, scalar_t( 1 ) / sqrt( s ) );
182 for( std::size_t i = 1; i < N; ++i )
184 for( std::size_t k = 0; k < i; ++k )
190 vmul( i, i, scalar_t( 1 ) / sqrt( s ) );
vector space out of a tensor product of fields.
Definition: fvector.hh:93
Implements a matrix constructed from a given type representing a field and compile-time given number ...
int factorial(int n)
Calculate n!
Definition: simplex.cc:282
Dune namespace.
Definition: alignedallocator.hh:10
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:157
A unique label for each type of element that can occur in a grid.