DUNE-FEM (unstable)

functionspace.hh
1#ifndef DUNE_FEM_FUNCTIONSPACE_HH
2#define DUNE_FEM_FUNCTIONSPACE_HH
3
6
7#include <dune/geometry/dimension.hh>
8
9#include <dune/fem/space/common/functionspaceinterface.hh>
10
11namespace Dune
12{
13
14 namespace Fem
15 {
16
17 // Forward declaration of
18 // base class for vector valued function spaces.
19 template< class DomainField, class RangeField, int dimD, int dimR>
20 class FunctionSpace;
21
23 template< class DomainField, class RangeField, int dimD, int dimR>
25 {
27 typedef DomainField DomainFieldType;
29 typedef RangeField RangeFieldType;
30
32 enum { dimDomain = dimD };
34 enum { dimRange = dimR };
35
38
41
44
48 };
49
56 template< class DomainField, class RangeField, int dimD, int dimR>
59 < VectorSpaceTraits< DomainField, RangeField, dimD, dimR> >
60 {
62
63 public:
65 };
66
67 /* Forward declaration of
68 base class for matrix valued function spaces.
69 */
70 template <typename DomainFieldImp,typename RangeFieldImp,int n,int m1,int m2>
72
76 template <typename K,int n,int m>
77 class RangeMatrix : public FieldMatrix<K,n,m> {
78 public:
80 typedef typename BaseType::row_type RowType;
81 enum {
88 };
89 //===== constructors
93
96 RangeMatrix (const K& k) : BaseType(k) {}
97
103 K& operator()(int r,int c) {
104 return static_cast<BaseType&>(*this)[r][c];
105 }
111 const K operator()(int r,int c) const {
112 return static_cast<const BaseType&>(*this)[r][c];
113 }
118 const RowType& row(int r) const{
119 return static_cast<BaseType&>(*this)[r];
120 }
125 RowType& row(int r){
126 return static_cast<BaseType&>(*this)[r];
127 }
128
133 K& operator[](int i) {
134 int r = i/cols;
135 int c = i%cols;
136 return (*this)(r,c);
137 }
142 const K operator[](int i) const {
143 int r = i/cols;
144 int c = i%cols;
145 return (*this)(r,c);
146 }
147
153 {
154 K ret(0);
155 for (int i=0; i<n; i++)
156 ret += static_cast<BaseType&>(*this)[i] * y[i];
157 return ret;
158 }
159
165 RangeMatrix& axpy (const K& a, const BaseType& y)
166 {
167 for (int i=0; i<n; i++)
168 static_cast<BaseType&>(*this)[i].axpy(a,y[i]);
169 return *this;
170 }
171 };
175 template <typename DomainFieldImp,typename RangeFieldImp,int n,int m1,int m2>
177 public FieldMatrix<RangeFieldImp,m1*m2,n> {
178 // Implement L : VD -> VR where VR is the space of FieldMatrix<RFI,m1,m2>
179 // VD is space of FieldVector<DFT,n>
180 public:
182 typedef DomainFieldImp DomainFieldType;
184 typedef RangeFieldImp RangeFieldType;
189 //===== constructors
195 MatrixMapping (const RangeFieldImp& k) : BaseType(k) {}
196
202 return static_cast<BaseType&>(*this)[i];
203 }
209 return static_cast<const BaseType&>(*this)[i];
210 }
211 };
212
214 template <typename DomainFieldImp,typename RangeFieldImp,int n,int m1,int m2>
217 typedef DomainFieldImp DomainFieldType;
219 typedef RangeFieldImp RangeFieldType;
229 enum { dimRange = m1 * m2};
231 enum { dimDomain = n };
232 };
233
237 template <typename DomainFieldImp,typename RangeFieldImp,int n,int m1,int m2>
238 class MatrixFunctionSpace : public
239 FunctionSpaceInterface<MatrixSpaceTraits<DomainFieldImp,RangeFieldImp,n,m1,m2> > {};
240
241 // function space converter objects
242 // --------------------------------
243
245 template < class FunctionSpaceImp, int newDimDomain >
247
249 template < class FunctionSpaceImp, int newDimRange >
251
253 template< class DomainFieldImp, class RangeFieldImp, int dimDomain, int dimRange, int newDimDomain >
254 struct ToNewDimDomainFunctionSpace< FunctionSpace< DomainFieldImp, RangeFieldImp, dimDomain, dimRange >, newDimDomain >
255 {
257 };
258
260 template< class DomainFieldImp, class RangeFieldImp, int n, int m1, int m2, int newDimDomain >
261 struct ToNewDimDomainFunctionSpace< MatrixFunctionSpace< DomainFieldImp, RangeFieldImp, n, m1, m2 >, newDimDomain >
262 {
264 };
265
267 template< class DomainFieldImp, class RangeFieldImp, int dimDomain, int dimRange, int newDimRange >
268 struct ToNewDimRangeFunctionSpace< FunctionSpace< DomainFieldImp, RangeFieldImp, dimDomain, dimRange >, newDimRange >
269 {
271 };
272
273
274
275 // GridFunctionSpace
276 // -----------------
277
278 namespace Impl
279 {
280
281 template< class GridPart, class >
282 struct GridFunctionSpace;
283
284 template< class GridPart, class K, int dimRange >
285 struct GridFunctionSpace< GridPart, FunctionSpace< typename GridPart::ctype, K, GridPart::dimensionworld, dimRange > >
286 {
288 };
289
290 template< class GridPart, class K, int rows, int cols >
291 struct GridFunctionSpace< GridPart, MatrixFunctionSpace< typename GridPart::ctype, K, GridPart::dimensionworld, rows, cols > >
292 {
293 typedef MatrixFunctionSpace< typename GridPart::ctype, K, GridPart::dimensionworld, rows, cols > Type;
294 };
295
296 template< class GridPart, class K, int dimRange >
297 struct GridFunctionSpace< GridPart, Dune::FieldVector< K, dimRange > >
298 {
299 typedef FunctionSpace< typename GridPart::ctype, K, GridPart::dimensionworld, dimRange > Type;
300 };
301
302 template< class GridPart, class K, int rows, int cols >
303 struct GridFunctionSpace< GridPart, Dune::FieldMatrix< K, rows, cols > >
304 {
305 typedef MatrixFunctionSpace< typename GridPart::ctype, K, GridPart::dimensionworld, rows, cols > Type;
306 };
307
308 template< class GridPart, int dimRange >
309 struct GridFunctionSpace< GridPart, Dune::Dim< dimRange > >
310 {
311 typedef typename GridFunctionSpace< GridPart, Dune::FieldVector< typename GridPart::ctype, dimRange > >::Type Type;
312 };
313
314 } // namespace Impl
315
316 template< class GridPart, class T >
317 using GridFunctionSpace = typename Impl::GridFunctionSpace< GridPart, T >::Type;
318
319 } // namespace Fem
320
321} // namespace Dune
322
323#endif // #ifndef DUNE_FEM_FUNCTIONSPACE_HH
derived_type & axpy(const field_type &a, const DenseMatrix< Other > &x)
vector space axpy operation (*this += a x)
Definition: densematrix.hh:338
interface for an arbitrary function space
Definition: functionspaceinterface.hh:40
A vector valued function space.
Definition: functionspace.hh:60
A matrix valued function space.
Definition: functionspace.hh:239
JacobianRangeType class for matrix valued functions - derived from FieldMatrix.
Definition: functionspace.hh:177
FieldVector< DomainFieldImp, n > & operator[](int i)
returning reference to row
Definition: functionspace.hh:201
MatrixMapping(const RangeFieldImp &k)
Constructor initializing the whole matrix with a scalar.
Definition: functionspace.hh:195
MatrixMapping()
Default constructor.
Definition: functionspace.hh:192
RangeFieldImp RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspace.hh:184
FieldMatrix< RangeFieldImp, m1 *m2, n > BaseType
type of base class
Definition: functionspace.hh:188
RangeMatrix< RangeFieldImp, m1, m2 > RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspace.hh:186
const FieldVector< DomainFieldImp, n > & operator[](int i) const
returning reference to row
Definition: functionspace.hh:208
DomainFieldImp DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspace.hh:182
RangeType class for matrix valued functions - derived from FieldMatrix but has representation as vect...
Definition: functionspace.hh:77
RangeMatrix & axpy(const K &a, const BaseType &y)
vector space axpy operation
Definition: functionspace.hh:165
const K operator[](int i) const
access i element where row = i/col and column = icol
Definition: functionspace.hh:142
RangeMatrix(const K &k)
Constructor initializing the whole matrix with a scalar.
Definition: functionspace.hh:96
K operator*(const BaseType &y)
scalar product
Definition: functionspace.hh:152
K & operator()(int r, int c)
access element in row r and column c
Definition: functionspace.hh:103
RangeMatrix()
Default constructor.
Definition: functionspace.hh:92
@ dimension
The total dimension of the matrix space.
Definition: functionspace.hh:87
@ cols
The number of columns.
Definition: functionspace.hh:85
@ rows
The number of rows.
Definition: functionspace.hh:83
RowType & row(int r)
access to row r
Definition: functionspace.hh:125
const RowType & row(int r) const
access to row r
Definition: functionspace.hh:118
const K operator()(int r, int c) const
access element in row r and column c
Definition: functionspace.hh:111
K & operator[](int i)
access i element where row = i/col and column = icol
Definition: functionspace.hh:133
A dense n x m matrix.
Definition: fmatrix.hh:117
static constexpr int rows
The number of rows.
Definition: fmatrix.hh:123
static constexpr int cols
The number of columns.
Definition: fmatrix.hh:125
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.
Dune namespace.
Definition: alignedallocator.hh:13
Traits class for matrix valued spaces.
Definition: functionspace.hh:215
MatrixFunctionSpace< DomainFieldImp, RangeFieldImp, n, 1, 1 > ScalarFunctionSpaceType
scalar function space type
Definition: functionspace.hh:227
DomainFieldImp DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspace.hh:217
RangeMatrix< RangeFieldImp, m1, m2 > RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspace.hh:223
FieldVector< DomainFieldImp, n > DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspace.hh:221
MatrixMapping< DomainFieldImp, RangeFieldImp, n, m1, m2 > LinearMappingType
linear mapping type
Definition: functionspace.hh:225
RangeFieldImp RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspace.hh:219
convert functions space to space with new dim domain
Definition: functionspace.hh:246
convert functions space to space with new dim range
Definition: functionspace.hh:250
Traits class for vector function spaces.
Definition: functionspace.hh:25
FunctionSpace< DomainFieldType, RangeFieldType, dimDomain, 1 > ScalarFunctionSpaceType
scalar function space type
Definition: functionspace.hh:47
FieldVector< RangeFieldType, dimRange > RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspace.hh:40
RangeField RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspace.hh:29
FieldMatrix< RangeFieldType, dimRange, dimDomain > LinearMappingType
linear mapping type
Definition: functionspace.hh:43
FieldVector< DomainFieldType, dimDomain > DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspace.hh:37
DomainField DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspace.hh:27
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)