1#ifndef DUNE_FEM_OPERATOR_LINEAR_ISTLADAPTER_HH
2#define DUNE_FEM_OPERATOR_LINEAR_ISTLADAPTER_HH
9#include <dune/fem/function/blockvectorfunction.hh>
10#include <dune/fem/operator/matrix/istlpreconditioner.hh>
21 template<
class Operator >
22 class ISTLLinearOperatorAdapter
23 :
public Dune::LinearOperator< typename Operator::DomainFunctionType::DofStorageType, typename Operator::RangeFunctionType::DofStorageType >
25 typedef ISTLLinearOperatorAdapter< Operator > ThisType;
32 typedef Operator OperatorType;
34 typedef typename DomainFunctionType::DiscreteFunctionSpaceType DomainFunctionSpaceType;
35 typedef typename RangeFunctionType::DiscreteFunctionSpaceType RangeFunctionSpaceType;
37 typedef typename BaseType::domain_type domain_type;
38 typedef typename BaseType::range_type range_type;
39 typedef typename BaseType::field_type field_type;
41 ISTLLinearOperatorAdapter (
const OperatorType &op,
42 const DomainFunctionSpaceType &domainSpace,
43 const RangeFunctionSpaceType &rangeSpace )
45 domainSpace_( domainSpace ),
46 rangeSpace_( rangeSpace )
49 virtual void apply (
const domain_type &x, range_type &y )
const override
51 const DomainFunctionType fx(
"ISTLLinearOperatorAdapter::apply::x", domainSpace_, x );
52 RangeFunctionType fy(
"ISTLLinearOperatorAdapter::apply::y", rangeSpace_, y );
56 virtual void applyscaleadd ( field_type alpha,
const domain_type &x, range_type &y )
const override
58 const DomainFunctionType fx(
"ISTLLinearOperatorAdapter::applyscaleadd::x", domainSpace_, x );
59 RangeFunctionType fy(
"ISTLLinearOperatorAdapter::applyscaleadd::y", rangeSpace_ );
61 y.axpy( alpha, fy.blockVector() );
67 const OperatorType &op_;
68 const DomainFunctionSpaceType &domainSpace_;
69 const RangeFunctionSpaceType &rangeSpace_;
72 template<
class Operator >
73 class ISTLMatrixFreeOperatorAdapter :
public ISTLLinearOperatorAdapter< Operator >
75 typedef ISTLMatrixFreeOperatorAdapter< Operator > ThisType;
76 typedef ISTLLinearOperatorAdapter< Operator > BaseType;
82 typedef Operator OperatorType;
84 typedef typename DomainFunctionType::DiscreteFunctionSpaceType DomainFunctionSpaceType;
85 typedef typename RangeFunctionType::DiscreteFunctionSpaceType RangeFunctionSpaceType;
88 struct IsISTLBlockVectorDiscreteFunction
90 static const bool value = false ;
93 template <
class Space,
class Block>
94 struct IsISTLBlockVectorDiscreteFunction< ISTLBlockVectorDiscreteFunction< Space, Block > >
96 static const bool value = true ;
100 static_assert( IsISTLBlockVectorDiscreteFunction< DomainFunctionType > :: value,
101 "ISTLMatrixFreeOperatorAdapter only works with ISTLBlockVectorDiscreteFunction" );
102 static_assert( IsISTLBlockVectorDiscreteFunction< RangeFunctionType > :: value,
103 "ISTLMatrixFreeOperatorAdapter only works with ISTLBlockVectorDiscreteFunction" );
105 typedef typename BaseType::domain_type domain_type;
106 typedef typename BaseType::range_type range_type;
107 typedef typename BaseType::field_type field_type;
109 typedef Fem::ParallelScalarProduct< RangeFunctionType > ParallelScalarProductType;
110 typedef Fem::IdentityPreconditionerWrapper< domain_type, range_type > PreconditionAdapterType;
113 ISTLMatrixFreeOperatorAdapter (
const OperatorType &op,
114 const DomainFunctionSpaceType &domainSpace,
115 const RangeFunctionSpaceType &rangeSpace )
116 : BaseType( op, domainSpace, rangeSpace ),
122 ISTLMatrixFreeOperatorAdapter (
const ISTLMatrixFreeOperatorAdapter& other )
124 scp_( other.rangeSpace_ ),
129 PreconditionAdapterType& preconditionAdapter() {
return preconditioner_; }
131 const PreconditionAdapterType& preconditionAdapter()
const {
return preconditioner_; }
133 virtual double residuum(
const range_type& rhs, domain_type& x)
const
135 range_type tmp( rhs );
141 return scp_.norm(tmp);
147 ParallelScalarProductType& scp()
const {
return scp_; }
150 double averageCommTime ()
const {
return 0; }
153 mutable ParallelScalarProductType scp_;
154 PreconditionAdapterType preconditioner_;
A linear operator.
Definition: operators.hh:68
Various macros to work with Dune module version numbers.
Dune namespace.
Definition: alignedallocator.hh:13
Define general, extensible interface for operators. The available implementation wraps a matrix.
DomainFunction DomainFunctionType
type of discrete function in the operator's domain
Definition: operator.hh:36
RangeFunction RangeFunctionType
type of discrete function in the operator's range
Definition: operator.hh:38
Category
Definition: solvercategory.hh:23
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:25