Loading...
Searching...
No Matches
lagrangedgbasis.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_LAGRANGEDGBASIS_HH
#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
#include <dune/common/exceptions.hh>
#include <dune/common/math.hh>
#include <dune/functions/functionspacebases/nodes.hh>
#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
#include <dune/functions/functionspacebases/lagrangebasis.hh>
#include <dune/functions/functionspacebases/leafprebasismappermixin.hh>
namespace Dune {
namespace Functions {
// *****************************************************************************
// This is the reusable part of the basis. It contains
//
// LagrangeDGPreBasis
// LagrangeDGNode
//
// 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<typename GV, int k, typename R=double>
using LagrangeDGNode = LagrangeNode<GV, k, R>;
template<typename GV, int k, typename R=double>
class LagrangeDGPreBasis :
public Dune::Functions::LeafPreBasisMapperMixin<GV>
{
using Base = Dune::Functions::LeafPreBasisMapperMixin<GV>;
static constexpr bool useDynamicOrder = (k<0);
static MCMGLayout dofLayout(int order)
{
return [order](Dune::GeometryType type, size_t dimGrid) {
if (type.dim() == dimGrid)
{
if (type.isLine())
return order+1;
if (type.isTriangle())
return (order+1)*(order+2)/2;
if (type.isQuadrilateral())
return (order+1)*(order+1);
if (type.isTetrahedron())
return (order+1)*(order+2)*(order+3)/6;
if (type.isPrism())
return (order+1)*(order+1)*(order+2)/2;
if (type.isHexahedron())
return (order+1)*(order+1)*(order+1);
if (type.isPyramid())
return (order+1)*(order+2)*(2*order+3)/6;
DUNE_THROW(Dune::NotImplemented, "Using LagrangeDGPreBasis with non-supported GeometryType");
}
return 0;
};
}
public:
using GridView = GV;
using size_type = typename Base::size_type;
// Precompute the number of dofs per entity type
[[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerEdge = k+1;
[[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerTriangle = (k+1)*(k+2)/2;
[[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerQuad = (k+1)*(k+1);
[[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerTetrahedron = (k+1)*(k+2)*(k+3)/6;
[[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerPrism = (k+1)*(k+1)*(k+2)/2;
[[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerHexahedron = (k+1)*(k+1)*(k+1);
[[deprecated("This constant will be removed after Dune 2.11")]] const static int dofsPerPyramid = (k+1)*(k+2)*(2*k+3)/6;
using Node = LagrangeDGNode<GV, k, R>;
LagrangeDGPreBasis(const GridView& gv)
requires(k>=0)
: Base(gv, dofLayout(k))
, order_(k)
{}
LagrangeDGPreBasis(const GridView& gv, unsigned int order)
requires(k<0)
: Base(gv, dofLayout(order))
, order_(order)
{}
Node makeNode() const
{
return Node{order_};
}
template<class Node, class It>
It indices(const Node& node, It it) const
{
size_type elementOffset = Base::mapper_.index(node.element());
for(auto i : Dune::range(node.size()))
{
*it = {{ (size_type)(elementOffset+i) }};
++it;
}
return it;
}
unsigned int order() const
{
return (useDynamicOrder) ? order_ : k;
}
protected:
unsigned int order_;
};
namespace BasisFactory {
template<std::size_t order, typename R=double>
auto lagrangeDG()
{
return [](const auto& gridView) {
return LagrangeDGPreBasis<std::decay_t<decltype(gridView)>, order, R>(gridView);
};
}
template<typename R=double>
auto lagrangeDG(unsigned int order)
{
return [order](const auto& gridView) {
return LagrangeDGPreBasis<std::decay_t<decltype(gridView)>, -1, R>(gridView, order);
};
}
} // end namespace BasisFactory
// *****************************************************************************
// This is the actual global basis implementation based on the reusable parts.
// *****************************************************************************
template<typename GV, int k=-1, typename R=double>
using LagrangeDGBasis = DefaultGlobalBasis<LagrangeDGPreBasis<GV, k, R> >;
} // end namespace Functions
} // end namespace Dune
#endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_LAGRANGEDGBASIS_HH
nodes.hh
lagrangebasis.hh
leafprebasismappermixin.hh
defaultglobalbasis.hh
Dune::Functions::BasisFactory::lagrangeDG
auto lagrangeDG()
Create a pre-basis factory that can create a LagrangeDG pre-basis.
Definition lagrangedgbasis.hh:166
Dune::Functions::LagrangeDGBasis
DefaultGlobalBasis< LagrangeDGPreBasis< GV, k, R > > LagrangeDGBasis
Basis of a scalar k-th-order Lagrangean-DG finite element space.
Definition lagrangedgbasis.hh:206
Dune
Definition monomialset.hh:19
Dune::Functions
Definition monomialset.hh:19
Dune::Functions::LagrangeDGNode
LagrangeNode< GV, k, R > LagrangeDGNode
Definition lagrangedgbasis.hh:38
Dune::Functions::BasisFactory
Definition argyrisbasis.hh:926
Dune::Functions::DefaultGlobalBasis
Global basis for given pre-basis.
Definition defaultglobalbasis.hh:53
Dune::Functions::LagrangeNode
Definition lagrangebasis.hh:379
Dune::Functions::LagrangeNode::element
const Element & element() const
Return current element, throw if unbound.
Definition lagrangebasis.hh:427
Dune::Functions::LagrangeDGPreBasis
PreBasis implementation for a Lagrangean-DG finite element space.
Definition lagrangedgbasis.hh:51
Dune::Functions::LagrangeDGPreBasis::makeNode
Node makeNode() const
Create tree node.
Definition lagrangedgbasis.hh:125
Dune::Functions::LagrangeDGPreBasis::LagrangeDGPreBasis
LagrangeDGPreBasis(const GridView &gv, unsigned int order)
Constructor for a given grid view object.
Definition lagrangedgbasis.hh:116
Dune::Functions::LagrangeDGPreBasis::dofsPerPrism
static const int dofsPerPrism
Definition lagrangedgbasis.hh:92
Dune::Functions::LagrangeDGPreBasis::Node
LagrangeDGNode< GV, k, R > Node
Definition lagrangedgbasis.hh:96
Dune::Functions::LagrangeDGPreBasis::dofsPerQuad
static const int dofsPerQuad
Definition lagrangedgbasis.hh:90
Dune::Functions::LagrangeDGPreBasis::dofsPerTriangle
static const int dofsPerTriangle
Definition lagrangedgbasis.hh:89
Dune::Functions::LagrangeDGPreBasis::size_type
typename Base::size_type size_type
Definition lagrangedgbasis.hh:85
Dune::Functions::LagrangeDGPreBasis::order
unsigned int order() const
Polynomial order used in the local Lagrange finite-elements.
Definition lagrangedgbasis.hh:143
Dune::Functions::LagrangeDGPreBasis::dofsPerPyramid
static const int dofsPerPyramid
Definition lagrangedgbasis.hh:94
Dune::Functions::LagrangeDGPreBasis::LagrangeDGPreBasis
LagrangeDGPreBasis(const GridView &gv)
Constructor for a given grid view object.
Definition lagrangedgbasis.hh:104
Dune::Functions::LagrangeDGPreBasis::dofsPerHexahedron
static const int dofsPerHexahedron
Definition lagrangedgbasis.hh:93
Dune::Functions::LagrangeDGPreBasis::indices
It indices(const Node &node, It it) const
Definition lagrangedgbasis.hh:131
Dune::Functions::LagrangeDGPreBasis::dofsPerEdge
static const int dofsPerEdge
Definition lagrangedgbasis.hh:88
Dune::Functions::LagrangeDGPreBasis::order_
unsigned int order_
Definition lagrangedgbasis.hh:150
Dune::Functions::LagrangeDGPreBasis::dofsPerTetrahedron
static const int dofsPerTetrahedron
Definition lagrangedgbasis.hh:91
Dune::Functions::LagrangeDGPreBasis::GridView
GV GridView
The grid view that the FE space is defined on.
Definition lagrangedgbasis.hh:84
Dune::Functions::LeafPreBasisMapperMixin
A generic MixIn class for PreBasis with flat indices computed from a mapper.
Definition leafprebasismappermixin.hh:62
Dune::Functions::LeafPreBasisMapperMixin::mapper_
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > mapper_
Definition leafprebasismappermixin.hh:133
Dune::Functions::LeafPreBasisMapperMixin::size_type
std::size_t size_type
Type used for index digits.
Definition leafprebasismappermixin.hh:71
Dune::Functions::BasisNodeMixin::size
size_type size() const
Obtain the number of basis function in the local node.
Definition nodes.hh:162