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-2022 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 transformation.
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 transformation
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 NONE
118  cyclicTransform();
119 
120  // Transformation set as UNSPECIFIED or NONE
121  cyclicTransform(const bool defaultIsNone);
122 
123  // Transformation read from dictionary
124  cyclicTransform(const dictionary& dict, const bool defaultIsNone);
125 
126  //- Construct from coupled patch data. Copies from the supplied
127  // transform and neighbour transform. Suitable for
128  // geometrically dissimilar patches.
130  (
131  const word& name,
132  const vectorField& areas,
133  const cyclicTransform& transform,
134  const word& nbrName,
135  const cyclicTransform& nbrTransform,
136  const scalar matchTolerance
137  );
138 
139  //- Construct from coupled patch data. Copies from the supplied
140  // transform and neighbour transform, then tries to determine missing
141  // parts of the transformation automatically from the patch geometry.
142  // Suitable for geometrically similar patches only.
144  (
145  const word& name,
146  const pointField& ctrs,
147  const vectorField& areas,
148  const cyclicTransform& transform,
149  const word& nbrName,
150  const pointField& nbrCtrs,
151  const vectorField& nbrAreas,
152  const cyclicTransform& nbrTransform,
153  const scalar matchTolerance
154  );
155 
156 
157 
158  // Destructor
159  virtual ~cyclicTransform();
160 
161 
162  // Member Functions
163 
164  // Access
165 
166  //- Type of transform
168  {
169  return transformType_;
170  }
171 
172  //- Is the transform fully specified?
173  bool transformComplete() const
174  {
175  return transformComplete_;
176  }
177 
178  //- Return transformation between the coupled patches
179  const transformer& transform() const
180  {
181  if (!transformComplete_)
182  {
184  << "The transformation has not been fully specified or "
185  << "calculated" << exit(FatalError);
186  }
187  return transform_;
188  }
189 
190 
191  //- Write the data to a dictionary
192  void write(Ostream& os) const;
193 
194 
195  // Global Operators
196 
197  friend cyclicTransform operator&
198  (
199  const transformer& t,
200  const cyclicTransform& c
201  );
202 
203  friend cyclicTransform inv(const cyclicTransform& c);
204 };
205 
206 
208 
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
TypeName("cyclicTransform")
Runtime type information.
dictionary dict
Vector-tensor class used to perform translations, rotations and scaling operations 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:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
bool transformComplete() const
Is the transform fully specified?
const dimensionedScalar c
Speed of light in a vacuum.
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 transformation.
friend cyclicTransform inv(const cyclicTransform &c)
transformTypes transformType() const
Type of transform.
Namespace for OpenFOAM.