DUNE-FEM (unstable)

scalarproducts.hh
1#ifndef DUNE_FEM_FUNCTION_TUPLEDISCRETEFUNCTION_SCALARPRODUCTS_HH
2#define DUNE_FEM_FUNCTION_TUPLEDISCRETEFUNCTION_SCALARPRODUCTS_HH
3
4#include <utility>
5
6#include <dune/fem/common/utility.hh>
7#include <dune/fem/function/common/scalarproducts.hh>
8#include <dune/fem/function/tuplediscretefunction/discretefunction.hh>
9
10
11namespace Dune
12{
13
14 namespace Fem
15 {
16
17 // ParallelScalarProduct
18 // ---------------------
19
20 template< class ... DiscreteFunctions >
21 class ParallelScalarProduct< TupleDiscreteFunction< DiscreteFunctions ... > >
22 {
23 typedef ParallelScalarProduct< TupleDiscreteFunction< DiscreteFunctions ... > > ThisType;
24
25 typedef std::tuple< ParallelScalarProduct< DiscreteFunctions > ... > ParallelScalarProductTuple;
26
27 typedef decltype ( std::index_sequence_for< DiscreteFunctions ... >() ) Sequence;
28
29 public:
30 typedef TupleDiscreteFunction< DiscreteFunctions ... > DiscreteFunctionType;
33
34 ParallelScalarProduct ( const DiscreteFunctionSpaceType &space )
35 : tuple_( createTuple( space, Sequence() ) )
36 {}
37
38 const DiscreteFunctionSpaceType &space () const { return space_; }
39
41 {
42 return scalarProductDofs( x, y, Sequence() );
43 }
44
45 template< class OtherDiscreteFunction >
46 RangeFieldType scalarProductDofs ( const DiscreteFunctionType &x, const OtherDiscreteFunction &y ) const
47 {
48 DUNE_THROW( NotImplemented, "Method scalarProductDofs ( DofVectorType, OtherDofVector ) not implemented" );
49 return RangeFieldType( 0 );
50 }
51
52 protected:
53 template< std::size_t ... I >
54 RangeFieldType scalarProductDofs ( const DiscreteFunctionType &x, const DiscreteFunctionType &y, std::index_sequence< I ... > ) const
55 {
56 return Std::sum( std::get< I >( tuple_ ).scalarProductDofs( x.template subDiscreteFunction< I >(), y.template subDiscreteFunction< I >() ) ... );
57 }
58
59 template< std::size_t ... I >
60 static ParallelScalarProductTuple createTuple ( const DiscreteFunctionSpaceType &space, std::index_sequence< I ... > )
61 {
62 return std::make_tuple( std::tuple_element< I, ParallelScalarProductTuple >::type( space.template subDiscreteFunctionSpace< I >() ) ... );
63 }
64
65 const DiscreteFunctionSpaceType &space_;
66 ParallelScalarProductTuple tuple_;
67 };
68
69 } // namespace Fem
70
71} // namespace Dune
72
73#endif // #ifndef DUNE_FEM_FUNCTION_TUPLEDISCRETEFUNCTION_SCALARPRODUCTS_HH
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field (usually a float type)
Definition: discretefunction.hh:623
forward declaration
Definition: discretefunction.hh:51
TupleDiscreteFunctionSpace< typename DiscreteFunctions::DiscreteFunctionSpaceType ... > DiscreteFunctionSpaceType
type for the discrete function space this function lives in
Definition: discretefunction.hh:69
RangeFieldType scalarProductDofs(const DiscreteFunctionType &x, const OtherDiscreteFunctionType &y) const
evaluate scalar product and omit auxiliary nodes
Definition: scalarproducts.hh:101
ParallelScalarProduct(const DiscreteFunctionSpaceType &space)
constructor taking space
Definition: scalarproducts.hh:90
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field
Definition: scalarproducts.hh:78
DiscreteFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of the discrete function space
Definition: scalarproducts.hh:71
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)