Loading...
Searching...
No Matches
transformedindexbasis.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_TRANSFORMEDINDEXBASIS_HH
#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TRANSFORMEDINDEXBASIS_HH
#include <tuple>
#include <utility>
#include <dune/common/hybridutilities.hh>
#include <dune/common/reservedvector.hh>
#include <dune/common/typeutilities.hh>
#include <dune/common/hybridutilities.hh>
#include <dune/functions/common/staticforloop.hh>
#include <dune/functions/common/type_traits.hh>
#include <dune/functions/common/utility.hh>
#include <dune/functions/functionspacebases/basistags.hh>
#include <dune/functions/functionspacebases/nodes.hh>
#include <dune/functions/functionspacebases/concepts.hh>
#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
namespace Dune {
namespace Functions {
namespace Experimental {
// *****************************************************************************
// *****************************************************************************
template<class RPB, class T>
class TransformedIndexPreBasis
{
using Transformation = T;
using This = TransformedIndexPreBasis<RPB, T>;
public:
using RawPreBasis = RPB;
using GridView = typename RawPreBasis::GridView;
using size_type = std::size_t;
using Node = typename RawPreBasis::Node;
static constexpr size_type maxMultiIndexSize = Transformation::maxIndexSize;
static constexpr size_type minMultiIndexSize = Transformation::minIndexSize;
static constexpr size_type multiIndexBufferSize = std::max(RawPreBasis::multiIndexBufferSize, maxMultiIndexSize);
template<class RPB_R, class T_R>
TransformedIndexPreBasis(RPB_R&& rawPreBasis, T_R&& transformation) :
rawPreBasis_(std::forward<RPB_R>(rawPreBasis)),
transformation_(std::forward<T_R>(transformation))
{}
void initializeIndices()
{
rawPreBasis_.initializeIndices();
}
const GridView& gridView() const
{
return rawPreBasis_.gridView();
}
void update(const GridView& gv)
{
rawPreBasis_.update(gv);
}
Node makeNode() const
{
return rawPreBasis_.makeNode();
}
size_type size() const
{
return size(Dune::ReservedVector<size_type, multiIndexBufferSize>{});
}
template<class SizePrefix>
size_type size(const SizePrefix& prefix) const
{
return transformation_.size(prefix, rawPreBasis_);
}
auto containerDescriptor() const
{
return transformation_.containerDescriptor(rawPreBasis_);
}
size_type dimension() const
{
return transformation_.dimension(rawPreBasis_);
}
size_type maxNodeSize() const
{
return rawPreBasis_.maxNodeSize();
}
const RawPreBasis& rawPreBasis() const
{
return rawPreBasis_;
}
RawPreBasis& rawPreBasis()
{
return rawPreBasis_;
}
template<class MultiIndex>
void transformIndex(MultiIndex& multiIndex) const
{
transformation_.transformIndex(multiIndex, rawPreBasis_);
}
template<typename It>
It indices(const Node& node, It it) const
{
rawPreBasis().indices(node, it);
for(std::size_t i=0; i<node.size(); ++i)
{
transformIndex(*it);
++it;
}
return it;
}
protected:
RawPreBasis rawPreBasis_;
Transformation transformation_;
};
template<class RPB, class T>
TransformedIndexPreBasis(RPB&&, T&&) -> TransformedIndexPreBasis<std::decay_t<RPB>, std::decay_t<T>>;
} // end namespace Experimental
namespace BasisFactory {
namespace Experimental {
template<class RawPreBasisFactory, class Transformation>
auto transformIndices(
RawPreBasisFactory&& preBasisFactory,
Transformation&& transformation)
{
return [
preBasisFactory=std::forward<RawPreBasisFactory>(preBasisFactory),
transformation =std::forward<Transformation>(transformation)
](const auto& gridView) {
return Dune::Functions::Experimental::TransformedIndexPreBasis(preBasisFactory(gridView), std::move(transformation));
};
}
template<class IndexTransformation, class SizeImplementation, class ContainerDescriptorImplementation, std::size_t minIS, std::size_t maxIS>
class GenericIndexingTransformation
{
public:
static constexpr std::size_t minIndexSize = minIS;
static constexpr std::size_t maxIndexSize = maxIS;
template<class IT_R, class SI_R, class CD_R>
GenericIndexingTransformation(IT_R&& indexTransformation, SI_R&& sizeImplementation, CD_R&& containerDescriptorImplementation) :
indexTransformation_(std::forward<IT_R>(indexTransformation)),
sizeImplementation_(std::forward<SI_R>(sizeImplementation)),
containerDescriptorImplementation_(std::forward<CD_R>(containerDescriptorImplementation))
{}
template<class MultiIndex, class PreBasis>
void transformIndex(MultiIndex& multiIndex, const PreBasis& preBasis) const
{
indexTransformation_(multiIndex, preBasis);
}
template<class Prefix, class PreBasis>
auto size(const Prefix& prefix, const PreBasis& preBasis) const
{
return sizeImplementation_(prefix, preBasis);
}
template<class PreBasis>
auto dimension(const PreBasis& preBasis) const
{
return preBasis.dimension();
}
template<class PreBasis>
auto containerDescriptor(const PreBasis& preBasis) const
{
return containerDescriptorImplementation_(preBasis);
}
private:
IndexTransformation indexTransformation_;
SizeImplementation sizeImplementation_;
ContainerDescriptorImplementation containerDescriptorImplementation_;
};
template<class IndexTransformation, class SizeImplementation, class ContainerDescriptorImplementation, std::size_t minIndexSize, std::size_t maxIndexSize>
auto indexTransformation(IndexTransformation&& indexTransformation,
SizeImplementation&& sizeImplementation,
ContainerDescriptorImplementation&& containerDescriptorImplementation,
Dune::index_constant<minIndexSize>,
Dune::index_constant<maxIndexSize>)
{
return GenericIndexingTransformation<
std::decay_t<IndexTransformation>,
std::decay_t<SizeImplementation>,
std::decay_t<ContainerDescriptorImplementation>,
minIndexSize, maxIndexSize>(
std::forward<IndexTransformation>(indexTransformation),
std::forward<SizeImplementation>(sizeImplementation),
std::forward<ContainerDescriptorImplementation>(containerDescriptorImplementation));
}
template<class IndexTransformation, class SizeImplementation,
std::size_t minIndexSize, std::size_t maxIndexSize>
auto indexTransformation(IndexTransformation&& indexTrafo,
SizeImplementation&& sizeImpl,
Dune::index_constant<minIndexSize> minSize,
Dune::index_constant<maxIndexSize> maxSize)
{
return indexTransformation(indexTrafo, sizeImpl,
[](auto&&) { return Dune::Functions::ContainerDescriptors::Unknown{}; },
minSize, maxSize);
}
} // end namespace Experimental
} // end namespace BasisFactory
} // end namespace Functions
} // end namespace Dune
#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_TRANSFORMEDINDEXBASIS_HH
nodes.hh
defaultglobalbasis.hh
basistags.hh
staticforloop.hh
type_traits.hh
utility.hh
Dune
Definition monomialset.hh:19
Dune::Functions
Definition monomialset.hh:19
Dune::Functions::Experimental
Definition subdomain.hh:28
Dune::Functions::Experimental::TransformedIndexPreBasis
TransformedIndexPreBasis(RPB &&, T &&) -> TransformedIndexPreBasis< std::decay_t< RPB >, std::decay_t< T > >
Dune::Functions::BasisFactory
Definition argyrisbasis.hh:926
Dune::Functions::BasisFactory::Experimental::indexTransformation
auto indexTransformation(IndexTransformation &&indexTransformation, SizeImplementation &&sizeImplementation, ContainerDescriptorImplementation &&containerDescriptorImplementation, Dune::index_constant< minIndexSize >, Dune::index_constant< maxIndexSize >)
A generic implementation of a transformation.
Definition transformedindexbasis.hh:296
Dune::Functions::BasisFactory::Experimental::transformIndices
auto transformIndices(RawPreBasisFactory &&preBasisFactory, Transformation &&transformation)
Create a TransformedIndexPreBasisFactory.
Definition transformedindexbasis.hh:197
Dune::Functions::ContainerDescriptors::Unknown
Fallback container descriptor if nothing else fits.
Definition containerdescriptors.hh:52
Dune::Functions::Experimental::TransformedIndexPreBasis
A pre-basis transforming multi-indices.
Definition transformedindexbasis.hh:52
Dune::Functions::Experimental::TransformedIndexPreBasis::indices
It indices(const Node &node, It it) const
Definition transformedindexbasis.hh:159
Dune::Functions::Experimental::TransformedIndexPreBasis::transformation_
Transformation transformation_
Definition transformedindexbasis.hh:172
Dune::Functions::Experimental::TransformedIndexPreBasis::initializeIndices
void initializeIndices()
Initialize the global indices.
Definition transformedindexbasis.hh:86
Dune::Functions::Experimental::TransformedIndexPreBasis::GridView
typename RawPreBasis::GridView GridView
The grid view that the FE basis is defined on.
Definition transformedindexbasis.hh:62
Dune::Functions::Experimental::TransformedIndexPreBasis::transformIndex
void transformIndex(MultiIndex &multiIndex) const
Definition transformedindexbasis.hh:153
Dune::Functions::Experimental::TransformedIndexPreBasis::rawPreBasis_
RawPreBasis rawPreBasis_
Definition transformedindexbasis.hh:171
Dune::Functions::Experimental::TransformedIndexPreBasis::Node
typename RawPreBasis::Node Node
Template mapping root tree path to type of created tree node.
Definition transformedindexbasis.hh:68
Dune::Functions::Experimental::TransformedIndexPreBasis::TransformedIndexPreBasis
TransformedIndexPreBasis(RPB_R &&rawPreBasis, T_R &&transformation)
Constructor for given child pre-basis objects.
Definition transformedindexbasis.hh:80
Dune::Functions::Experimental::TransformedIndexPreBasis::rawPreBasis
RawPreBasis & rawPreBasis()
Definition transformedindexbasis.hh:147
Dune::Functions::Experimental::TransformedIndexPreBasis::maxMultiIndexSize
static constexpr size_type maxMultiIndexSize
Definition transformedindexbasis.hh:70
Dune::Functions::Experimental::TransformedIndexPreBasis::update
void update(const GridView &gv)
Update the stored grid view, to be called if the grid has changed.
Definition transformedindexbasis.hh:98
Dune::Functions::Experimental::TransformedIndexPreBasis::makeNode
Node makeNode() const
Create tree node.
Definition transformedindexbasis.hh:106
Dune::Functions::Experimental::TransformedIndexPreBasis::gridView
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition transformedindexbasis.hh:92
Dune::Functions::Experimental::TransformedIndexPreBasis::size
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition transformedindexbasis.hh:119
Dune::Functions::Experimental::TransformedIndexPreBasis::RawPreBasis
RPB RawPreBasis
Definition transformedindexbasis.hh:59
Dune::Functions::Experimental::TransformedIndexPreBasis::size
size_type size() const
Same as size(prefix) with empty prefix.
Definition transformedindexbasis.hh:112
Dune::Functions::Experimental::TransformedIndexPreBasis::maxNodeSize
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition transformedindexbasis.hh:137
Dune::Functions::Experimental::TransformedIndexPreBasis::size_type
std::size_t size_type
Type used for indices and size information.
Definition transformedindexbasis.hh:65
Dune::Functions::Experimental::TransformedIndexPreBasis::multiIndexBufferSize
static constexpr size_type multiIndexBufferSize
Definition transformedindexbasis.hh:72
Dune::Functions::Experimental::TransformedIndexPreBasis::dimension
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition transformedindexbasis.hh:131
Dune::Functions::Experimental::TransformedIndexPreBasis::rawPreBasis
const RawPreBasis & rawPreBasis() const
Definition transformedindexbasis.hh:142
Dune::Functions::Experimental::TransformedIndexPreBasis::minMultiIndexSize
static constexpr size_type minMultiIndexSize
Definition transformedindexbasis.hh:71
Dune::Functions::Experimental::TransformedIndexPreBasis::containerDescriptor
auto containerDescriptor() const
Return the container descriptor of the transformed pre-basis.
Definition transformedindexbasis.hh:125
Dune::Functions::BasisFactory::Experimental::GenericIndexingTransformation
A generic implementation of a transformation.
Definition transformedindexbasis.hh:231
Dune::Functions::BasisFactory::Experimental::GenericIndexingTransformation::GenericIndexingTransformation
GenericIndexingTransformation(IT_R &&indexTransformation, SI_R &&sizeImplementation, CD_R &&containerDescriptorImplementation)
Definition transformedindexbasis.hh:238
Dune::Functions::BasisFactory::Experimental::GenericIndexingTransformation::maxIndexSize
static constexpr std::size_t maxIndexSize
Definition transformedindexbasis.hh:235
Dune::Functions::BasisFactory::Experimental::GenericIndexingTransformation::containerDescriptor
auto containerDescriptor(const PreBasis &preBasis) const
Definition transformedindexbasis.hh:263
Dune::Functions::BasisFactory::Experimental::GenericIndexingTransformation::dimension
auto dimension(const PreBasis &preBasis) const
Definition transformedindexbasis.hh:257
Dune::Functions::BasisFactory::Experimental::GenericIndexingTransformation::size
auto size(const Prefix &prefix, const PreBasis &preBasis) const
Definition transformedindexbasis.hh:251
Dune::Functions::BasisFactory::Experimental::GenericIndexingTransformation::minIndexSize
static constexpr std::size_t minIndexSize
Definition transformedindexbasis.hh:234
Dune::Functions::BasisFactory::Experimental::GenericIndexingTransformation::transformIndex
void transformIndex(MultiIndex &multiIndex, const PreBasis &preBasis) const
Definition transformedindexbasis.hh:245
concepts.hh