DUNE PDELab (git)

transformedfiniteelementmixin.hh
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 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_FUNCTIONS_FUNCTIONSPACEBASES_TRANSFORMEDFINITEELEMENTMIXIN_HH
8#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TRANSFORMEDFINITEELEMENTMIXIN_HH
9
10namespace Dune::Functions::Impl {
11
19template<class FEImplementation, class ReferenceLocalBasisTraits>
20class TransformedLocalBasis
21{
22 public:
23 using Traits = ReferenceLocalBasisTraits;
24
25 TransformedLocalBasis(FEImplementation const& feImpl)
26 : feImpl_(&feImpl)
27 {}
28
29 public:
34 auto size() const
35 {
36 return feImpl_->size();
37 }
38
40 void evaluateFunction(const typename Traits::DomainType &x,
41 std::vector<typename Traits::RangeType> &out) const
42 {
43 feImpl_->referenceLocalBasis().evaluateFunction(x, rangeBuffer_);
44 out.resize(size());
45 feImpl_->transform(rangeBuffer_, out);
46 }
47
54 void evaluateJacobian(const typename Traits::DomainType &x,
55 std::vector<typename Traits::JacobianType> &out) const
56 {
57 feImpl_->referenceLocalBasis().evaluateJacobian(x, jacobianBuffer_);
58 out.resize(size());
59 feImpl_->transform(jacobianBuffer_, out);
60 }
61
72 template<class TT,
73 std::enable_if_t<std::is_same_v<TT, typename Traits::HessianType>, int> = 0>
74 void evaluateHessian(const typename Traits::DomainType &x,
75 std::vector<TT> &out) const
76 {
77 feImpl_->referenceLocalBasis().evaluateHessian(x, hessianBuffer_);
78 out.resize(size());
79 feImpl_->transform(hessianBuffer_, out);
80 }
81
89 void partial(std::array<unsigned int, Traits::dimDomain> const &order,
90 const typename Traits::DomainType &x,
91 std::vector<typename Traits::RangeType> &out) const
92 {
93 feImpl_->referenceLocalBasis().partial(order, x, rangeBuffer_);
94 out.resize(size());
95 feImpl_->transform(rangeBuffer_, out);
96 }
97
99 auto order() const { return feImpl_->referenceLocalBasis().order(); }
100
101 private:
102 FEImplementation const* feImpl_;
103 mutable std::vector<typename Traits::RangeType> rangeBuffer_;
104 mutable std::vector<typename Traits::JacobianType> jacobianBuffer_;
105 mutable std::vector<typename Traits::HessianType> hessianBuffer_;
106};
107
108
109
141template<class FEImplementation, class ReferenceLocalBasisTraits>
142class TransformedFiniteElementMixin
143{
144 public:
145 TransformedFiniteElementMixin()
146 : tlb_(this->asImpl())
147 {}
148
149 TransformedFiniteElementMixin(TransformedFiniteElementMixin const& other)
150 : TransformedFiniteElementMixin()
151 {}
152
153 const FEImplementation& asImpl() const
154 {
155 return *(static_cast<FEImplementation const*>(this));
156 }
157
158 auto const& localBasis() const
159 {
160 return tlb_;
161 }
162
163 protected:
164 TransformedLocalBasis<FEImplementation, ReferenceLocalBasisTraits> tlb_;
165};
166
167} // end namespace Dune::Functions::Impl
168
169#endif
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)