Dune-Fufem 2.12-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
24
25
26
27namespace Dune::Fufem
28{
29
30 namespace Impl
31 {
32
39 template <class LV, class M>
40 class LeafNodeLaplaceAssembler
41 {
42 public:
43
44 using LocalView = LV;
45 using Matrix = M;
46 using field_type = typename M::field_type;
47
54 LeafNodeLaplaceAssembler(const LV& lv, M& m)
55 : localView_(lv)
56 , matrix_(m)
57 {}
58
59 template<class Node, class TreePath>
60 void operator()(Node& node, [[maybe_unused]] TreePath treePath)
61 {
62 const auto& element = localView_.element();
63 const auto& geometry = element.geometry();
64 const auto& finiteElement = node.finiteElement();
65 const auto& localBasis = finiteElement.localBasis();
66 using JacobianType = typename std::decay_t<decltype(localBasis)>::Traits::JacobianType;
67 constexpr int gridDim = LocalView::GridView::dimension;
68
69 auto feQuadKey = QuadratureRuleKey(finiteElement);
70 // we have a product of jacobians
71 auto quadKey = feQuadKey.derivative().square();
72 const auto& quad = QuadratureRuleCache<double, gridDim>::rule(quadKey);
73
74 for( const auto& qp : quad )
75 {
76 const auto& quadPos = qp.position();
77 const auto integrationElement = geometry.integrationElement(quadPos);
78
79 std::vector<JacobianType> referenceJacobians;
80 localBasis.evaluateJacobian(quadPos, referenceJacobians);
81
82 const auto& jacobianInverse = geometry.jacobianInverse(quadPos);
83
84 // transform jacobians
85 std::vector<decltype(referenceJacobians[0] * jacobianInverse)> jacobians(referenceJacobians.size());
86 for (size_t i=0; i<jacobians.size(); i++)
87 jacobians[i] = referenceJacobians[i] * jacobianInverse;
88
89 // compute matrix entries = inner products of jacobians
90 auto z = qp.weight() * integrationElement;
91 for (std::size_t i=0; i<localBasis.size(); ++i)
92 for (std::size_t j=0; j<localBasis.size(); ++j)
93 for ( std::size_t ii=0; ii<jacobians[i].N(); ii++ )
94 for ( std::size_t jj=0; jj<jacobians[i].M(); jj++ )
95 matrix_[node.localIndex(i)][node.localIndex(j)] += z*jacobians[i][ii][jj]*jacobians[j][ii][jj];
96 }
97 }
98
99 private:
100 const LocalView& localView_;
101 Matrix& matrix_;
102 };
103
104 } // namespace Impl
105
114 class
115 [[deprecated("This class is deprecated and will be removed after 2.11. Use Dune::Fufem::Forms instead.")]]
117 {
118 public:
119
120 [[deprecated("This class is deprecated and will be removed after 2.11. Use Dune::Fufem::Forms instead.")]]
122 {}
123
124 template<class Element, class LocalMatrix, class LocalView>
125 void operator()(const Element& element, LocalMatrix& localMatrix, const LocalView& testLocalView, const LocalView& ansatzLocalView) const
126 {
127 // the Laplace matrix operator assumes test == ansatz
128 if (&testLocalView != &ansatzLocalView)
129 DUNE_THROW(Dune::Exception,"The Laplace matrix operator assumes equal ansatz and test functions");
130
131 // create a tree visitor and compute the inner products of the local functions at the leaf nodes
132 Impl::LeafNodeLaplaceAssembler leadNodeLaplaceAssembler(testLocalView,localMatrix);
133 TypeTree::forEachLeafNode(testLocalView.tree(),leadNodeLaplaceAssembler);
134 }
135
136 };
137
138} // namespace Dune::Fufem
139
140
141
142#endif // DUNE_FUFEM_ASSEMBLERS_LOCALASSEMBLERS_LAPLACEASSEMBLER_HH
143
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)
Local Laplace (stiffness) assembler for dune-functions basis.
Definition laplaceassembler.hh:117
LaplaceAssembler()
Definition laplaceassembler.hh:121
void operator()(const Element &element, LocalMatrix &localMatrix, const LocalView &testLocalView, const LocalView &ansatzLocalView) const
Definition laplaceassembler.hh:125
static const Dune::QuadratureRule< coord_type, dim > & rule(const Dune::GeometryType &gt, const int order, int refinement)
Definition quadraturerulecache.hh:196
A token that specifies a quadrature rule.
Definition quadraturerulecache.hh:39
Definition dunefunctionsboundaryfunctionalassembler.hh:29
T size(T... args)