dune-grid  2.4.1-rc2
periodicfacetrans.hh
Go to the documentation of this file.
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 
10 
11 
12 namespace Dune
13 {
14 
15  namespace dgf
16  {
17 
18  // PeriodicFaceTransformationBlock
19  // -------------------------------
20 
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
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 >
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 
98  {
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 &
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
std::vector< double > shift
Definition: periodicfacetrans.hh:100
Definition: periodicfacetrans.hh:21
int cols() const
Definition: periodicfacetrans.hh:87
Matrix(int rows, int cols)
Definition: periodicfacetrans.hh:66
const AffineTransformation & transformation(int i) const
Definition: periodicfacetrans.hh:39
int rows() const
Definition: periodicfacetrans.hh:82
friend std::ostream & operator<<(std::ostream &os, const BasicBlock &b)
Definition: basic.hh:101
Matrix< double > matrix
Definition: periodicfacetrans.hh:99
Include standard header files.
Definition: agrid.hh:59
Definition: periodicfacetrans.hh:25
int numTransformations() const
Definition: periodicfacetrans.hh:45
AffineTransformation(int dimworld)
Definition: periodicfacetrans.hh:102
Definition: basic.hh:28