dune-fem 2.8.0
Loading...
Searching...
No Matches
explicitfieldvector.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_COMMON_EXPLICITFIELDVECTOR_HH
2#define DUNE_FEM_COMMON_EXPLICITFIELDVECTOR_HH
3
4#include <type_traits>
5#include <utility>
6
7#include <dune/common/fmatrix.hh>
8#include <dune/common/fvector.hh>
9#include <dune/common/typeutilities.hh>
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 {
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 {
77 typedef Dune::FieldVector<T, N> BaseType;
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>
106 ExplicitFieldVector(const DenseVector<C>& x,
107 typename std::enable_if<(
108 IsFieldVectorSizeCorrect<C, N>::value
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>
143 ExplicitFieldVector& operator=(const FieldVector<C, N>& other)
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>
151 {
152 static_cast<BaseType&>(*this) = other;
153 return *this;
154 }
155
156 };
157
158 template<class FV>
160 {
161 using Type = FV;
162 };
163
164 template<class Field, int Size>
165 struct MakeExplicit<FieldVector<Field, Size> >
166 {
168 };
169
170 template<class FV>
172
173 } // Fem
174
175} // Dune
176
177
178#endif // DUNE_FEM_COMMON_EXPLICITFIELDVECTOR_HH
STL namespace.
Definition: bindguard.hh:11
typename MakeExplicit< FV >::Type Explicit
Definition: explicitfieldvector.hh:171
Definition: explicitfieldvector.hh:75
ExplicitFieldVector & operator=(const ExplicitFieldVector< C, N > &other)
Definition: explicitfieldvector.hh:150
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 std::initializer_list< T > &values)
Definition: explicitfieldvector.hh:92
ExplicitFieldVector & operator=(const FieldVector< C, N > &other)
Definition: explicitfieldvector.hh:143
ExplicitFieldVector(const DenseVector< C > &x, typename std::enable_if<(IsFieldVectorSizeCorrect< C, N >::value &&AcceptElementImplicitConstruction< C, T >::value) >::type *dummy=0)
Definition: explicitfieldvector.hh:106
Fem::ExplicitFieldVector< T, N > derived_type
Definition: explicitfieldvector.hh:27
Definition: explicitfieldvector.hh:46
Definition: explicitfieldvector.hh:60
Definition: explicitfieldvector.hh:160
FV Type
Definition: explicitfieldvector.hh:161