DUNE-ACFEM (2.5.1)

functionalexpression.hh
1#ifndef __DUNE_ACFEM_FUNCTIONAL_EXPRESSIONS_HH__
2#define __DUNE_ACFEM_FUNCTIONAL_EXPRESSIONS_HH__
3
4#include "functionalexpressionbase.hh"
5#include "../../expressions/parameterexpression.hh"
6
7namespace Dune {
8
9 namespace ACFem {
10
34 template<class UnOp, class Functional>
35 class UnaryFunctionalExpression;
36
37 template<class UnOp, class Functional>
38 class UnaryLocalFunctionalExpression;
39
40 template<class BinOp, class LeftFunctionional, class RightFunctionional>
41 class BinaryFunctionalExpression;
42
43 template<class BinOp, class LeftFunctionional, class RightFunctionional>
44 class BinaryLocalFunctionalExpression;
45
46 template<class UnOp>
47 struct UnaryFunctionalExpressionOperation
48 {};
49
50 template<>
51 struct UnaryFunctionalExpressionOperation<MinusOperation>
52 {
53 template<class Scalar>
54 static Scalar apply(const Scalar& s)
55 {
56 return -s;
57 }
58 };
59
60 template<>
61 struct UnaryFunctionalExpressionOperation<IdentityOperation>
62 {
63 template<class Scalar>
64 static Scalar apply(const Scalar& s)
65 {
66 return s;
67 }
68 };
69
71 template<class UnOp, class Functional>
73 : public LinearFunctionalTraitsDefault<UnaryFunctionalExpression<UnOp, Functional>,
74 UnaryLocalFunctionalExpression<UnOp, Functional> >
75 {};
76
77 template<class UnOp, class Functional>
78 class UnaryFunctionalExpression
79 : public DiscreteLinearFunctionalExpression<typename Functional::DiscreteFunctionSpaceType,
80 UnaryFunctionalExpressionTraits<UnOp, Functional> >
81 {
82 typedef UnOp OpType;
83 typedef UnaryFunctionalExpression ThisType;
84 public:
85 typedef typename Functional::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
87 private:
88 typedef DiscreteLinearFunctionalExpression<DiscreteFunctionSpaceType, TraitsType> BaseType;
89 public:
90 typedef Functional ContainedExpressionType;
91 typedef typename TraitsType::LocalFunctionalType LocalFunctionalType;
92 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
93 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
94 typedef typename DiscreteFunctionSpaceType::RangeFieldType FieldType;
95 typedef FieldType RangeType;
96
97 UnaryFunctionalExpression(const ContainedExpressionType& phi)
98 : BaseType(phi.space()), functional_(phi)
99 {}
100
101 using BaseType::operator();
102 using BaseType::coefficients;
103 using BaseType::space;
104 using BaseType::localFunctional;
105
106 const ContainedExpressionType& containedExpression() const
107 {
108 return functional_();
109 }
110
111 std::string name() const
112 {
113 return OpType::name() + "(" + functional_().name() + ")";
114 }
115
116 protected:
117 ExpressionStorage<ContainedExpressionType> functional_;
118 };
119
120 template<class UnOp, class Functional>
121 class UnaryLocalFunctionalExpression
122 : public
123 LocalLinearFunctionalDefault<typename Functional::DiscreteFunctionSpaceType,
124 UnaryFunctionalExpressionTraits<UnOp, Functional> >
125 {
126 typedef UnOp OpType;
127 typedef UnaryFunctionalExpressionOperation<OpType> OperationType;
128 typedef UnaryLocalFunctionalExpression ThisType;
129 public:
130 typedef typename Functional::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
131 typedef UnaryFunctionalExpressionTraits<OpType, Functional> TraitsType;
132 typedef typename TraitsType::GlobalFunctionalType FunctionalType;
133 typedef typename TraitsType::LocalFunctionalType LocalFunctionalType;
134 private:
135 typedef LocalLinearFunctionalDefault<DiscreteFunctionSpaceType, TraitsType> BaseType;
136 protected:
137 typedef Functional ContainedFunctionalType;
138 typedef typename Functional::LocalFunctionalType ContainedLocalFunctionalType;
139 public:
140 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
141 typedef typename DiscreteFunctionSpaceType::RangeFieldType FieldType;
142 typedef FieldType RangeType;
143
144 UnaryLocalFunctionalExpression(const FunctionalType& expr)
145 : BaseType(expr), localContainedFunctional_(expr.containedExpression())
146 {}
147
148 UnaryLocalFunctionalExpression(const EntityType& entity, const FunctionalType& expr)
149 : BaseType(entity, expr),
150 localContainedFunctional_(expr.containedExpression().localFunctional(entity))
151 {}
152
153 public:
154 void init(const EntityType& entity)
155 {
156 localContainedFunctional_.init(entity);
157 BaseType::init(entity);
158 }
159
160 template<class LocalFunction>
161 RangeType operator()(const LocalFunction& arg)
162 {
163 return OperationType::apply(localContainedFunctional_(arg));
164 }
165
166 template<class LocalFunction>
167 void coefficients(const RangeType& c, LocalFunction& coeffs) const
168 {
169 localContainedFunctional_.coefficients(OperationType::apply(c), coeffs);
170 }
171
172 template<class LocalFunction>
173 void coefficients(LocalFunction& coeffs) const
174 {
176 }
177
178 using BaseType::functional;
179 using BaseType::entity;
180
181 protected:
182 ContainedLocalFunctionalType localContainedFunctional_;
183 };
184
186
187
189
190 template<class BinOp>
191 struct BinaryFunctionalExpressionOperation
192 {};
193
194 template<>
195 struct BinaryFunctionalExpressionOperation<PlusOperation>
196 {
197 template<class Field>
198 static Field apply(const Field& left, const Field& right)
199 {
200 return left + right;
201 }
202
203 template<class Field, class LeftArg, class RightArg, class LocalFunction>
204 static void apply(const Field& c, const LeftArg& left, const RightArg& right, LocalFunction& coeffs)
205 {
206 left.coefficients(c, coeffs);
207 right.coefficients(c, coeffs);
208 }
209
210 template<class Left>
211 static std::string leftName(const Left& left)
212 {
213 return left.name();
214 }
215
216 template<class Right>
217 static std::string rightName(const Right& right)
218 {
219 return right.name();
220 }
221 };
222
223 template<>
224 struct BinaryFunctionalExpressionOperation<MinusOperation>
225 {
226 template<class Field>
227 static Field apply(const Field& left, const Field& right)
228 {
229 return left - right;
230 }
231
232 template<class Field, class LeftArg, class RightArg, class LocalFunction>
233 static void apply(const Field& c, const LeftArg& left, const RightArg& right, LocalFunction& coeffs)
234 {
235 left.coefficients(c, coeffs);
236 right.coefficients(-c, coeffs);
237 }
238
239 template<class Left>
240 static std::string leftName(const Left& left)
241 {
242 return left.name();
243 }
244
245 template<class Right>
246 static std::string rightName(const Right& right)
247 {
248 return right.name();
249 }
250 };
251
252 template<>
253 struct BinaryFunctionalExpressionOperation<SMultiplyOperation>
254 {
255 template<class Field>
256 static Field apply(const Field& left, const Field& right)
257 {
258 return left * right;
259 }
260
261 template<class Field, class LocalFunctional, class LocalFunction>
262 static void apply(const Field& c, const Field& left, const LocalFunctional& phiLoc, LocalFunction& coeffs)
263 {
264 phiLoc.coefficients(c * left, coeffs);
265 }
266
267 template<class Field>
268 static std::string leftName(const Field& left)
269 {
270 std::string factorName = std::to_string(parameterValue(left));
271 if (ParameterValue<Field>::isParameter) {
272 factorName = "P(" + factorName + ")";
273 }
274 return factorName;
275 }
276
277 template<class Right>
278 static std::string rightName(const Right& right)
279 {
280 return right.name();
281 }
282 };
283
285 template<class BinOp, class LeftArg, class RightArg>
287 : public LinearFunctionalTraitsDefault<BinaryFunctionalExpression<BinOp, LeftArg, RightArg>,
288 BinaryLocalFunctionalExpression<BinOp, LeftArg, RightArg> >
289 {};
290
294 template<class BinOp, class LeftArg, class RightArg>
296 : public DiscreteLinearFunctionalExpression<typename RightArg::DiscreteFunctionSpaceType,
297 BinaryFunctionalExpressionTraits<BinOp, LeftArg, RightArg> >
298 {
299 typedef BinOp OpType;
300 typedef BinaryFunctionalExpressionOperation<OpType> OperationType;
302 public:
303 typedef typename RightArg::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
305 private:
306 typedef DiscreteLinearFunctionalExpression<DiscreteFunctionSpaceType, TraitsType> BaseType;
307 public:
308 typedef LeftArg LeftExpressionType;
309 typedef RightArg RightExpressionType;
310 typedef typename TraitsType::LocalFunctionalType LocalFunctionalType;
311 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
312 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
313 typedef typename DiscreteFunctionSpaceType::RangeFieldType FieldType;
314 typedef FieldType RangeType;
315
316 BinaryFunctionalExpression(const LeftExpressionType& left, const RightExpressionType& right)
317 : BaseType(right.space()), left_(left), right_(right)
318 {}
319
320 using BaseType::operator();
321 using BaseType::coefficients;
322 using BaseType::space;
323 using BaseType::localFunctional;
324
325 const LeftExpressionType& leftExpression() const
326 {
327 return left_();
328 }
329 const RightExpressionType& rightExpression() const
330 {
331 return right_();
332 }
333
334 std::string name() const
335 {
336 return ("(" +
337 OperationType::leftName(left_())
338 + " " +
339 OpType::name()
340 + " " +
341 OperationType::rightName(right_())
342 + ")");
343 }
344
345 protected:
348 };
349
350 template<class BinOp, class LeftArg, class RightArg>
351 class BinaryLocalFunctionalExpression
352 : public
353 LocalLinearFunctionalDefault<typename LeftArg::DiscreteFunctionSpaceType,
354 BinaryFunctionalExpressionTraits<BinOp, LeftArg, RightArg> >
355 {
356 typedef BinOp OpType;
357 typedef BinaryFunctionalExpressionOperation<OpType> OperationType;
358 typedef BinaryLocalFunctionalExpression ThisType;
359 public:
360 typedef typename LeftArg::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
362 typedef typename TraitsType::GlobalFunctionalType FunctionalType;
363 typedef typename TraitsType::LocalFunctionalType LocalFunctionalType;
364 private:
366 protected:
367 typedef LeftArg LeftExpressionType;
368 typedef RightArg RightExpressionType;
369 typedef typename LeftArg::LocalFunctionalType LeftLocalFunctionalType;
370 typedef typename RightArg::LocalFunctionalType RightLocalFunctionalType;
371 public:
372 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
373 typedef typename DiscreteFunctionSpaceType::RangeFieldType FieldType;
374 typedef FieldType RangeType;
375
376 BinaryLocalFunctionalExpression(const FunctionalType& expr)
377 : BaseType(expr),
378 leftLocalFunctional_(expr.leftExpression()),
379 rightLocalFunctional_(expr.rightExpression())
380 {}
381
382 BinaryLocalFunctionalExpression(const EntityType& entity, const FunctionalType& expr)
383 : BaseType(entity, expr),
384 leftLocalFunctional_(expr.leftExpression().localFunctional(entity)),
385 rightLocalFunctional_(expr.rightExpression().localFunctional(entity))
386 {}
387
388 public:
389 void init(const EntityType& entity)
390 {
391 leftLocalFunctional_.init(entity);
392 rightLocalFunctional_.init(entity);
393 BaseType::init(entity);
394 }
395
396 template<class LocalFunction>
397 RangeType operator()(const LocalFunction& arg)
398 {
399 return OperationType::apply(leftLocalFunctional_(arg), rightLocalFunctional_(arg));
400 }
401
402 template<class LocalFunction>
403 void coefficients(const RangeType& c, LocalFunction& coeffs) const
404 {
405 OperationType::apply(c, leftLocalFunctional_, rightLocalFunctional_, coeffs);
406 }
407
408 template<class LocalFunction>
409 void coefficients(LocalFunction& coeffs) const
410 {
412 }
413
414 using BaseType::functional;
415 using BaseType::entity;
416
417 protected:
418 LeftLocalFunctionalType leftLocalFunctional_;
419 RightLocalFunctionalType rightLocalFunctional_;
420 };
421
423 //
424 // S-multiplication by scalars and parameter
425
426 // No need to change the Traits stuff
427
434 template<class LeftArg, class RightArg>
435 class BinaryLocalFunctionalExpression<SMultiplyOperation, LeftArg, RightArg>
436 : public
437 LocalLinearFunctionalDefault<typename RightArg::DiscreteFunctionSpaceType,
438 BinaryFunctionalExpressionTraits<SMultiplyOperation, LeftArg, RightArg> >
439 {
441 typedef BinaryFunctionalExpressionOperation<OpType> OperationType;
442 typedef BinaryLocalFunctionalExpression ThisType;
443 public:
444 typedef typename RightArg::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
446 typedef typename TraitsType::GlobalFunctionalType FunctionalType;
447 typedef typename TraitsType::LocalFunctionalType LocalFunctionalType;
448 private:
450 protected:
451 typedef LeftArg LeftExpressionType;
452 typedef RightArg RightExpressionType;
453 typedef LeftExpressionType FactorType;
454 typedef typename RightArg::LocalFunctionalType SubLocalFunctionalType;
455 public:
456 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
457 typedef typename DiscreteFunctionSpaceType::RangeFieldType FieldType;
458 typedef FieldType RangeType;
459
460 BinaryLocalFunctionalExpression(const FunctionalType& expr)
461 : BaseType(expr),
462 scalar_(expr.leftExpression()),
463 localFunctional_(expr.rightExpression())
464 {}
465
466 BinaryLocalFunctionalExpression(const EntityType& entity, const FunctionalType& expr)
467 : BaseType(entity, expr),
468 scalar_(expr.leftExpression()),
469 localFunctional_(expr.rightExpression().localFunctional(entity))
470 {}
471
472 public:
473 void init(const EntityType& entity)
474 {
475 localFunctional_.init(entity);
476 BaseType::init(entity);
477 }
478
479 template<class LocalFunction>
480 RangeType operator()(const LocalFunction& arg)
481 {
482 return OperationType::apply(RangeType(parameterValue(scalar_)), localFunctional_(arg));
483 }
484
485 template<class LocalFunction>
486 void coefficients(const RangeType& c, LocalFunction& coeffs) const
487 {
488 OperationType::apply(c, RangeType(parameterValue(scalar_)), localFunctional_, coeffs);
489 }
490
491 template<class LocalFunction>
492 void coefficients(LocalFunction& coeffs) const
493 {
495 }
496
497 using BaseType::functional;
498 using BaseType::entity;
499
500 protected:
501 const FactorType& scalar_;
502 SubLocalFunctionalType localFunctional_;
503 };
504
505 //
506 //
508
509
510
511 // Operator definitions, unary operations
512
513 template<class DiscreteFunctionSpace, class Traits>
514 UnaryFunctionalExpression<MinusOperation, typename Traits::GlobalFunctionalType>
516 {
517 typedef typename Traits::GlobalFunctionalType FunctionalType;
518 const FunctionalType& phi(static_cast<const FunctionalType&>(phi_));
519
520 typedef
521 UnaryFunctionalExpression<MinusOperation, FunctionalType>
522 ExpressionType;
523
524 return ExpressionType(phi);
525 }
526
528 template<class DiscreteFunctionSpace, class Traits>
529 UnaryFunctionalExpression<IdentityOperation, typename Traits::GlobalFunctionalType>
531 {
532 typedef typename Traits::GlobalFunctionalType FunctionalType;
533 const FunctionalType& phi(static_cast<const FunctionalType&>(phi_));
534
535 typedef
536 UnaryFunctionalExpression<IdentityOperation, FunctionalType>
537 ExpressionType;
538
539 return ExpressionType(phi);
540 }
541
542 // Operator definitions, binary operations
543
545 template<class DiscreteFunctionSpace, class LeftTraits, class RightTraits>
546 BinaryFunctionalExpression<PlusOperation,
547 typename LeftTraits::GlobalFunctionalType,
548 typename RightTraits::GlobalFunctionalType>
551 {
552 typedef typename LeftTraits::GlobalFunctionalType LeftType;
553 typedef typename RightTraits::GlobalFunctionalType RightType;
554
555 const LeftType& left(static_cast<const LeftType&>(left_));
556 const RightType& right(static_cast<const RightType&>(right_));
557
558 typedef
560 ExpressionType;
561
562 return ExpressionType(left, right);
563 }
564
566 template<class DiscreteFunctionSpace, class LeftTraits, class RightTraits>
567 BinaryFunctionalExpression<MinusOperation,
568 typename LeftTraits::GlobalFunctionalType,
569 typename RightTraits::GlobalFunctionalType>
572 {
573 typedef typename LeftTraits::GlobalFunctionalType LeftType;
574 typedef typename RightTraits::GlobalFunctionalType RightType;
575
576 const LeftType& left(static_cast<const LeftType&>(left_));
577 const RightType& right(static_cast<const RightType&>(right_));
578
579 typedef
581 ExpressionType;
582
583 return ExpressionType(left, right);
584 }
585
587 template<class DiscreteFunctionSpace, class LeftTraits, class Functional>
588 auto
590 const UnaryFunctionalExpression<MinusOperation, Functional>& right_)
591 -> decltype(asImp(left_) + right_.containedExpression())
592 {
593 return asImp(left_) + right_.containedExpression();
594 }
595
597 template<class DiscreteFunctionSpace, class Functional, class RightTraits>
598 auto
599 operator+(const UnaryFunctionalExpression<MinusOperation, Functional>& left_,
601 -> decltype(asImp(right_) - left_.containedExpression())
602 {
603 return asImp(right_) - left_.containedExpression();
604 }
605
607 template<class DiscreteFunctionSpace, class LeftTraits, class Functional>
608 auto
610 const UnaryFunctionalExpression<MinusOperation, Functional>& right_)
611 -> decltype(asImp(left_) - right_.containedExpression())
612 {
613 return asImp(left_) - right_.containedExpression();
614 }
615
617 template<class Left, class Right>
618 auto
619 operator+(const UnaryFunctionalExpression<MinusOperation, Left>& left_,
620 const UnaryFunctionalExpression<MinusOperation, Right>& right_)
621 -> decltype(-(left_.containedExpression() + right_.containedExpression()))
622 {
623 return left_.containedExpression() + right_.containedExpression();
624 }
625
627 //
628 // S-Multiplication
629
631 template<class DiscreteFunctionSpace, class Traits>
632 BinaryFunctionalExpression<SMultiplyOperation,
633 const typename DiscreteFunctionSpace::RangeFieldType,
634 typename Traits::GlobalFunctionalType>
635 operator*(const typename DiscreteFunctionSpace::RangeFieldType& left_,
637 {
638 typedef typename Traits::GlobalFunctionalType FunctionalType;
639 typedef typename DiscreteFunctionSpace::RangeFieldType ScalarType;
640
641 typedef
643 const ScalarType,
644 FunctionalType>
645 ExpressionType;
646
647 const FunctionalType& right(static_cast<const FunctionalType&>(right_));
648
649 return ExpressionType(left_, right);
650 }
651
653 template<class DiscreteFunctionSpace, class Traits>
654 auto
656 const typename DiscreteFunctionSpace::RangeFieldType& right_)
657 -> decltype(right_ * asImp(left_))
658 {
659 return right_ * asImp(left_);
660 }
661
663 template<class DiscreteFunctionSpace, class Traits>
664 auto
666 const typename DiscreteFunctionSpace::RangeFieldType& right_)
667 -> decltype(asImp(left_) * (1.0/right_))
668 {
669 return asImp(left_) * (1.0/right_);
670 }
671
673 template<class Parameter, class DiscreteFunctionSpace, class Traits>
674 BinaryFunctionalExpression<SMultiplyOperation, Parameter, typename Traits::GlobalFunctionalType>
677 {
678 typedef typename Traits::GlobalFunctionalType FunctionalType;
679 typedef Parameter ScalarType;
680
681 typedef
683 ExpressionType;
684
685 const ScalarType& left(static_cast<const ScalarType&>(left_));
686 const FunctionalType& right(static_cast<const FunctionalType&>(right_));
687
688 return ExpressionType(left, right);
689 }
690
692 template<class DiscreteFunctionSpace, class Traits, class Parameter>
693 auto
695 const ParameterInterface<Parameter>& right_)
696 -> decltype(asImp(right_) * asImp(left_))
697 {
698 return asImp(right_) * asImp(left_);
699 }
700
709 template<class Field, class Functional>
710 static inline
711 auto operator*(const Field& s,
713 -> decltype((s * psi.leftExpression()) * psi.rightExpression())
714 {
715 return (s * psi.leftExpression()) * psi.rightExpression();
716 }
717
719 template<class Parameter, class Field, class Functional>
720 static inline
723 -> decltype(psi.leftExpression() * (asImp(p_) * psi.rightExpression()))
724 {
725 return psi.leftExpression() * (asImp(p_) * psi.rightExpression());
726 }
727
729 template<class Field, class Parameter, class DiscreteFunctionSpace, class Traits>
730 static inline
731 auto operator*(const BinaryParameterExpression<SMultiplyOperation, Field, Parameter>& p_,
733 -> decltype(p_.left() * (p_.right() * asImp(psi_)))
734 {
735 return p_.left() * (p_.right() * asImp(psi_));
736 }
737
739 template<class Parameter, class DiscreteFunctionSpace, class ZeroTraits>
740 static inline
741 auto
743 BinaryParameterExpression<SMultiplyOperation, typename DiscreteFunctionSpace::RangeFieldType, Parameter>& p,
744 const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits>& phi_)
745 -> decltype(*phi_)
746 {
747 return *phi_;
748 }
749
751 template<class DiscreteFunctionSpace, class Traits>
752 typename Traits::GlobalFunctionalType
753 operator*(const DiscreteLinearFunctionalExpression<DiscreteFunctionSpace, Traits>& phi_)
754 {
755 return phi_.expression();
756 }
757
765 template<class Functional>
766 auto
767 operator-(const UnaryFunctionalExpression<MinusOperation, Functional>& phi_)
768 -> decltype(*phi_.containedExpression())
769 {
770 return *phi_.containedExpression();
771 }
772
774 template<class DiscreteFunctionSpace, class Traits>
775 auto
776 operator-(const ZeroFunctionalExpression<DiscreteFunctionSpace, Traits>& phi_)
777 -> decltype(*phi_)
778 {
779 return *phi_;
780 }
781
783 template<class DiscreteFunctionSpace, class Traits, class ZeroTraits>
784 auto
786 const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits>& z_)
787 -> decltype(*asImp(phi_))
788 {
789 return *asImp(phi_);
790 }
791
793 template<class DiscreteFunctionSpace, class Traits, class ZeroTraits>
794 auto
795 operator+(const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits>& z_,
797 -> decltype(*asImp(phi_))
798 {
799 return *asImp(phi_);
800 }
801
803 template<class DiscreteFunctionSpace, class ZeroTraits1, class ZeroTraits2>
804 ZeroFunctional<DiscreteFunctionSpace>
805 operator+(const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits1>& left_,
806 const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits2>& right_)
807 {
808 return ZeroFunctional<DiscreteFunctionSpace>(left_.space());
809 }
810
812 template<class DiscreteFunctionSpace, class Traits, class ZeroTraits>
813 auto
815 const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits>& z_)
816 -> decltype(*asImp(phi_))
817 {
818 return *asImp(phi_);
819 }
820
822 template<class DiscreteFunctionSpace, class Traits, class ZeroTraits>
823 auto
824 operator-(const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits>& z_,
826 -> decltype(-asImp(phi_))
827 {
828 return -asImp(phi_);
829 }
830
832 template<class DiscreteFunctionSpace, class ZeroTraits1, class ZeroTraits2>
833 ZeroFunctional<DiscreteFunctionSpace>
834 operator-(const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits1>& left_,
835 const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits2>& right_)
836 {
837 return ZeroFunctional<DiscreteFunctionSpace>(left_.space());
838 }
839
841 template<class DiscreteFunctionSpace, class ZeroTraits>
842 auto
843 operator*(const typename DiscreteFunctionSpace::RangeFieldType& s,
844 const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits>& z)
845 -> decltype(*z)
846 {
847 return *z;
848 }
849
851 template<class DiscreteFunctionSpace, class ZeroTraits>
852 auto
853 operator*(const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits>& z,
854 const typename DiscreteFunctionSpace::RangeFieldType& s)
855 -> decltype(*z)
856 {
857 return *z;
858 }
859
861 template<class Parameter, class DiscreteFunctionSpace, class ZeroTraits>
862 auto
864 const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits>& z)
865 -> decltype(*z)
866 {
867 return *z;
868 }
869
871 template<class Parameter, class DiscreteFunctionSpace, class ZeroTraits>
872 auto
873 operator*(const ZeroFunctionalExpression<DiscreteFunctionSpace, ZeroTraits>& z,
875 -> decltype(*z)
876 {
877 return *z;
878 }
879
881
883
885
886 } // ACFem::
887
888} // Dune::
889
890#endif // __DUNE_ACFEM_FUNCTIONAL_EXPRESSIONS_HH__
Binary functional expression.
Definition: functionalexpression.hh:298
Interface class for a discrete linear functional.
Definition: linearfunctional.hh:52
Default implementation for LocalLinearFunctional.
Definition: linearfunctional.hh:362
void coefficients(const RangeType &c, LocalFunction &coeffs) const
Definition: linearfunctional.hh:443
void coefficients(LocalFunction &coeffs) const
Compute the basis representation, which means: do the assembling stuff.
Definition: linearfunctional.hh:436
void init(const EntityType &entity)
Bind to an entity.
Definition: linearfunctional.hh:403
RangeType operator()(const LocalFunction &arg) const
Compute the value.
Definition: linearfunctional.hh:410
Parameters are quasi-constant quantities, like the time-step size in one time-step when solving trans...
Definition: parameterinterface.hh:80
This is the famous "do-nothing" functional.
Definition: zerofunctional.hh:42
static auto operator/(const Fem::Function< typename Left::FunctionSpaceType, Left > &f_, const BoundarySupportedFunction< Right, RightInd > &g_) -> decltype(asBndryFct(asEssBndryFct(f_/asExprArg(g_))))
f / Wrapped(g) = Wrapped(f / g)
Definition: boundaryfunctionexpression.hh:657
const Implementation & asImp(const Fem::BartonNackmanInterface< Interface, Implementation > &arg)
Up-cast to the implementation for any Fem::BartonNackmanInterface.
Definition: expressionoperations.hh:71
ParameterValue< Value >::ResultType parameterValue(const Value &value)
Return the unaltered argument for non-parameters and otherwise the parameter value.
Definition: parameterinterface.hh:263
BinaryParameterExpression< MultiplyOperation, Left, Right > operator*(const ParameterInterface< Left > &left, const ParameterInterface< Right > &right)
Scalar product between parameters.
Definition: parameterexpression.hh:321
"No-storage", traits, stuff lives on the stack
Definition: functionalexpression.hh:289
Default traits were the local objects are not cached, but created on the fly.
Definition: linearfunctional.hh:38
Multiplication by scalars from the left.
Definition: expressionoperations.hh:257
"No-storage", traits, stuff lives on the stack
Definition: functionalexpression.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)