Loading...
Searching...
No Matches
transformedfiniteelementmixin.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TRANSFORMEDFINITEELEMENTMIXIN_HH
#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TRANSFORMEDFINITEELEMENTMIXIN_HH
#include <array>
#include <type_traits>
#include <utility>
#include <vector>
namespace Dune::Functions::Impl {
template<class FEImplementation, class ReferenceLocalBasisTraits>
class TransformedLocalBasis
{
public:
using Traits = ReferenceLocalBasisTraits;
TransformedLocalBasis(FEImplementation const& feImpl)
: feImpl_(&feImpl)
{}
public:
auto size() const
{
return feImpl_->size();
}
void evaluateFunction(const typename Traits::DomainType &x,
std::vector<typename Traits::RangeType> &out) const
{
feImpl_->referenceLocalBasis().evaluateFunction(x, rangeBuffer_);
out.resize(size());
feImpl_->transform(rangeBuffer_, out);
}
void evaluateJacobian(const typename Traits::DomainType &x,
std::vector<typename Traits::JacobianType> &out) const
{
feImpl_->referenceLocalBasis().evaluateJacobian(x, jacobianBuffer_);
out.resize(size());
feImpl_->transform(jacobianBuffer_, out);
}
template<class TT,
std::enable_if_t<std::is_same_v<TT, typename Traits::HessianType>, int> = 0>
void evaluateHessian(const typename Traits::DomainType &x,
std::vector<TT> &out) const
{
feImpl_->referenceLocalBasis().evaluateHessian(x, hessianBuffer_);
out.resize(size());
feImpl_->transform(hessianBuffer_, out);
}
void partial(std::array<unsigned int, Traits::dimDomain> const &order,
const typename Traits::DomainType &x,
std::vector<typename Traits::RangeType> &out) const
{
feImpl_->referenceLocalBasis().partial(order, x, rangeBuffer_);
out.resize(size());
feImpl_->transform(rangeBuffer_, out);
}
auto order() const { return feImpl_->referenceLocalBasis().order(); }
private:
FEImplementation const* feImpl_;
mutable std::vector<typename Traits::RangeType> rangeBuffer_;
mutable std::vector<typename Traits::JacobianType> jacobianBuffer_;
mutable std::vector<typename Traits::HessianType> hessianBuffer_;
};
template<class FEImplementation, class ReferenceLocalBasisTraits>
class TransformedFiniteElementMixin
{
public:
TransformedFiniteElementMixin()
: tlb_(this->asImpl())
{}
TransformedFiniteElementMixin(TransformedFiniteElementMixin const& other)
: TransformedFiniteElementMixin()
{}
const FEImplementation& asImpl() const
{
return *(static_cast<FEImplementation const*>(this));
}
auto const& localBasis() const
{
return tlb_;
}
protected:
TransformedLocalBasis<FEImplementation, ReferenceLocalBasisTraits> tlb_;
};
} // end namespace Dune::Functions::Impl
#endif