dune-fem 2.8.0
Loading...
Searching...
No Matches
tuplediscretefunction/scalarproducts.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_FUNCTION_TUPLEDISCRETEFUNCTION_SCALARPRODUCTS_HH
2#define DUNE_FEM_FUNCTION_TUPLEDISCRETEFUNCTION_SCALARPRODUCTS_HH
3
4#include <utility>
5
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
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
66 ParallelScalarProductTuple tuple_;
67 };
68
69 } // namespace Fem
70
71} // namespace Dune
72
73#endif // #ifndef DUNE_FEM_FUNCTION_TUPLEDISCRETEFUNCTION_SCALARPRODUCTS_HH
const DiscreteFunctionSpaceType & space_
Definition: common/scalarproducts.hh:173
const DiscreteFunctionSpaceType & space() const
Definition: common/scalarproducts.hh:102
RangeFieldType scalarProductDofs(const DiscreteFunctionType &x, const OtherDiscreteFunctionType &y) const
evaluate scalar product and omit auxiliary nodes
Definition: common/scalarproducts.hh:109
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field
Definition: common/scalarproducts.hh:86
Definition: bindguard.hh:11
static constexpr std::decay_t< T > sum(T a)
Definition: utility.hh:33
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field, i.e. dof type
Definition: common/discretefunction.hh:109
Definition: common/scalarproducts.hh:73
forward declaration
Definition: tuplediscretefunction/discretefunction.hh:51
TupleDiscreteFunction< DiscreteFunctions ... > DiscreteFunctionType
Definition: tuplediscretefunction/scalarproducts.hh:30
static ParallelScalarProductTuple createTuple(const DiscreteFunctionSpaceType &space, std::index_sequence< I ... >)
Definition: tuplediscretefunction/scalarproducts.hh:60
RangeFieldType scalarProductDofs(const DiscreteFunctionType &x, const DiscreteFunctionType &y) const
Definition: tuplediscretefunction/scalarproducts.hh:40
ParallelScalarProductTuple tuple_
Definition: tuplediscretefunction/scalarproducts.hh:66
DiscreteFunctionType::RangeFieldType RangeFieldType
Definition: tuplediscretefunction/scalarproducts.hh:32
ParallelScalarProduct(const DiscreteFunctionSpaceType &space)
Definition: tuplediscretefunction/scalarproducts.hh:34
DiscreteFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: tuplediscretefunction/scalarproducts.hh:31
const DiscreteFunctionSpaceType & space_
Definition: tuplediscretefunction/scalarproducts.hh:65
RangeFieldType scalarProductDofs(const DiscreteFunctionType &x, const DiscreteFunctionType &y, std::index_sequence< I ... >) const
Definition: tuplediscretefunction/scalarproducts.hh:54
RangeFieldType scalarProductDofs(const DiscreteFunctionType &x, const OtherDiscreteFunction &y) const
Definition: tuplediscretefunction/scalarproducts.hh:46
const DiscreteFunctionSpaceType & space() const
Definition: tuplediscretefunction/scalarproducts.hh:38
Definition: tuplespace.hh:192