AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
BoundaryOperator.hpp
1#pragma once
2
3#include <amdis/BoundarySubset.hpp>
4#include <amdis/ContextGeometry.hpp>
5
6namespace AMDiS
7{
9 template <class LocalOperator, class Intersection>
11 {
12 public:
15 : lop_(std::move(lop))
16 , bs_(std::move(bs))
17 {}
18
20 template <class Element>
21 void bind(Element const& element)
22 {
23 if ((bound_ = element.hasBoundaryIntersections(), bound_))
24 lop_.bind(element);
25 }
26
28 void unbind()
29 {
30 if (bound_) {
31 lop_.unbind();
32 bound_ = false;
33 }
34 }
35
43 template <class... Args>
44 void assemble(ContextGeometry<Intersection> const& cg, Args&&... args) const
45 {
46 if (bound_ && bs_(cg.context()))
47 lop_.assemble(cg,FWD(args)...);
48 }
49
50 private:
51 LocalOperator lop_;
53 bool bound_ = false;
54 };
55
56
64 template <class Operator, class Intersection>
66 {
67 public:
69 : op_(std::move(op))
70 , bs_(std::move(bs))
71 {}
72
74 template <class GridView>
75 void update(GridView const& gridView)
76 {
77 op_.update(gridView);
78 }
79
81 friend auto localOperator(BoundaryOperator const& bop)
82 {
83 return BoundaryLocalOperator{localOperator(bop.op_), bop.bs_};
84 }
85
86 private:
87 Operator op_;
89 };
90
91} // end namespace AMDiS
The local operator associated to BoundaryOperator.
Definition: BoundaryOperator.hpp:11
void bind(Element const &element)
Bind the local-operators to the element if the element has boundary intersections.
Definition: BoundaryOperator.hpp:21
void assemble(ContextGeometry< Intersection > const &cg, Args &&... args) const
Assemble a local element matrix on the given intersection if it belongs to the boundary subset.
Definition: BoundaryOperator.hpp:44
BoundaryLocalOperator(LocalOperator lop, BoundarySubset< Intersection > bs)
Constructor, stores all arguments in local variables.
Definition: BoundaryOperator.hpp:14
void unbind()
Unbind the local-operators from the element.
Definition: BoundaryOperator.hpp:28
An operator to be assembled on a boundary intersection belonging to a given boundary subset.
Definition: BoundaryOperator.hpp:66
friend auto localOperator(BoundaryOperator const &bop)
Transform an operator into a local-operator.
Definition: BoundaryOperator.hpp:81
void update(GridView const &gridView)
Update the operator data on a GridView.
Definition: BoundaryOperator.hpp:75
The base class for a local operator to be used in a Assembler.
Definition: LocalOperator.hpp:75
void bind(Element const &element)
Binds the local operator to an element.
Definition: LocalOperator.hpp:106
void assemble(ContextGeo const &cg, Nodes const &... ns, MatVec &mv) const
Assemble a local element matrix or vector on the element that is bound.
Definition: LocalOperator.hpp:123
void unbind()
Unbinds operator from element.
Definition: LocalOperator.hpp:112
The base class for an operator to be used in an Assembler.
Definition: Operator.hpp:80
void update(GridView const &gv)
Update the operator data on a GridView.
Definition: Operator.hpp:102
Wrapper class for element and geometry.
Definition: ContextGeometry.hpp:49
Context const & context() const
Return the LocalContext, either the element or an intersection.
Definition: ContextGeometry.hpp:85