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 | Copyright (C) 2011-2015 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::globalIndexAndTransform
26 
27 Description
28  Determination and storage of the possible independent transforms
29  introduced by coupledPolyPatches, as well as all of the possible
30  permutations of these transforms generated by the presence of
31  multiple coupledPolyPatches, i.e. more than one cyclic boundary.
32 
33  Also provides global index encoding and decoding for entity
34  (i.e. cell) index, processor index and transform index (0 or
35  positive integer) to a labelPair.
36 
37 SourceFiles
38  globalIndexAndTransform.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef globalIndexAndTransform_H
43 #define globalIndexAndTransform_H
44 
45 #include "labelPair.H"
46 #include "vectorTensorTransform.H"
47 #include "HashSet.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 class polyMesh;
55 
56 
57 /*---------------------------------------------------------------------------*\
58  Class globalIndexAndTransform Declaration
59 \*---------------------------------------------------------------------------*/
60 
62 {
63 public:
64 
65  // Public classes
66 
67  //- Less function class used in sorting encoded transforms and indices
68  // Minimum of:
69  // - processor
70  // - local index
71  // - transform
72  class less
73  {
74  public:
75 
76  inline bool operator()(const labelPair&, const labelPair&) const;
77  };
78 
79 
80 private:
81 
82  // Private data
83 
84  //- Reference to mesh
85  const polyMesh& mesh_;
86 
87  //- The possible independent (non-permuted) transforms of the
88  // geometry, i.e. for a geometry with two cyclics, this
89  // stores the two transforms, not the eight permutations.
90  // There may not be more than three transforms in the range
91  // of coupledPolyPatch geometries (separated XOR
92  // non-parallel) and symmetries (cuboid periodicity only)
93  // supported.
95 
96  //- The permutations of the transforms, stored for lookup
97  // efficiency. If there are n transforms, then there are
98  // (3^n) permutations, including the no-transformation
99  // transform.
101 
102  //- Index of identity transform.
104 
105  //- Mapping from patch index to which transform it matches (or
106  // -1 for none) (.first()) and what sign to use for it,
107  // i.e. +/- 1 (.second()).
109 
110 
111  // Private static data
112 
113  //- Number of spaces to reserve for transform encoding
114  static const label base_;
115 
116 
117  // Private Member Functions
118 
119  //- Determine all of the independent basic transforms of the
120  // geometry by analysing the coupledPolyPatches
121  void determineTransforms();
122 
123  //- Generate all of the transformation permutations
125 
126  //- Determine which patch uses which transform (if any) and which
127  //- Sign to use
129 
130  //- Test a list of reference transforms to see if the test
131  // transform matches one. Return +1 or -1 depending on the
132  // sign of the match, or 0 if none matches.
134  (
135  const List<vectorTensorTransform>& refTransforms,
136  label& matchedRefTransformI,
137  const vectorTensorTransform& testTransform,
138  scalar tolerance,
139  bool checkBothSigns
140  ) const;
141 
142  //- Encode transform index. Hardcoded to 3 independent transforms max.
144  (
145  const FixedList<Foam::label, 3>& permutationIndices
146  ) const;
147 
148  //- Decode transform index. Hardcoded to 3 independent transforms max.
150  (
151  const label transformIndex
152  ) const;
153 
154  //- Disallow default bitwise copy construct
156 
157  //- Disallow default bitwise assignment
158  void operator=(const globalIndexAndTransform&);
159 
160 
161 public:
162 
163  //- Declare friendship with the entry class for IO
164  friend class globalPoints;
165 
166 
167  // Declare name of the class and its debug switch
168  ClassName("globalIndexAndTransform");
169 
170 
171  // Constructors
172 
173  //- Construct from components
175 
176 
177  //- Destructor
179 
180 
181  // Member Functions
182 
183  //- Generate a transform index from the permutation indices of
184  // the independent transforms. Permutations indices must
185  // only be -1, 0 or +1.
187  (
188  const List<label>& permutationIndices
189  ) const;
190 
191  //- Add patch transformation to transformIndex. Return new
192  // transformIndex. (by default the patch is the sending, not the
193  // receiving, patch)
195  (
196  const label transformIndex,
197  const label patchI,
198  const bool isSendingSide = true,
199  const scalar tol = SMALL
200  ) const;
201 
202  //- Combine two transformIndices
204  (
205  const label transformIndex0,
206  const label transformIndex1
207  ) const;
208 
209  //- Combine two transformIndices
211  (
212  const label transformIndex0,
213  const label transformIndex1
214  ) const;
215 
216  //- Subtract two transformIndices
218  (
219  const label transformIndex0,
220  const label transformIndex1
221  ) const;
222 
223  //- Encode index and bare index as components on own processor
224  inline static labelPair encode
225  (
226  const label index,
227  const label transformIndex
228  );
229 
230  //- Encode index and bare index as components on given processor
231  inline static labelPair encode
232  (
233  const label procI,
234  const label index,
235  const label transformIndex
236  );
237 
238  //- Index carried by the object
239  inline static label index(const labelPair& globalIAndTransform);
240 
241  //- Which processor does this come from?
242  inline static label processor(const labelPair& globalIAndTransform);
243 
244  //- Transform carried by the object
245  inline static label transformIndex
246  (
247  const labelPair& globalIAndTransform
248  );
249 
250  // Access
251 
252  //- Return the number of independent transforms
253  inline label nIndependentTransforms() const;
254 
255  //- Return access to the stored independent transforms
256  inline const List<vectorTensorTransform>& transforms() const;
257 
258  //- Return access to the permuted transforms
259  inline const List<vectorTensorTransform>&
260  transformPermutations() const;
261 
262  //- Return the transformIndex (index in transformPermutations)
263  // of the identity transform
264  inline label nullTransformIndex() const;
265 
266  //- Return access to the per-patch transform-sign pairs
267  inline const List<Pair<label> >& patchTransformSign() const;
268 
269  //- Access the overall (permuted) transform corresponding
270  // to the transformIndex
271  inline const vectorTensorTransform& transform
272  (
274  ) const;
275 
276  //- Access the all of the indices of the transform
277  // permutations corresponding the transforms of the
278  // listed patch indices
280  (
281  const labelHashSet& patchIs
282  ) const;
283 
284  //- Apply all of the transform permutations
285  // corresponding the transforms of the listed patch
286  // indices to the supplied point
288  (
289  const labelHashSet& patchIs,
290  const point& pt
291  ) const;
292 
293 };
294 
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 } // End namespace Foam
299 
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 #endif
307 
308 // ************************************************************************* //
Foam::globalIndexAndTransform::determineTransformPermutations
void determineTransformPermutations()
Generate all of the transformation permutations.
Definition: globalIndexAndTransform.C:309
Foam::globalPoints
Calculates points shared by more than two processor patches or cyclic patches.
Definition: globalPoints.H:100
Foam::globalIndexAndTransform::operator=
void operator=(const globalIndexAndTransform &)
Disallow default bitwise assignment.
Foam::globalIndexAndTransform::decodeTransformIndex
FixedList< label, 3 > decodeTransformIndex(const label transformIndex) const
Decode transform index. Hardcoded to 3 independent transforms max.
Definition: globalIndexAndTransformI.H:138
Foam::globalIndexAndTransform::transformPermutations
const List< vectorTensorTransform > & transformPermutations() const
Return access to the permuted transforms.
Definition: globalIndexAndTransformI.H:423
Foam::globalIndexAndTransform::less::operator()
bool operator()(const labelPair &, const labelPair &) const
Definition: globalIndexAndTransformI.H:31
Foam::globalIndexAndTransform::nIndependentTransforms
label nIndependentTransforms() const
Return the number of independent transforms.
Definition: globalIndexAndTransformI.H:409
Foam::globalIndexAndTransform::transformPermutations_
List< vectorTensorTransform > transformPermutations_
The permutations of the transforms, stored for lookup.
Definition: globalIndexAndTransform.H:99
Foam::globalIndexAndTransform::nullTransformIndex_
label nullTransformIndex_
Index of identity transform.
Definition: globalIndexAndTransform.H:102
Foam::globalIndexAndTransform::encode
static labelPair encode(const label index, const label transformIndex)
Encode index and bare index as components on own processor.
Definition: globalIndexAndTransformI.H:340
Foam::HashSet< label, Hash< label > >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::globalIndexAndTransform::patchTransformSign
const List< Pair< label > > & patchTransformSign() const
Return access to the per-patch transform-sign pairs.
Definition: globalIndexAndTransformI.H:436
Foam::globalIndexAndTransform::nullTransformIndex
label nullTransformIndex() const
Return the transformIndex (index in transformPermutations)
Definition: globalIndexAndTransformI.H:429
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::globalIndexAndTransform::transformIndex
static label transformIndex(const labelPair &globalIAndTransform)
Transform carried by the object.
Definition: globalIndexAndTransformI.H:401
Foam::globalIndexAndTransform::base_
static const label base_
Number of spaces to reserve for transform encoding.
Definition: globalIndexAndTransform.H:113
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::globalIndexAndTransform::mergeTransformIndex
label mergeTransformIndex(const label transformIndex0, const label transformIndex1) const
Combine two transformIndices.
Foam::globalIndexAndTransform::determineTransforms
void determineTransforms()
Determine all of the independent basic transforms of the.
Definition: globalIndexAndTransform.C:126
Foam::globalIndexAndTransform::matchTransform
label matchTransform(const List< vectorTensorTransform > &refTransforms, label &matchedRefTransformI, const vectorTensorTransform &testTransform, scalar tolerance, bool checkBothSigns) const
Test a list of reference transforms to see if the test.
Definition: globalIndexAndTransform.C:41
Foam::globalIndexAndTransform::index
static label index(const labelPair &globalIAndTransform)
Index carried by the object.
Definition: globalIndexAndTransformI.H:383
Foam::globalIndexAndTransform::ClassName
ClassName("globalIndexAndTransform")
Foam::globalIndexAndTransform::~globalIndexAndTransform
~globalIndexAndTransform()
Destructor.
Definition: globalIndexAndTransform.C:554
HashSet.H
Foam::globalIndexAndTransform::transformIndicesForPatches
labelList transformIndicesForPatches(const labelHashSet &patchIs) const
Access the all of the indices of the transform.
Definition: globalIndexAndTransformI.H:452
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::globalIndexAndTransform::encodeTransformIndex
label encodeTransformIndex(const FixedList< Foam::label, 3 > &permutationIndices) const
Encode transform index. Hardcoded to 3 independent transforms max.
Definition: globalIndexAndTransformI.H:110
Foam::globalIndexAndTransform::transformPatches
pointField transformPatches(const labelHashSet &patchIs, const point &pt) const
Apply all of the transform permutations.
Definition: globalIndexAndTransformI.H:627
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::globalIndexAndTransform::globalIndexAndTransform
globalIndexAndTransform(const globalIndexAndTransform &)
Disallow default bitwise copy construct.
Foam::globalIndexAndTransform::subtractTransformIndex
label subtractTransformIndex(const label transformIndex0, const label transformIndex1) const
Subtract two transformIndices.
Definition: globalIndexAndTransformI.H:322
Foam::globalIndexAndTransform::transform
const vectorTensorTransform & transform(label transformIndex) const
Access the overall (permuted) transform corresponding.
Definition: globalIndexAndTransformI.H:443
Foam::globalIndexAndTransform::determinePatchTransformSign
void determinePatchTransformSign()
Definition: globalIndexAndTransform.C:350
Foam::globalIndexAndTransform::mesh_
const polyMesh & mesh_
Reference to mesh.
Definition: globalIndexAndTransform.H:84
globalIndexAndTransformI.H
Foam::globalIndexAndTransform::processor
static label processor(const labelPair &globalIAndTransform)
Which processor does this come from?
Definition: globalIndexAndTransformI.H:392
Foam::Pair
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::globalIndexAndTransform::less
Less function class used in sorting encoded transforms and indices.
Definition: globalIndexAndTransform.H:71
Foam::vectorTensorTransform
Vector-tensor class used to perform translations and rotations in 3D space.
Definition: vectorTensorTransform.H:61
Foam::FixedList
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
Foam::globalIndexAndTransform::patchTransformSign_
List< Pair< label > > patchTransformSign_
Mapping from patch index to which transform it matches (or.
Definition: globalIndexAndTransform.H:107
Foam::globalIndexAndTransform::transforms_
List< vectorTensorTransform > transforms_
The possible independent (non-permuted) transforms of the.
Definition: globalIndexAndTransform.H:93
Foam::globalIndexAndTransform::addToTransformIndex
label addToTransformIndex(const label transformIndex, const label patchI, const bool isSendingSide=true, const scalar tol=SMALL) const
Add patch transformation to transformIndex. Return new.
Definition: globalIndexAndTransformI.H:176
vectorTensorTransform.H
Foam::globalIndexAndTransform
Determination and storage of the possible independent transforms introduced by coupledPolyPatches,...
Definition: globalIndexAndTransform.H:60
Foam::globalIndexAndTransform::transforms
const List< vectorTensorTransform > & transforms() const
Return access to the stored independent transforms.
Definition: globalIndexAndTransformI.H:416
Foam::globalIndexAndTransform::minimumTransformIndex
label minimumTransformIndex(const label transformIndex0, const label transformIndex1) const
Combine two transformIndices.
Definition: globalIndexAndTransformI.H:278
labelPair.H