Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
laplaceassembler.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3
4#ifndef DUNE_FUFEM_ASSEMBLERS_LOCALASSEMBLERS_LAPLACEASSEMBLER_HH
5#define DUNE_FUFEM_ASSEMBLERS_LOCALASSEMBLERS_LAPLACEASSEMBLER_HH
6
7#ifndef DUNE_FUFEM_DISABLE_HEADER_DEPRECATION
8#warning This header is deprecated and will be removed after 2.11. Use Dune::Fufem::Forms instead.
9#endif
10
20
21#include <dune/istl/matrix.hh>
22
23#if DUNE_VERSION_GTE(DUNE_FUNCTIONS, 2, 11)
25#else
26#include <dune/typetree/traversal.hh>
27#endif
28
30
31
32
33namespace Dune::Fufem
34{
35
36 namespace Impl
37 {
38
45 template <class LV, class M>
46 class LeafNodeLaplaceAssembler
47 {
48 public:
49
50 using LocalView = LV;
51 using Matrix = M;
52 using field_type = typename M::field_type;
53
60 LeafNodeLaplaceAssembler(const LV& lv, M& m)
61 : localView_(lv)
62 , matrix_(m)
63 {}
64
65 template<class Node, class TreePath>
66 void operator()(Node& node, [[maybe_unused]] TreePath treePath)
67 {
68 const auto& element = localView_.element();
69 const auto& geometry = element.geometry();
70 const auto& finiteElement = node.finiteElement();
71 const auto& localBasis = finiteElement.localBasis();
72 using JacobianType = typename std::decay_t<decltype(localBasis)>::Traits::JacobianType;
73 constexpr int gridDim = LocalView::GridView::dimension;
74
75 auto feQuadKey = QuadratureRuleKey(finiteElement);
76 // we have a product of jacobians
77 auto quadKey = feQuadKey.derivative().square();
78 const auto& quad = QuadratureRuleCache<double, gridDim>::rule(quadKey);
79
80 for( const auto& qp : quad )
81 {
82 const auto& quadPos = qp.position();
83 const auto integrationElement = geometry.integrationElement(quadPos);
84
85 std::vector<JacobianType> referenceJacobians;
86 localBasis.evaluateJacobian(quadPos, referenceJacobians);
87
88 const auto& jacobianInverse = geometry.jacobianInverse(quadPos);
89
90 // transform jacobians
91 std::vector<decltype(referenceJacobians[0] * jacobianInverse)> jacobians(referenceJacobians.size());
92 for (size_t i=0; i<jacobians.size(); i++)
93 jacobians[i] = referenceJacobians[i] * jacobianInverse;
94
95 // compute matrix entries = inner products of jacobians
96 auto z = qp.weight() * integrationElement;
97 for (std::size_t i=0; i<localBasis.size(); ++i)
98 for (std::size_t j=0; j<localBasis.size(); ++j)
99 for ( std::size_t ii=0; ii<jacobians[i].N(); ii++ )
100 for ( std::size_t jj=0; jj<jacobians[i].M(); jj++ )
101 matrix_[node.localIndex(i)][node.localIndex(j)] += z*jacobians[i][ii][jj]*jacobians[j][ii][jj];
102 }
103 }
104
105 private:
106 const LocalView& localView_;
107 Matrix& matrix_;
108 };
109
110 } // namespace Impl
111
120 class
121 [[deprecated("This class is deprecated and will be removed after 2.11. Use Dune::Fufem::Forms instead.")]]
123 {
124 public:
125
126 [[deprecated("This class is deprecated and will be removed after 2.11. Use Dune::Fufem::Forms instead.")]]
129
130 template<class Element, class LocalMatrix, class LocalView>
131 void operator()(const Element& element, LocalMatrix& localMatrix, const LocalView& testLocalView, const LocalView& ansatzLocalView) const
132 {
133 // the Laplace matrix operator assumes test == ansatz
134 if (&testLocalView != &ansatzLocalView)
135 DUNE_THROW(Dune::Exception,"The Laplace matrix operator assumes equal ansatz and test functions");
136
137 // create a tree visitor and compute the inner products of the local functions at the leaf nodes
138 Impl::LeafNodeLaplaceAssembler leadNodeLaplaceAssembler(testLocalView,localMatrix);
139 TypeTree::forEachLeafNode(testLocalView.tree(),leadNodeLaplaceAssembler);
140 }
141
142 };
143
144} // namespace Dune::Fufem
145
146
147
148#endif // DUNE_FUFEM_ASSEMBLERS_LOCALASSEMBLERS_LAPLACEASSEMBLER_HH
149
Dune::BCRSMatrix< FieldMatrix< T, n, m >, TA > Matrix
static constexpr size_type M()
virtual void operator()()=0
#define DUNE_THROW(E,...)
void forEachLeafNode(Tree &&tree, LeafFunc &&leafFunc)
Definition dunefunctionsboundaryfunctionalassembler.hh:29
Local Laplace (stiffness) assembler for dune-functions basis.
Definition laplaceassembler.hh:123
LaplaceAssembler()
Definition laplaceassembler.hh:127
void operator()(const Element &element, LocalMatrix &localMatrix, const LocalView &testLocalView, const LocalView &ansatzLocalView) const
Definition laplaceassembler.hh:131
A token that specifies a quadrature rule.
Definition quadraturerulecache.hh:39
static const Dune::QuadratureRule< coord_type, dim > & rule(const Dune::GeometryType &gt, const int order, int refinement)
Definition quadraturerulecache.hh:196
T size(T... args)