cyclicTransform.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::cyclicTransform
26 
27 Description
28  Cyclic plane tranformation.
29 
30 SourceFiles
31  cyclicTransform.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef cyclicTransform_H
36 #define cyclicTransform_H
37 
38 #include "transformer.H"
39 #include "dictionary.H"
40 #include "NamedEnum.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class cyclicTransform Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class cyclicTransform
52 {
53 public:
54 
55  enum transformTypes
56  {
57  UNSPECIFIED, // Unspecified -> automatic transformation
58  NONE, // No tranformation
59  ROTATIONAL, // Rotation around a coordinate axis
60  TRANSLATIONAL // Translation
61  };
62 
64 
65 
66 private:
67 
68  // Private Data
69 
70  //- Type of transformation
71  transformTypes transformType_;
72 
73  //- Axis of rotation
74  vector rotationAxis_;
75 
76  //- Centre of rotation
77  point rotationCentre_;
78 
79  //- Rotation angle
80  scalar rotationAngle_;
81 
82  //- Separation vector
83  vector separation_;
84 
85  //- Is the transformation specification complete, or do some parts of
86  // the above data still need to be computed from the patch geometry?
87  bool transformComplete_;
88 
89  //- Generic transformer object
90  transformer transform_;
91 
92 
93  // Private Member Functions
94 
95  //- Re-calculate the transformer object from the other data if possible
96  void update();
97 
98  //- Set the transform to that supplied. Return true if the
99  // transformations are compatible. Used for copying transformation
100  // data from the neighbour patch.
101  bool set
102  (
103  const cyclicTransform& t,
104  const scalar lengthScale,
105  const scalar matchTolerance
106  );
107 
108 
109 public:
110 
111  //- Runtime type information
112  TypeName("cyclicTransform");
113 
114 
115  // Constructors
116 
117  // Transformation set as UNSPECIFIED or NONE
118  cyclicTransform(const bool defaultIsNone);
119 
120  // Transformation read from dictionary
121  cyclicTransform(const dictionary& dict, const bool defaultIsNone);
122 
123  //- Construct from coupled patch data. Copies from the supplied
124  // transform and neighbour transform. Suitable for
125  // geometrically dissimilar patches.
127  (
128  const word& name,
129  const vectorField& areas,
130  const cyclicTransform& transform,
131  const word& nbrName,
132  const cyclicTransform& nbrTransform,
133  const scalar matchTolerance
134  );
135 
136  //- Construct from coupled patch data. Copies from the supplied
137  // transform and neighbour transform, then tries to determine missing
138  // parts of the transformation automatically from the patch geometry.
139  // Suitable for geometrically similar patches only.
141  (
142  const word& name,
143  const pointField& ctrs,
144  const vectorField& areas,
145  const cyclicTransform& transform,
146  const word& nbrName,
147  const pointField& nbrCtrs,
148  const vectorField& nbrAreas,
149  const cyclicTransform& nbrTransform,
150  const scalar matchTolerance
151  );
152 
153 
154 
155  // Destructor
156  virtual ~cyclicTransform();
157 
158 
159  // Member Functions
160 
161  // Access
162 
163  //- Type of transform
165  {
166  return transformType_;
167  }
168 
169  //- Is the transform fully specified?
170  bool transformComplete() const
171  {
172  return transformComplete_;
173  }
174 
175  //- Return transformation between the coupled patches
176  const transformer& transform() const
177  {
178  if (!transformComplete_)
179  {
181  << "The transformation has not been fully specified or "
182  << "calculated" << exit(FatalError);
183  }
184  return transform_;
185  }
186 
187 
188  //- Write the data to a dictionary
189  void write(Ostream& os) const;
190 
191 
192  // Global Operators
193 
194  friend cyclicTransform operator&
195  (
196  const transformer& t,
197  const cyclicTransform& c
198  );
199 
200  friend cyclicTransform inv(const cyclicTransform& c);
201 };
202 
203 
205 
207 
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 } // End namespace Foam
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #endif
216 
217 // ************************************************************************* //
TypeName("cyclicTransform")
Runtime type information.
dictionary dict
Vector-tensor class used to perform translations and rotations in 3D space.
Definition: transformer.H:83
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
bool transformComplete() const
Is the transform fully specified?
const dimensionedScalar & c
Speed of light in a vacuum.
cyclicTransform(const bool defaultIsNone)
void write(Ostream &os) const
Write the data to a dictionary.
A class for handling words, derived from string.
Definition: word.H:59
const transformer & transform() const
Return transformation between the coupled patches.
static const NamedEnum< transformTypes, 4 > transformTypeNames
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
friend cyclicTransform operator &(const transformer &t, const cyclicTransform &c)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Cyclic plane tranformation.
friend cyclicTransform inv(const cyclicTransform &c)
transformTypes transformType() const
Type of transform.
Namespace for OpenFOAM.