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  const bool global = false
138  );
139 
140  //- Construct from coupled patch data. Copies from the supplied
141  // transform and neighbour transform, then tries to determine missing
142  // parts of the transformation automatically from the patch geometry.
143  // Suitable for geometrically similar patches only.
145  (
146  const word& name,
147  const pointField& ctrs,
148  const vectorField& areas,
149  const cyclicTransform& transform,
150  const word& nbrName,
151  const pointField& nbrCtrs,
152  const vectorField& nbrAreas,
153  const cyclicTransform& nbrTransform,
154  const scalar matchTolerance,
155  const bool global = false
156  );
157 
158 
159  // Destructor
160  virtual ~cyclicTransform();
161 
162 
163  // Member Functions
164 
165  // Access
166 
167  //- Type of transform
169  {
170  return transformType_;
171  }
172 
173  //- Is the transform fully specified?
174  bool transformComplete() const
175  {
176  return transformComplete_;
177  }
178 
179  //- Return transformation between the coupled patches
180  const transformer& transform() const
181  {
182  if (!transformComplete_)
183  {
185  << "The transformation has not been fully specified or "
186  << "calculated" << exit(FatalError);
187  }
188  return transform_;
189  }
190 
191 
192  //- Write the data to a dictionary
193  void write(Ostream& os) const;
194 
195 
196  // Global Operators
197 
198  friend cyclicTransform operator&
199  (
200  const transformer& t,
201  const cyclicTransform& c
202  );
203 
204  friend cyclicTransform inv(const cyclicTransform& c);
205 };
206 
207 
209 
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Cyclic plane transformation.
bool transformComplete() const
Is the transform fully specified?
static const NamedEnum< transformTypes, 4 > transformTypeNames
friend cyclicTransform inv(const cyclicTransform &c)
void write(Ostream &os) const
Write the data to a dictionary.
transformTypes transformType() const
Type of transform.
const transformer & transform() const
Return transformation between the coupled patches.
TypeName("cyclicTransform")
Runtime type information.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
tmp< VolField< Type > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
error FatalError
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
dictionary dict