1#ifndef __DUNE_ACFEM_BOUNDARY_CONSTRAINTS_HH__
2#define __DUNE_ACFEM_BOUNDARY_CONSTRAINTS_HH__
4#include <dune/fem/misc/bartonnackmaninterface.hh>
6#include "../expressions/expressionoperations.hh"
37 template<
class Implementation>
39 :
public Dune::Fem::BartonNackmanInterface<BoundaryIndicatorInterface<Implementation>,
42 typedef Implementation ImplementationType;
44 typedef Dune::Fem::BartonNackmanInterface<ThisType, ImplementationType> BaseType;
60 template<
class Intersection>
61 bool applies(
const Intersection &intersection)
const
63 return asImp().applies(intersection);
73 template<
class Implementation>
84 template<
class Intersection>
85 bool applies(
const Intersection &intersection)
const
92 template<
class Implementation,
template<
class>
class ExpressionTag = ExpressionTemplate>
95 public ExpressionTag<Implementation>
115 template<
class Intersection>
118 return !intersection.neighbor() && intersection.boundary();
124 template<
class Intersection>
127 return intersection.neighbor() && intersection.boundary();
133 template<
class Intersection>
136 if (intersection.neighbor()) {
137 return intersection.outside().partitionType() == GhostEntity;
139 return !intersection.boundary();
147 template<
class Intersection>
150 return intersection.neighbor();
153 template<
bool answer = true>
154 struct ConstantBoundaryIndicator;
157 struct ConstantBoundaryIndicator<true>
158 :
public BoundaryIndicatorExpression<ConstantBoundaryIndicator<true>, NonZeroExpression>
161 enum { answer =
true };
165 template<
class Intersection>
166 bool applies(
const Intersection &intersection)
const
173 struct ConstantBoundaryIndicator<false>
174 :
public BoundaryIndicatorExpression<ConstantBoundaryIndicator<false>, ZeroExpression>
177 typedef ConstantBoundaryIndicator<false> EmptyBoundaryIndicatorType;
178 typedef ConstantBoundaryIndicator<true> EntireBoundaryIndicatorType;
190 template<
class Intersection>
191 bool applies(
const Intersection &intersection)
const
193 return intersection.boundaryId() == id_;
200 template<
class Indicator>
204 typedef Indicator ContainedIndicatorType;
206 : indicator_(indicator)
210 template<
class Intersection>
211 bool applies(
const Intersection &intersection)
const
213 return !indicator_().applies(intersection);
216 const ContainedIndicatorType& containedExpression()
const
221 ExpressionStorage<ContainedIndicatorType> indicator_;
225 template<
class Indicator>
229 typedef Indicator ContainedIndicatorType;
231 : indicator_(indicator)
235 template<
class Intersection>
236 bool applies(
const Intersection &intersection)
const
238 return indicator_().applies(intersection);
246 template<
class One,
class Two>
250 typedef One IndicatorOneType;
251 typedef Two IndicatorTwoType;
254 : one_(one), two_(two)
258 template<
class Intersection>
259 bool applies(
const Intersection &intersection)
const
261 return one_().applies(intersection) || two_().applies(intersection);
270 template<
class One,
class Two>
274 typedef One IndicatorOneType;
275 typedef Two IndicatorTwoType;
278 : one_(one), two_(two)
282 template<
class Intersection>
283 bool applies(
const Intersection &intersection)
const
285 return one_().applies(intersection) && two_().applies(intersection);
312 template<
class Indicator>
313 BoundaryIndicatorWrapper<Indicator>
318 return ExpressionType(arg);
322 template<
class Indicator>
325 ->
decltype(*
asImp(arg))
331 template<
class Indicator>
339 template<
class Indicator>
340 ComplementBoundaryIndicator<Indicator>
345 return ExpressionType(arg);
349 template<
class Indicator>
352 ->
decltype(!
asImp(arg))
358 template<
class Indicator>
361 ->
decltype(*arg.containedExpression())
363 return *arg.containedExpression();
367 template<
class One,
class Two>
368 UnionBoundaryIndicator<One, Two>
374 return ExpressionType(one, two);
378 template<
class One,
class Two>
388 template<
class One,
class Two>
389 IntersectionBoundaryIndicator<One, Two>
395 return ExpressionType(one, two);
399 template<
class One,
class Two>
409 template<
class One,
class Two>
427 EntireBoundaryIndicatorType
430 return EntireBoundaryIndicatorType();
435 EmptyBoundaryIndicatorType
438 return EmptyBoundaryIndicatorType();
442 template<
class Other>
446 ->
decltype(*
asImp(two))
452 template<
class Other>
455 const EmptyBoundaryIndicatorType& two)
456 ->
decltype(*
asImp(one))
463 EmptyBoundaryIndicatorType
465 const EmptyBoundaryIndicatorType& two)
467 return EmptyBoundaryIndicatorType();
471 template<
class Other>
473 EntireBoundaryIndicatorType
477 return EntireBoundaryIndicatorType();
481 template<
class Other>
483 EntireBoundaryIndicatorType
485 const EntireBoundaryIndicatorType& two)
487 return EntireBoundaryIndicatorType();
492 EntireBoundaryIndicatorType
494 const EntireBoundaryIndicatorType& two)
496 return EntireBoundaryIndicatorType();
505 auto operator||(
const BoundaryIndicatorInterface<Some>& one,
506 const BoundaryIndicatorInterface<Some>& two)
507 ->
decltype(*
asImp(one))
515 EntireBoundaryIndicatorType
517 const EmptyBoundaryIndicatorType& two)
519 return EntireBoundaryIndicatorType();
524 EntireBoundaryIndicatorType
526 const EntireBoundaryIndicatorType& two)
528 return EntireBoundaryIndicatorType();
532 template<
class Other>
534 EmptyBoundaryIndicatorType
538 return EmptyBoundaryIndicatorType();
542 template<
class Other>
544 const EmptyBoundaryIndicatorType& fixed)
551 template<
class Other>
555 ->
decltype(*
asImp(other))
557 return *
asImp(other);
561 template<
class Other>
564 const EntireBoundaryIndicatorType& fixed)
565 ->
decltype(*
asImp(other))
567 return *
asImp(other);
574 template<
class Other>
576 operator&&(
const BoundaryIndicatorInterface<Other>& one,
577 const EntireBoundaryIndicatorType& two)
586 EmptyBoundaryIndicatorType
588 const EmptyBoundaryIndicatorType& two)
590 return EmptyBoundaryIndicatorType();
595 EntireBoundaryIndicatorType
597 const EntireBoundaryIndicatorType& two)
599 return EntireBoundaryIndicatorType();
604 EmptyBoundaryIndicatorType
606 const EntireBoundaryIndicatorType& two)
608 return EmptyBoundaryIndicatorType();
613 EmptyBoundaryIndicatorType
615 const EmptyBoundaryIndicatorType& two)
617 return EmptyBoundaryIndicatorType();
625 template<
class Other>
626 EmptyBoundaryIndicatorType
627 operator&&(
const BoundaryIndicatorInterface<Other>& some,
628 const ComplementBoundaryIndicator<Other>& notSome)
630 typedef EmptyBoundaryIndicatorType ExpressionType;
632 return ExpressionType();
636 template<
class Other>
638 operator&&(
const ComplementBoundaryIndicator<Other>& notSome,
639 const BoundaryIndicatorInterface<Other>& some)
640 ->
decltype(
asImp(some) && notSome)
642 return asImp(some) && notSome;
A simple interface class for a boundary-indicator.
Definition: boundaryindicator.hh:41
bool applies(const Intersection &intersection) const
Classify a boundary facet.
Definition: boundaryindicator.hh:61
bool isInterior(const Intersection &intersection)
Return true if there is a neighbor.
Definition: boundaryindicator.hh:148
bool isProcessorBoundary(const Intersection &intersection)
Retrun true if at the border to another computing note.
Definition: boundaryindicator.hh:134
bool isDomainBoundary(const Intersection &intersection)
Return true if at the global domain boundary.
Definition: boundaryindicator.hh:116
bool isPeriodicBoundary(const Intersection &intersection)
Return true if at a periodic boundary.
Definition: boundaryindicator.hh:125
const Implementation & asImp(const Fem::BartonNackmanInterface< Interface, Implementation > &arg)
Up-cast to the implementation for any Fem::BartonNackmanInterface.
Definition: expressionoperations.hh:71
IntersectionBoundaryIndicator< One, Two > operator&&(const BoundaryIndicatorInterface< One > &one, const BoundaryIndicatorInterface< Two > &two)
Intersection of two indicators.
Definition: boundaryindicator.hh:390
UnionBoundaryIndicator< One, Two > operator||(const BoundaryIndicatorInterface< One > &one, const BoundaryIndicatorInterface< Two > &two)
Union of two indicators.
Definition: boundaryindicator.hh:369
ComplementBoundaryIndicator< Indicator > operator!(const BoundaryIndicatorInterface< Indicator > &arg)
Boolean negation, take the complement.
Definition: boundaryindicator.hh:341
BinaryParameterExpression< MultiplyOperation, Left, Right > operator*(const ParameterInterface< Left > &left, const ParameterInterface< Right > &right)
Scalar product between parameters.
Definition: parameterexpression.hh:321
Apply to boundary segments which carry the respective id.
Definition: boundaryindicator.hh:183
BoundaryIdIndicator(int id)
Construct the indicator with the given id.
Definition: boundaryindicator.hh:185
bool applies(const Intersection &intersection) const
Classify a boundary facet.
Definition: boundaryindicator.hh:191
Expression tag-class for boundary indicators.
Definition: boundaryindicator.hh:96
Wrap another boundary indicator.
Definition: boundaryindicator.hh:228
bool applies(const Intersection &intersection) const
Classify a boundary facet.
Definition: boundaryindicator.hh:236
Turn any boundary-indicator into its complement.
Definition: boundaryindicator.hh:203
bool applies(const Intersection &intersection) const
Classify a boundary facet.
Definition: boundaryindicator.hh:211
Default boundary indicator: like EntireBoundaryIndicator<false>
Definition: boundaryindicator.hh:76
bool applies(const Intersection &intersection) const
Classify a boundary facet.
Definition: boundaryindicator.hh:85
const ExpressionType & expression() const
Return a const reference to the underlying expression.
Definition: expressionoperations.hh:42
Intersection of two indicators, apply iff both apply.
Definition: boundaryindicator.hh:273
bool applies(const Intersection &intersection) const
Classify a boundary facet.
Definition: boundaryindicator.hh:283
Union of two indicators, apply to the union of both boundary parts.
Definition: boundaryindicator.hh:249
bool applies(const Intersection &intersection) const
Classify a boundary facet.
Definition: boundaryindicator.hh:259