1#ifndef __DUNE_ACFEM_GRIDFUNCTIONEXPRESSION_HH__
2#define __DUNE_ACFEM_GRIDFUNCTIONEXPRESSION_HH__
4#include <dune/fem/version.hh>
5#include <dune/fem/function/common/discretefunction.hh>
7#include "../functions/gridfunctionexpressionbase.hh"
8#include "../functions/parameterfunction.hh"
9#include "../functions/functionoperations.hh"
10#include "../functions/functionexpression.hh"
11#include "../functions/localfunctionwrapper.hh"
12#include "../functions/gridfunctionwrapper.hh"
13#include "../functions/gridfunctionwrapperexpression.hh"
14#include "../functions/boundarysupportedfunction.hh"
15#include "../expressions/parameterinterface.hh"
16#include "../expressions/parameterexpression.hh"
58 template<
class Gr
idFunction>
60 const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>&
63 typedef Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction> Interface;
64 return static_cast<const Interface&
>(arg);
71 template<
class UnOp,
class Function>
73 const UnaryGridFunctionExpression<UnOp, Function>&
83 template<
class BinOp,
class LeftFunction,
class RightFunction>
85 const BinaryGridFunctionExpression<BinOp, LeftFunction, RightFunction>&
110 template<
class F1,
class F2>
113 typename FunctionMultiplicationResultTraits<
typename F1::FunctionSpaceType,
114 typename F2::FunctionSpaceType>::FunctionSpaceType,
115 typename F1::GridPartType>
119 FunctionMultiplicationResultTraits<
typename F1::FunctionSpaceType,
120 typename F2::FunctionSpaceType>
122 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
123 typedef typename F1::GridPartType GridPartType;
130 template<
class Gr
idFunction>
131 typename GridFunction::LocalFunctionType localFunction(
const GridFunction& f)
133 return typename GridFunction::LocalFunctionType(f);
136 template<
class DiscreteSpace,
class Dof =
typename DiscreteSpace::RangeFieldType>
137 Fem::TemporaryLocalFunction<DiscreteSpace, Dof>
138 temporaryLocalFunction(
const DiscreteSpace& space,
const Dof& dummy = Dof())
140 return Fem::TemporaryLocalFunction<DiscreteSpace, Dof>(space);
155 template<
class FunctionSpace,
class Gr
idPart>
156 FractionGridFunction<typename FunctionSpace::FunctionSpaceType::ScalarFunctionSpaceType, GridPart, 1L, 1UL>
163 return ResultType(gridPart);
183 auto zeroFunction(
const Fem::Function<typename F::FunctionSpaceType, F>& f_)
191 auto constantFunction(
const Fem::Function<typename F::FunctionSpaceType, F>& f_,
const typename F::FunctionSpaceType::RangeType& c)
203 template<
class BinOp,
class LeftFunctionType,
class RightFunctionType>
204 struct BinaryGridFunctionExpressionBaseTraits;
206 template<
class LeftFunction,
class RightFunction>
207 struct BinaryGridFunctionExpressionBaseTraits<PlusOperation, LeftFunction, RightFunction>
208 :
public BinaryFunctionExpressionTraits<PlusOperation, LeftFunction, RightFunction>
210 typedef LeftFunction LeftFunctionType;
211 typedef RightFunction RightFunctionType;
212 typedef typename LeftFunctionType::DiscreteFunctionSpaceType LeftDiscreteFunctionSpaceType;
213 typedef typename RightFunctionType::DiscreteFunctionSpaceType RightDiscreteFunctionSpaceType;
215 static_assert(std::is_same<
typename LeftFunctionType::FunctionSpaceType,
216 typename RightFunctionType::FunctionSpaceType>::value,
217 "Cannot add functions over differing function spaces");
218 static_assert(std::is_same<
typename LeftFunctionType::GridPartType,
219 typename RightFunctionType::GridPartType>::value,
220 "Cannot add functions over different grid-parts");
222 Fem::DiscreteFunctionSpaceAdapter<
typename LeftFunctionType::FunctionSpaceType,
223 typename LeftFunctionType::GridPartType>
224 DiscreteFunctionSpaceType;
228 std::integral_constant<bool, std::is_base_of<IsPieceWiseConstant, LeftFunction>::value>
229 LeftPieceWiseConstantType;
231 std::integral_constant<bool, std::is_base_of<IsPieceWiseConstant, RightFunction>::value>
232 RightPieceWiseConstantType;
234 std::integral_constant<bool, LeftPieceWiseConstantType::value && RightPieceWiseConstantType::value>
235 PieceWiseConstantType;
238 typename std::conditional<PieceWiseConstantType::value,
239 IsPieceWiseConstant, IsNotPieceWiseConstant>::type
240 PieceWiseConstantTagType;
243 constexpr static unsigned combinedOrder(
unsigned order1,
unsigned order2) {
244 return PieceWiseConstantType() ? 0 : (order1 > order2 ? order1 : order2);
248 static const unsigned int order = combinedOrder(LeftDiscreteFunctionSpaceType::polynomialOrder,
249 RightDiscreteFunctionSpaceType::polynomialOrder);
252 typedef BoundaryFunctionTraits<LeftFunction> LeftBoundaryTraits;
253 typedef BoundaryFunctionTraits<RightFunction> RightBoundaryTraits;
255 hasBoundarySupport = LeftBoundaryTraits::hasBoundarySupport || RightBoundaryTraits::hasBoundarySupport
258 typename std::conditional<hasBoundarySupport,
259 HasBoundarySupport, HasNoBoundarySupport>::type
260 BoundarySupportTagType;
262 typedef typename LeftBoundaryTraits::IndicatorType LeftIndicatorType;
263 typedef typename RightBoundaryTraits::IndicatorType RightIndicatorType;
265 typename std::remove_reference<
266 typename std::remove_const<decltype(std::declval<LeftIndicatorType>()
268 std::declval<RightIndicatorType>())>::type
273 emptySupport = ExpressionTraits<IndicatorType>::isZero,
274 globalSupport = std::is_same<IndicatorType, EntireBoundaryIndicatorType>::value
277 static const bool boundarySupported(
bool left,
bool right)
279 return globalSupport || (!emptySupport && (left || right));
282 static IndicatorType indicator(
const LeftFunction& left,
const RightFunction& right)
284 return LeftBoundaryTraits::indicator(left) || RightBoundaryTraits::indicator(right);
288 template<
class LeftFunction,
class RightFunction>
289 struct BinaryGridFunctionExpressionBaseTraits<MinusOperation, LeftFunction, RightFunction>
290 :
public BinaryGridFunctionExpressionBaseTraits<PlusOperation, LeftFunction, RightFunction>
293 template<
class LeftFunction,
class RightFunction>
294 struct BinaryGridFunctionExpressionBaseTraits<MultiplyOperation, LeftFunction, RightFunction>
296 typedef LeftFunction LeftFunctionType;
297 typedef RightFunction RightFunctionType;
298 typedef typename LeftFunctionType::FunctionSpaceType LeftFunctionSpaceType;
299 typedef typename RightFunctionType::FunctionSpaceType RightFunctionSpaceType;
302 FunctionMultiplicationResultTraits<LeftFunctionSpaceType, RightFunctionSpaceType>::FunctionSpaceType
305 typedef typename LeftFunctionType::DiscreteFunctionSpaceType LeftDiscreteFunctionSpaceType;
306 typedef typename RightFunctionType::DiscreteFunctionSpaceType RightDiscreteFunctionSpaceType;
308 typedef typename LeftDiscreteFunctionSpaceType::GridPartType GridPartType;
310 typedef Fem::DiscreteFunctionSpaceAdapter<FunctionSpaceType, GridPartType> DiscreteFunctionSpaceType;
314 std::integral_constant<bool, std::is_base_of<IsPieceWiseConstant, LeftFunction>::value>
315 LeftPieceWiseConstantType;
317 std::integral_constant<bool, std::is_base_of<IsPieceWiseConstant, RightFunction>::value>
318 RightPieceWiseConstantType;
320 std::integral_constant<bool, LeftPieceWiseConstantType::value && RightPieceWiseConstantType::value>
321 PieceWiseConstantType;
324 typename std::conditional<PieceWiseConstantType::value,
325 IsPieceWiseConstant, IsNotPieceWiseConstant>::type
326 PieceWiseConstantTagType;
329 constexpr static unsigned combinedOrder(
unsigned order1,
unsigned order2)
331 return PieceWiseConstantType() ? 0 : order1 + order2;
336 static const unsigned int order = combinedOrder(LeftDiscreteFunctionSpaceType::polynomialOrder,
337 RightDiscreteFunctionSpaceType::polynomialOrder);
340 typedef BoundaryFunctionTraits<LeftFunction> LeftBoundaryTraits;
341 typedef BoundaryFunctionTraits<RightFunction> RightBoundaryTraits;
343 hasBoundarySupport = LeftBoundaryTraits::hasBoundarySupport || RightBoundaryTraits::hasBoundarySupport
346 typename std::conditional<hasBoundarySupport,
347 HasBoundarySupport, HasNoBoundarySupport>::type
348 BoundarySupportTagType;
349 typedef typename LeftBoundaryTraits::IndicatorType LeftIndicatorType;
350 typedef typename RightBoundaryTraits::IndicatorType RightIndicatorType;
352 typename std::remove_reference<
353 typename std::remove_const<decltype(std::declval<LeftIndicatorType>()
355 std::declval<RightIndicatorType>())>::type
359 emptySupport = ExpressionTraits<IndicatorType>::isZero,
360 globalSupport = std::is_same<IndicatorType, EntireBoundaryIndicatorType>::value
363 static const bool boundarySupported(
bool left,
bool right)
365 return globalSupport || (!emptySupport && (left && right));
368 static IndicatorType indicator(
const LeftFunction& left,
const RightFunction& right)
370 return LeftBoundaryTraits::indicator(left) && RightBoundaryTraits::indicator(right);
375 template<
class BinOp,
class LeftFunction,
class RightFunction>
377 :
public BinaryGridFunctionExpressionBaseTraits<BinOp, LeftFunction, RightFunction>
380 BinaryGridFunctionExpressionBaseTraits<BinOp, LeftFunction, RightFunction>
383 typedef LeftFunction LeftFunctionType;
384 typedef RightFunction RightFunctionType;
386 typedef typename BaseType::FunctionSpaceType FunctionSpaceType;
387 typedef typename BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
389 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
390 typedef typename FunctionSpaceType::DomainFieldType DomainFieldType;
391 typedef typename FunctionSpaceType::RangeType RangeType;
392 typedef typename FunctionSpaceType::DomainType DomainType;
393 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
394 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
396 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
397 typedef typename GridPartType::GridType GridType;
398 typedef typename GridPartType::template Codim<0>::EntityType EntityType;
400 typedef typename GridPartType::template Codim<0>::IteratorType
IteratorType;
406 using BaseType::order;
407 using BaseType::combinedOrder;
416 template<
class BinOp,
class LeftFunction,
class RightFunction>
419 BinaryGridFunctionExpressionTraits<BinOp, LeftFunction, RightFunction>::FunctionSpaceType,
420 BinaryGridFunctionExpression<BinOp, LeftFunction, RightFunction> >,
424 typedef LeftFunction LeftFunctionType;
425 typedef RightFunction RightFunctionType;
431 typedef Fem::Function<typename TraitsType::FunctionSpaceType, ThisType> BaseType;
432 typedef BinOp OperationTagType;
433 typedef BinaryFunctionExpressionOperation<BinOp> OperationType;
435 typedef typename TraitsType::LeftPieceWiseConstantType LeftPieceWiseConstantType;
436 typedef typename TraitsType::RightPieceWiseConstantType RightPieceWiseConstantType;
437 typedef typename TraitsType::PieceWiseConstantType PieceWiseConstantType;
447 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
453 typedef typename DiscreteFunctionSpaceType::GridType
GridType;
455 static const int dimRange = DiscreteFunctionSpaceType::dimRange;
456 static const int dimDomain = GridPartType::GridType::dimensionworld;
457 static const int dimLocal = GridPartType::GridType::dimension;
464 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
466 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
482 using ExpressionBaseType::expressionName_;
490 const RightFunctionType &g)
498 : space_(other.space_),
499 leftFunction_(other.leftFunction_),
500 rightFunction_(other.rightFunction_)
506 OperationType::evaluate(leftFunction_(), rightFunction_(), global, result);
512 if (PieceWiseConstantType()) {
516 OperationType::jacobian(leftFunction_(), rightFunction_(), global, result,
517 LeftPieceWiseConstantType(), RightPieceWiseConstantType());
523 if (PieceWiseConstantType()) {
527 OperationType::hessian(leftFunction_(), rightFunction_(), global, result);
545 expressionName_ = operationName(OperationTagType(), leftFunction().
name(), rightFunction().
name());
546 return expressionName_;
557 return space().gridPart();
571 globalSupport = std::is_same<IndicatorType, EntireBoundaryIndicatorType>::value
578 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
585 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
591 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
592 return TraitsType::indicator(leftFunction_(), rightFunction_());
598 const LeftFunctionType& leftFunction()
const {
return leftFunction_(); }
599 const RightFunctionType& rightFunction()
const {
return rightFunction_(); }
602 ExpressionStorage<LeftFunctionType> leftFunction_;
603 ExpressionStorage<RightFunctionType> rightFunction_;
604 mutable std::string name_;
611 template<
class BinOp,
class LeftFunctionType,
class RightFunctionType>
615 typedef BinOp OperationTagType;
616 typedef BinaryFunctionExpressionOperation<BinOp> OperationType;
621 typedef typename LeftFunctionType::LocalFunctionType LeftLocalFunctionType;
622 typedef typename RightFunctionType::LocalFunctionType RightLocalFunctionType;
623 typedef typename DiscreteFunctionSpaceType::GridPartType
GridPartType;
624 typedef typename EntityType::Geometry GeometryType;
628 static const int dimRange = DiscreteFunctionSpaceType::dimRange;
629 static const int dimDomain = GridPartType::GridType::dimensionworld;
630 static const int dimLocal = GridPartType::GridType::dimension;
640 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
642 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
654 rightLocalFunction_(df.rightFunction().
localFunction(entity)),
656 order_(df.
space().order())
663 leftLocalFunction_(df.leftFunction()),
664 rightLocalFunction_(df.rightFunction()),
666 order_(df.
space().order())
670 template<
class Po
intType>
677 OperationType::evaluate(leftLocalFunction_, rightLocalFunction_, x, ret);
681 template<
class Po
intType>
684 if (DiscreteFunctionType::PieceWiseConstantType() || !supported()) {
688 OperationType::jacobian(leftLocalFunction_, rightLocalFunction_, x, ret);
692 template<
class Po
intType>
695 if (DiscreteFunctionType::PieceWiseConstantType() || !supported()) {
699 OperationType::hessian(leftLocalFunction_, rightLocalFunction_, x, ret);
703 template<
class QuadratureType,
class VectorType>
706 assert(values.size() == quadrature.nop());
707 DiscreteFunctionType::evaluateQuadratureImp(*
this, quadrature, values, values[0]);
711 int order()
const {
return order_; }
716 leftLocalFunction_.init(entity);
717 rightLocalFunction_.init(entity);
745 leftLocalFunction_(LeftLocalFunctionType(df.leftFunction())),
746 rightLocalFunction_(RightLocalFunctionType(df.rightFunction())),
747 order_(df.
space().order())
749 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
750 init(entity, intersection);
756 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
765 intersection_ = &intersection;
771 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
772 assert(intersection_);
773 return *intersection_;
789 LeftLocalFunctionType leftLocalFunction_;
790 RightLocalFunctionType rightLocalFunction_;
801 template<
class Factor,
class Function>
805 typedef Factor FactorType;
806 typedef Function FunctionType;
808 typedef typename FunctionType::FunctionSpaceType FunctionSpaceType;
809 typedef typename FunctionType::DiscreteFunctionSpaceType FunctionDiscreteFunctionSpaceType;
811 typedef typename FunctionDiscreteFunctionSpaceType::GridPartType GridPartType;
814 typedef Fem::DiscreteFunctionSpaceAdapter<FunctionSpaceType, GridPartType> DiscreteFunctionSpaceType;
816 typedef typename GridPartType::GridType GridType;
817 typedef typename GridPartType::template Codim<0>::EntityType EntityType;
819 typedef typename GridPartType::template Codim<0>::IteratorType
IteratorType;
827 isPieceWiseConstant = std::is_base_of<IsPieceWiseConstant, Function>::value
832 typename std::conditional<isPieceWiseConstant,
834 PieceWiseConstantTagType;
836 static const unsigned int order =
837 isPieceWiseConstant ? 0 : DiscreteFunctionSpaceType::polynomialOrder;
842 hasBoundarySupport = BoundaryTraits::hasBoundarySupport
845 typename std::conditional<hasBoundarySupport,
846 HasBoundarySupport, HasNoBoundarySupport>::type
847 BoundarySupportTagType;
850 typename BoundaryFunctionTraits<FunctionType>::IndicatorType
854 emptySupport = ExpressionTraits<IndicatorType>::isZero,
855 globalSupport = std::is_same<IndicatorType, EntireBoundaryIndicatorType>::value
863 template<
class Factor,
class Function>
866 BinaryGridFunctionExpression<SMultiplyOperation, Factor, Function> >,
871 typedef Fem::Function<typename Function::FunctionSpaceType, ThisType> BaseType;
876 static_assert((std::is_base_of<Fem::HasLocalFunction, Function>::value),
877 "FunctionType must be a discrete function type.");
891 isPieceWiseConstant = TraitsType::isPieceWiseConstant
901 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
907 typedef typename DiscreteFunctionSpaceType::GridType
GridType;
914 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
916 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
929 using ExpressionBaseType::expressionName_;
937 : space_(f.
space().gridPart(), f.
space().order()),
944 : space_(other.space_),
945 scalar_(other.scalar_),
946 function_(other.function_)
952 function().evaluate(global, result);
959 if (isPieceWiseConstant) {
963 function().jacobian(global, result);
970 if (isPieceWiseConstant) {
974 function().hessian(global, result);
975 for (
int k = 0; k < HessianRangeType::dimension; ++k) {
995 std::string factorName = std::to_string(
parameterValue(scalar()));
996 if (ParameterValue<FactorType>::isParameter) {
997 factorName =
"P(" + factorName +
")";
1000 return expressionName_;
1019 globalSupport = std::is_same<IndicatorType, EntireBoundaryIndicatorType>::value
1023 const IntersectionType &intersection)
const
1025 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1030 const IntersectionType &intersection)
1032 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1038 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1045 const FactorType& scalar()
const {
return scalar_(); }
1046 const ContainedFunctionType& function()
const {
return function_(); }
1049 ExpressionStorage<FactorType> scalar_;
1050 ExpressionStorage<ContainedFunctionType> function_;
1051 mutable std::string name_;
1055 template<
class FactorType,
class FunctionType>
1056 class BinaryGridFunctionExpression<SMultiplyOperation, FactorType, FunctionType>::LocalFunction
1058 typedef LocalFunction ThisType;
1059 typedef SMultiplyOperation OperationTagType;
1060 typedef BinaryFunctionExpressionOperation<SMultiplyOperation> OperationType;
1062 typedef BinaryGridFunctionExpression<SMultiplyOperation, FactorType, FunctionType>
DiscreteFunctionType;
1064 typedef typename DiscreteFunctionType::FunctionSpaceType FunctionSpaceType;
1066 typedef typename FunctionType::LocalFunctionType SubLocalFunctionType;
1067 typedef typename DiscreteFunctionSpaceType::GridPartType
GridPartType;
1068 typedef typename EntityType::Geometry GeometryType;
1071 static const int dimRange = DiscreteFunctionSpaceType::dimRange;
1072 static const int dimDomain = GridPartType::GridType::dimensionworld;
1073 static const int dimLocal = GridPartType::GridType::dimension;
1080 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
1082 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
1092 scalar_(df.scalar()),
1095 order_(df.
space().order())
1101 scalar_(df.scalar()),
1102 localFunction_(df.function()),
1104 order_(df.
space().order())
1108 template<
class Po
intType>
1115 localFunction_.evaluate(x, ret);
1120 template<
class Po
intType>
1123 if (DiscreteFunctionType::isPieceWiseConstant || !supported()) {
1127 localFunction_.jacobian(x, ret);
1132 template<
class Po
intType>
1135 if (DiscreteFunctionType::isPieceWiseConstant || !supported()) {
1139 localFunction_.hessian(x, ret);
1140 for (
int k = 0; k < HessianRangeType::dimension; ++k) {
1146 template<
class QuadratureType,
class VectorType>
1149 assert(values.size() == quadrature.nop());
1150 DiscreteFunctionType::evaluateQuadratureImp(*
this, quadrature, values, values[0]);
1156 return DiscreteFunctionType::isPieceWiseConstant ? 0 : order_;
1163 localFunction_.init(entity);
1187 : scalar_(df.scalar()),
1188 localFunction_(LocalFunctiontype(df.function())),
1189 order_(df.
space().order())
1191 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1192 init(entity, intersection);
1198 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1204 intersection_ = &intersection;
1210 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1211 assert(intersection_);
1212 return *intersection_;
1227 const FactorType& scalar_;
1228 SubLocalFunctionType localFunction_;
1240 template<
class UnOp,
class FunctionType>
1241 struct UnaryGridFunctionExpressionBaseTraits
1243 typedef typename FunctionType::FunctionSpaceType FunctionSpaceType;
1244 typedef typename FunctionType::DiscreteFunctionSpaceType FunctionDiscreteFunctionSpaceType;
1245 typedef typename FunctionDiscreteFunctionSpaceType::GridPartType GridPartType;
1247 typedef Fem::DiscreteFunctionSpaceAdapter<FunctionSpaceType, GridPartType> DiscreteFunctionSpaceType;
1249 static const unsigned int order =
1251 FunctionDiscreteFunctionSpaceType::polynomialOrder);
1254 template<
class FunctionType>
1255 struct UnaryGridFunctionExpressionBaseTraits<SquareOperation, FunctionType>
1257 typedef typename FunctionType::DiscreteFunctionSpaceType::ScalarFunctionSpaceType FunctionSpaceType;
1258 typedef typename FunctionType::DiscreteFunctionSpaceType FunctionDiscreteFunctionSpaceType;
1259 typedef typename FunctionDiscreteFunctionSpaceType::GridPartType GridPartType;
1261 typedef Fem::DiscreteFunctionSpaceAdapter<FunctionSpaceType, GridPartType> DiscreteFunctionSpaceType;
1263 static const unsigned int order = 2*FunctionDiscreteFunctionSpaceType::polynomialOrder;
1267 template <
class UnOp,
class Function>
1269 :
public UnaryGridFunctionExpressionBaseTraits<UnOp, Function>
1271 typedef UnaryGridFunctionExpressionBaseTraits<UnOp, Function> BaseType;
1272 typedef Function FunctionType;
1273 typedef typename BaseType::FunctionSpaceType FunctionSpaceType;
1275 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
1276 typedef typename FunctionSpaceType::DomainFieldType DomainFieldType;
1277 typedef typename FunctionSpaceType::RangeType RangeType;
1278 typedef typename FunctionSpaceType::DomainType DomainType;
1279 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
1281 typedef typename BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
1283 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
1284 typedef typename GridPartType::GridType GridType;
1285 typedef typename GridPartType::template Codim<0>::EntityType EntityType;
1287 typedef typename GridPartType::template Codim<0>::IteratorType
IteratorType;
1295 isPieceWiseConstant = std::is_base_of<IsPieceWiseConstant, Function>::value
1299 typename std::conditional<isPieceWiseConstant,
1301 PieceWiseConstantTagType;
1303 static const unsigned int order = isPieceWiseConstant ? 0 : BaseType::order;
1308 hasBoundarySupport = BoundaryTraits::hasBoundarySupport
1311 typename std::conditional<hasBoundarySupport,
1312 HasBoundarySupport, HasNoBoundarySupport>::type
1313 BoundarySupportTagType;
1322 template<
class UnOp,
class FunctionType>
1324 :
public GridFunctionExpression<typename UnaryGridFunctionExpressionTraits<UnOp, FunctionType>::FunctionSpaceType,
1325 UnaryGridFunctionExpression<UnOp, FunctionType> >,
1334 typedef Fem::Function<typename TraitsType::FunctionSpaceType, ThisType> BaseType;
1335 typedef UnOp OperationTagType;
1336 typedef UnaryFunctionExpressionOperation<UnOp> OperationType;
1339 static_assert((std::is_base_of<Fem::HasLocalFunction, FunctionType>::value),
1340 "FunctionType must have a LocalFunctionType type.");
1343 isPieceWiseConstant = TraitsType::isPieceWiseConstant
1354 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
1360 typedef typename DiscreteFunctionSpaceType::GridType
GridType;
1367 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
1369 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
1377 typedef typename GridPartType::IntersectionType IntersectionType;
1380 class LocalFunction;
1382 using ExpressionBaseType::expressionName_;
1396 : space_(other.space_),
1397 function_(other.function_)
1403 OperationType::evaluate(function(), global, result);
1409 if (isPieceWiseConstant) {
1413 OperationType::jacobian(function(), global, result);
1419 if (isPieceWiseConstant) {
1423 OperationType::hessian(function(), global, result);
1441 expressionName_ = operationName(OperationTagType(), function().
name());
1442 return expressionName_;
1461 globalSupport = std::is_same<IndicatorType, EntireBoundaryIndicatorType>::value
1466 const IntersectionType &intersection)
const
1468 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1474 const IntersectionType &intersection)
1476 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1482 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1489 const FunctionType& function()
const {
return function_(); }
1492 ExpressionStorage<FunctionType> function_;
1493 mutable std::string name_;
1499 template<
class UnOp,
class FunctionType>
1500 class UnaryGridFunctionExpression<UnOp, FunctionType>::LocalFunction
1502 typedef LocalFunction ThisType;
1503 typedef UnOp OperationTagType;
1504 typedef UnaryFunctionExpressionOperation<UnOp> OperationType;
1508 typedef typename DiscreteFunctionType::FunctionSpaceType FunctionSpaceType;
1511 typedef typename DiscreteFunctionSpaceType::GridPartType
GridPartType;
1512 typedef typename EntityType::Geometry GeometryType;
1515 static const int dimRange = DiscreteFunctionSpaceType::dimRange;
1516 static const int dimDomain = GridPartType::GridType::dimensionworld;
1517 static const int dimLocal = GridPartType::GridType::dimension;
1520 typedef typename DiscreteFunctionSpaceType::DomainFieldType
DomainFieldType;
1522 typedef typename DiscreteFunctionSpaceType::RangeFieldType
RangeFieldType;
1524 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
1526 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
1528 typedef typename DiscreteFunctionSpaceType::JacobianRangeType
JacobianRangeType;
1530 typedef typename DiscreteFunctionSpaceType::HessianRangeType
HessianRangeType;
1537 order_(df.
space().order())
1543 localFunction_(df.function()),
1544 order_(df.
space().order())
1548 template<
class Po
intType>
1555 OperationType::evaluate(localFunction_, x, ret);
1559 template<
class Po
intType>
1562 if (DiscreteFunctionType::isPieceWiseConstant || !supported()) {
1566 OperationType::jacobian(localFunction_, x, ret);
1570 template<
class Po
intType>
1573 if (DiscreteFunctionType::isPieceWiseConstant || !supported()) {
1577 OperationType::hessian(localFunction_, x, ret);
1581 template<
class QuadratureType,
class VectorType>
1582 void evaluateQuadrature(
const QuadratureType& quadrature, VectorType& values)
const
1584 assert(values.size() == quadrature.nop());
1585 DiscreteFunctionType::evaluateQuadratureImp(*
this, quadrature, values, values[0]);
1589 int order()
const {
return order_; }
1594 localFunction_.init(entity);
1599 localFunction_.entity();
1614 const IntersectionType &intersection,
1616 : localFunction_(LocalFunctiontype(df.function())),
1617 order_(df.
space().order())
1619 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1620 init(entity, intersection);
1624 void init(
const EntityType& entity,
const IntersectionType& intersection)
1626 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1628 BoundaryFunctionTraits<FunctionType>::init(localFunction_, entity, intersection);
1629 supported_ = BoundaryFunctionTraits<FunctionType>::supported(localFunction_);
1631 intersection_ = &intersection;
1635 const IntersectionType &intersection()
const
1637 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1638 assert(intersection_);
1639 return *intersection_;
1642 bool supported()
const
1648 const IntersectionType *intersection_;
1662 template<
class FunctionType>
1665 UnaryGridFunctionExpression<IdentityOperation, FunctionType> >,
1670 typedef Fem::Function<typename FunctionType::FunctionSpaceType, ThisType> BaseType;
1672 typedef UnaryFunctionExpressionOperation<OperationTagType> OperationType;
1675 static_assert((std::is_base_of<Fem::HasLocalFunction, FunctionType>::value),
1676 "FunctionType must be a discrete function type.");
1683 isPieceWiseConstant = TraitsType::isPieceWiseConstant
1692 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
1698 typedef typename DiscreteFunctionSpaceType::GridType
GridType;
1705 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
1707 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
1715 typedef typename GridPartType::IntersectionType IntersectionType;
1718 class LocalFunction;
1720 using ExpressionBaseType::expressionName_;
1734 : space_(other.space_),
1735 function_(other.function_)
1741 function().evaluate(global, result);
1747 if (isPieceWiseConstant) {
1751 function().jacobian(global, result);
1757 if (isPieceWiseConstant) {
1761 function().hessian(global, result);
1780 return expressionName_;
1799 globalSupport = std::is_same<IndicatorType, EntireBoundaryIndicatorType>::value
1804 const IntersectionType &intersection)
const
1806 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1812 const IntersectionType &intersection)
1814 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1820 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1827 const FunctionType& function()
const {
return function_(); }
1830 ExpressionStorage<FunctionType> function_;
1831 mutable std::string name_;
1836 template<
class FunctionType>
1837 class UnaryGridFunctionExpression<IdentityOperation, FunctionType>::LocalFunction
1839 typedef LocalFunction ThisType;
1840 typedef IdentityOperation OperationTagType;
1841 typedef UnaryFunctionExpressionOperation<OperationTagType> OperationType;
1845 typedef typename DiscreteFunctionType::FunctionSpaceType FunctionSpaceType;
1848 typedef typename DiscreteFunctionSpaceType::GridPartType
GridPartType;
1849 typedef typename EntityType::Geometry GeometryType;
1852 static const int dimRange = DiscreteFunctionSpaceType::dimRange;
1853 static const int dimDomain = GridPartType::GridType::dimensionworld;
1854 static const int dimLocal = GridPartType::GridType::dimension;
1857 typedef typename DiscreteFunctionSpaceType::DomainFieldType
DomainFieldType;
1859 typedef typename DiscreteFunctionSpaceType::RangeFieldType
RangeFieldType;
1861 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
1863 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
1865 typedef typename DiscreteFunctionSpaceType::JacobianRangeType
JacobianRangeType;
1867 typedef typename DiscreteFunctionSpaceType::HessianRangeType
HessianRangeType;
1879 localFunction_(df.function())
1883 template<
class Po
intType>
1890 localFunction_.evaluate(x, ret);
1894 template<
class Po
intType>
1897 if (DiscreteFunctionType::isPieceWiseConstant || !supported()) {
1901 localFunction_.jacobian(x, ret);
1905 template<
class Po
intType>
1908 if (DiscreteFunctionType::isPieceWiseConstant || !supported()) {
1912 localFunction_.hessian(x, ret);
1916 template<
class QuadratureType,
class VectorType>
1917 void evaluateQuadrature(
const QuadratureType& quadrature, VectorType& values)
const
1919 assert(values.size() == quadrature.nop());
1920 DiscreteFunctionType::evaluateQuadratureImp(*
this, quadrature, values, values[0]);
1924 int order()
const {
return localFunction_.order(); }
1929 localFunction_.init(entity);
1935 return localFunction_.entity();
1950 const IntersectionType &intersection,
1952 : localFunction_(LocalFunctiontype(df.function()))
1954 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1955 init(entity, intersection);
1959 void init(
const EntityType& entity,
const IntersectionType& intersection)
1961 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1963 BoundaryFunctionTraits<FunctionType>::init(localFunction_, entity, intersection);
1964 supported_ = BoundaryFunctionTraits<FunctionType>::supported(localFunction_);
1966 intersection_ = &intersection;
1970 const IntersectionType &intersection()
const
1972 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
1973 assert(intersection_);
1974 return *intersection_;
1977 bool supported()
const
1983 const IntersectionType *intersection_;
2003 template<
class FunctionType>
2006 UnaryGridFunctionExpression<InvertOperation, FunctionType> >,
2010 typedef Fem::Function<typename FunctionType::FunctionSpaceType, ThisType> BaseType;
2012 typedef UnaryFunctionExpressionOperation<OperationTagType> OperationType;
2015 static_assert((std::is_base_of<Fem::HasLocalFunction, FunctionType>::value),
2016 "FunctionType must be a discrete function type.");
2023 isPieceWiseConstant = TraitsType::isPieceWiseConstant
2032 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
2038 typedef typename DiscreteFunctionSpaceType::GridType
GridType;
2045 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
2047 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
2055 typedef typename GridPartType::IntersectionType IntersectionType;
2058 class LocalFunction;
2060 using ExpressionBaseType::expressionName_;
2074 : space_(other.space_),
2075 function_(other.function_)
2081 OperationType::evaluate(function(), global, result);
2087 if (isPieceWiseConstant) {
2091 OperationType::jacobian(function(), global, result);
2097 if (isPieceWiseConstant) {
2101 OperationType::hessian(function(), global, result);
2120 return expressionName_;
2144 const IntersectionType &intersection)
const
2146 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
2152 const IntersectionType &intersection)
2154 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
2160 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
2167 const FunctionType& function()
const {
return function_(); }
2170 ExpressionStorage<FunctionType> function_;
2171 mutable std::string name_;
2176 template<
class FunctionType>
2177 class UnaryGridFunctionExpression<InvertOperation, FunctionType>::LocalFunction
2179 typedef LocalFunction ThisType;
2183 typedef typename DiscreteFunctionType::FunctionSpaceType FunctionSpaceType;
2185 typedef InvertOperation OperationTagType;
2186 typedef UnaryFunctionExpressionOperation<OperationTagType> OperationType;
2189 typedef typename DiscreteFunctionSpaceType::GridPartType
GridPartType;
2190 typedef typename EntityType::Geometry GeometryType;
2193 static const int dimRange = DiscreteFunctionSpaceType::dimRange;
2194 static const int dimDomain = GridPartType::GridType::dimensionworld;
2195 static const int dimLocal = GridPartType::GridType::dimension;
2198 typedef typename DiscreteFunctionSpaceType::DomainFieldType
DomainFieldType;
2200 typedef typename DiscreteFunctionSpaceType::RangeFieldType
RangeFieldType;
2202 typedef typename DiscreteFunctionSpaceType::DomainType
DomainType;
2204 typedef typename DiscreteFunctionSpaceType::RangeType
RangeType;
2206 typedef typename DiscreteFunctionSpaceType::JacobianRangeType
JacobianRangeType;
2208 typedef typename DiscreteFunctionSpaceType::HessianRangeType
HessianRangeType;
2220 localFunction_(df.function()) {}
2223 template<
class Po
intType>
2230 OperationType::evaluate(localFunction_, x, ret);
2234 template<
class Po
intType>
2237 if (DiscreteFunctionType::isPieceWiseConstant || !supported()) {
2241 OperationType::jacobian(localFunction_, x, ret);
2245 template<
class Po
intType>
2248 if (DiscreteFunctionType::isPieceWiseConstant || !supported()) {
2252 OperationType::hessian(localFunction_, x, ret);
2256 template<
class QuadratureType,
class VectorType>
2257 void evaluateQuadrature(
const QuadratureType& quadrature, VectorType& values)
const
2259 assert(values.size() == quadrature.nop());
2260 DiscreteFunctionType::evaluateQuadratureImp(*
this, quadrature, values, values[0]);
2266 return DiscreteFunctionType::isPieceWiseConstant ? 0 : 111;
2272 localFunction_.init(entity);
2278 return localFunction_.entity();
2293 const IntersectionType &intersection,
2295 : localFunction_(LocalFunctiontype(df.function()))
2297 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
2298 init(entity, intersection);
2302 void init(
const EntityType& entity,
const IntersectionType& intersection)
2304 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
2306 BoundaryFunctionTraits<FunctionType>::init(localFunction_, entity, intersection);
2307 supported_ = BoundaryFunctionTraits<FunctionType>::supported(localFunction_);
2309 intersection_ = &intersection;
2313 const IntersectionType &intersection()
const
2315 static_assert(TraitsType::hasBoundarySupport,
"This is not a BoundarySupportedFunction");
2316 assert(intersection_);
2317 return *intersection_;
2320 bool supported()
const
2326 const IntersectionType *intersection_;
2339 template<
class LeftFunction,
class RightFunction>
2341 BinaryGridFunctionExpression<MultiplyOperation, LeftFunction, RightFunction>
2342 operator*(
const Fem::Function<typename LeftFunction::FunctionSpaceType, LeftFunction>& f_,
2343 const Fem::Function<typename RightFunction::FunctionSpaceType, RightFunction>& g_)
2345 typedef LeftFunction LeftFunctionType;
2346 typedef RightFunction RightFunctionType;
2348 static_assert(std::is_base_of<Fem::HasLocalFunction, LeftFunctionType>::value,
2349 "Left operand must be a GridFunction");
2350 static_assert(std::is_base_of<Fem::HasLocalFunction, RightFunctionType>::value,
2351 "Right operand must be a GridFunction");
2353 const LeftFunctionType& f(
static_cast<const LeftFunctionType&
>(f_));
2354 const RightFunctionType& g(
static_cast<const RightFunctionType&
>(g_));
2356 typedef BinaryGridFunctionExpression<MultiplyOperation, LeftFunctionType, RightFunctionType> ExpressionType;
2357 return ExpressionType(f, g);
2363 template<
class Function>
2365 BinaryGridFunctionExpression<SMultiplyOperation, typename Function::RangeFieldType, Function>
2366 operator*(
const typename Function::RangeFieldType& s,
2367 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2369 typedef Function FunctionType;
2371 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2372 "Right operand must be a GridFunction");
2374 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2375 typedef typename FunctionType::RangeFieldType RangeFieldType;
2376 typedef BinaryGridFunctionExpression<SMultiplyOperation, RangeFieldType, FunctionType> ExpressionType;
2378 return ExpressionType(s, f);
2382 template<
class Function>
2384 auto operator*(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
2385 const typename Function::RangeFieldType& s)
2386 ->
decltype(s *
asImp(f_))
2388 return s *
asImp(f_);
2392 template<
class Parameter,
class Function>
2394 BinaryGridFunctionExpression<SMultiplyOperation, Parameter, Function>
2396 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2398 typedef Function FunctionType;
2399 typedef Parameter ParameterType;
2401 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2402 "Right operand must be a GridFunction");
2404 const ParameterType& s(
static_cast<const ParameterType&
>(s_));
2405 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2408 return ExpressionType(s, f);
2412 template<
class Parameter,
class Function>
2414 auto operator*(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
2427 template<
class LeftFunction,
class RightFunction>
2428 auto operator/(
const Fem::Function<typename LeftFunction::FunctionSpaceType, LeftFunction>& l_,
2429 const Fem::Function<typename RightFunction::FunctionSpaceType::ScalarFunctionSpaceType, RightFunction>& r_)
2430 ->
decltype(
asImp(l_) * std::declval<UnaryGridFunctionExpression<InvertOperation, RightFunction> >())
2432 typedef RightFunction RightFunctionType;
2434 static_assert(std::is_base_of<Fem::HasLocalFunction, RightFunctionType>::value,
2435 "Right operand must be a GridFunction");
2439 return asImp(l_) * InvertExpressionType(
asImp(r_));
2443 template<
class RightFunction>
2444 auto operator/(
const typename RightFunction::RangeFieldType& l_,
2445 const Fem::Function<typename RightFunction::FunctionSpaceType::ScalarFunctionSpaceType, RightFunction>& r_)
2446 ->
decltype(l_ * std::declval<UnaryGridFunctionExpression<InvertOperation, RightFunction> >())
2448 typedef RightFunction RightFunctionType;
2450 static_assert(std::is_base_of<Fem::HasLocalFunction, RightFunctionType>::value,
2451 "Right operand must be a GridFunction");
2455 return l_ * InvertExpressionType(
asImp(r_));
2459 template<
class LeftParameter,
class RightFunction>
2461 const Fem::Function<typename RightFunction::FunctionSpaceType::ScalarFunctionSpaceType, RightFunction>& r_)
2462 ->
decltype(
asImp(l_) * std::declval<UnaryGridFunctionExpression<InvertOperation, RightFunction> >())
2464 typedef RightFunction RightFunctionType;
2466 static_assert(std::is_base_of<Fem::HasLocalFunction, RightFunctionType>::value,
2467 "Right operand must be a GridFunction");
2471 return asImp(l_) * InvertExpressionType(
asImp(r_));
2475 template<
class Function>
2477 auto operator/(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
2478 const typename Function::RangeFieldType& s)
2479 ->
decltype((1.0/s) *
asImp(f_))
2481 return (1.0/s) *
asImp(f_);
2490 template<
class LeftFunction,
class RightFunction>
2492 BinaryGridFunctionExpression<PlusOperation, LeftFunction, RightFunction>
2493 operator+(
const Fem::Function<typename LeftFunction::FunctionSpaceType, LeftFunction>& f_,
2494 const Fem::Function<typename RightFunction::FunctionSpaceType, RightFunction>& g_)
2496 typedef LeftFunction LeftFunctionType;
2497 typedef RightFunction RightFunctionType;
2499 static_assert(std::is_base_of<Fem::HasLocalFunction, LeftFunctionType>::value,
2500 "Left operand must be a GridFunction");
2501 static_assert(std::is_base_of<Fem::HasLocalFunction, RightFunctionType>::value,
2502 "Right operand must be a GridFunction");
2504 const LeftFunctionType& f(
static_cast<const LeftFunctionType&
>(f_));
2505 const RightFunctionType& g(
static_cast<const RightFunctionType&
>(g_));
2507 typedef BinaryGridFunctionExpression<PlusOperation, LeftFunctionType, RightFunctionType> ExpressionType;
2509 return ExpressionType(f, g);
2517 template<
class Function>
2519 BinaryGridFunctionExpression<PlusOperation,
2520 ConstantGridFunction<typename Function::FunctionSpaceType, typename Function::GridPartType>,
2522 operator+(
const typename Function::RangeType& s,
2523 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2525 typedef Function FunctionType;
2527 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2528 "Right operand must be a GridFunction");
2530 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2532 typedef typename FunctionType::GridPartType GridPartType;
2533 typedef typename FunctionType::FunctionSpaceType FunctionSpaceType;
2538 ConstantFunctionType constant(s, f.space().gridPart());
2540 return ExpressionType(constant, f);
2548 template<
class Function>
2551 operator+(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
2552 const typename Function::RangeType& s_)
2553 ->
decltype(s_ + f_)
2563 template<
class Parameter,
class Function>
2565 BinaryGridFunctionExpression<PlusOperation,
2566 ParameterGridFunction<Parameter,
typename Function::FunctionSpaceType,
2567 typename Function::GridPartType>,
2570 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2572 typedef Function FunctionType;
2573 typedef Parameter ParameterType;
2575 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2576 "Right operand must be a GridFunction");
2578 const ParameterType& s(
static_cast<const ParameterType&
>(s_));
2579 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2581 typedef typename FunctionType::GridPartType GridPartType;
2582 typedef typename FunctionType::FunctionSpaceType FunctionSpaceType;
2587 ParameterFunctionType parameter(s, f.space().gridPart());
2589 return ExpressionType(parameter, f);
2597 template<
class Parameter,
class Function>
2600 operator+(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
2602 ->
decltype(s_ + f_)
2611 template<
class LeftFunction,
class RightFunction>
2613 BinaryGridFunctionExpression<MinusOperation, LeftFunction, RightFunction>
2614 operator-(
const Fem::Function<typename LeftFunction::FunctionSpaceType, LeftFunction>& f_,
2615 const Fem::Function<typename RightFunction::FunctionSpaceType, RightFunction>& g_)
2617 typedef LeftFunction LeftFunctionType;
2618 typedef RightFunction RightFunctionType;
2620 static_assert(std::is_base_of<Fem::HasLocalFunction, LeftFunctionType>::value,
2621 "Left operand must be a GridFunction");
2622 static_assert(std::is_base_of<Fem::HasLocalFunction, RightFunctionType>::value,
2623 "Right operand must be a GridFunction");
2625 const LeftFunctionType& f(
static_cast<const LeftFunctionType&
>(f_));
2626 const RightFunctionType& g(
static_cast<const RightFunctionType&
>(g_));
2628 typedef BinaryGridFunctionExpression<MinusOperation, LeftFunctionType, RightFunctionType> ExpressionType;
2630 return ExpressionType(f, g);
2633 template<
class Function>
2635 BinaryGridFunctionExpression<MinusOperation,
2636 ConstantGridFunction<typename Function::FunctionSpaceType::ScalarFunctionSpaceType, typename Function::GridPartType>,
2638 operator-(
const typename Function::RangeFieldType& s,
2639 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2641 typedef Function FunctionType;
2643 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2644 "Right operand must be a GridFunction");
2646 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2648 typedef typename FunctionType::GridPartType GridPartType;
2649 typedef typename FunctionType::FunctionSpaceType FunctionSpaceType;
2650 typedef typename FunctionSpaceType::ScalarFunctionSpaceType ScalarFunctionSpaceType;
2651 typedef ConstantGridFunction<ScalarFunctionSpaceType, GridPartType> ConstantFunctionType;
2652 typedef BinaryGridFunctionExpression<MinusOperation, ConstantFunctionType, FunctionType>
2655 ConstantFunctionType scalar(s, f.space().gridPart());
2657 return ExpressionType(scalar, f);
2660 template<
class Function>
2662 BinaryGridFunctionExpression<MinusOperation,
2664 ConstantGridFunction<typename Function::FunctionSpaceType::ScalarFunctionSpaceType, typename Function::GridPartType> >
2665 operator-(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
2666 const typename Function::RangeFieldType& s)
2668 typedef Function FunctionType;
2670 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2671 "Left operand must be a GridFunction");
2673 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2675 typedef typename FunctionType::GridPartType GridPartType;
2676 typedef typename FunctionType::FunctionSpaceType FunctionSpaceType;
2677 typedef typename FunctionSpaceType::ScalarFunctionSpaceType ScalarFunctionSpaceType;
2678 typedef ConstantGridFunction<ScalarFunctionSpaceType, GridPartType> ConstantFunctionType;
2679 typedef BinaryGridFunctionExpression<MinusOperation, FunctionType, ConstantFunctionType>
2681 ConstantFunctionType scalar(s, f.space().gridPart());
2683 return ExpressionType(f, scalar);
2691 template<
class Parameter,
class Function>
2693 BinaryGridFunctionExpression<MinusOperation,
2694 ParameterGridFunction<Parameter,
typename Function::FunctionSpaceType,
2695 typename Function::GridPartType>,
2698 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2700 typedef Function FunctionType;
2701 typedef Parameter ParameterType;
2703 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2704 "Right operand must be a GridFunction");
2706 const ParameterType& s(
static_cast<const ParameterType&
>(s_));
2707 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2709 typedef typename FunctionType::GridPartType GridPartType;
2710 typedef typename FunctionType::FunctionSpaceType FunctionSpaceType;
2715 ParameterFunctionType parameter(s, f.space().gridPart());
2717 return ExpressionType(parameter, f);
2725 template<
class Parameter,
class Function>
2727 BinaryGridFunctionExpression<MinusOperation,
2729 ParameterGridFunction<Parameter,
typename Function::FunctionSpaceType,
2730 typename Function::GridPartType> >
2731 operator-(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
2735 typedef Function FunctionType;
2736 typedef Parameter ParameterType;
2738 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2739 "Right operand must be a GridFunction");
2741 const ParameterType& s(
static_cast<const ParameterType&
>(s_));
2742 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2744 typedef typename FunctionType::GridPartType GridPartType;
2745 typedef typename FunctionType::FunctionSpaceType FunctionSpaceType;
2750 ParameterFunctionType parameter(s, f.space().gridPart());
2752 return ExpressionType(f, parameter);
2762 template<
class Function>
2764 UnaryGridFunctionExpression<IdentityOperation, Function>
2765 operator*(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2767 typedef Function FunctionType;
2769 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2770 "Operand must be a GridFunction");
2772 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2776 return ExpressionType(f);
2784 template<
class Function>
2787 operator+(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2788 ->
decltype(*
asImp(f_))
2797 template<
class Function>
2799 UnaryGridFunctionExpression<MinusOperation, Function>
2800 operator-(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2802 typedef Function FunctionType;
2804 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2805 "Operand must be a GridFunction");
2807 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2809 typedef UnaryGridFunctionExpression<MinusOperation, FunctionType> ExpressionType;
2811 return ExpressionType(f);
2819 template<
class Function>
2821 UnaryGridFunctionExpression<ExpOperation, Function>
2822 exp(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2824 typedef Function FunctionType;
2826 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2827 "Operand must be a GridFunction");
2829 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2833 return ExpressionType(f);
2841 template<
class Function>
2843 UnaryGridFunctionExpression<LogOperation, Function>
2844 log(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2846 typedef Function FunctionType;
2848 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2849 "Operand must be a GridFunction");
2851 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2855 return ExpressionType(f);
2863 template<
class Function>
2865 UnaryGridFunctionExpression<SqrtOperation, Function>
2866 sqrt(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2868 typedef Function FunctionType;
2870 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2871 "Operand must be a GridFunction");
2873 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2877 return ExpressionType(f);
2881 template<
class Function>
2883 UnaryGridFunctionExpression<SquareOperation, Function>
2884 sqr(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2886 typedef Function FunctionType;
2888 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2889 "Operand must be a GridFunction");
2891 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2895 return ExpressionType(f);
2903 template<
class Function>
2905 UnaryGridFunctionExpression<SinOperation, Function>
2906 sin(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2908 typedef Function FunctionType;
2910 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2911 "Operand must be a GridFunction");
2913 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2917 return ExpressionType(f);
2925 template<
class Function>
2927 UnaryGridFunctionExpression<CosOperation, Function>
2928 cos(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2930 typedef Function FunctionType;
2932 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2933 "Operand must be a GridFunction");
2935 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2939 return ExpressionType(f);
2947 template<
class Function>
2949 UnaryGridFunctionExpression<TanOperation, Function>
2950 tan(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2952 typedef Function FunctionType;
2954 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2955 "Operand must be a GridFunction");
2957 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2961 return ExpressionType(f);
2969 template<
class Function>
2971 UnaryGridFunctionExpression<AtanOperation, Function>
2972 atan(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2974 typedef Function FunctionType;
2976 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2977 "Operand must be a GridFunction");
2979 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
2983 return ExpressionType(f);
2991 template<
class Function>
2993 UnaryGridFunctionExpression<AsinOperation, Function>
2994 asin(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
2996 typedef Function FunctionType;
2998 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
2999 "Operand must be a GridFunction");
3001 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
3005 return ExpressionType(f);
3013 template<
class Function>
3015 UnaryGridFunctionExpression<AcosOperation, Function>
3016 acos(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
3018 typedef Function FunctionType;
3020 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
3021 "Operand must be a GridFunction");
3023 const FunctionType& f(
static_cast<const FunctionType&
>(f_));
3027 return ExpressionType(f);
3040 template<
class FunctionSpace,
class Expression>
3049 template<
class FunctionSpace,
class Gr
idPart>
3051 ZeroGridFunction<FunctionSpace, GridPart>
3066 ->
decltype(+expr.function())
3068 return +expr.function();
3072 template<
class F1,
class F2>
3075 ->
decltype(expr.rightFunction() - expr.leftFunction())
3077 return expr.rightFunction() - expr.leftFunction();
3081 template<
class F1,
class F2>
3085 ->
decltype(expr.leftFunction().function() - expr.rightFunction())
3087 return expr.leftFunction().function() - expr.rightFunction();
3099 template<
class Field,
class Function>
3102 const Fem::Function<
typename Function::FunctionSpaceType,
3104 ->
decltype((s_ *
asImp(f_).scalar()) *
asImp(f_).function())
3106 return (s_ *
asImp(f_).scalar()) *
asImp(f_).function();
3110 template<
class Field,
class Function1,
class Function2>
3112 auto operator*(
const Fem::Function<
typename Function1::FunctionSpaceType,
3114 const Fem::Function<typename Function2::FunctionSpaceType, Function2>& f2_)
3115 ->
decltype(
asImp(f1_).scalar() * (
asImp(f1_).function() *
asImp(f2_)))
3121 template<
class Field,
class Function1,
class Function2>
3123 auto operator*(
const Fem::Function<typename Function1::FunctionSpaceType, Function1>& f1_,
3124 const Fem::Function<
typename Function2::FunctionSpaceType,
3126 ->
decltype(
asImp(f2_).scalar() * (
asImp(f1_) *
asImp(f2_).function()))
3132 template<
class Field1,
class Field2,
class Function1,
class Function2>
3134 auto operator*(
const Fem::Function<
typename Function1::FunctionSpaceType,
3136 const Fem::Function<
typename Function2::FunctionSpaceType,
3138 ->
decltype((
asImp(f1_).scalar() *
asImp(f2_).scalar()) * (
asImp(f1_).function() *
asImp(f2_).function()))
3140 return (
asImp(f1_).scalar() *
asImp(f2_).scalar()) * (
asImp(f1_).function() *
asImp(f2_).function());
3144 template<
class Parameter,
class Function>
3147 const Fem::Function<
typename Function::FunctionSpaceType,
3155 template<
class Field,
class Parameter,
class Function>
3157 auto operator*(
const BinaryParameterExpression<SMultiplyOperation, Field, Parameter>& p_,
3158 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
3159 ->
decltype(p_.left() * (p_.right() *
asImp(f_)))
3161 return p_.left() * (p_.right() *
asImp(f_));
3167 template<
class Parameter,
class ZeroExpression>
3170 operator*(
const BinaryParameterExpression<SMultiplyOperation, typename ZeroExpression::RangeFieldType, Parameter>& p_,
3183 template<
class ZeroExpression>
3193 template<
class Parameter,
class ZeroExpression>
3203 template<
class Function,
class ZeroExpression>
3207 const Fem::Function<typename Function::FunctionSpaceType, Function>& g_)
3214 template<
class Function,
class ZeroExpression>
3217 operator*(
const Fem::Function<typename Function::FunctionSpaceType, Function>& g_,
3219 ->
decltype(z_ * g_)
3225 template<
class ZeroExpression1,
class ZeroExpression2>
3237 template<
class Function,
class ZeroExpression>
3241 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
3242 ->
decltype(*
asImp(f_))
3244 typedef Function FunctionType;
3246 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
3247 "Operand must be a GridFunction");
3255 template<
class Function,
class ZeroExpression>
3258 operator+(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
3260 ->
decltype(*
asImp(f_))
3262 typedef Function FunctionType;
3264 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
3265 "Operand must be a GridFunction");
3272 template<
class ZeroExpression1,
class ZeroExpression2>
3283 template<
class Function,
class ZeroExpression>
3286 operator-(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
3288 ->
decltype(*
asImp(f_))
3290 typedef Function FunctionType;
3292 static_assert(std::is_base_of<Fem::HasLocalFunction, FunctionType>::value,
3293 "Operand must be a GridFunction");
3300 template<
class Function,
class ZeroExpression>
3304 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
3305 ->
decltype(-
asImp(f_))
3313 template<
class ZeroExpression1,
class ZeroExpression2>
3323 template<
class ZeroExpression>
3340 template<
class Function>
3343 const Fem::Function<typename Function::FunctionSpaceType, Function>& f_)
3344 ->
decltype(*
asImp(f_))
3349 template<
class Function>
3351 auto operator*(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
3352 const decltype(
oneFunction(std::declval<Function>()))& one)
3353 ->
decltype(*
asImp(f_))
3358 template<
class FunctionSpace,
class Gr
idPart>
3360 FractionGridFunction<typename FunctionSpace::ScalarFunctionSpaceType, GridPart, 1L, 1UL>
3361 operator*(
const FractionGridFunction<FunctionSpace, GridPart, 1L, 1UL>& l,
3362 const FractionGridFunction<FunctionSpace, GridPart, 1L, 1UL>& r)
3365 FractionGridFunction<typename FunctionSpace::ScalarFunctionSpaceType, GridPart, 1L, 1UL>
3368 return ExpressionType(l.gridPart());
3371 template<
class Function>
3373 auto operator/(
const Fem::Function<typename Function::FunctionSpaceType, Function>& f_,
3374 const decltype(
oneFunction(std::declval<Function>()))& one)
3375 ->
decltype(*
asImp(f_))
3380 template<
class FunctionSpace,
class Gr
idPart>
3382 FractionGridFunction<typename FunctionSpace::ScalarFunctionSpaceType, GridPart, 1L, 1UL>
3383 operator/(
const FractionGridFunction<FunctionSpace, GridPart, 1L, 1UL>& l,
3384 const FractionGridFunction<FunctionSpace, GridPart, 1L, 1UL>& r)
3387 FractionGridFunction<typename FunctionSpace::ScalarFunctionSpaceType, GridPart, 1L, 1UL>
3390 return ExpressionType(l.gridPart());
3404 using ACFem::operator+;
3405 using ACFem::operator-;
3406 using ACFem::operator*;
3407 using ACFem::operator/;
General local function object for binary grid-function expressions.
Definition: gridfunctionexpression.hh:613
const IntersectionType & intersection() const
Definition: gridfunctionexpression.hh:769
LocalFunction(const EntityType &entity, const DiscreteFunctionType &df)
constructor initializing local function
Definition: gridfunctionexpression.hh:649
LocalFunction(const EntityType &entity, const IntersectionType &intersection, const DiscreteFunctionType &df)
Construct from intersection.
Definition: gridfunctionexpression.hh:741
DiscreteFunctionSpaceType::FunctionSpaceType FunctionSpaceType
function space type
Definition: gridfunctionexpression.hh:633
DiscreteFunctionSpaceType::HessianRangeType HessianRangeType
hessian type (from function space)
Definition: gridfunctionexpression.hh:646
DiscreteFunctionSpaceType::DomainType DomainType
domain type (from function space)
Definition: gridfunctionexpression.hh:640
int order() const
Return a bound on or suggestion for the piece-wise polynomial order.
Definition: gridfunctionexpression.hh:711
void init(const EntityType &entity, const IntersectionType &intersection)
Definition: gridfunctionexpression.hh:754
bool supported() const
Construct from intersection.
Definition: gridfunctionexpression.hh:776
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian type (from function space)
Definition: gridfunctionexpression.hh:644
void init(const EntityType &entity)
init local function
Definition: gridfunctionexpression.hh:714
void evaluateQuadrature(const QuadratureType &quadrature, VectorType &values) const
evaluate function or jacobian of function for given quadrature
Definition: gridfunctionexpression.hh:704
void evaluate(const PointType &x, RangeType &ret) const
evaluate local function
Definition: gridfunctionexpression.hh:671
void hessian(const PointType &x, HessianRangeType &ret) const
hessian of local function
Definition: gridfunctionexpression.hh:693
const EntityType & entity() const
Return a reference to the currently active entity.
Definition: gridfunctionexpression.hh:723
void jacobian(const PointType &x, JacobianRangeType &ret) const
jacobian of local function
Definition: gridfunctionexpression.hh:682
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
domain type (from function space)
Definition: gridfunctionexpression.hh:636
DiscreteFunctionSpaceType::RangeType RangeType
range type (from function space)
Definition: gridfunctionexpression.hh:642
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
range type (from function space)
Definition: gridfunctionexpression.hh:638
S-multiplication with RangeFieldType scalars.
Definition: gridfunctionexpression.hh:869
LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection)
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:1029
void hessian(const DomainType &global, HessianRangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:968
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian type (from function space)
Definition: gridfunctionexpression.hh:918
TraitsType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: gridfunctionexpression.hh:898
BinaryGridFunctionExpressionTraits< SMultiplyOperation, Factor, ContainedFunctionType > TraitsType
type of traits
Definition: gridfunctionexpression.hh:887
Factor FactorType
type of factor
Definition: gridfunctionexpression.hh:881
DiscreteFunctionSpaceType::GridPartType GridPartType
type of gridPart
Definition: gridfunctionexpression.hh:904
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
range type (from function space)
Definition: gridfunctionexpression.hh:912
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
domain type (from function space)
Definition: gridfunctionexpression.hh:910
const LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection) const
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:1022
const LocalFunctionType localFunction(const EntityType &entity) const
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity) const.
Definition: gridfunctionexpression.hh:981
void jacobian(const DomainType &global, JacobianRangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:957
ThisType DiscreteFunctionType
type of discrete function (self)
Definition: gridfunctionexpression.hh:895
DiscreteFunctionSpaceType::GridType GridType
type of grid
Definition: gridfunctionexpression.hh:907
const DiscreteFunctionSpaceType & space() const
See Fem::DiscreteFunctionInterface::space() const.
Definition: gridfunctionexpression.hh:1004
DiscreteFunctionSpaceType::DomainType DomainType
domain type (from function space)
Definition: gridfunctionexpression.hh:914
BoundaryFunctionTraits< ContainedFunctionType >::IndicatorType IndicatorType
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:1013
DiscreteFunctionSpaceType::RangeType RangeType
range type (from function space)
Definition: gridfunctionexpression.hh:916
void evaluate(const DomainType &global, RangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:950
const std::string & expressionName() const
See Fem::DiscreteFunctionInterface::name() const.
Definition: gridfunctionexpression.hh:993
Function ContainedFunctionType
type of function
Definition: gridfunctionexpression.hh:884
LocalFunctionType localFunction(const EntityType &entity)
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)
Definition: gridfunctionexpression.hh:987
DiscreteFunctionSpaceType::HessianRangeType HessianRangeType
hessian type (from function space)
Definition: gridfunctionexpression.hh:920
TraitsType::EntityType EntityType
type of codim 0 entity
Definition: gridfunctionexpression.hh:923
LocalFunction LocalFunctionType
type of local function to export
Definition: gridfunctionexpression.hh:933
IndicatorType indicator() const
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:1036
BinaryGridFunctionExpression implements point-wise vector-space operations for GridFunction-types.
Definition: gridfunctionexpression.hh:423
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
domain type (from function space)
Definition: gridfunctionexpression.hh:460
const DiscreteFunctionSpaceType & space() const
See Fem::DiscreteFunctionInterface::space() const.
Definition: gridfunctionexpression.hh:550
void evaluate(const DomainType &global, RangeType &result) const
evaluate function at global coordinates
Definition: gridfunctionexpression.hh:504
DiscreteFunctionSpaceType::HessianRangeType HessianRangeType
hessian type (from function space)
Definition: gridfunctionexpression.hh:470
BinaryGridFunctionExpressionTraits< BinOp, LeftFunctionType, RightFunctionType > TraitsType
type of traits
Definition: gridfunctionexpression.hh:428
GridPartType::IntersectionType IntersectionType
type of intersection
Definition: gridfunctionexpression.hh:476
const LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection) const
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)> const.
Definition: gridfunctionexpression.hh:575
void hessian(const DomainType &global, HessianRangeType &result) const
hessian at global coordinates
Definition: gridfunctionexpression.hh:521
DiscreteFunctionSpaceType::GridType GridType
type of grid
Definition: gridfunctionexpression.hh:453
TraitsType::EntityType EntityType
type of codim 0 entity
Definition: gridfunctionexpression.hh:473
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian type (from function space)
Definition: gridfunctionexpression.hh:468
TraitsType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: gridfunctionexpression.hh:444
TraitsType::IndicatorType IndicatorType
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:565
ThisType DiscreteFunctionType
type of discrete function (self)
Definition: gridfunctionexpression.hh:441
const std::string & expressionName() const
See Fem::DiscreteFunctionInterface::name() const.
Definition: gridfunctionexpression.hh:543
BinaryGridFunctionExpression(const LeftFunctionType &f, const RightFunctionType &g)
Constructor.
Definition: gridfunctionexpression.hh:489
const LocalFunctionType localFunction(const EntityType &entity) const
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)> const.
Definition: gridfunctionexpression.hh:531
DiscreteFunctionSpaceType::RangeType RangeType
range type (from function space)
Definition: gridfunctionexpression.hh:466
LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection)
See Fem::DiscreteFunctionInterface::localFunction(const IntersectionType &intersection)
Definition: gridfunctionexpression.hh:583
DiscreteFunctionSpaceType::GridPartType GridPartType
type of gridPart
Definition: gridfunctionexpression.hh:450
LocalFunction LocalFunctionType
type of local function to export
Definition: gridfunctionexpression.hh:486
LocalFunctionType localFunction(const EntityType &entity)
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)
Definition: gridfunctionexpression.hh:537
IndicatorType indicator() const
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:589
DiscreteFunctionSpaceType::DomainType DomainType
domain type (from function space)
Definition: gridfunctionexpression.hh:464
@ emptySupport
Definition: gridfunctionexpression.hh:569
@ globalSupport
Definition: gridfunctionexpression.hh:571
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
range type (from function space)
Definition: gridfunctionexpression.hh:462
void jacobian(const DomainType &global, JacobianRangeType &result) const
jacobian at global coordinates
Definition: gridfunctionexpression.hh:510
ConstantGridFunction implements a constant function.
Definition: constantfunction.hh:108
A grid-function which is constant with a scalar fractional value.
Definition: constantfunction.hh:598
A class providing some basic functionality common to all expressions.
Definition: gridfunctionexpressionbase.hh:35
const std::string & name() const
Return a descriptive name for the function.
Definition: gridfunctionexpressionbase.hh:56
ParameterGridFunction implements a constant function where the value is defined by something which fu...
Definition: parameterfunction.hh:112
Parameters are quasi-constant quantities, like the time-step size in one time-step when solving trans...
Definition: parameterinterface.hh:80
Specialize for the identity wrapper operation.
Definition: gridfunctionexpression.hh:1668
TraitsType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: gridfunctionexpression.hh:1689
const DiscreteFunctionSpaceType & space() const
See Fem::DiscreteFunctionInterface::space() const.
Definition: gridfunctionexpression.hh:1784
DiscreteFunctionSpaceType::GridType GridType
type of grid
Definition: gridfunctionexpression.hh:1698
DiscreteFunctionSpaceType::DomainType DomainType
domain type (from function space)
Definition: gridfunctionexpression.hh:1705
LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection)
See Fem::DiscreteFunctionInterface::localFunction(const IntersectionType &intersection)
Definition: gridfunctionexpression.hh:1811
DiscreteFunctionSpaceType::HessianRangeType HessianRangeType
hessian type (from function space)
Definition: gridfunctionexpression.hh:1711
DiscreteFunctionSpaceType::GridPartType GridPartType
type of gridPart
Definition: gridfunctionexpression.hh:1695
const LocalFunctionType localFunction(const EntityType &entity) const
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity) const.
Definition: gridfunctionexpression.hh:1765
LocalFunctionType localFunction(const EntityType &entity)
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)
Definition: gridfunctionexpression.hh:1771
IndicatorType indicator() const
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:1818
void hessian(const DomainType &global, HessianRangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:1755
LocalFunction LocalFunctionType
type of local function to export
Definition: gridfunctionexpression.hh:1724
const LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection) const
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)> const.
Definition: gridfunctionexpression.hh:1803
BoundaryFunctionTraits< FunctionType >::IndicatorType IndicatorType
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:1793
DiscreteFunctionSpaceType::RangeType RangeType
range type (from function space)
Definition: gridfunctionexpression.hh:1707
const std::string & expressionName() const
See Fem::DiscreteFunctionInterface::name() const.
Definition: gridfunctionexpression.hh:1777
void evaluate(const DomainType &global, RangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:1739
UnaryGridFunctionExpressionTraits< OperationTagType, FunctionType > TraitsType
type of traits
Definition: gridfunctionexpression.hh:1680
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
range type (from function space)
Definition: gridfunctionexpression.hh:1703
TraitsType::EntityType EntityType
type of codim 0 entity
Definition: gridfunctionexpression.hh:1714
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian type (from function space)
Definition: gridfunctionexpression.hh:1709
void jacobian(const DomainType &global, JacobianRangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:1745
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
domain type (from function space)
Definition: gridfunctionexpression.hh:1701
For the sake of BoundarySupportedFunction we need to specialize the InvertOperation.
Definition: gridfunctionexpression.hh:2008
void hessian(const DomainType &global, HessianRangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:2095
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
range type (from function space)
Definition: gridfunctionexpression.hh:2043
const DiscreteFunctionSpaceType & space() const
See Fem::DiscreteFunctionInterface::space() const.
Definition: gridfunctionexpression.hh:2124
const LocalFunctionType localFunction(const EntityType &entity) const
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity) const.
Definition: gridfunctionexpression.hh:2105
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
domain type (from function space)
Definition: gridfunctionexpression.hh:2041
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian type (from function space)
Definition: gridfunctionexpression.hh:2049
DiscreteFunctionSpaceType::GridType GridType
type of grid
Definition: gridfunctionexpression.hh:2038
TraitsType::EntityType EntityType
type of codim 0 entity
Definition: gridfunctionexpression.hh:2054
UnaryGridFunctionExpressionTraits< OperationTagType, FunctionType > TraitsType
type of traits
Definition: gridfunctionexpression.hh:2020
LocalFunctionType localFunction(const EntityType &entity)
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)
Definition: gridfunctionexpression.hh:2111
const LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection) const
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)> const.
Definition: gridfunctionexpression.hh:2143
LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection)
See Fem::DiscreteFunctionInterface::localFunction(const IntersectionType &intersection)
Definition: gridfunctionexpression.hh:2151
TraitsType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: gridfunctionexpression.hh:2029
IndicatorType indicator() const
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:2158
LocalFunction LocalFunctionType
type of local function to export
Definition: gridfunctionexpression.hh:2064
EntireBoundaryIndicatorType IndicatorType
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:2133
DiscreteFunctionSpaceType::RangeType RangeType
range type (from function space)
Definition: gridfunctionexpression.hh:2047
void evaluate(const DomainType &global, RangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:2079
const std::string & expressionName() const
See Fem::DiscreteFunctionInterface::name() const.
Definition: gridfunctionexpression.hh:2117
DiscreteFunctionSpaceType::DomainType DomainType
domain type (from function space)
Definition: gridfunctionexpression.hh:2045
void jacobian(const DomainType &global, JacobianRangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:2085
DiscreteFunctionSpaceType::GridPartType GridPartType
type of gridPart
Definition: gridfunctionexpression.hh:2035
DiscreteFunctionSpaceType::HessianRangeType HessianRangeType
hessian type (from function space)
Definition: gridfunctionexpression.hh:2051
UnaryGridFunctionExpression implements point-wise unary operations for GridFunction-types.
Definition: gridfunctionexpression.hh:1328
const std::string & expressionName() const
See Fem::DiscreteFunctionInterface::name() const.
Definition: gridfunctionexpression.hh:1439
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian type (from function space)
Definition: gridfunctionexpression.hh:1371
LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection)
See Fem::DiscreteFunctionInterface::localFunction(const IntersectionType &intersection)
Definition: gridfunctionexpression.hh:1473
DiscreteFunctionSpaceType::GridType GridType
type of grid
Definition: gridfunctionexpression.hh:1360
ThisType DiscreteFunctionType
export DiscreteFunctionType
Definition: gridfunctionexpression.hh:1348
UnaryGridFunctionExpressionTraits< UnOp, FunctionType > TraitsType
type of traits
Definition: gridfunctionexpression.hh:1331
void evaluate(const DomainType &global, RangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:1401
LocalFunctionType localFunction(const EntityType &entity)
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)
Definition: gridfunctionexpression.hh:1433
DiscreteFunctionSpaceType::RangeType RangeType
range type (from function space)
Definition: gridfunctionexpression.hh:1369
@ globalSupport
Definition: gridfunctionexpression.hh:1461
@ emptySupport
Definition: gridfunctionexpression.hh:1459
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
range type (from function space)
Definition: gridfunctionexpression.hh:1365
void hessian(const DomainType &global, HessianRangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:1417
DiscreteFunctionSpaceType::GridPartType GridPartType
type of gridPart
Definition: gridfunctionexpression.hh:1357
const DiscreteFunctionSpaceType & space() const
See Fem::DiscreteFunctionInterface::space() const.
Definition: gridfunctionexpression.hh:1446
TraitsType::EntityType EntityType
type of codim 0 entity
Definition: gridfunctionexpression.hh:1376
DiscreteFunctionSpaceType::DomainType DomainType
domain type (from function space)
Definition: gridfunctionexpression.hh:1367
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
domain type (from function space)
Definition: gridfunctionexpression.hh:1363
BoundaryFunctionTraits< FunctionType >::IndicatorType IndicatorType
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:1455
void jacobian(const DomainType &global, JacobianRangeType &result) const
evaluate function on local coordinate local
Definition: gridfunctionexpression.hh:1407
IndicatorType indicator() const
Resulting Boundary indicator type.
Definition: gridfunctionexpression.hh:1480
TraitsType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: gridfunctionexpression.hh:1351
const LocalFunctionType localFunction(const EntityType &entity, const IntersectionType &intersection) const
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity)> const.
Definition: gridfunctionexpression.hh:1465
LocalFunction LocalFunctionType
type of local function to export
Definition: gridfunctionexpression.hh:1386
const LocalFunctionType localFunction(const EntityType &entity) const
See Fem::DiscreteFunctionInterface::localFunction(const EntityType &entity) const.
Definition: gridfunctionexpression.hh:1427
DiscreteFunctionSpaceType::HessianRangeType HessianRangeType
hessian type (from function space)
Definition: gridfunctionexpression.hh:1373
A base class for zero function expression.
Definition: gridfunctionexpressionbase.hh:110
A grid-function always returning 0.
Definition: constantfunction.hh:352
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
auto constantFunction(const Fem::Function< typename F::FunctionSpaceType, F > &f_, const typename F::FunctionSpaceType::RangeType &c) -> ConstantGridFunction< typename F::FunctionSpaceType, typename F::GridPartType >
Generate a ConstantGridFunction on the same function space.
Definition: gridfunctionexpression.hh:191
static ZeroGridFunction< typename FunctionMultiplicationResultTraits< typename F1::FunctionSpaceType, typename F2::FunctionSpaceType >::FunctionSpaceType, typename F1::GridPartType > zeroProduct(const F1 &f1, const F2 &f2)
Generate the proper zero-functions for products evaluating to zero.
Definition: gridfunctionexpression.hh:116
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
auto zeroFunction(const Fem::Function< typename F::FunctionSpaceType, F > &f_) -> ZeroGridFunction< typename F::FunctionSpaceType, typename F::GridPartType >
Generate a ZeroGridFunction on the same function space.
Definition: gridfunctionexpression.hh:183
FractionGridFunction< typename FunctionSpace::FunctionSpaceType::ScalarFunctionSpaceType, GridPart, 1L, 1UL > oneFunction(const FunctionSpace &space, const GridPart &gridPart)
Generate a proper constant-one function from the given Fem::FunctionSpace and Fem::GridPart.
Definition: gridfunctionexpression.hh:157
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
Multiplication from the left by a scalar constant.
Definition: functionoperations.hh:567
traits of BinaryFunctionExpression
Definition: functionexpression.hh:96
GridPartType::IndexSetType IndexSetType
type of IndexSet
Definition: gridfunctionexpression.hh:821
GridPartType::template Codim< 0 >::IteratorType IteratorType
type of iterator
Definition: gridfunctionexpression.hh:819
traits of BinaryGridFunctionExpression
Definition: gridfunctionexpression.hh:378
GridPartType::IndexSetType IndexSetType
type of IndexSet
Definition: gridfunctionexpression.hh:402
GridPartType::template Codim< 0 >::IteratorType IteratorType
type of iterator
Definition: gridfunctionexpression.hh:400
Helper traits in order to treat function w/o dedicated boundary support in the same way,...
Definition: boundarysupportedfunction.hh:52
const ExpressionType & expression() const
Return a const reference to the underlying expression.
Definition: expressionoperations.hh:42
A traits class in order to collect properties of expressions.
Definition: expressionoperations.hh:465
Identity, i.e. just wrap the object.
Definition: expressionoperations.hh:284
Inversion of an object.
Definition: expressionoperations.hh:275
Negation of IsPieceWiseConstant, in order to have something to branch to with std::conditional.
Definition: gridfunctionexpressionbase.hh:119
Tag type, consequences are zero Jacobian and Hessian.
Definition: gridfunctionexpressionbase.hh:114
Addition of two objects.
Definition: expressionoperations.hh:230
Multiplication by scalars from the left.
Definition: expressionoperations.hh:257
The default result type is void in order to trigger compilation errors.
Definition: expressionoperations.hh:589
traits of UnaryGridFunctionExpression
Definition: gridfunctionexpression.hh:1270
GridPartType::template Codim< 0 >::IteratorType IteratorType
type of iterator
Definition: gridfunctionexpression.hh:1287
GridPartType::IndexSetType IndexSetType
type of IndexSet
Definition: gridfunctionexpression.hh:1289