Loading...
Searching...
No Matches
defaultlocalview.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_DEFAULTLOCALVIEW_HH
#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTLOCALVIEW_HH
#include <tuple>
#include <optional>
#include <dune/common/concept.hh>
#include <dune/common/hybridutilities.hh>
#include <dune/common/reservedvector.hh>
#include <dune/functions/common/overflowarray.hh>
#include <dune/functions/common/multiindex.hh>
#include <dune/functions/functionspacebases/concepts.hh>
namespace Dune {
namespace Functions {
template<class GB>
class DefaultLocalView
{
public:
using GlobalBasis = GB;
using GridView = typename GlobalBasis::GridView;
using Element = typename GridView::template Codim<0>::Entity;
using size_type = std::size_t;
using Tree = typename GlobalBasis::PreBasis::Node;
protected:
using PreBasis = typename GlobalBasis::PreBasis;
// Type used to store the multi indices of the basis vectors.
// In contrast to MultiIndex this always has dynamic size.
// It's guaranteed, that you can always cast it to MultiIndex
using MultiIndexStorage =
std::conditional_t<(PreBasis::minMultiIndexSize == PreBasis::maxMultiIndexSize),
OverflowArray<StaticMultiIndex<size_type, PreBasis::maxMultiIndexSize>, PreBasis::multiIndexBufferSize>,
Dune::ReservedVector<size_type, PreBasis::multiIndexBufferSize>>;
public:
using MultiIndex =
std::conditional_t<(PreBasis::minMultiIndexSize == PreBasis::maxMultiIndexSize),
StaticMultiIndex<size_type, PreBasis::maxMultiIndexSize>,
Dune::ReservedVector<size_type, PreBasis::multiIndexBufferSize>>;
DefaultLocalView(const GlobalBasis& globalBasis) :
globalBasis_(&globalBasis),
tree_(globalBasis_->preBasis().makeNode())
{
static_assert(models<Concept::BasisTree<GridView>, Tree>(), "Tree type passed to DefaultLocalView does not model the BasisNode concept.");
initializeTree(tree_);
}
DefaultLocalView(const DefaultLocalView& other) :
globalBasis_(other.globalBasis_),
tree_(globalBasis_->preBasis().makeNode())
{
initializeTree(tree_);
if (other.bound())
bind(other.element());
}
void bind(const Element& e)
{
element_ = e;
bindTree(tree_, *element_);
indices_.resize(size());
globalBasis_->preBasis().indices(tree_, indices_.begin());
}
bool bound() const
{
return static_cast<bool>(element_);
}
const Element& element() const
{
return *element_;
}
void unbind()
{
element_.reset();
}
const Tree& tree() const
{
return tree_;
}
size_type size() const
{
return tree_.size();
}
size_type maxSize() const
{
return globalBasis_->preBasis().maxNodeSize();
}
const MultiIndex& index(size_type i) const
{
return indices_[i];
}
const GlobalBasis& globalBasis() const
{
return *globalBasis_;
}
const DefaultLocalView& rootLocalView() const
{
return *this;
}
protected:
const GlobalBasis* globalBasis_;
std::optional<Element> element_;
Tree tree_;
std::vector<MultiIndexStorage> indices_;
};
} // end namespace Functions
} // end namespace Dune
#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTLOCALVIEW_HH
multiindex.hh
overflowarray.hh
Dune
Definition monomialset.hh:19
Dune::Functions
Definition monomialset.hh:19
Dune::Functions::bindTree
void bindTree(Tree &tree, const Entity &entity, std::size_t offset=0)
Definition nodes.hh:469
Dune::Functions::initializeTree
void initializeTree(Tree &tree, std::size_t treeIndexOffset=0)
Definition nodes.hh:476
Dune::Functions::StaticMultiIndex
A statically sized MultiIndex type.
Definition multiindex.hh:30
Dune::Functions::OverflowArray
A dynamically sized array-like class with overflow.
Definition overflowarray.hh:49
Dune::Functions::DefaultGlobalBasis::GridView
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition defaultglobalbasis.hh:64
Dune::Functions::DefaultGlobalBasis::PreBasis
PB PreBasis
Pre-basis providing the implementation details.
Definition defaultglobalbasis.hh:58
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::PreBasis
typename GlobalBasis::PreBasis PreBasis
Definition defaultlocalview.hh:52
Dune::Functions::DefaultLocalView::unbind
void unbind()
Unbind from the current element.
Definition defaultlocalview.hh:123
Dune::Functions::DefaultLocalView::bound
bool bound() const
Return if the view is bound to a grid element.
Definition defaultlocalview.hh:105
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::GridView
typename GlobalBasis::GridView GridView
Definition defaultlocalview.hh:39
Dune::Functions::DefaultLocalView::index
const MultiIndex & index(size_type i) const
Maps from subtree index set [0..size-1] to a globally unique multi index in global basis.
Definition defaultlocalview.hh:156
Dune::Functions::DefaultLocalView::DefaultLocalView
DefaultLocalView(const DefaultLocalView &other)
Deep copy of the local view.
Definition defaultlocalview.hh:81
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::element_
std::optional< Element > element_
Definition defaultlocalview.hh:175
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::Element
typename GridView::template Codim< 0 >::Entity Element
Definition defaultlocalview.hh:42
Dune::Functions::DefaultLocalView::tree
const Tree & tree() const
Return the local ansatz tree associated to the bound entity.
Definition defaultlocalview.hh:132
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::MultiIndex
std::conditional_t<(PreBasis::minMultiIndexSize==PreBasis::maxMultiIndexSize), StaticMultiIndex< size_type, PreBasis::maxMultiIndexSize >, Dune::ReservedVector< size_type, PreBasis::multiIndexBufferSize > > MultiIndex
Definition defaultlocalview.hh:65
Dune::Functions::DefaultLocalView::bind
void bind(const Element &e)
Bind the view to a grid element.
Definition defaultlocalview.hh:95
Dune::Functions::DefaultLocalView::element
const Element & element() const
Return the grid element that the view is bound to.
Definition defaultlocalview.hh:114
Dune::Functions::DefaultLocalView::size
size_type size() const
Total number of degrees of freedom on this element.
Definition defaultlocalview.hh:139
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::GlobalBasis
DefaultGlobalBasis< PreBasis > GlobalBasis
Definition defaultlocalview.hh:36
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::tree_
Tree tree_
Definition defaultlocalview.hh:176
Dune::Functions::DefaultLocalView::maxSize
size_type maxSize() const
Maximum local size for any element on the GridView.
Definition defaultlocalview.hh:150
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::size_type
std::size_t size_type
Definition defaultlocalview.hh:45
Dune::Functions::DefaultLocalView::rootLocalView
const DefaultLocalView & rootLocalView() const
Definition defaultlocalview.hh:168
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::MultiIndexStorage
std::conditional_t<(PreBasis::minMultiIndexSize==PreBasis::maxMultiIndexSize), OverflowArray< StaticMultiIndex< size_type, PreBasis::maxMultiIndexSize >, PreBasis::multiIndexBufferSize >, Dune::ReservedVector< size_type, PreBasis::multiIndexBufferSize > > MultiIndexStorage
Definition defaultlocalview.hh:57
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::indices_
std::vector< MultiIndexStorage > indices_
Definition defaultlocalview.hh:177
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::Tree
typename GlobalBasis::PreBasis::Node Tree
Definition defaultlocalview.hh:48
Dune::Functions::DefaultLocalView::DefaultLocalView
DefaultLocalView(const GlobalBasis &globalBasis)
Construct local view for a given global finite element basis.
Definition defaultlocalview.hh:72
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::globalBasis_
const GlobalBasis * globalBasis_
Definition defaultlocalview.hh:174
Dune::Functions::DefaultLocalView< DefaultGlobalBasis< PreBasis > >::globalBasis
const GlobalBasis & globalBasis() const
Definition defaultlocalview.hh:163
concepts.hh