globalIndexAndTransform.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::globalIndexAndTransform
28
29Description
30 Determination and storage of the possible independent transforms
31 introduced by coupledPolyPatches, as well as all of the possible
32 permutations of these transforms generated by the presence of
33 multiple coupledPolyPatches, i.e. more than one cyclic boundary. Note that
34 any given point can be on maximum 3 transforms only (and these transforms
35 have to be perpendicular)
36
37 Also provides global index encoding and decoding for entity
38 (i.e. cell) index, processor index and transform index (0 or
39 positive integer) to a labelPair.
40
41SourceFiles
42 globalIndexAndTransform.C
43
44\*---------------------------------------------------------------------------*/
45
46#ifndef globalIndexAndTransform_H
47#define globalIndexAndTransform_H
48
49#include "labelPair.H"
51#include "HashSet.H"
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57
58class polyMesh;
59
60
61/*---------------------------------------------------------------------------*\
62 Class globalIndexAndTransform Declaration
63\*---------------------------------------------------------------------------*/
66{
67public:
68
69 // Public classes
70
71 //- Less function class used in sorting encoded transforms and indices
72 // Minimum of:
73 // - processor
74 // - local index
75 // - transform
76 class less
77 {
78 const globalIndexAndTransform& gi_;
79
80 public:
83 :
84 gi_(gi)
85 {}
86
87 inline bool operator()(const labelPair&, const labelPair&) const;
88 };
89
90
91private:
92
93 // Private data
94
95 //- Reference to mesh
96 const polyMesh& mesh_;
97
98 //- The possible independent (non-permuted) transforms of the
99 // geometry, i.e. for a geometry with two cyclics, this
100 // stores the two transforms, not the eight permutations.
101 // Any point can not be on more than three transforms but overall
102 // the mesh can have more than three.
103 List<vectorTensorTransform> transforms_;
104
105 //- The permutations of the transforms, stored for lookup
106 // efficiency. If there are n transforms, then there are
107 // (3^n) permutations, including the no-transformation
108 // transform.
109 List<vectorTensorTransform> transformPermutations_;
110
111 //- Index of identity transform.
112 label nullTransformIndex_;
113
114 //- Mapping from patch index to which transform it matches (or
115 // -1 for none) (.first()) and what sign to use for it,
116 // i.e. +/- 1 (.second()).
117 List<labelPair> patchTransformSign_;
118
119
120 // Private Member Functions
121
122 //- Determine all of the independent basic transforms of the
123 // geometry by analysing the coupledPolyPatches
124 void determineTransforms();
125
126 //- Generate all of the transformation permutations
127 void determineTransformPermutations();
128
129 //- Determine which patch uses which transform (if any) and which
130 // sign to use
131 void determinePatchTransformSign();
132
133 //- Test a list of reference transforms to see if the test
134 // transform matches one. Return +1 or -1 depending on the
135 // sign of the match, or 0 if none matches.
136 label matchTransform
137 (
138 const List<vectorTensorTransform>& refTransforms,
139 label& matchedRefTransformI,
140 const vectorTensorTransform& testTransform,
141 scalar tolerance,
142 bool checkBothSigns
143 ) const;
144
145 //- Return true if transform is not yet present in trafos. Issues
146 // warning if too many transforms
147 bool uniqueTransform
148 (
149 const point& pt,
150 labelPairList& trafos,
151 const label patchi,
152 const labelPair& patchTrafo
153 ) const;
154
155 //- No copy construct
157
158 //- No copy assignment
159 void operator=(const globalIndexAndTransform&) = delete;
160
161
162public:
163
164 // Declare name of the class and its debug switch
165 ClassName("globalIndexAndTransform");
166
167
168 // Constructors
169
170 //- Construct from components
172
173
174 // Member Functions
175
176 //- Generate a transform index from the permutation indices of
177 // the independent transforms. Permutations indices must
178 // only be -1, 0 or +1.
179 inline label encodeTransformIndex
180 (
181 const labelList& permutationIndices
182 ) const;
183
184 //- Decode transform index
185 inline labelList decodeTransformIndex(const label transformIndex) const;
186
187 //- Add patch transformation to transformIndex. Return new
188 // transformIndex. (by default the patch is the sending, not the
189 // receiving, patch)
190 inline label addToTransformIndex
191 (
192 const label transformIndex,
193 const label patchi,
194 const bool isSendingSide = true,
195 const scalar tol = SMALL
196 ) const;
197
198 //- Combine two transformIndices
199 inline label mergeTransformIndex
200 (
201 const label transformIndex0,
202 const label transformIndex1
203 ) const;
204
205 //- Combine two transformIndices
206 inline label minimumTransformIndex
207 (
208 const label transformIndex0,
209 const label transformIndex1
210 ) const;
211
212 //- Subtract two transformIndices
213 inline label subtractTransformIndex
214 (
215 const label transformIndex0,
216 const label transformIndex1
217 ) const;
218
219 //- Encode index and bare index as components on own processor
220 inline labelPair encode
221 (
222 const label index,
223 const label transformIndex
224 ) const;
225
226 //- Encode index and bare index as components on given processor
227 inline labelPair encode
228 (
229 const label proci,
230 const label index,
231 const label transformIndex
232 ) const;
233
234 //- Index carried by the object
235 inline label index(const labelPair& globalIAndTransform) const;
236
237 //- Which processor does this come from?
238 inline label processor(const labelPair& globalIAndTransform) const;
239
240 //- Transform carried by the object
241 inline label transformIndex(const labelPair& globalIAndTransform) const;
242
243 //- Return the number of independent transforms
244 inline label nIndependentTransforms() const;
245
246 //- Return access to the stored independent transforms
247 inline const List<vectorTensorTransform>& transforms() const;
248
249 //- Return access to the permuted transforms
250 inline const List<vectorTensorTransform>&
251 transformPermutations() const;
252
253 //- Return the transformIndex (index in transformPermutations)
254 // of the identity transform
255 inline label nullTransformIndex() const;
256
257 //- Return access to the per-patch transform-sign pairs
258 inline const List<labelPair>& patchTransformSign() const;
259
260 //- Access the overall (permuted) transform corresponding
261 // to the transformIndex
262 inline const vectorTensorTransform& transform
263 (
264 label transformIndex
265 ) const;
266
267 //- Access the all of the indices of the transform
268 // permutations corresponding the transforms of the
269 // listed patch indices. This only allows a maximum of three
270 // transformations (since routine is used to transform points and
271 // any given point can only be on 3 or less transforms)
273 (
274 const labelHashSet& patchIs
275 ) const;
276
277 //- Apply all of the transform permutations
278 // corresponding the transforms of the listed patch
279 // indices to the supplied point
281 (
282 const labelHashSet& patchIs,
283 const point& pt
284 ) const;
285
286};
287
288
289// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290
291} // End namespace Foam
292
293// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294
296
297// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298
299#endif
300
301// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Less function class used in sorting encoded transforms and indices.
bool operator()(const labelPair &, const labelPair &) const
less(const globalIndexAndTransform &gi)
Determination and storage of the possible independent transforms introduced by coupledPolyPatches,...
labelList transformIndicesForPatches(const labelHashSet &patchIs) const
Access the all of the indices of the transform.
pointField transformPatches(const labelHashSet &patchIs, const point &pt) const
Apply all of the transform permutations.
label mergeTransformIndex(const label transformIndex0, const label transformIndex1) const
Combine two transformIndices.
label transformIndex(const labelPair &globalIAndTransform) const
Transform carried by the object.
label processor(const labelPair &globalIAndTransform) const
Which processor does this come from?
const vectorTensorTransform & transform(label transformIndex) const
Access the overall (permuted) transform corresponding.
const List< vectorTensorTransform > & transforms() const
Return access to the stored independent transforms.
label encodeTransformIndex(const labelList &permutationIndices) const
Generate a transform index from the permutation indices of.
label nullTransformIndex() const
Return the transformIndex (index in transformPermutations)
labelPair encode(const label index, const label transformIndex) const
Encode index and bare index as components on own processor.
const List< vectorTensorTransform > & transformPermutations() const
Return access to the permuted transforms.
labelList decodeTransformIndex(const label transformIndex) const
Decode transform index.
label subtractTransformIndex(const label transformIndex0, const label transformIndex1) const
Subtract two transformIndices.
ClassName("globalIndexAndTransform")
const List< labelPair > & patchTransformSign() const
Return access to the per-patch transform-sign pairs.
label index(const labelPair &globalIAndTransform) const
Index carried by the object.
label addToTransformIndex(const label transformIndex, const label patchi, const bool isSendingSide=true, const scalar tol=SMALL) const
Add patch transformation to transformIndex. Return new.
label nIndependentTransforms() const
Return the number of independent transforms.
label minimumTransformIndex(const label transformIndex0, const label transformIndex1) const
Combine two transformIndices.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Vector-tensor class used to perform translations and rotations in 3D space.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
dynamicFvMesh & mesh
Namespace for OpenFOAM.