initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / syncTools / syncTools.H
blob754eaf907c3c4ff4cf1e2dcaf3ed793204fd5743
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::syncTools
28 Description
29     Various tools to aid synchronizing lists across coupled patches.
31     Require
32     - combineOperator (e.g. sumEqOp - not sumOp!) that is defined for the
33       type and combineReduce(UList\<T\>, combineOperator) should be defined.
34     - null value which gets overridden by any valid value.
35     - transform function
37     Can apply coordinate rotation/separation on cyclics but only for faces
38     or if there is a single rotation/separation tensor.
40 SourceFiles
41     syncTools.C
42     syncToolsTemplates.C
44 \*---------------------------------------------------------------------------*/
46 #ifndef syncTools_H
47 #define syncTools_H
49 #include "UList.H"
50 #include "Pstream.H"
51 #include "transformList.H"
52 #include "Map.H"
53 #include "EdgeMap.H"
54 #include "PackedBoolList.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 namespace Foam
61 class polyBoundaryMesh;
62 class polyMesh;
63 class coupledPolyPatch;
65 /*---------------------------------------------------------------------------*\
66                            Class syncTools Declaration
67 \*---------------------------------------------------------------------------*/
69 class syncTools
71     // Private Member Functions
73         //- Check whether uses couples.
74         static bool hasCouples(const polyBoundaryMesh&);
76         //- Check for single transformation tensor only.
77         static void checkTransform(const coupledPolyPatch&, const bool);
79         //- Apply separation to list. Either single vector or one vector
80         //  per element.
81         template <class T>
82         static void separateList(const vectorField&, UList<T>&);
84         template <class T>
85         static void separateList(const vectorField&, Map<T>&);
87         template <class T>
88         static void separateList(const vectorField&, EdgeMap<T>&);
90         //- Combine value with existing value in map.
91         template <class T, class CombineOp>
92         static void combine
93         (
94             Map<T>& pointValues,
95             const CombineOp& cop,
96             const label index,
97             const T& val
98         );
100         //- Combine val with existing value at (implicit index) e.
101         template <class T, class CombineOp>
102         static void combine
103         (
104             EdgeMap<T>& edgeValues,
105             const CombineOp& cop,
106             const edge& index,
107             const T& val
108         );
111 public:
113     // Static data members
115         //- Synchronize values on all mesh points.
116         //  Applies rotation and optionally separation for parallel cyclics
117         template <class T, class CombineOp>
118         static void syncPointList
119         (
120             const polyMesh&,
121             UList<T>&,
122             const CombineOp& cop,
123             const T& nullValue,
124             const bool applySeparation
125         );
127         //- Synchronize values on selected mesh points.
128         //  Applies rotation and optionally separation for parallel cyclics
129         template <class T, class CombineOp>
130         static void syncPointList
131         (
132             const polyMesh&,
133             const labelList& meshPoints,
134             UList<T>&,
135             const CombineOp& bop,
136             const T& nullValue,
137             const bool applySeparation
138         );
140         //- Synchronize values on all mesh edges.
141         //  Applies rotation and optionally separation for parallel cyclics
142         template <class T, class CombineOp>
143         static void syncEdgeList
144         (
145             const polyMesh&,
146             UList<T>&,
147             const CombineOp& cop,
148             const T& nullValue,
149             const bool applySeparation
150         );
152         //- Synchronize values on boundary faces only.
153         //  Optionally applies rotation tensor for non-parallel cyclics
154         //  (but not separation!)
155         template <class T, class CombineOp>
156         static void syncBoundaryFaceList
157         (
158             const polyMesh&,
159             UList<T>&,
160             const CombineOp& cop,
161             const bool applySeparation
162         );
164         //- Synchronize values on all mesh faces.
165         //  Optionally applies rotation tensor for non-parallel cyclics
166         //  (but not separation!)
167         template <class T, class CombineOp>
168         static void syncFaceList
169         (
170             const polyMesh&,
171             UList<T>&,
172             const CombineOp& cop,
173             const bool applySeparation
174         );
176         //- Swap coupled face values.
177         //  Applies rotation and optionally separation for parallel cyclics
178         template <class T>
179         static void swapBoundaryFaceList
180         (
181             const polyMesh&,
182             UList<T>&,
183             const bool applySeparation
184         );
186         //- Swap coupled face values.
187         //  Applies rotation and optionally separation for parallel cyclics
188         template <class T>
189         static void swapFaceList
190         (
191             const polyMesh&,
192             UList<T>&,
193             const bool applySeparation
194         );
196         // Sparse versions
198             //- Synchronize values on selected points.
199             //  Applies rotation and optionally separation for parallel
200             //  cyclics.
201             template <class T, class CombineOp>
202             static void syncPointMap
203             (
204                 const polyMesh&,
205                 Map<T>& pointValues,
206                 const CombineOp& cop,
207                 const bool applySeparation
208             );
210             //- Synchronize values on selected edges. Edges are represented
211             //  by the two vertices that make it up so global edges never get
212             //  constructed.
213             //  Applies rotation and optionally separation for parallel
214             //  cyclics.
215             template <class T, class CombineOp>
216             static void syncEdgeMap
217             (
218                 const polyMesh&,
219                 EdgeMap<T>& edgeValues,
220                 const CombineOp& cop,
221                 const bool applySeparation
222             );
224         // PackedList versions
226             template <unsigned nBits, class CombineOp>
227             static void syncFaceList
228             (
229                 const polyMesh& mesh,
230                 PackedList<nBits>& faceValues,
231                 const CombineOp& cop
232             );
234             template <unsigned nBits>
235             static void swapFaceList
236             (
237                 const polyMesh& mesh,
238                 PackedList<nBits>& faceValues
239             );
241             template <unsigned nBits, class CombineOp>
242             static void syncPointList
243             (
244                 const polyMesh& mesh,
245                 PackedList<nBits>& pointValues,
246                 const CombineOp& cop,
247                 const unsigned int nullValue
248             );
250             template <unsigned nBits, class CombineOp>
251             static void syncEdgeList
252             (
253                 const polyMesh& mesh,
254                 PackedList<nBits>& edgeValues,
255                 const CombineOp& cop,
256                 const unsigned int nullValue
257             );
259         // Other
261             //- Get per point whether is it master (of a coupled set of points)
262             static PackedBoolList getMasterPoints(const polyMesh&);
264             //- Get per edge whether is it master (of a coupled set of edges)
265             static PackedBoolList getMasterEdges(const polyMesh&);
267             //- Get per face whether is it master (of a coupled set of faces)
268             static PackedBoolList getMasterFaces(const polyMesh&);
273 template<>
274 void syncTools::separateList(const vectorField&, UList<vector>&);
276 template<>
277 void syncTools::separateList(const vectorField&, Map<vector>&);
279 template<>
280 void syncTools::separateList(const vectorField&, EdgeMap<vector>&);
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 } // End namespace Foam
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 #ifdef NoRepository
290 #   include "syncToolsTemplates.C"
291 #endif
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 #endif
297 // ************************************************************************* //