dune-localfunctions 2.12-git
Loading...
Searching...
No Matches
cache.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5#ifndef DUNE_LOCALFUNCTIONS_LAGRANGE_CACHE_HH
6#define DUNE_LOCALFUNCTIONS_LAGRANGE_CACHE_HH
7
8#include <map>
9#include <optional>
10#include <type_traits>
11
12#include <dune/geometry/type.hh>
14
22
23
24namespace Dune {
25
39template <class Domain, class Range, int dim,
40 class SF=Range, class CF=Range>
42{
43public:
45
47 explicit DynamicLagrangeLocalFiniteElementCache (unsigned int order)
48 : order_(order)
49 , data_()
50 {}
51
59 {
60 auto [it,_] = data_.try_emplace(type,type,order_);
61 return it->second;
62 }
63
64private:
65 unsigned int order_;
67};
68
69
81template <GeometryType::Id id, class Domain, class Range, std::size_t dim, std::size_t order>
83{
84 struct UnknownToplogy {};
85
86 static constexpr bool isSimplex = GeometryType(id).isSimplex();
87 static constexpr bool isCube = GeometryType(id).isCube();
88 static constexpr bool isPrism = GeometryType(id).isPrism();
89 static constexpr bool isPyramid = GeometryType(id).isPyramid();
90
91public:
97
103
105 const FiniteElementType& get ([[maybe_unused]] GeometryType type) const
106 {
107 assert(GeometryType::Id(type) == id);
108 assert(!!lfe_);
109 return *lfe_;
110 }
111
112private:
114};
115
116
130template <class Domain, class Range, std::size_t dim, std::size_t order>
131class StaticLagrangeLocalFiniteElementCache<GeometryType::Id(~0u), Domain, Range, dim, order>
132 : public LagrangeLocalFiniteElementCache<Domain,Range,dim,order>
133{
135public:
136 using Base::Base;
137};
138
139} // namespace Dune
140
141#endif // DUNE_LOCALFUNCTIONS_LAGRANGE_CACHE_HH
Convenience header that includes all implementations of Lagrange finite elements.
size_type dim() const
constexpr bool isPyramid() const
constexpr bool isPrism() const
constexpr bool isCube() const
constexpr bool isSimplex() const
A cache storing a compile time selection of local finite element implementations.
Definition localfiniteelementvariantcache.hh:75
Lagrange local finite elements for a given set of interpolation points.
Definition lagrange.hh:65
A cache that stores Lagrange finite elements for the given dimension and order.
Definition cache.hh:42
const FiniteElementType & get(GeometryType type) const
Obtain the cached local finite-element.
Definition cache.hh:58
DynamicLagrangeLocalFiniteElementCache(unsigned int order)
Construct an empty cache.
Definition cache.hh:47
A cache that stores all available Pk/Qk like local finite elements for the given dimension and order ...
Definition cache.hh:83
const FiniteElementType & get(GeometryType type) const
Obtain the cached local finite-element.
Definition cache.hh:105
StaticLagrangeLocalFiniteElementCache(std::integral_constant< std::size_t, order >={})
Construct the local-finite element for the order specified as template parameter.
Definition cache.hh:99