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-2025 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  static const wordList keywords;
66 
67 
68 private:
69 
70  // Private Data
71 
72  //- Type of transformation
73  transformTypes transformType_;
74 
75  //- Axis of rotation
76  vector rotationAxis_;
77 
78  //- Centre of rotation
79  point rotationCentre_;
80 
81  //- Rotation angle
82  scalar rotationAngle_;
83 
84  //- Separation vector
85  vector separation_;
86 
87  //- Is the transformation specification complete, or do some parts of
88  // the above data still need to be computed from the patch geometry?
89  bool transformComplete_;
90 
91  //- Generic transformer object
92  transformer transform_;
93 
94 
95  // Private Member Functions
96 
97  //- Re-calculate the transformer object from the other data if possible
98  void update();
99 
100  //- Set the transform to that supplied. Return true if the
101  // transformations are compatible. Used for copying transformation
102  // data from the neighbour patch.
103  bool set
104  (
105  const cyclicTransform& t,
106  const scalar lengthScale,
107  const scalar matchTolerance
108  );
109 
110 
111 public:
112 
113  //- Runtime type information
114  TypeName("cyclicTransform");
115 
116 
117  // Constructors
118 
119  // Transformation set NONE
120  cyclicTransform();
121 
122  // Transformation set as UNSPECIFIED or NONE
123  cyclicTransform(const bool defaultIsNone);
124 
125  // Transformation read from dictionary
126  cyclicTransform(const dictionary& dict, const bool defaultIsNone);
127 
128  //- Construct from coupled patch data. Copies from the supplied
129  // transform and neighbour transform. Suitable for
130  // geometrically dissimilar patches.
132  (
133  const word& name,
134  const vectorField& areas,
135  const cyclicTransform& transform,
136  const word& nbrName,
137  const cyclicTransform& nbrTransform,
138  const scalar matchTolerance,
139  const bool global = false
140  );
141 
142  //- Construct from coupled patch data. Copies from the supplied
143  // transform and neighbour transform, then tries to determine missing
144  // parts of the transformation automatically from the patch geometry.
145  // Suitable for geometrically similar patches only.
147  (
148  const word& name,
149  const pointField& ctrs,
150  const vectorField& areas,
151  const cyclicTransform& transform,
152  const word& nbrName,
153  const pointField& nbrCtrs,
154  const vectorField& nbrAreas,
155  const cyclicTransform& nbrTransform,
156  const scalar matchTolerance,
157  const bool global = false
158  );
159 
160 
161  // Destructor
162  virtual ~cyclicTransform();
163 
164 
165  // Member Functions
166 
167  // Access
168 
169  //- Type of transform
171  {
172  return transformType_;
173  }
174 
175  //- Is the transform fully specified?
176  bool transformComplete() const
177  {
178  return transformComplete_;
179  }
180 
181  //- Return transformation between the coupled patches
182  const transformer& transform() const
183  {
184  if (!transformComplete_)
185  {
187  << "The transformation has not been fully specified or "
188  << "calculated" << exit(FatalError);
189  }
190  return transform_;
191  }
192 
193 
194  //- Write the data to a dictionary
195  void write(Ostream& os) const;
196 
197  //- Generate a string representation of the transform
198  string str() const;
199 
200 
201  // Global Operators
202 
203  friend cyclicTransform operator&
204  (
205  const transformer& t,
206  const cyclicTransform& c
207  );
208 
209  friend cyclicTransform inv(const cyclicTransform& c);
210 };
211 
212 
214 
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace Foam
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Cyclic plane transformation.
string str() const
Generate a string representation of the transform.
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.
static const wordList keywords
const transformer & transform() const
Return transformation between the coupled patches.
TypeName("cyclicTransform")
Runtime type information.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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
tmp< VolField< Type > > operator&(const fvMatrix< Type > &, const DimensionedField< Type, volMesh > &)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
void inv(LagrangianPatchField< tensor > &f, const LagrangianPatchField< tensor > &f1)
dictionary dict