Loading...
Searching...
No Matches
restrictedbasis.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_RESTRICTEDBASIS_HH
#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RESTRICTEDBASIS_HH
#include <cstddef>
#include <utility>
#include <dune/common/typetree/traversal.hh>
#include <dune/functions/functionspacebases/nodes.hh>
namespace Dune::Functions::Experimental {
template<class GV, class SDPB, class SD>
class RestrictedPreBasis
{
using This = RestrictedPreBasis<GV, SDPB, SD>;
public:
using SubDomain = SD;
using SubDomainPreBasis = SDPB;
using SubDomainGridView = typename SubDomainPreBasis::GridView;
using GridView = GV;
using size_type = std::size_t;
class Node
: public SubDomainPreBasis::Node
{
using Base = typename SubDomainPreBasis::Node;
public:
using Element = typename Base::Element;
Node(Base&& base, const SubDomainGridView& subDomainGridView, const SubDomain& subDomain)
: Base(base)
, subDomainGridView_(subDomainGridView)
, subDomain_(subDomain)
{}
void bind(const Element& element)
{
if (subDomainGridView_.contains(element))
Base::bind(element);
else
{
Dune::TypeTree::forEachNode(static_cast<Base&>(*this) , [&](auto& node, const auto& treePath) {
Dune::Functions::Impl::BasisNodeSetupHelper::setOffset(node, this->offset());
Dune::Functions::Impl::BasisNodeSetupHelper::setSize(node, 0);
});
}
}
const SubDomain& subDomain() const
{
return subDomain_;
}
private:
const SubDomainGridView& subDomainGridView_;
const SubDomain& subDomain_;
};
static constexpr size_type maxMultiIndexSize = SubDomainPreBasis::maxMultiIndexSize;
static constexpr size_type minMultiIndexSize = SubDomainPreBasis::minMultiIndexSize;
static constexpr size_type multiIndexBufferSize = SubDomainPreBasis::multiIndexBufferSize;
RestrictedPreBasis(const GridView& gridView, SubDomainPreBasis&& subDomainPreBasis, const SubDomain& subDomain)
: gridView_(gridView)
, subDomainPreBasis_(std::move(subDomainPreBasis))
, subDomainPtr_(&subDomain)
{}
void initializeIndices()
{
subDomainPreBasis_.initializeIndices();
}
const GridView& gridView() const
{
return gridView_;
}
void update(const GridView& gv)
{
gridView_ = gv;
subDomainPreBasis_.update(subDomainPtr_->gridView());
}
Node makeNode() const
{
return Node(subDomainPreBasis_.makeNode(), subDomainPreBasis_.gridView(), *subDomainPtr_);
}
size_type size() const
{
return subDomainPreBasis_.size();
}
template<class SizePrefix>
size_type size(const SizePrefix& prefix) const
{
return subDomainPreBasis_.size(prefix);
}
auto containerDescriptor() const
{
return subDomainPreBasis_.containerDescriptor();
}
size_type dimension() const
{
return subDomainPreBasis_.dimension();
}
size_type maxNodeSize() const
{
return subDomainPreBasis_.maxNodeSize();
}
const SubDomainPreBasis& subDomainPreBasis() const
{
return subDomainPreBasis_;
}
SubDomainPreBasis& subDomainPreBasis()
{
return subDomainPreBasis_;
}
template<typename It>
It indices(const Node& node, It it) const
{
if (node.size() == 0)
return it;
else
return subDomainPreBasis_.indices(node, it);
}
protected:
GridView gridView_;
SubDomainPreBasis subDomainPreBasis_;
const SubDomain* subDomainPtr_;
};
namespace BasisFactory {
template<class SubDomainBasisFactory, class SubDomain>
auto restrict(SubDomainBasisFactory&& subPreBasisFactory, const SubDomain& subDomain)
{
return [
subPreBasisFactory=std::forward<SubDomainBasisFactory>(subPreBasisFactory),
&subDomain
](const auto& gridView) {
return Dune::Functions::Experimental::RestrictedPreBasis(gridView, subPreBasisFactory(subDomain.gridView()), subDomain);
};
}
} // end namespace BasisFactory
} // end namespace Dune::Functions::Experimental
#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_RESTRICTEDBASIS_HH
nodes.hh
Dune::Functions::Experimental::BasisFactory::restrict
auto restrict(SubDomainBasisFactory &&subPreBasisFactory, const SubDomain &subDomain)
Create a RestrictedPreBasisFactory.
Definition restrictedbasis.hh:225
Dune::Functions::Experimental
Definition subdomain.hh:28
Dune::Functions::Experimental::BasisFactory
Definition restrictedbasis.hh:205
Dune::Functions::Experimental::SubDomain
Class representing a sub-domain of a GridView.
Definition subdomain.hh:534
Dune::Functions::Experimental::SubDomain::gridView
GridView gridView() const
Create grid view representing the SubDomain.
Definition subdomain.hh:565
Dune::Functions::Experimental::RestrictedPreBasis
A pre-basis restricted to a sub-domain.
Definition restrictedbasis.hh:44
Dune::Functions::Experimental::RestrictedPreBasis::size_type
std::size_t size_type
Type used for indices and size information.
Definition restrictedbasis.hh:57
Dune::Functions::Experimental::RestrictedPreBasis::RestrictedPreBasis
RestrictedPreBasis(const GridView &gridView, SubDomainPreBasis &&subDomainPreBasis, const SubDomain &subDomain)
Constructor for given sub-domain pre-basis.
Definition restrictedbasis.hh:107
Dune::Functions::Experimental::RestrictedPreBasis::initializeIndices
void initializeIndices()
Initialize the global indices.
Definition restrictedbasis.hh:114
Dune::Functions::Experimental::RestrictedPreBasis::subDomainPreBasis
const SubDomainPreBasis & subDomainPreBasis() const
Definition restrictedbasis.hh:178
Dune::Functions::Experimental::RestrictedPreBasis::SubDomainPreBasis
SDPB SubDomainPreBasis
Definition restrictedbasis.hh:50
Dune::Functions::Experimental::RestrictedPreBasis::minMultiIndexSize
static constexpr size_type minMultiIndexSize
Definition restrictedbasis.hh:98
Dune::Functions::Experimental::RestrictedPreBasis::dimension
size_type dimension() const
Get the total dimension of the space spanned by this basis.
Definition restrictedbasis.hh:167
Dune::Functions::Experimental::RestrictedPreBasis::subDomainPreBasis_
SubDomainPreBasis subDomainPreBasis_
Definition restrictedbasis.hh:199
Dune::Functions::Experimental::RestrictedPreBasis::subDomainPreBasis
SubDomainPreBasis & subDomainPreBasis()
Definition restrictedbasis.hh:183
Dune::Functions::Experimental::RestrictedPreBasis::GridView
GV GridView
The grid view that the FE basis is defined on.
Definition restrictedbasis.hh:54
Dune::Functions::Experimental::RestrictedPreBasis::maxNodeSize
size_type maxNodeSize() const
Get the maximal number of DOFs associated to node for any element.
Definition restrictedbasis.hh:173
Dune::Functions::Experimental::RestrictedPreBasis::SubDomain
SD SubDomain
Definition restrictedbasis.hh:49
Dune::Functions::Experimental::RestrictedPreBasis::size
size_type size() const
Same as size(prefix) with empty prefix.
Definition restrictedbasis.hh:148
Dune::Functions::Experimental::RestrictedPreBasis::subDomainPtr_
const SubDomain * subDomainPtr_
Definition restrictedbasis.hh:200
Dune::Functions::Experimental::RestrictedPreBasis::size
size_type size(const SizePrefix &prefix) const
Return number of possible values for next position in multi index.
Definition restrictedbasis.hh:155
Dune::Functions::Experimental::RestrictedPreBasis::SubDomainGridView
typename SubDomainPreBasis::GridView SubDomainGridView
Definition restrictedbasis.hh:51
Dune::Functions::Experimental::RestrictedPreBasis::multiIndexBufferSize
static constexpr size_type multiIndexBufferSize
Definition restrictedbasis.hh:99
Dune::Functions::Experimental::RestrictedPreBasis::gridView_
GridView gridView_
Definition restrictedbasis.hh:198
Dune::Functions::Experimental::RestrictedPreBasis::gridView
const GridView & gridView() const
Obtain the grid view that the basis is defined on.
Definition restrictedbasis.hh:120
Dune::Functions::Experimental::RestrictedPreBasis::indices
It indices(const Node &node, It it) const
Definition restrictedbasis.hh:189
Dune::Functions::Experimental::RestrictedPreBasis::containerDescriptor
auto containerDescriptor() const
Return the container descriptor of the pre-basis.
Definition restrictedbasis.hh:161
Dune::Functions::Experimental::RestrictedPreBasis::makeNode
Node makeNode() const
Create tree node.
Definition restrictedbasis.hh:142
Dune::Functions::Experimental::RestrictedPreBasis::maxMultiIndexSize
static constexpr size_type maxMultiIndexSize
Definition restrictedbasis.hh:97
Dune::Functions::Experimental::RestrictedPreBasis::update
void update(const GridView &gv)
Update the stored grid view, to be called.
Definition restrictedbasis.hh:133
Dune::Functions::Experimental::RestrictedPreBasis::Node
Template mapping root tree path to type of created tree node.
Definition restrictedbasis.hh:62
Dune::Functions::Experimental::RestrictedPreBasis::Node::Element
typename Base::Element Element
Definition restrictedbasis.hh:66
Dune::Functions::Experimental::RestrictedPreBasis::Node::bind
void bind(const Element &element)
Definition restrictedbasis.hh:74
Dune::Functions::Experimental::RestrictedPreBasis::Node::subDomain
const SubDomain & subDomain() const
Definition restrictedbasis.hh:87
Dune::Functions::Experimental::RestrictedPreBasis::Node::Node
Node(Base &&base, const SubDomainGridView &subDomainGridView, const SubDomain &subDomain)
Definition restrictedbasis.hh:68