1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
29 Various tools to aid synchronizing lists across coupled patches.
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.
37 Can apply coordinate rotation/separation on cyclics but only for faces
38 or if there is a single rotation/separation tensor.
44 \*---------------------------------------------------------------------------*/
51 #include "transformList.H"
54 #include "PackedBoolList.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 class polyBoundaryMesh;
63 class coupledPolyPatch;
65 /*---------------------------------------------------------------------------*\
66 Class syncTools Declaration
67 \*---------------------------------------------------------------------------*/
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
82 static void separateList(const vectorField&, UList<T>&);
85 static void separateList(const vectorField&, Map<T>&);
88 static void separateList(const vectorField&, EdgeMap<T>&);
90 //- Combine value with existing value in map.
91 template <class T, class CombineOp>
100 //- Combine val with existing value at (implicit index) e.
101 template <class T, class CombineOp>
104 EdgeMap<T>& edgeValues,
105 const CombineOp& cop,
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
122 const CombineOp& cop,
124 const bool applySeparation
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
133 const labelList& meshPoints,
135 const CombineOp& bop,
137 const bool applySeparation
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
147 const CombineOp& cop,
149 const bool applySeparation
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
160 const CombineOp& cop,
161 const bool applySeparation
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
172 const CombineOp& cop,
173 const bool applySeparation
176 //- Swap coupled face values.
177 // Applies rotation and optionally separation for parallel cyclics
179 static void swapBoundaryFaceList
183 const bool applySeparation
186 //- Swap coupled face values.
187 // Applies rotation and optionally separation for parallel cyclics
189 static void swapFaceList
193 const bool applySeparation
198 //- Synchronize values on selected points.
199 // Applies rotation and optionally separation for parallel
201 template <class T, class CombineOp>
202 static void syncPointMap
206 const CombineOp& cop,
207 const bool applySeparation
210 //- Synchronize values on selected edges. Edges are represented
211 // by the two vertices that make it up so global edges never get
213 // Applies rotation and optionally separation for parallel
215 template <class T, class CombineOp>
216 static void syncEdgeMap
219 EdgeMap<T>& edgeValues,
220 const CombineOp& cop,
221 const bool applySeparation
224 // PackedList versions
226 template <unsigned nBits, class CombineOp>
227 static void syncFaceList
229 const polyMesh& mesh,
230 PackedList<nBits>& faceValues,
234 template <unsigned nBits>
235 static void swapFaceList
237 const polyMesh& mesh,
238 PackedList<nBits>& faceValues
241 template <unsigned nBits, class CombineOp>
242 static void syncPointList
244 const polyMesh& mesh,
245 PackedList<nBits>& pointValues,
246 const CombineOp& cop,
247 const unsigned int nullValue
250 template <unsigned nBits, class CombineOp>
251 static void syncEdgeList
253 const polyMesh& mesh,
254 PackedList<nBits>& edgeValues,
255 const CombineOp& cop,
256 const unsigned int nullValue
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&);
274 void syncTools::separateList(const vectorField&, UList<vector>&);
277 void syncTools::separateList(const vectorField&, Map<vector>&);
280 void syncTools::separateList(const vectorField&, EdgeMap<vector>&);
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 } // End namespace Foam
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 # include "syncToolsTemplates.C"
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 // ************************************************************************* //