Dune-Fufem 2.12-git
Loading...
Searching...
No Matches
integratedboundarybilinearform.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUFEM_FORMS_INTEGRATEDBOUNDARYBILINEARFORM_HH
8#define DUNE_FUFEM_FORMS_INTEGRATEDBOUNDARYBILINEARFORM_HH
9
10#include <cstddef>
11#include <type_traits>
12#include <utility>
13
16
23
24
25
26namespace Dune::Fufem::Forms {
27
28
29
44 template<class BilinearOperator, class Domain, class QuadratureHint=Dune::Fufem::Forms::QuadratureHints::KeepOrder>
45 requires IsSumOperator<BilinearOperator>::value && (BilinearOperator::arity==2)
46 && IsBoundaryDomain<Domain>::value && QuadratureHints::IsQuadratureHint<QuadratureHint>::value
48 {
50 using TestRootLocalView = typename TestRootBasis::LocalView;
51 using TestRootTree = typename TestRootLocalView::Tree;
52
53 using AnsatzRootBasis = std::decay_t<decltype(std::get<1>(std::declval<BilinearOperator>().basis()))>;
54 using AnsatzRootLocalView = typename AnsatzRootBasis::LocalView;
55 using AnsatzRootTree = typename AnsatzRootLocalView::Tree;
56
57 using LocalOperator = decltype(localOperator(std::declval<BilinearOperator>()));
58
60
61 public:
62
63 using Element = typename LocalOperator::Element;
64 using Intersection = typename LocalOperator::Intersection;
65
66 IntegratedBoundaryBilinearForm(const BilinearOperator& sumOperator, const Domain& domain, QuadratureHint quadratureHint)
67 : sumOperator_(sumOperator)
68 , sumLocalOperator_(localOperator(sumOperator_))
69 , domain_(domain)
70 , quadratureHint_(quadratureHint)
71 {}
72
73 IntegratedBoundaryBilinearForm(const BilinearOperator& sumOperator, const Domain& domain)
75 : IntegratedBoundaryBilinearForm(sumOperator, domain, QuadratureHint{})
76 {}
77
78 // The following constructors are deleted, to avoid storing a reference to a temporary domain.
79 IntegratedBoundaryBilinearForm(const BilinearOperator&, Domain&&, QuadratureHint) = delete;
80 IntegratedBoundaryBilinearForm(const BilinearOperator&, const Domain&&, QuadratureHint) = delete;
81 IntegratedBoundaryBilinearForm(const BilinearOperator&, Domain&&) = delete;
82 IntegratedBoundaryBilinearForm(const BilinearOperator&, const Domain&&) = delete;
83
84 const BilinearOperator& integrandOperator() const
85 {
86 return sumOperator_;
87 }
88
89 // Dune::Assembler interface
90
91 void bindLocalViews (const TestRootLocalView& testLocalView, const AnsatzRootLocalView& ansatzLocalView)
92 {
93 cacheManager_.clear();
94 sumLocalOperator_.registerLocalViews(testLocalView.rootLocalView(), ansatzLocalView.rootLocalView());
95 sumLocalOperator_.registerCaches(cacheManager_.prototype());
96 insidePtr_ = &testLocalView.element();
97 }
98
99 void bindElement (const Element& element)
100 {}
101
102 template <class LocalPattern>
103 void assembleBoundaryIntersectionMatrixPattern(const Intersection& intersection, LocalPattern& localPattern)
104 {
105 if (not domain_.contains(intersection))
106 return;
107 localPattern.addAll();
108 }
109
110 template<class LocalMatrix>
111 void assembleBoundaryIntersectionMatrix(const Intersection& intersection, LocalMatrix& localMatrix)
112 {
113 using namespace Dune::Indices;
114 using namespace Dune::Fufem::Forms::Impl::Tensor;
115
116 if (not domain_.contains(intersection))
117 return;
118
119 sumLocalOperator_.bind(intersection, *insidePtr_, *insidePtr_);
120
121 auto facet = intersection.indexInInside();
122
123 const auto& geometry = intersection.geometry();
124
125 Impl::forEachTupleEntry(sumLocalOperator_.operators(), [&](auto& op) {
126 cacheManager_[FacetKey(quadratureHint_(op.quadratureRuleKey()), facet)].invalidate();
127 });
128
129 // Lift rank by 2 to prepend zero indices for inside
130 auto localTensor = LiftRank(TensorView(localMatrix, _2), _2);
131
132 Impl::forEachTupleEntry(sumLocalOperator_.operators(), [&](auto& op) {
133 auto& cacheForRule = cacheManager_[FacetKey(quadratureHint_(op.quadratureRuleKey()), facet)];
134 op.bindToCaches(cacheForRule);
135 const auto& quadRule = cacheForRule.rule();
136 for (auto k : Dune::range(quadRule.size()))
137 {
138 const auto& quadPoint = quadRule[k];
139 auto quadPointPositionInFacet = intersection.geometryInInside().local(quadPoint.position());
140 const auto integrationWeight = quadPoint.weight() * geometry.integrationElement(quadPointPositionInFacet);
141 axpy(integrationWeight, op(k), localTensor);
142 }
143 });
144 }
145
146 // Dune::Fufem interface
147
158 template<class TestLocalView, class AnsatzLocalView>
159 [[deprecated("This method will be removed after 2.11. Use the local interface of dune-assembler instead")]]
160 void preprocess(const TestLocalView& testLocalView, const AnsatzLocalView& ansatzLocalView)
161 {
162 cacheManager_.clear();
163 sumLocalOperator_.registerLocalViews(testLocalView.rootLocalView(), ansatzLocalView.rootLocalView());
164 sumLocalOperator_.registerCaches(cacheManager_.prototype());
165 insidePtr_ = &testLocalView.element();
166 }
167
172 template<class LocalMatrix, class TestLocalView, class AnsatzLocalView>
173 [[deprecated("This method will be removed after 2.11. Use the local interface of dune-assembler instead")]]
174 void operator()(const Element& element, LocalMatrix& localMatrix, const TestLocalView& testSubspaceLocalView, const AnsatzLocalView& ansatzSubspaceLocalView)
175 {
176 bool processElement = true;
177 if constexpr (requires{domain_.containsFaceOf(element);})
178 processElement = domain_.containsFaceOf(element);
179 if (processElement)
180 {
181 bindElement(element);
182 const auto& gridView = testSubspaceLocalView.globalBasis().rootBasis().gridView();
183 for(const auto& intersection : intersections(gridView, element))
184 if (intersection.boundary() && !intersection.neighbor())
185 assembleBoundaryIntersectionMatrix(intersection, localMatrix);
186 }
187 }
188
189 private:
190 const BilinearOperator sumOperator_;
191 mutable LocalOperator sumLocalOperator_;
192 const Element* insidePtr_ = nullptr;
194 const Domain& domain_;
195 QuadratureHint quadratureHint_;
196 };
197
198 template<class BilinearOperator, class Domain>
199 IntegratedBoundaryBilinearForm(const BilinearOperator&, const Domain&) -> IntegratedBoundaryBilinearForm<BilinearOperator, Domain>;
200
201
202
203 template<class BilinearOperator, class Domain, class QuadratureHint>
204 struct IsLocalAssembler<IntegratedBoundaryBilinearForm<BilinearOperator, Domain, QuadratureHint>> : public std::true_type {};
205
206
207
208} // namespace Dune::Fufem::Forms
209
210
211#endif // DUNE_FUFEM_FORMS_INTEGRATEDBOUNDARYBILINEARFORM_HH
virtual void operator()()=0
IteratorRange<... > intersections(const GV &gv, const Entity &e)
ALBERTA EL Element
A cache providing multiple versions for different quadrature rules.
Definition shapefunctioncache.hh:466
std::pair< QuadratureRuleKey, std::size_t > FacetKey
Definition shapefunctioncache.hh:477
T forward(T... args)
constexpr Boundary boundary
Object representing the full grid view boundary as integration domain.
Definition domains.hh:243
Definition baseclass.hh:22
IntegratedBoundaryBilinearForm(const BilinearOperator &, const Domain &) -> IntegratedBoundaryBilinearForm< BilinearOperator, Domain >
Definition localsumassembler.hh:80