1#ifndef DUNE_FEM_SCALARPRODURCTS_HH
2#define DUNE_FEM_SCALARPRODURCTS_HH
11#include <dune/common/exceptions.hh>
12#include <dune/common/genericiterator.hh>
13#include <dune/common/ftraits.hh>
14#include <dune/common/version.hh>
16#include <dune/grid/common/gridenums.hh>
17#include <dune/grid/common/datahandleif.hh>
20#include <dune/istl/scalarproducts.hh>
42 template <
class DofVector>
43 struct ISTLScalarProductSelector
45 typedef Dune::FieldVector< typename DofVector::FieldType, DofVector::blockSize > Block;
46 typedef Dune::BlockVector< Block > type;
49 template <
class Block>
50 struct ISTLScalarProductSelector<
Dune::Fem::ISTLBlockVector< Block > >
51 :
public Dune::ScalarProduct< typename Dune::Fem::ISTLBlockVector< Block > :: DofContainerType >
53#if ! DUNE_VERSION_NEWER(DUNE_ISTL, 2, 6)
55 enum { category=Dune::SolverCategory::sequential };
58 typedef typename ISTLBlockVector< Block > :: DofContainerType type;
60#if DUNE_VERSION_NEWER(DUNE_ISTL, 2, 6)
61 Dune::SolverCategory::Category category ()
const override {
return SolverCategory::sequential; }
68 template<
class DiscreteFunction >
71 :
public ISTLScalarProductSelector< typename DiscreteFunction :: DofVectorType >
78 typedef typename DiscreteFunctionType :: DiscreteFunctionSpaceType
89 typedef typename DiscreteFunctionSpaceType :: BlockMapperType
MapperType;
95 typedef typename Dune::FieldTraits< RangeFieldType >::real_type
real_type;
108 template <
class OtherDiscreteFunctionType >
111 assert(x.space() == y.space());
112 assert(x.space() ==
space());
113 return dotProduct( x.dofVector(), y.dofVector() );
118 return space().auxiliaryDofs();
123 template <
class DofVector,
class OtherDofVector >
126 typedef typename DiscreteFunctionSpaceType::LocalBlockIndices LocalBlockIndices;
130 Hybrid::forEach( LocalBlockIndices(), [ &x, &y, &scp, i ] (
auto &&j ) { scp += x[ i ][ j ] * y[ i ][ j ]; } );
131 return space().gridPart().comm().sum( scp );
136 typedef typename ISTLScalarProductSelector< typename DiscreteFunction :: DofVectorType > :: type BlockVectorType;
140 virtual field_type dot (
const BlockVectorType& x,
141 const BlockVectorType& y)
const
147 virtual real_type norm(
const BlockVectorType& x )
const
153 void deleteNonInterior( BlockVectorType& x)
const
158 const bool deleteGhostEntries = (
space().gridPart().grid().leafGridView().overlapSize( 0 ) == 0) && !
space().continuous();
161 if( deleteGhostEntries )
167 for(
int auxiliary = 0; auxiliary<auxiliarySize; ++auxiliary)
Dune::FieldTraits< RangeFieldType >::real_type real_type
Definition: common/scalarproducts.hh:95
const DiscreteFunctionSpaceType & space_
Definition: common/scalarproducts.hh:173
const AuxiliaryDofsType & auxiliaryDofs() const
Definition: common/scalarproducts.hh:116
const DiscreteFunctionSpaceType & space() const
Definition: common/scalarproducts.hh:102
static PrimaryDofs< AuxiliaryDofs > primaryDofs(const AuxiliaryDofs &auxiliaryDofs)
Definition: auxiliarydofs.hh:341
RangeFieldType scalarProductDofs(const DiscreteFunctionType &x, const OtherDiscreteFunctionType &y) const
evaluate scalar product and omit auxiliary nodes
Definition: common/scalarproducts.hh:109
AuxiliaryDofs< typename DiscreteFunctionSpaceType::GridPartType, MapperType > AuxiliaryDofsType
Definition: common/scalarproducts.hh:92
RangeFieldType field_type
Definition: common/scalarproducts.hh:94
DiscreteFunctionSpaceType::BlockMapperType MapperType
type of used mapper
Definition: common/scalarproducts.hh:89
DiscreteFunction DiscreteFunctionType
Definition: common/scalarproducts.hh:75
ParallelScalarProduct(const DiscreteFunctionSpaceType &space)
constructor taking space
Definition: common/scalarproducts.hh:98
RangeFieldType dotProduct(const DofVector &x, const OtherDofVector &y) const
evaluate scalar product on dofVector and omit auxiliary nodes
Definition: common/scalarproducts.hh:124
int size() const
return number of auxiliary dofs
Definition: auxiliarydofs.hh:122
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field
Definition: common/scalarproducts.hh:86
DiscreteFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of the discrete function space
Definition: common/scalarproducts.hh:79
double sqrt(const Dune::Fem::Double &v)
Definition: double.hh:977
Dune::Fem::Double abs(const Dune::Fem::Double &a)
Definition: double.hh:942
Definition: bindguard.hh:11
static void forEach(IndexRange< T, sz > range, F &&f)
Definition: hybrid.hh:129
Definition: common/scalarproducts.hh:73
In parallel computations the dofs of a discrete function are made up by all primary dofs....
Definition: auxiliarydofs.hh:47