6#include <dune/common/fmatrix.hh>
7#include <dune/common/fvector.hh>
8#include <dune/common/typetraits.hh>
9#include <dune/geometry/type.hh>
11#include <amdis/common/DerivativeTraits.hpp>
12#include <amdis/common/FieldMatVec.hpp>
25 template <
class LocalBasisTraits, std::
size_t dimGlobal>
28 static const std::size_t dimDomainLocal = LocalBasisTraits::dimDomain;
29 static const std::size_t dimDomainGlobal = dimGlobal;
30 static const std::size_t dimRange = LocalBasisTraits::dimRange;
32 using DomainField =
typename LocalBasisTraits::DomainFieldType;
33 using DomainLocal =
typename LocalBasisTraits::DomainType;
34 using DomainGlobal = FieldVector<DomainField, dimDomainGlobal>;
36 using RangeField =
typename LocalBasisTraits::RangeFieldType;
37 using Range =
typename LocalBasisTraits::RangeType;
63 template <
class BasisCache,
class Geometry>
66 using LocalBasis =
typename BasisCache::LocalBasis;
68 static_assert(std::is_same_v<typename LocalBasis::Traits::DomainFieldType, typename Geometry::ctype>,
69 "LocalToGlobalBasisAdapter: LocalBasis must use the same ctype as Geometry");
71 static_assert(std::size_t(LocalBasis::Traits::dimDomain) == std::size_t(Geometry::mydimension),
72 "LocalToGlobalBasisAdapter: LocalBasis domain dimension must match local dimension of Geometry");
75 using Cache = BasisCache;
89 : localBasis_(cache.finiteElement().localBasis())
92 , size_(localBasis_.
size())
96 std::size_t
size()
const {
return size_; }
108 if (geometry_.affine())
110 return localBasis_.order();
113 return localBasis_.order() + Traits::dimDomainGlobal - 1;
118 std::vector<typename Traits::Range>& out)
const
120 out = cache_.localBasisValuesAt(x);
125 auto const&
valuesAt(
typename Traits::DomainLocal
const& x)
const
127 return cache_.localBasisValuesAt(x);
133 std::vector<typename Traits::GradientRange>& out)
const
135 auto const& localJacobian = cache_.localBasisJacobiansAt(x);
136 auto&& geoJacobian = geometry_.jacobianInverseTransposed(x);
139 for (std::size_t i = 0; i < size_; ++i)
140 geoJacobian.mv(Dune::MatVec::as_vector(localJacobian[i]),
141 Dune::MatVec::as_vector(out[i]));
147 auto const&
gradientsAt(
typename Traits::DomainLocal
const& x)
const
157 std::vector<typename Traits::PartialRange>& out)
const
159 auto const& localJacobian = cache_.localBasisJacobiansAt(x);
161 auto&& geoJacobian = geometry_.jacobianInverseTransposed(x);
164 typename Traits::GradientRange grad;
165 auto&& grad_ = Dune::MatVec::as_vector(grad);
166 for (std::size_t i = 0; i < size_; ++i) {
167 geoJacobian.mv(Dune::MatVec::as_vector(localJacobian[i]), grad_);
168 out[i] = grad_[comp];
175 auto const&
partialsAt(
typename Traits::DomainLocal
const& x, std::size_t comp)
const
183 LocalBasis
const& localBasis_;
189 Geometry
const& geometry_;
195 mutable std::vector<typename Traits::GradientRange> outGrad_;
196 mutable std::vector<typename Traits::PartialRange> outPartials_;
Convert a simple (scalar) local basis into a global basis.
Definition: LocalToGlobalAdapter.hpp:65
void evaluatePartial(typename Traits::DomainLocal const &x, std::size_t comp, std::vector< typename Traits::PartialRange > &out) const
Definition: LocalToGlobalAdapter.hpp:155
LocalToGlobalBasisAdapter(Cache const &cache, Geometry const &geometry)
Construct a LocalToGlobalBasisAdapter.
Definition: LocalToGlobalAdapter.hpp:88
std::size_t order() const
Return maximum polynomial order of the base function.
Definition: LocalToGlobalAdapter.hpp:106
void evaluateGradient(typename Traits::DomainLocal const &x, std::vector< typename Traits::GradientRange > &out) const
Definition: LocalToGlobalAdapter.hpp:132
auto const & partialsAt(typename Traits::DomainLocal const &x, std::size_t comp) const
Definition: LocalToGlobalAdapter.hpp:175
auto const & gradientsAt(typename Traits::DomainLocal const &x) const
Definition: LocalToGlobalAdapter.hpp:147
void evaluateFunction(typename Traits::DomainLocal const &x, std::vector< typename Traits::Range > &out) const
Evaluate the local basis functions in the local coordinate x
Definition: LocalToGlobalAdapter.hpp:117
std::size_t size() const
Return the number of local basis functions.
Definition: LocalToGlobalAdapter.hpp:96
auto const & valuesAt(typename Traits::DomainLocal const &x) const
Definition: LocalToGlobalAdapter.hpp:125
Definition: DerivativeTraits.hpp:29
Traits class for local-to-global basis adaptors.
Definition: LocalToGlobalAdapter.hpp:27
Definition: DerivativeTraits.hpp:19
Definition: DerivativeTraits.hpp:22