Dune Core Modules (2.5.0)

periodicfacetrans.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_DGF_PERIODICFACETRANSBLOCK_HH
4#define DUNE_DGF_PERIODICFACETRANSBLOCK_HH
5
6#include <iostream>
7#include <vector>
8
9#include <dune/grid/io/file/dgfparser/blocks/basic.hh>
10
11
12namespace Dune
13{
14
15 namespace dgf
16 {
17
18 // PeriodicFaceTransformationBlock
19 // -------------------------------
20
21 struct PeriodicFaceTransformationBlock
22 : public BasicBlock
23 {
24 template< class T >
25 class Matrix;
26
27 struct AffineTransformation;
28
29 private:
30 std::vector< AffineTransformation > transformations_;
31
32 // copy not implemented
33 PeriodicFaceTransformationBlock ( const PeriodicFaceTransformationBlock & );
34
35 public:
36 // initialize block and get dimension of world
37 PeriodicFaceTransformationBlock ( std::istream &in, int dimworld );
38
39 const AffineTransformation &transformation ( int i ) const
40 {
41 assert( i < numTransformations() );
42 return transformations_[ i ];
43 }
44
45 int numTransformations () const
46 {
47 return transformations_.size();
48 }
49
50 private:
51 void match ( char what );
52 };
53
54
55 // PeriodicFaceTransformationBlock::Matrix
56 // ---------------------------------------
57
58 template< class T >
59 class PeriodicFaceTransformationBlock::Matrix
60 {
61 int rows_;
62 int cols_;
63 std::vector< T > fields_;
64
65 public:
66 Matrix ( int rows, int cols )
67 : rows_( rows ),
68 cols_( cols ),
69 fields_( rows * cols )
70 {}
71
72 const T &operator() ( int i, int j ) const
73 {
74 return fields_[ i * cols_ + j ];
75 }
76
77 T &operator() ( int i, int j )
78 {
79 return fields_[ i * cols_ + j ];
80 }
81
82 int rows () const
83 {
84 return rows_;
85 }
86
87 int cols () const
88 {
89 return cols_;
90 }
91 };
92
93
94 // PeriodicFaceTransformationBlock::AffineTransformation
95 // -----------------------------------------------------
96
97 struct PeriodicFaceTransformationBlock::AffineTransformation
98 {
99 Matrix< double > matrix;
100 std::vector< double > shift;
101
102 explicit AffineTransformation ( int dimworld )
103 : matrix( dimworld, dimworld ),
104 shift( dimworld )
105 {}
106 };
107
108
109 inline std::ostream &
110 operator<< ( std::ostream &out, const PeriodicFaceTransformationBlock::AffineTransformation &trafo )
111 {
112 for( int i = 0; i < trafo.matrix.rows(); ++i )
113 {
114 out << (i > 0 ? ", " : "");
115 for( int j = 0; j < trafo.matrix.cols(); ++j )
116 out << (j > 0 ? " " : "") << trafo.matrix( i, j );
117 }
118 out << " +";
119 for( unsigned int i = 0; i < trafo.shift.size(); ++i )
120 out << " " << trafo.shift[ i ];
121 return out;
122 }
123
124 } // end namespace dgf
125
126} // end namespace Dune
127
128#endif
Dune namespace.
Definition: alignment.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)