DUNE PDELab (2.8)

gridfunctionadapter.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_PDELAB_GRIDFUNCTIONSPACE_GRIDFUNCTIONADAPTER_HH
4#define DUNE_PDELAB_GRIDFUNCTIONSPACE_GRIDFUNCTIONADAPTER_HH
5
6#include <dune/pdelab/common/function.hh>
7
8namespace Dune {
9 namespace PDELab {
10
16 template<typename T1, typename T2>
19 Dune::PDELab::GridFunctionTraits<typename T1::Traits::GridViewType,
20 typename T1::Traits::RangeFieldType,
21 1,
22 Dune::FieldVector<typename T1::Traits::RangeFieldType,1> >,
23 DifferenceAdapter<T1,T2> >
24 {
25 public:
26 typedef Dune::PDELab::GridFunctionTraits<typename T1::Traits::GridViewType,
27 typename T1::Traits::RangeFieldType,
29
31 DifferenceAdapter (const T1& t1_, const T2& t2_) : t1(t1_), t2(t2_) {}
32
34 inline void evaluate (const typename Traits::ElementType& e,
35 const typename Traits::DomainType& x,
36 typename Traits::RangeType& y) const
37 {
38 typename Traits::RangeType y1;
39 t1.evaluate(e,x,y1);
40 typename Traits::RangeType y2;
41 t2.evaluate(e,x,y2);
42 y1 -= y2;
43 y = y1;
44 }
45
46 inline const typename Traits::GridViewType& getGridView () const
47 {
48 return t1.getGridView();
49 }
50
51 private:
52 const T1& t1;
53 const T2& t2;
54 };
55
56
62 template<typename T1, typename T2>
65 Dune::PDELab::GridFunctionTraits<typename T1::Traits::GridViewType,
66 typename T1::Traits::RangeFieldType,
67 1,
68 Dune::FieldVector<typename T1::Traits::RangeFieldType,1> >,
69 DifferenceSquaredAdapter<T1,T2> >
70 {
71 public:
72 typedef Dune::PDELab::GridFunctionTraits<typename T1::Traits::GridViewType,
73 typename T1::Traits::RangeFieldType,
75
77 DifferenceSquaredAdapter (const T1& t1_, const T2& t2_) : t1(t1_), t2(t2_) {}
78
80 inline void evaluate (const typename Traits::ElementType& e,
81 const typename Traits::DomainType& x,
82 typename Traits::RangeType& y) const
83 {
84 typename T1::Traits::RangeType y1;
85 t1.evaluate(e,x,y1);
86 typename T2::Traits::RangeType y2;
87 t2.evaluate(e,x,y2);
88 y1 -= y2;
89 y = y1.two_norm2();
90 }
91
92 inline const typename Traits::GridViewType& getGridView () const
93 {
94 return t1.getGridView();
95 }
96
97 private:
98 const T1& t1;
99 const T2& t2;
100 };
101
102 }
103}
104#endif
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Adapter returning f1(x)-f2(x) for two given grid functions.
Definition: gridfunctionadapter.hh:24
DifferenceAdapter(const T1 &t1_, const T2 &t2_)
constructor
Definition: gridfunctionadapter.hh:31
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeType &y) const
Evaluate the GridFunction at given position.
Definition: gridfunctionadapter.hh:34
Adapter returning ||f1(x)-f2(x)||^2 for two given grid functions.
Definition: gridfunctionadapter.hh:70
DifferenceSquaredAdapter(const T1 &t1_, const T2 &t2_)
constructor
Definition: gridfunctionadapter.hh:77
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &x, typename Traits::RangeType &y) const
Evaluate the GridFunction at given position.
Definition: gridfunctionadapter.hh:80
leaf of a function tree
Definition: function.hh:302
Dune namespace.
Definition: alignedallocator.hh:11
traits class holding the function signature, same as in local function
Definition: function.hh:183
GV::Traits::template Codim< 0 >::Entity ElementType
codim 0 entity
Definition: function.hh:119
GV GridViewType
The type of the grid view the function lives on.
Definition: function.hh:116
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)