1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Various tools to aid synchronizing lists across coupled patches.
31 - combineOperator (e.g. sumEqOp - not sumOp!) that is defined for the
32 type and combineReduce(UList\<T\>, combineOperator) should be defined.
33 - null value which gets overridden by any valid value.
36 Can apply coordinate rotation/separation on cyclics but only for faces
37 or if there is a single rotation/separation tensor.
43 \*---------------------------------------------------------------------------*/
50 #include "transformList.H"
53 #include "PackedBoolList.H"
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 class polyBoundaryMesh;
62 class coupledPolyPatch;
64 /*---------------------------------------------------------------------------*\
65 Class syncTools Declaration
66 \*---------------------------------------------------------------------------*/
70 // Private Member Functions
72 //- Check whether uses couples.
73 static bool hasCouples(const polyBoundaryMesh&);
75 //- Check for single transformation tensor only.
76 static void checkTransform(const coupledPolyPatch&, const bool);
78 //- Apply separation to list. Either single vector or one vector
81 static void separateList(const vectorField&, UList<T>&);
84 static void separateList(const vectorField&, Map<T>&);
87 static void separateList(const vectorField&, EdgeMap<T>&);
89 //- Combine value with existing value in map.
90 template <class T, class CombineOp>
99 //- Combine val with existing value at (implicit index) e.
100 template <class T, class CombineOp>
103 EdgeMap<T>& edgeValues,
104 const CombineOp& cop,
112 // Static data members
114 //- Synchronize values on all mesh points.
115 // Applies rotation and optionally separation for parallel cyclics
116 template <class T, class CombineOp>
117 static void syncPointList
121 const CombineOp& cop,
123 const bool applySeparation
126 //- Synchronize values on selected mesh points.
127 // Applies rotation and optionally separation for parallel cyclics
128 template <class T, class CombineOp>
129 static void syncPointList
132 const labelList& meshPoints,
134 const CombineOp& bop,
136 const bool applySeparation
139 //- Synchronize values on all mesh edges.
140 // Applies rotation and optionally separation for parallel cyclics
141 template <class T, class CombineOp>
142 static void syncEdgeList
146 const CombineOp& cop,
148 const bool applySeparation
151 //- Synchronize values on boundary faces only.
152 // Optionally applies rotation tensor for non-parallel cyclics
153 // (but not separation!)
154 template <class T, class CombineOp>
155 static void syncBoundaryFaceList
159 const CombineOp& cop,
160 const bool applySeparation
163 //- Synchronize values on all mesh faces.
164 // Optionally applies rotation tensor for non-parallel cyclics
165 // (but not separation!)
166 template <class T, class CombineOp>
167 static void syncFaceList
171 const CombineOp& cop,
172 const bool applySeparation
175 //- Swap coupled face values.
176 // Applies rotation and optionally separation for parallel cyclics
178 static void swapBoundaryFaceList
182 const bool applySeparation
185 //- Swap coupled face values.
186 // Applies rotation and optionally separation for parallel cyclics
188 static void swapFaceList
192 const bool applySeparation
197 //- Synchronize values on selected points.
198 // Applies rotation and optionally separation for parallel
200 template <class T, class CombineOp>
201 static void syncPointMap
205 const CombineOp& cop,
206 const bool applySeparation
209 //- Synchronize values on selected edges. Edges are represented
210 // by the two vertices that make it up so global edges never get
212 // Applies rotation and optionally separation for parallel
214 template <class T, class CombineOp>
215 static void syncEdgeMap
218 EdgeMap<T>& edgeValues,
219 const CombineOp& cop,
220 const bool applySeparation
223 // PackedList versions
225 template <unsigned nBits, class CombineOp>
226 static void syncFaceList
228 const polyMesh& mesh,
229 PackedList<nBits>& faceValues,
233 template <unsigned nBits>
234 static void swapFaceList
236 const polyMesh& mesh,
237 PackedList<nBits>& faceValues
240 template <unsigned nBits, class CombineOp>
241 static void syncPointList
243 const polyMesh& mesh,
244 PackedList<nBits>& pointValues,
245 const CombineOp& cop,
246 const unsigned int nullValue
249 template <unsigned nBits, class CombineOp>
250 static void syncEdgeList
252 const polyMesh& mesh,
253 PackedList<nBits>& edgeValues,
254 const CombineOp& cop,
255 const unsigned int nullValue
260 //- Get per point whether is it master (of a coupled set of points)
261 static PackedBoolList getMasterPoints(const polyMesh&);
263 //- Get per edge whether is it master (of a coupled set of edges)
264 static PackedBoolList getMasterEdges(const polyMesh&);
266 //- Get per face whether is it master (of a coupled set of faces)
267 static PackedBoolList getMasterFaces(const polyMesh&);
273 void syncTools::separateList(const vectorField&, UList<vector>&);
276 void syncTools::separateList(const vectorField&, Map<vector>&);
279 void syncTools::separateList(const vectorField&, EdgeMap<vector>&);
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 } // End namespace Foam
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 # include "syncToolsTemplates.C"
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 // ************************************************************************* //