dune-grid 2.9.0
periodicfacetrans.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 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
14namespace Dune
15{
16
17 namespace dgf
18 {
19
20 // PeriodicFaceTransformationBlock
21 // -------------------------------
22
24 : public BasicBlock
25 {
26 template< class T >
27 class Matrix;
28
30
31 private:
32 std::vector< AffineTransformation > transformations_;
33
34 // copy not implemented
36
37 public:
38 // initialize block and get dimension of world
39 PeriodicFaceTransformationBlock ( std::istream &in, int dimworld );
40
41 const AffineTransformation &transformation ( int i ) const
42 {
43 assert( i < numTransformations() );
44 return transformations_[ i ];
45 }
46
47 int numTransformations () const
48 {
49 return transformations_.size();
50 }
51
52 private:
53 void match ( char what );
54 };
55
56
57 // PeriodicFaceTransformationBlock::Matrix
58 // ---------------------------------------
59
60 template< class T >
62 {
63 int rows_;
64 int cols_;
65 std::vector< T > fields_;
66
67 public:
68 Matrix ( int rows, int cols )
69 : rows_( rows ),
70 cols_( cols ),
71 fields_( rows * cols )
72 {}
73
74 const T &operator() ( int i, int j ) const
75 {
76 return fields_[ i * cols_ + j ];
77 }
78
79 T &operator() ( int i, int j )
80 {
81 return fields_[ i * cols_ + j ];
82 }
83
84 int rows () const
85 {
86 return rows_;
87 }
88
89 int cols () const
90 {
91 return cols_;
92 }
93 };
94
95
96 // PeriodicFaceTransformationBlock::AffineTransformation
97 // -----------------------------------------------------
98
100 {
102 std::vector< double > shift;
103
104 explicit AffineTransformation ( int dimworld )
105 : matrix( dimworld, dimworld ),
106 shift( dimworld )
107 {}
108 };
109
110
111 inline std::ostream &
113 {
114 for( int i = 0; i < trafo.matrix.rows(); ++i )
115 {
116 out << (i > 0 ? ", " : "");
117 for( int j = 0; j < trafo.matrix.cols(); ++j )
118 out << (j > 0 ? " " : "") << trafo.matrix( i, j );
119 }
120 out << " +";
121 for( unsigned int i = 0; i < trafo.shift.size(); ++i )
122 out << " " << trafo.shift[ i ];
123 return out;
124 }
125
126 } // end namespace dgf
127
128} // end namespace Dune
129
130#endif
Include standard header files.
Definition: agrid.hh:60
std::ostream & operator<<(std::ostream &out, const IntervalBlock::Interval &interval)
Definition: interval.hh:123
Definition: basic.hh:31
Definition: periodicfacetrans.hh:25
int numTransformations() const
Definition: periodicfacetrans.hh:47
const AffineTransformation & transformation(int i) const
Definition: periodicfacetrans.hh:41
Definition: periodicfacetrans.hh:62
int rows() const
Definition: periodicfacetrans.hh:84
const T & operator()(int i, int j) const
Definition: periodicfacetrans.hh:74
int cols() const
Definition: periodicfacetrans.hh:89
Matrix(int rows, int cols)
Definition: periodicfacetrans.hh:68
Matrix< double > matrix
Definition: periodicfacetrans.hh:101
std::vector< double > shift
Definition: periodicfacetrans.hh:102
AffineTransformation(int dimworld)
Definition: periodicfacetrans.hh:104