DUNE-FEM (unstable)

preconditionfunctionwrapper.hh
1#ifndef DUNE_FEM_SOLVER_PRECONDITIONFUNCTIONWRAPPER_HH
2#define DUNE_FEM_SOLVER_PRECONDITIONFUNCTIONWRAPPER_HH
3
4#include <functional>
5
6#include <dune/fem/operator/common/operator.hh>
7
8namespace Dune
9{
10 namespace Fem
11 {
20 template <class DomainFunction, class RangeFunction = DomainFunction>
22 : public virtual Operator< DomainFunction, RangeFunction >
23 {
24 public:
25 typedef DomainFunction DomainFunctionType;
26 typedef RangeFunction RangeFunctionType;
27
28 typedef std::reference_wrapper< const DomainFunctionType > ConstDomainDFType;
29 typedef std::reference_wrapper< RangeFunctionType > RangeDFType;
30 typedef std::function< void( ConstDomainDFType& , RangeDFType& ) > PreconditionerFunctionType;
31
32 protected:
33 const PreconditionerFunctionType& preconditioner_; // function given from Python side
34 public:
35 PreconditionerFunctionWrapper( const PreconditionerFunctionType& pre )
36 : preconditioner_( pre ) {}
37
38 virtual void operator() ( const DomainFunctionType &u, RangeFunctionType &v ) const final override
39 {
40 // convert to reference_wrapper to avoid copying
41 ConstDomainDFType uR( u );
42 RangeDFType vR( v );
43
44 // callback to python applying preconditioner
45 preconditioner_( uR, vR );
46 }
47 };
48
49 } // end namespace Fem
50
51} // end namespace Dune
52#endif
Wrapper for functions passed from Python side that implements a preconditioner.
Definition: preconditionfunctionwrapper.hh:23
Dune namespace.
Definition: alignedallocator.hh:13
abstract operator
Definition: operator.hh:34
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)