Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
integratedlinearform.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_INTEGRATEDLINEARFORM_HH
8#define DUNE_FUFEM_FORMS_INTEGRATEDLINEARFORM_HH
9
10#include <cstddef>
11#include <type_traits>
12#include <utility>
13
16
22
23
24
25namespace Dune::Fufem::Forms {
26
27
28
42 template<class LinearOperator, class Domain=Dune::Fufem::Forms::Bulk>
44 {
46 using TestRootLocalView = typename TestRootBasis::LocalView;
47 using TestRootTree = typename TestRootLocalView::Tree;
48
49 using LocalOperator = decltype(localOperator(std::declval<LinearOperator>()));
50
51 public:
52 using Element = typename LinearOperator::Element;
53
54 IntegratedLinearForm(const LinearOperator& sumOperator, const Domain& domain) :
55 sumOperator_(sumOperator),
56 sumLocalOperator_(localOperator(sumOperator_)),
57 domain_(domain)
58 {}
59
64
66 {
67 return sumOperator_;
68 }
69
70 // Dune::Assembler interface
71
72 void bindLocalView (const TestRootLocalView& testLocalView)
73 {
74 cacheManager_.clear();
75 sumLocalOperator_.registerLocalViews(testLocalView.rootLocalView());
76 sumLocalOperator_.registerCaches(cacheManager_.prototype());
77 }
78
79 void bindElement (const Element& element)
80 {}
81
82 template <class LocalVector>
83 void assembleElementVector (const Element& element, LocalVector& localVector)
84 {
85 using namespace Dune::Indices;
86 using namespace Dune::Fufem::Forms::Impl::Tensor;
87
88 if (not domain_.contains(element))
89 return;
90 sumLocalOperator_.bind(element);
91
92 const auto& geometry = element.geometry();
93
94 Impl::forEachTupleEntry(sumLocalOperator_.operators(), [&](auto& op) {
95 cacheManager_[op.quadratureRuleKey()].invalidate();
96 });
97
98 // Lift rank by 1 to prepend zero index for inside
99 auto localTensor = LiftRank(TensorView(localVector, _1), _1);
100
101 Impl::forEachTupleEntry(sumLocalOperator_.operators(), [&](auto& op) {
102 auto& cacheForRule = cacheManager_[op.quadratureRuleKey()];
103 op.bindToCaches(cacheForRule);
104 const auto& quadRule = cacheForRule.rule();
105 for (auto k : Dune::range(quadRule.size()))
106 {
107 const auto& quadPoint = quadRule[k];
108 const auto integrationWeight = quadPoint.weight() * geometry.integrationElement(quadPoint.position());
109 axpy(integrationWeight, op(k), localTensor);
110 }
111 });
112 }
113
114 // Dune::Fufem interface
115
123 template<class TestLocalView>
124 void preprocess(const TestLocalView& testLocalView)
125 {
126 cacheManager_.clear();
127 sumLocalOperator_.registerLocalViews(testLocalView.rootLocalView());
128 sumLocalOperator_.registerCaches(cacheManager_.prototype());
129 }
130
131 template<class LocalVector, class TestLocalView>
132 void operator()(const Element& element, LocalVector& localVector, const TestLocalView& testSubspaceLocalView)
133 {
134 bindElement(element);
135 assembleElementVector(element, localVector);
136 }
137
138 private:
139 const LinearOperator sumOperator_;
140 LocalOperator sumLocalOperator_;
142 const Domain& domain_;
143 };
144
145
146
147 template<class LinearOperator, class Domain>
149
150
151
152} // namespace Dune::Fufem::Forms
153
154
155#endif // DUNE_FUFEM_FORMS_INTEGRATEDLINEARFORM_HH
constexpr Bulk bulk
Object representing the full grid view as integration domain.
Definition domains.hh:233
Definition baseclass.hh:22
Local assembler corresponding to a bulk linear form.
Definition integratedlinearform.hh:44
void operator()(const Element &element, LocalVector &localVector, const TestLocalView &testSubspaceLocalView)
Definition integratedlinearform.hh:132
const LinearOperator & integrandOperator() const
Definition integratedlinearform.hh:65
void preprocess(const TestLocalView &testLocalView)
Register local view.
Definition integratedlinearform.hh:124
typename LinearOperator::Element Element
Definition integratedlinearform.hh:52
void bindLocalView(const TestRootLocalView &testLocalView)
Definition integratedlinearform.hh:72
void assembleElementVector(const Element &element, LocalVector &localVector)
Definition integratedlinearform.hh:83
void bindElement(const Element &element)
Definition integratedlinearform.hh:79
IntegratedLinearForm(const LinearOperator &sumOperator)
Definition integratedlinearform.hh:60
IntegratedLinearForm(const LinearOperator &sumOperator, const Domain &domain)
Definition integratedlinearform.hh:54
Definition localsumassembler.hh:80
A cache providing multiple versions for different quadrature rules.
Definition shapefunctioncache.hh:467
T forward(T... args)