version 0.4.1
febase.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021-2024 The Ikarus Developers mueller@ibb.uni-stuttgart.de
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
13#pragma once
14
18
19namespace Ikarus {
20
21template <typename PreFE, template <typename, typename> class... Skills>
22class FE;
23
31template <typename BH, bool useFlat = true, bool useEigenRef = false>
32struct PreFE
33{
34 using BasisHandler = BH;
35 static constexpr int worldDim = BasisHandler::Basis::worlddim;
36 static constexpr bool useEigenReference = useEigenRef;
37 static constexpr bool useFlatBasis = useFlat;
39
40 template <template <typename, typename> class... Skills>
41 using FE = FE<PreFE, Skills...>;
42};
43
44namespace Impl {
45 // Since base classes are initialized, in declaration order before member variables, we have to make sure the
46 // localview_ object of FE is defined. To do this we add this artificial inheritance by inheriting below first from
47 // FEInit, which initializes the localview object first, siche we the other FEMixin base class constructors are called
48 template <typename PreFE, typename FE>
49 struct FEInit
50 {
51 using Traits = PreFE::Traits;
53 using LocalView = typename Traits::LocalView;
54 friend FE;
55 FEInit(const BasisHandler& basisHandler)
56 : localView_{[&]() -> LocalView {
57 if constexpr (Traits::useFlatBasis)
58 return basisHandler.flat().localView();
59 else
60 return basisHandler.untouched().localView();
61 }()} {}
62
63 private:
64 LocalView localView_;
65 };
66} // namespace Impl
67
77template <typename PreFE, template <typename, typename> class... Skills>
78class FE : private Impl::FEInit<PreFE, FE<PreFE, Skills...>>, public FEMixin<PreFE, Skills...>
79{
80 friend Impl::FEInit<PreFE, FE>;
81
82protected:
83 using Mixin = FEMixin<PreFE, Skills...>;
84 friend Mixin;
85
86public:
89 using LocalView = typename Traits::LocalView;
90 using GridView = typename Traits::GridView;
92 using GridElement = typename Traits::Element;
93 using typename Mixin::Requirement;
94
95 static constexpr int myDim = Traits::mydim;
96 static constexpr int worldDim = Traits::worlddim;
97 using PreTuple = std::tuple<typename Skills<PreFE, FE>::Pre...>;
98
105 explicit FE(const BasisHandler& basisHandler, typename Skills<PreFE, FE>::Pre... skillsArgs)
106 : Impl::FEInit<PreFE, FE>(basisHandler),
107 FEMixin<PreFE, Skills...>(std::forward<typename Skills<PreFE, FE>::Pre>(skillsArgs)...) {}
108
113 void bind(const GridElement& element) {
114 this->localView_.bind(element);
115 Mixin::bind();
116 }
117
122 [[nodiscard]] constexpr size_t size() const { return this->localView_.size(); }
123
128 const GridElement& gridElement() const { return this->localView_.element(); }
129
134 const LocalView& localView() const { return this->localView_; }
135
140 LocalView& localView() { return this->localView_; }
141};
142} // namespace Ikarus
FETraits template structure for finite element traits.
Definition of the LinearElastic class for finite element mechanics computations.
Implementation of the finite element CRTP mixin class.
STL namespace.
Definition: assemblermanipulatorbuildingblocks.hh:22
FE class is a base class for all finite elements.
Definition: febase.hh:79
const LocalView & localView() const
Get the const reference to the local view.
Definition: febase.hh:134
constexpr size_t size() const
Get the size of the local view.
Definition: febase.hh:122
Traits::BasisHandler BasisHandler
Type of the basisHandler.
Definition: febase.hh:88
std::tuple< typename Skills< PreFE, FE >::Pre... > PreTuple
Definition: febase.hh:97
FE(const BasisHandler &basisHandler, typename Skills< PreFE, FE >::Pre... skillsArgs)
Constructor for the FE class.
Definition: febase.hh:105
void bind(const GridElement &element)
Convenient function to bind the local view to the element.
Definition: febase.hh:113
typename Traits::GridView GridView
Type of the global view.
Definition: febase.hh:90
static constexpr int worldDim
Definition: febase.hh:96
typename Traits::LocalView LocalView
Type of the local view.
Definition: febase.hh:89
friend Mixin
Definition: febase.hh:84
LocalView & localView()
Get the reference to the local view.
Definition: febase.hh:140
static constexpr int myDim
Definition: febase.hh:95
typename Traits::Element GridElement
Type of the grid element.
Definition: febase.hh:92
const GridElement & gridElement() const
Get the grid element associated with the local view.
Definition: febase.hh:128
typename Traits::GlobalIndex GlobalIndex
Type of the global index.
Definition: febase.hh:91
PreFE struct acts as a convenient wrapper for the FE class to access different type traits.
Definition: febase.hh:33
static constexpr bool useEigenReference
Definition: febase.hh:36
static constexpr bool useFlatBasis
Definition: febase.hh:37
FETraits< BH, useEigenRef, useFlat > Traits
Definition: febase.hh:38
BH BasisHandler
Definition: febase.hh:34
static constexpr int worldDim
Definition: febase.hh:35
FE< PreFE, Skills... > FE
Definition: febase.hh:41
Traits for handling finite elements.
Definition: fetraits.hh:25
typename Basis::LocalView LocalView
Type of the local view.
Definition: fetraits.hh:42
BH BasisHandler
Type of the basis of the finite element.
Definition: fetraits.hh:27
typename Basis::GridView GridView
Type of the grid view.
Definition: fetraits.hh:45
static constexpr int worlddim
Dimension of the world space.
Definition: fetraits.hh:60
typename LocalView::MultiIndex GlobalIndex
Type of the global index.
Definition: fetraits.hh:54
typename LocalView::Element Element
Type of the grid element.
Definition: fetraits.hh:48
static constexpr bool useFlatBasis
A bool to indicate if the provided basishandler should hand out the flat basis.
Definition: fetraits.hh:30
static constexpr int mydim
Dimension of the geometry.
Definition: fetraits.hh:63
CRTP mixin class for finite elements with additional skills.
Definition: mixin.hh:28
RequirementType< requirementDetected >::type Requirement
Definition: mixin.hh:89
void bind()
Call all bind functions if the skill implements it.
Definition: mixin.hh:171
Struct representing a collection of skills.
Definition: mixin.hh:269
Wrapper class for a hierarchical basis constructed from a pre-basis.
Definition: utils/basis.hh:30
auto & flat()
Returns a reference to the flat version of the basis.
Definition: utils/basis.hh:55
auto & untouched()
Returns a reference to the untouched version of the basis.
Definition: utils/basis.hh:62