dune-localfunctions
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
localfunctions
lagrange
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>
13
#include <dune/geometry/typeindex.hh>
14
15
#include <
dune/localfunctions/lagrange.hh
>
16
#include <
dune/localfunctions/lagrange/equidistantpoints.hh
>
17
#include <
dune/localfunctions/lagrange/lagrangecube.hh
>
18
#include <
dune/localfunctions/lagrange/lagrangelfecache.hh
>
19
#include <
dune/localfunctions/lagrange/lagrangeprism.hh
>
20
#include <
dune/localfunctions/lagrange/lagrangepyramid.hh
>
21
#include <
dune/localfunctions/lagrange/lagrangesimplex.hh
>
22
23
24
namespace
Dune
{
25
39
template
<
class
Domain,
class
Range,
int
dim,
40
class
SF=Range,
class
CF=Range>
41
class
DynamicLagrangeLocalFiniteElementCache
42
{
43
public
:
44
using
FiniteElementType
=
LagrangeLocalFiniteElement<EquidistantPointSet, dim, Domain, Range, SF, CF>
;
45
47
explicit
DynamicLagrangeLocalFiniteElementCache
(
unsigned
int
order)
48
: order_(order)
49
, data_()
50
{}
51
58
const
FiniteElementType
&
get
(GeometryType type)
const
59
{
60
auto
[it,_] = data_.try_emplace(type,type,order_);
61
return
it->second;
62
}
63
64
private
:
65
unsigned
int
order_;
66
mutable
std::map<GeometryType, FiniteElementType> data_;
67
};
68
69
81
template
<GeometryType::Id
id
,
class
Domain,
class
Range, std::
size_t
dim, std::
size_t
order>
82
class
StaticLagrangeLocalFiniteElementCache
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
91
public
:
92
using
FiniteElementType
93
= std::conditional_t<isSimplex, LagrangeSimplexLocalFiniteElement<Domain,Range,dim,order>,
94
std::conditional_t<isCube, LagrangeCubeLocalFiniteElement<Domain,Range,dim,order>,
95
std::conditional_t<isPrism, LagrangePrismLocalFiniteElement<Domain,Range,order>,
96
std::conditional_t<isPyramid, LagrangePyramidLocalFiniteElement<Domain,Range,order>, UnknownToplogy> > > >;
97
98
//! Construct the local-finite element for the order specified as template parameter.
99
explicit
StaticLagrangeLocalFiniteElementCache
(std::integral_constant<std::size_t,order> = {})
100
{
101
lfe_.emplace();
102
}
103
104
//! Obtain the cached local finite-element.
105
const
FiniteElementType
&
get
([[maybe_unused]] GeometryType type)
const
106
{
107
assert(GeometryType::Id(type) ==
id
);
108
assert(!!lfe_);
109
return
*lfe_;
110
}
111
112
private
:
113
std::optional<FiniteElementType> lfe_{};
114
};
115
116
130
template
<
class
Domain,
class
Range, std::
size_t
dim, std::
size_t
order>
131
class
StaticLagrangeLocalFiniteElementCache
<GeometryType::Id(~0u), Domain, Range, dim, order>
132
:
public
LagrangeLocalFiniteElementCache
<Domain,Range,dim,order>
133
{
134
using
Base =
LagrangeLocalFiniteElementCache<Domain,Range,dim,order>
;
135
public
:
136
using
Base::Base;
137
};
138
139
}
// namespace Dune
140
141
#endif
// DUNE_LOCALFUNCTIONS_LAGRANGE_CACHE_HH
lagrange.hh
Convenience header that includes all implementations of Lagrange finite elements.
equidistantpoints.hh
lagrangecube.hh
lagrangelfecache.hh
lagrangeprism.hh
lagrangepyramid.hh
lagrangesimplex.hh
Dune
Definition
bdfmcube.hh:18
Dune::LagrangeLocalFiniteElementCache
LocalFiniteElementVariantCache< Impl::ImplementedLagrangeFiniteElements< D, R, dim, order > > LagrangeLocalFiniteElementCache
A cache that stores all available Pk/Qk like local finite elements for the given dimension and order.
Definition
lagrangelfecache.hh:118
Dune::LagrangeLocalFiniteElement
Lagrange local finite elements for a given set of interpolation points.
Definition
lagrange.hh:69
Dune::DynamicLagrangeLocalFiniteElementCache::FiniteElementType
LagrangeLocalFiniteElement< EquidistantPointSet, dim, Domain, Range, SF, CF > FiniteElementType
Definition
cache.hh:44
Dune::DynamicLagrangeLocalFiniteElementCache::get
const FiniteElementType & get(GeometryType type) const
Obtain the cached local finite-element.
Definition
cache.hh:58
Dune::DynamicLagrangeLocalFiniteElementCache::DynamicLagrangeLocalFiniteElementCache
DynamicLagrangeLocalFiniteElementCache(unsigned int order)
Construct an empty cache.
Definition
cache.hh:47
Dune::StaticLagrangeLocalFiniteElementCache::get
const FiniteElementType & get(GeometryType type) const
Obtain the cached local finite-element.
Definition
cache.hh:104
Dune::StaticLagrangeLocalFiniteElementCache::FiniteElementType
std::conditional_t< isSimplex, LagrangeSimplexLocalFiniteElement< Domain, Range, dim, order >, std::conditional_t< isCube, LagrangeCubeLocalFiniteElement< Domain, Range, dim, order >, std::conditional_t< isPrism, LagrangePrismLocalFiniteElement< Domain, Range, order >, std::conditional_t< isPyramid, LagrangePyramidLocalFiniteElement< Domain, Range, order >, UnknownToplogy > > > > FiniteElementType
Definition
cache.hh:92
Dune::StaticLagrangeLocalFiniteElementCache::StaticLagrangeLocalFiniteElementCache
StaticLagrangeLocalFiniteElementCache(std::integral_constant< std::size_t, order >={})
Construct the local-finite element for the order specified as template parameter.
Definition
cache.hh:98
Generated by
1.17.0