1#ifndef __DUNE_ACFEM_GRIDFUNCTIONWRAPPEREXPRESSION_HH__
2#define __DUNE_ACFEM_GRIDFUNCTIONWRAPPEREXPRESSION_HH__
4#include "../functions/gridfunctionwrapper.hh"
5#include "../functions/functionexpression.hh"
6#include "../functions/gridfunctionexpressionbase.hh"
7#include "../expressions/parameterexpression.hh"
45 template<
class UnOp,
class Function>
46 class UnaryGridFunctionExpression;
49 template<
class BinOp,
class LeftFunction,
class RightFunction>
50 class BinaryGridFunctionExpression;
55 template<
class Gr
idFunction,
class Gr
idPart>
56 struct EssGridFunction
58 typedef GridFunctionWrapper<GridFunction, GridPart> WrappedFunctionType;
60 hasLocalFunction = std::is_base_of<Fem::HasLocalFunction, GridFunction>::value
63 template<
bool hasLF,
class dummy =
void>
67 struct Helper<true, dummy>
69 typedef GridFunction FunctionType;
70 static const FunctionType& construct(
const WrappedFunctionType& arg)
72 return arg.function();
77 struct Helper<false, dummy>
79 typedef WrappedFunctionType FunctionType;
80 static const FunctionType& construct(
const WrappedFunctionType& arg)
86 typedef Helper<hasLocalFunction> HelperType;
87 typedef typename HelperType::FunctionType FunctionType;
88 static const FunctionType& construct(
const WrappedFunctionType& arg)
90 return HelperType::construct(arg);
95 template<
class Gr
idFunction,
class Gr
idPart>
96 const typename EssGridFunction<GridFunction, GridPart>::FunctionType&
97 asEssGridFct(
const GridFunctionWrapper<GridFunction, GridPart>& arg)
99 return EssGridFunction<GridFunction, GridPart>::construct(arg);
104 template<
class Gr
idFunction,
class Gr
idPart>
106 asExprArg(
const GridFunctionWrapper<GridFunction, GridPart>& arg)
115 template<
class Function,
class Gr
idPart>
120 typedef decltype(-asExprArg(f_)) InnerExpressionType;
121 typedef GridPart GridPartType;
124 auto inner(-asExprArg(f_));
126 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
130 template<
class Function,
class Gr
idPart>
139 template<
class Left,
class Right,
class Gr
idPart>
145 typedef decltype(asExprArg(f_) + asExprArg(g_)) InnerExpressionType;
146 typedef GridPart GridPartType;
149 auto inner(asExprArg(f_) + asExprArg(g_));
151 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
155 template<
class Left,
class Right,
class Gr
idPart>
161 typedef decltype(asExprArg(f_) - asExprArg(g_)) InnerExpressionType;
162 typedef GridPart GridPartType;
165 auto inner(asExprArg(f_) - asExprArg(g_));
167 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
171 template<
class Function,
class Gr
idPart>
173 auto operator*(
const typename Function::RangeFieldType& s_,
177 typedef decltype(s_ * asExprArg(f_)) InnerExpressionType;
178 typedef GridPart GridPartType;
181 auto inner(s_ * asExprArg(f_));
183 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
187 template<
class Function,
class Gr
idPart>
190 const typename Function::RangeFieldType& s_)
197 template<
class Parameter,
class Function,
class Gr
idPart>
203 typedef decltype(
asImp(p_) * asExprArg(f_)) InnerExpressionType;
204 typedef GridPart GridPartType;
207 auto inner(
asImp(p_) * asExprArg(f_));
209 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
213 template<
class Parameter,
class Function,
class Gr
idPart>
217 ->
decltype(
asImp(p_) * f_)
219 return asImp(p_) * f_;
223 template<
class Field,
class Parameter,
class Function,
class Gr
idPart>
225 auto operator*(
const BinaryParameterExpression<SMultiplyOperation, Field, Parameter>& p_,
227 ->
decltype(p_.left() * (p_.right() * f_))
229 return p_.left() * (p_.right() * f_);
233 template<
class Left,
class Right,
class Gr
idPart>
239 typedef decltype(asExprArg(f_) * asExprArg(g_)) InnerExpressionType;
240 typedef GridPart GridPartType;
243 auto inner(asExprArg(f_) * asExprArg(g_));
245 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
249 template<
class Left,
class Right,
class Gr
idPart>
255 typedef decltype(asExprArg(f_) / asExprArg(g_)) InnerExpressionType;
256 typedef GridPart GridPartType;
259 auto inner(asExprArg(f_) / asExprArg(g_));
261 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
265 template<
class Function,
class Gr
idPart>
267 auto operator/(
const typename Function::RangeFieldType& s_,
271 typedef decltype(s_ / asExprArg(f_)) InnerExpressionType;
272 typedef GridPart GridPartType;
275 auto inner(s_ / asExprArg(f_));
277 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
281 template<
class Parameter,
class Function,
class Gr
idPart>
287 typedef decltype(
asImp(p_) / asExprArg(f_)) InnerExpressionType;
288 typedef GridPart GridPartType;
291 auto inner(
asImp(p_) / asExprArg(f_));
293 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
297 template<
class Function,
class Gr
idPart>
302 typedef decltype(exp(asExprArg(f_))) InnerExpressionType;
305 auto inner(exp(asExprArg(f_)));
307 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
311 template<
class Function,
class Gr
idPart>
316 typedef decltype(
log(asExprArg(f_))) InnerExpressionType;
319 auto inner(
log(asExprArg(f_)));
321 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
325 template<
class Function,
class Gr
idPart>
330 typedef decltype(sqrt(asExprArg(f_))) InnerExpressionType;
333 auto inner(sqrt(asExprArg(f_)));
335 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
339 template<
class Function,
class Gr
idPart>
344 typedef decltype(sqr(asExprArg(f_))) InnerExpressionType;
347 auto inner(sqr(asExprArg(f_)));
349 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
353 template<
class Function,
class Gr
idPart>
358 typedef decltype(sin(asExprArg(f_))) InnerExpressionType;
361 auto inner(sin(asExprArg(f_)));
363 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
367 template<
class Function,
class Gr
idPart>
372 typedef decltype(cos(asExprArg(f_))) InnerExpressionType;
375 auto inner(cos(asExprArg(f_)));
377 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
381 template<
class Function,
class Gr
idPart>
386 typedef decltype(tan(asExprArg(f_))) InnerExpressionType;
389 auto inner(tan(asExprArg(f_)));
391 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
395 template<
class Function,
class Gr
idPart>
400 typedef decltype(atan(asExprArg(f_))) InnerExpressionType;
403 auto inner(atan(asExprArg(f_)));
405 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
409 template<
class Function,
class Gr
idPart>
414 typedef decltype(asin(asExprArg(f_))) InnerExpressionType;
417 auto inner(asin(asExprArg(f_)));
419 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
423 template<
class Function,
class Gr
idPart>
428 typedef decltype(acos(asExprArg(f_))) InnerExpressionType;
431 auto inner(acos(asExprArg(f_)));
433 return ExpressionType(inner.name(), inner, f_.gridPart(), inner.space().order());
A special version of Fem::GridFunctionAdapter which stores a copy to the function,...
Definition: gridfunctionwrapper.hh:51
Parameters are quasi-constant quantities, like the time-step size in one time-step when solving trans...
Definition: parameterinterface.hh:80
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
static UnaryGridFunctionExpression< LogOperation, Function > log(const Fem::Function< typename Function::FunctionSpaceType, Function > &f_)
Component-wise logarithm, log(f)(x) = [log(f(x)_0),...,log(f(x)_N].
Definition: gridfunctionexpression.hh:2844
static const Fem::Function< typename GridFunction::FunctionSpaceType, GridFunction > & asExprFunction(const GridFunction &arg)
Cast to the proper underlying expression class; for the generic case this is just the underlying Fem:...
Definition: gridfunctionexpression.hh:61
BinaryParameterExpression< MultiplyOperation, Left, Right > operator*(const ParameterInterface< Left > &left, const ParameterInterface< Right > &right)
Scalar product between parameters.
Definition: parameterexpression.hh:321