dune-fem  2.4.1-rc
istladapter.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_OPERATOR_LINEAR_ISTLADAPTER_HH
2 #define DUNE_FEM_OPERATOR_LINEAR_ISTLADAPTER_HH
3 
4 #if HAVE_DUNE_ISTL
5 
6 #include <dune/istl/operators.hh>
7 
8 namespace Dune
9 {
10 
11  namespace Fem
12  {
13 
14  // ISTLLinearOperatorAdapter
15  // -------------------------
16 
17  template< class Operator >
18  class ISTLLinearOperatorAdapter
19  : public Dune::LinearOperator< typename Operator::DomainFunctionType::DofStorageType, typename Operator::RangeFunctionType::DofStorageType >
20  {
21  typedef ISTLLinearOperatorAdapter< Operator > ThisType;
22  typedef Dune::LinearOperator< typename Operator::DomainFunctionType::DofStorageType, typename Operator::RangeFunctionType::DofStorageType > BaseType;
23 
24  typedef typename Operator::DomainFunctionType DomainFunctionType;
25  typedef typename Operator::RangeFunctionType RangeFunctionType;
26 
27  public:
28  enum {category=SolverCategory::sequential};
29 
30  typedef Operator OperatorType;
31 
32  typedef typename DomainFunctionType::DiscreteFunctionSpaceType DomainFunctionSpaceType;
33  typedef typename RangeFunctionType::DiscreteFunctionSpaceType RangeFunctionSpaceType;
34 
35  typedef typename BaseType::domain_type domain_type;
36  typedef typename BaseType::range_type range_type;
37  typedef typename BaseType::field_type field_type;
38 
39  ISTLLinearOperatorAdapter ( const OperatorType &op,
40  const DomainFunctionSpaceType &domainSpace,
41  const RangeFunctionSpaceType &rangeSpace )
42  : op_( op ),
43  domainSpace_( domainSpace ),
44  rangeSpace_( rangeSpace )
45  {}
46 
47  virtual void apply ( const domain_type &x, range_type &y ) const
48  {
49  const DomainFunctionType fx( "ISTLLinearOperatorAdapter::apply::x", domainSpace_, x );
50  RangeFunctionType fy( "ISTLLinearOperatorAdapter::apply::y", rangeSpace_, y );
51  op_( fx, fy );
52  }
53 
54  virtual void applyscaleadd ( field_type alpha, const domain_type &x, range_type &y ) const
55  {
56  const DomainFunctionType fx( "ISTLLinearOperatorAdapter::applyscaleadd::x", domainSpace_, x );
57  RangeFunctionType fy( "ISTLLinearOperatorAdapter::applyscaleadd::y", rangeSpace_ );
58  op_( fx, fy );
59  y.axpy( alpha, fy.blockVector() );
60  }
61 
62  private:
63  const OperatorType &op_;
64  const DomainFunctionSpaceType &domainSpace_;
65  const RangeFunctionSpaceType &rangeSpace_;
66  };
67 
68  } // namespace Fem
69 
70 } // namespace Dune
71 
72 #endif // #if HAVE_DUNE_ISTL
73 
74 #endif // #ifndef DUNE_FEM_OPERATOR_LINEAR_ISTLADAPTER_HH
RangeFunction RangeFunctionType
type of discrete function in the operator&#39;s range
Definition: operator.hh:30
Definition: coordinate.hh:4
DomainFunction DomainFunctionType
type of discrete function in the operator&#39;s domain
Definition: operator.hh:28