DUNE-ACFEM (2.5.1)

zerofunctional.hh
1#ifndef __DUNE_ACFEM_ZERO_FUNCTIONAL_HH__
2#define __DUNE_ACFEM_ZERO_FUNCTIONAL_HH__
3
4#include "functionalexpressionbase.hh"
5
6namespace Dune {
7
8 namespace ACFem {
9
10// #define FUNCTIONAL_TESTING 1
11
20 template<class DiscreteFunctionSpace>
21 class ZeroFunctional;
22
23 template<class DiscreteFunctionSpace>
24 class LocalZeroFunctional;
25
26 template<class DiscreteFunctionSpace>
27 struct ZeroFunctionalTraits
28 : public LinearFunctionalTraitsDefault<ZeroFunctional<DiscreteFunctionSpace>,
29 LocalZeroFunctional<DiscreteFunctionSpace> >
30 {};
31
38 template<class DiscreteFunctionSpace>
40 : public ZeroFunctionalExpression<DiscreteFunctionSpace,
41 ZeroFunctionalTraits<DiscreteFunctionSpace> >
42 {
43 public:
44 typedef ZeroFunctionalTraits<DiscreteFunctionSpace> TraitsType;
45 private:
47 typedef ZeroFunctionalExpression<DiscreteFunctionSpace, TraitsType> BaseType;
48 public:
49 typedef typename TraitsType::LocalFunctionalType LocalFunctionalType;
50 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
51 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
52 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
53 typedef typename DiscreteFunctionSpace::FunctionSpaceType FunctionSpaceType;
54 typedef typename FunctionSpaceType::RangeFieldType FieldType;
55 typedef FieldType RangeType;
56
57 ZeroFunctional(const DiscreteFunctionSpaceType& space)
58 : BaseType(space)
59 {}
60
61#if !FUNCTIONAL_TESTING
62 template<class DFTraits>
63 RangeType operator()(const Fem::DiscreteFunctionInterface<DFTraits>& arg) const
64 {
65 static_assert(std::is_same<DiscreteFunctionSpaceType, typename DFTraits::DiscreteFunctionSpaceType>::value,
66 "Invalid Argument");
67 return 0;
68 }
69
70 template<class DFTraits>
71 void coefficients(Fem::DiscreteFunctionInterface<DFTraits>& coeffs)
72 {
73 static_assert(std::is_same<DiscreteFunctionSpaceType, typename DFTraits::DiscreteFunctionSpaceType>::value,
74 "Invalid Argument");
75 coeffs.clear();
76 }
77#else
78 using BaseType::operator();
79 using BaseType::coefficients;
80#endif
81 using BaseType::localFunctional;
82
83 std::string name() const
84 {
85 return "<0,...>";
86 }
87 };
88
89 template<class DiscreteFunctionSpace>
90 class LocalZeroFunctional
91 : public LocalLinearFunctionalDefault<DiscreteFunctionSpace,
92 ZeroFunctionalTraits<DiscreteFunctionSpace> >
93 {
94 typedef LocalZeroFunctional ThisType;
95 typedef ZeroFunctional<DiscreteFunctionSpace> FunctionalType;
96 typedef
97 LocalLinearFunctionalDefault<DiscreteFunctionSpace,
98 ZeroFunctionalTraits<DiscreteFunctionSpace> >
99 BaseType;
100 friend FunctionalType;
101 public:
102 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
103 //typedef typename DiscreteFunctionType::LocalFunctionType LocalFunctionType;
104 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
105 //typedef LocalFunctionType LocalDomainFunctionType;
106 typedef typename DiscreteFunctionSpaceType::RangeFieldType FieldType;
107 typedef FieldType RangeType;
108
109 public:
110 LocalZeroFunctional(const FunctionalType& zero)
111 : BaseType(zero)
112 {}
113
114 LocalZeroFunctional(const EntityType& entity, const FunctionalType& zero)
115 : BaseType(entity, zero)
116 {}
117
118 template<class LocalFunction>
119 RangeType operator()(const LocalFunction& arg) const
120 {
121 return 0;
122 }
123
124 template<class LocalFunction>
125 void coefficients(const RangeType& c, LocalFunction& coeffs) const
126 {
127 // nothing
128 }
129
130 template<class LocalFunction>
131 void coefficients(LocalFunction& coeffs)
132 {
133 // nothing;
134 }
135
136 using BaseType::functional;
137 using BaseType::entity;
138
139 protected:
140 using BaseType::entity_;
141 };
142
144
146
147 } // namespace ACFem
148
149} // namespace Dune
150
151#endif // __DUNE_ACFEM_ZERO_FUNCTIONAL_HH__
Default implementation for linear functionals.
Definition: linearfunctional.hh:132
Interface class for a discrete linear functional.
Definition: linearfunctional.hh:52
Default implementation for LocalLinearFunctional.
Definition: linearfunctional.hh:362
This is the famous "do-nothing" functional.
Definition: zerofunctional.hh:42
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)