DUNE-FEM (unstable)

explicitfieldvector.hh
1#ifndef DUNE_FEM_COMMON_EXPLICITFIELDVECTOR_HH
2#define DUNE_FEM_COMMON_EXPLICITFIELDVECTOR_HH
3
4#include <type_traits>
5#include <utility>
6
10
11namespace Dune
12{
13
14 namespace Fem
15 {
19 template<class T, int N>
20 class ExplicitFieldVector;
21 }
22
23 template<class T, int N>
24 struct DenseMatVecTraits< Fem::ExplicitFieldVector<T, N> >
25 : DenseMatVecTraits<FieldVector<T, N> >
26 {
27 typedef Fem::ExplicitFieldVector<T, N> derived_type;
28 };
29
30 template<class T, int N>
31 struct FieldTraits<Fem::ExplicitFieldVector<T, N> >
32 : FieldTraits<FieldVector<T, N> >
33 {};
34
35 template<typename T, int N, int M>
36 struct IsFieldVectorSizeCorrect<Fem::ExplicitFieldVector<T, N>, M>
37 : IsFieldVectorSizeCorrect<FieldVector<T, N>, M>
38 {};
39
40 namespace Fem {
41
43 template<class T>
45 : std::is_same<typename FieldTraits<T>::field_type, T>
46 {};
47
57 template<class C, class T, class SFINAE = void>
59 : IsFieldType<C>
60 {};
61
62 template<class C, class T>
64 C, T,
65 std::enable_if_t<((IsFieldType<typename DenseMatVecTraits<C>::value_type>::value
66 ==
67 IsFieldType<T>::value)
68 )> >
69 : std::true_type
70 {};
71
72 template<class T, int N>
74 : public Dune::FieldVector<T, N>
75 {
78 public:
81 : BaseType()
82 {}
83
87 template< class... Args, disableCopyMove< ThisType, Args... > = 0, std::enable_if_t< std::is_constructible< BaseType, Args &&... >::value, int > = 0 >
88 explicit ExplicitFieldVector ( Args &&... args )
89 : BaseType( std::forward< Args >( args )... )
90 {}
91
92 ExplicitFieldVector ( const std::initializer_list< T > &values )
93 : BaseType( values )
94 {}
95
105 template<class C>
107 typename std::enable_if<(
109 &&
111 >::type* dummy=0 )
112 : BaseType(x)
113 {}
114
116 template<typename C,
117 std::enable_if_t<(
118 N == 1 &&
120 std::is_assignable<T, C>::value &&
121 ! std::is_base_of<DenseVector<typename FieldTraits<T>::field_type>, T
122 >::value
123 ), int> = 0
124 >
125 ExplicitFieldVector& operator=(const C& c)
126 {
127 (*this)[0] = c;
128 return *this;
129 }
130
132 // using BaseType::operator=; <- give ambiguous overloads
133 using DenseVector<FieldVector<T, N> >::operator=;
134
137 {
138 static_cast<BaseType&>(*this) = static_cast<const BaseType&>(other);
139 return *this;
140 }
141
142 template <typename C, std::enable_if_t<std::is_assignable<T, C>::value, int> = 0>
144 {
145 static_cast<BaseType&>(*this) = other;
146 return *this;
147 }
148
149 template <typename C, std::enable_if_t<std::is_assignable<T, C>::value, int> = 0>
150 ExplicitFieldVector& operator=(const ExplicitFieldVector<C, N>& other)
151 {
152 static_cast<BaseType&>(*this) = other;
153 return *this;
154 }
155
156 };
157
158 template<class FV>
159 struct MakeExplicit
160 {
161 using Type = FV;
162 };
163
164 template<class Field, int Size>
165 struct MakeExplicit<FieldVector<Field, Size> >
166 {
167 using Type = ExplicitFieldVector<Field, Size>;
168 };
169
170 template<class FV>
171 using Explicit = typename MakeExplicit<FV>::Type;
172
173 } // Fem
174
175} // Dune
176
177
178#endif // DUNE_FEM_COMMON_EXPLICITFIELDVECTOR_HH
Interface for a class of dense vectors over a given field.
Definition: densevector.hh:229
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition: densevector.hh:727
Definition: explicitfieldvector.hh:75
constexpr ExplicitFieldVector()
Constructor making default-initialized vector.
Definition: explicitfieldvector.hh:80
ExplicitFieldVector & operator=(const ExplicitFieldVector &other)
copy assignment operator
Definition: explicitfieldvector.hh:136
ExplicitFieldVector(Args &&... args)
Definition: explicitfieldvector.hh:88
ExplicitFieldVector(const DenseVector< C > &x, typename std::enable_if<(IsFieldVectorSizeCorrect< C, N >::value &&AcceptElementImplicitConstruction< C, T >::value) >::type *dummy=0)
Definition: explicitfieldvector.hh:106
ExplicitFieldVector & operator=(const C &c)
Assignment operator for scalar.
Definition: explicitfieldvector.hh:125
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > disableCopyMove
Helper to disable constructor as copy and move constructor.
Definition: typeutilities.hh:45
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Definition: explicitfieldvector.hh:60
Definition: explicitfieldvector.hh:46
TMP to check the size of a DenseVectors statically, if possible.
Definition: fvector.hh:66
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 24, 22:29, 2024)