Loading...
Searching...
No Matches
powerbasis.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_POWERBASIS_HH
#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH
#include <dune/common/reservedvector.hh>
#include <dune/common/typeutilities.hh>
#include <dune/common/indices.hh>
#include <dune/common/typetree/nodeconcepts.hh>
#include <dune/functions/common/utility.hh>
#include <dune/functions/common/type_traits.hh>
#include <dune/functions/functionspacebases/basistags.hh>
#include <dune/functions/functionspacebases/dynamicpowerbasis.hh>
#include <dune/functions/functionspacebases/nodes.hh>
#include <dune/functions/functionspacebases/concepts.hh>
#include <dune/functions/functionspacebases/containerdescriptors.hh>
#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
namespace Dune {
namespace Functions {
// *****************************************************************************
// This is the reusable part of the power bases. It contains
//
// PowerPreBasis
//
// The pre-basis allows to create the others and is the owner of possible shared
// state. These components do _not_ depend on the global basis and local view
// and can be used without a global basis.
// *****************************************************************************
template<class IMS, class SPB, std::size_t C>
class PowerPreBasis :
public DynamicPowerPreBasis<IMS,SPB>
{
using Base = DynamicPowerPreBasis<IMS,SPB>;
public:
using SubPreBasis = SPB;
using Node = PowerBasisNode<typename SubPreBasis::Node, C>;
using size_type = typename Base::size_type;
using IndexMergingStrategy = IMS;
inline static constexpr std::integral_constant<std::size_t,C> children = {};
template<class... SFArgs,
disableCopyMove<PowerPreBasis, SFArgs...> = 0,
enableIfConstructible<SubPreBasis, SFArgs...> = 0>
explicit PowerPreBasis(SFArgs&&... sfArgs) :
Base(std::size_t(C), std::forward<SFArgs>(sfArgs)...)
{}
Node makeNode() const
{
Node node{};
for (std::size_t i=0; i<children(); ++i)
node.setChild(i, Base::subPreBasis_.makeNode());
return node;
}
size_type size() const
{
return size(Dune::ReservedVector<size_type, Base::multiIndexBufferSize>{});
}
template<class SizePrefix>
size_type size(const SizePrefix& prefix) const
{
return Base::sizeImpl(prefix, children, IndexMergingStrategy{});
}
template<class NodeType, typename It>
requires Dune::TypeTree::Concept::UniformInnerTreeNode<NodeType>
It indices(const NodeType& node, It it) const
{
return Base::indicesImpl(node, it, children, IndexMergingStrategy{});
}
auto containerDescriptor() const
{
return Base::containerDescriptorImpl(children);
}
};
namespace BasisFactory {
template<std::size_t k, class ChildPreBasisFactory, class IndexMergingStrategy>
auto power(ChildPreBasisFactory&& childPreBasisFactory, const IndexMergingStrategy&)
{
return [childPreBasisFactory](const auto& gridView) {
auto childPreBasis = childPreBasisFactory(gridView);
return PowerPreBasis<IndexMergingStrategy, decltype(childPreBasis), k>(std::move(childPreBasis));
};
}
template<std::size_t k, class ChildPreBasisFactory>
[[deprecated("Using the method `power` without an explicit index merging strategy"
" will change its meaning after the release of dune-functions 2.11."
" Previously, the default merging strategy was `BlockedInterleaved`,"
" but this will change to `FlatInterleaved`."
" Change the call to `power(..., blockedInterleaved())` to retain the old behavior.")]]
auto power(ChildPreBasisFactory&& childPreBasisFactory)
{
return [childPreBasisFactory](const auto& gridView) {
auto childPreBasis = childPreBasisFactory(gridView);
return PowerPreBasis<BlockedInterleaved, decltype(childPreBasis), k>(std::move(childPreBasis));
};
}
} // end namespace BasisFactory
} // end namespace Functions
} // end namespace Dune
#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_POWERBASIS_HH
nodes.hh
dynamicpowerbasis.hh
defaultglobalbasis.hh
containerdescriptors.hh
Lightweight representation of (hierarchical) size and block structure extracted from a basis to descr...
basistags.hh
type_traits.hh
utility.hh
Dune::Functions::BasisFactory::power
auto power(ChildPreBasisFactory &&childPreBasisFactory, std::size_t k, const IndexMergingStrategy &)
Create a pre-basis factory that can build a PowerPreBasis.
Definition dynamicpowerbasis.hh:410
Dune::Functions::enableIfConstructible
std::enable_if_t< std::is_constructible_v< T, Args... >, int > enableIfConstructible
Helper to constrain forwarding constructors.
Definition type_traits.hh:30
Dune
Definition monomialset.hh:19
Dune::Functions
Definition monomialset.hh:19
Dune::Functions::BasisFactory::IndexMergingStrategy
Base class for index merging strategies to simplify detection.
Definition basistags.hh:48
Dune::Functions::DynamicPowerPreBasis::size_type
std::size_t size_type
Type used for indices and size information.
Definition dynamicpowerbasis.hh:62
Dune::Functions::DynamicPowerPreBasis::DynamicPowerPreBasis
DynamicPowerPreBasis(std::size_t c, SFArgs &&... sfArgs)
Constructor for given child pre-basis objects.
Definition dynamicpowerbasis.hh:82
Dune::Functions::DynamicPowerPreBasis::containerDescriptorImpl
auto containerDescriptorImpl(Children children) const
Definition dynamicpowerbasis.hh:374
Dune::Functions::DynamicPowerPreBasis::sizeImpl
size_type sizeImpl(SizePrefix prefix, Children children, BasisFactory::FlatInterleaved) const
Definition dynamicpowerbasis.hh:139
Dune::Functions::DynamicPowerPreBasis::subPreBasis_
SubPreBasis subPreBasis_
Definition dynamicpowerbasis.hh:391
Dune::Functions::DynamicPowerPreBasis::indicesImpl
It indicesImpl(const NodeType &node, It multiIndices, Children children, BasisFactory::FlatInterleaved) const
Definition dynamicpowerbasis.hh:264
Dune::Functions::PowerBasisNode
Definition nodes.hh:268
Dune::Functions::PowerBasisNode::setChild
void setChild(Index i, TT &&t)
Definition nodes.hh:317
Dune::Functions::PowerPreBasis
A pre-basis for power bases.
Definition powerbasis.hh:54
Dune::Functions::PowerPreBasis::IndexMergingStrategy
IMS IndexMergingStrategy
Strategy used to merge the global indices of the child factories.
Definition powerbasis.hh:69
Dune::Functions::PowerPreBasis::size_type
typename Base::size_type size_type
Type used for indices and size information.
Definition powerbasis.hh:66
Dune::Functions::PowerPreBasis::SubPreBasis
SPB SubPreBasis
The child pre-basis.
Definition powerbasis.hh:60
Dune::Functions::PowerPreBasis::containerDescriptor
auto containerDescriptor() const
Return the associated container descriptor.
Definition powerbasis.hh:119
Dune::Functions::PowerPreBasis::Node
PowerBasisNode< typename SubPreBasis::Node, C > Node
Template mapping root tree path to type of created tree node.
Definition powerbasis.hh:63
Dune::Functions::PowerPreBasis::PowerPreBasis
PowerPreBasis(SFArgs &&... sfArgs)
Constructor for given child pre-basis objects for static size of the power-basis.
Definition powerbasis.hh:82
Dune::Functions::PowerPreBasis::size
size_type size() const
Same as size(prefix) with empty prefix.
Definition powerbasis.hh:98
Dune::Functions::PowerPreBasis::makeNode
Node makeNode() const
Create tree node.
Definition powerbasis.hh:89
Dune::Functions::PowerPreBasis::children
static constexpr std::integral_constant< std::size_t, C > children
Number of children provided as an integral constant.
Definition powerbasis.hh:72
Dune::Functions::PowerPreBasis::indices
It indices(const NodeType &node, It it) const
Maps from subtree index set [0..size-1] to a globally unique multi index in global basis.
Definition powerbasis.hh:113
Dune::Functions::PowerPreBasis::size
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition powerbasis.hh:105
concepts.hh