dune-grid  2.11
periodicfacetrans.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_DGF_PERIODICFACETRANSBLOCK_HH
6 #define DUNE_DGF_PERIODICFACETRANSBLOCK_HH
7 
8 #include <iostream>
9 #include <vector>
10 
12 
13 
14 namespace Dune
15 {
16 
17  namespace dgf
18  {
19 
20  // PeriodicFaceTransformationBlock
21  // -------------------------------
22 
24  : public BasicBlock
25  {
26  template< class T >
27  class Matrix
28  {
29  int rows_;
30  int cols_;
31  std::vector< T > fields_;
32 
33  public:
34  Matrix ( int rows, int cols )
35  : rows_( rows ),
36  cols_( cols ),
37  fields_( rows * cols )
38  {}
39 
40  const T &operator() ( int i, int j ) const
41  {
42  return fields_[ i * cols_ + j ];
43  }
44 
45  T &operator() ( int i, int j )
46  {
47  return fields_[ i * cols_ + j ];
48  }
49 
50  int rows () const
51  {
52  return rows_;
53  }
54 
55  int cols () const
56  {
57  return cols_;
58  }
59  };
60 
62  {
64  std::vector< double > shift;
65 
66  explicit AffineTransformation ( int dimworld )
67  : matrix( dimworld, dimworld ),
68  shift( dimworld )
69  {}
70  };
71 
72  private:
73  std::vector< AffineTransformation > transformations_;
74 
75  // copy not implemented
77 
78  public:
79  // initialize block and get dimension of world
80  PeriodicFaceTransformationBlock ( std::istream &in, int dimworld );
81 
82  const AffineTransformation &transformation ( int i ) const
83  {
84  assert( i < numTransformations() );
85  return transformations_[ i ];
86  }
87 
88  int numTransformations () const
89  {
90  return transformations_.size();
91  }
92 
93  private:
94  void match ( char what );
95  };
96 
97 
98 
99  // PeriodicFaceTransformationBlock::AffineTransformation
100  // -----------------------------------------------------
101 
102 
103  inline std::ostream &
105  {
106  for( int i = 0; i < trafo.matrix.rows(); ++i )
107  {
108  out << (i > 0 ? ", " : "");
109  for( int j = 0; j < trafo.matrix.cols(); ++j )
110  out << (j > 0 ? " " : "") << trafo.matrix( i, j );
111  }
112  out << " +";
113  for( unsigned int i = 0; i < trafo.shift.size(); ++i )
114  out << " " << trafo.shift[ i ];
115  return out;
116  }
117 
118  } // end namespace dgf
119 
120 } // end namespace Dune
121 
122 #endif
int cols() const
Definition: periodicfacetrans.hh:55
Matrix(int rows, int cols)
Definition: periodicfacetrans.hh:34
std::vector< double > shift
Definition: periodicfacetrans.hh:64
AffineTransformation(int dimworld)
Definition: periodicfacetrans.hh:66
const AffineTransformation & transformation(int i) const
Definition: periodicfacetrans.hh:82
Matrix< double > matrix
Definition: periodicfacetrans.hh:63
Definition: periodicfacetrans.hh:27
int rows() const
Definition: periodicfacetrans.hh:50
Include standard header files.
Definition: agrid.hh:59
int numTransformations() const
Definition: periodicfacetrans.hh:88
Definition: basic.hh:30
Definition: periodicfacetrans.hh:23
std::ostream & operator<<(std::ostream &out, const IntervalBlock::Interval &interval)
Definition: interval.hh:123
const T & operator()(int i, int j) const
Definition: periodicfacetrans.hh:40