syncTools.H 9.04 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
Mark Olesen's avatar
Mark Olesen committed
5
    \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM; if not, write to the Free Software Foundation,
    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Class
    Foam::syncTools

Description
    Various tools to aid synchronizing lists across coupled patches.

    Require 
    - combineOperator (e.g. sumEqOp - not sumOp!) that is defined for the
      type and combineReduce(UList\<T\>, combineOperator) should be defined.
    - null value which gets overridden by any valid value.
    - transform function

    Can apply coordinate rotation/separation on cyclics but only for faces
    or if there is a single rotation/separation tensor.

SourceFiles
    syncTools.C
    syncToolsTemplates.C

\*---------------------------------------------------------------------------*/

#ifndef syncTools_H
#define syncTools_H

#include "UList.H"
#include "Pstream.H"
#include "transformList.H"
#include "Map.H"
#include "EdgeMap.H"
#include "PackedList.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

class polyBoundaryMesh;
class polyMesh;
class coupledPolyPatch;

/*---------------------------------------------------------------------------*\
                           Class syncTools Declaration
\*---------------------------------------------------------------------------*/

class syncTools
{
    // Private Member Functions

        //- Check whether uses couples.
        static bool hasCouples(const polyBoundaryMesh&);

        //- Check for single transformation tensor only.
        static void checkTransform(const coupledPolyPatch&, const bool);

        //- Apply separation to list. Either single vector or one vector
        //  per element.
        template <class T>
        static void separateList(const vectorField&, UList<T>&);

        template <class T>
        static void separateList(const vectorField&, Map<T>&);

        template <class T>
        static void separateList(const vectorField&, EdgeMap<T>&);

        //- Combine value with existing value in map.
        template <class T, class CombineOp>
        static void combine
        (
            Map<T>& pointValues,
            const CombineOp& cop,
            const label index,
            const T& val
        );

        //- Combine val with existing value at (implicit index) e.
        template <class T, class CombineOp>
        static void combine
        (
            EdgeMap<T>& edgeValues,
            const CombineOp& cop,
            const edge& index,
            const T& val
        );


public:

    // Static data members

        //- Synchronize values on all mesh points.
        //  Applies rotation and optionally separation for parallel cyclics
        template <class T, class CombineOp>
        static void syncPointList
        (
            const polyMesh&,
            UList<T>&,
            const CombineOp& cop,
            const T& nullValue,
            const bool applySeparation
        );

        //- Synchronize values on selected mesh points.
        //  Applies rotation and optionally separation for parallel cyclics
        template <class T, class CombineOp>
        static void syncPointList
        (
            const polyMesh&,
            const labelList& meshPoints,
            UList<T>&,
            const CombineOp& bop,
            const T& nullValue,
            const bool applySeparation
        );

        //- Synchronize values on all mesh edges.
        //  Applies rotation and optionally separation for parallel cyclics
        template <class T, class CombineOp>
        static void syncEdgeList
        (
            const polyMesh&,
            UList<T>&,
            const CombineOp& cop,
            const T& nullValue,
            const bool applySeparation
        );

        //- Synchronize values on boundary faces only.
        //  Optionally applies rotation tensor for non-parallel cyclics
        //  (but not separation!)
        template <class T, class CombineOp>
        static void syncBoundaryFaceList
        (
            const polyMesh&,
            UList<T>&,
            const CombineOp& cop,
            const bool applySeparation
        );

        //- Synchronize values on all mesh faces.
        //  Optionally applies rotation tensor for non-parallel cyclics
        //  (but not separation!)
        template <class T, class CombineOp>
        static void syncFaceList
        (
            const polyMesh&,
            UList<T>&,
            const CombineOp& cop,
            const bool applySeparation
        );

        //- Swap coupled face values.
        //  Applies rotation and optionally separation for parallel cyclics
        template <class T>
        static void swapBoundaryFaceList
        (
            const polyMesh&,
            UList<T>&,
            const bool applySeparation
        );

        //- Swap coupled face values.
        //  Applies rotation and optionally separation for parallel cyclics
        template <class T>
        static void swapFaceList
        (
            const polyMesh&,
            UList<T>&,
            const bool applySeparation
        );

        // Sparse versions

            //- Synchronize values on selected points.
            //  Applies rotation and optionally separation for parallel
            //  cyclics.
            template <class T, class CombineOp>
            static void syncPointMap
            (
                const polyMesh&,
                Map<T>& pointValues,
                const CombineOp& cop,
                const bool applySeparation
            );

            //- Synchronize values on selected edges. Edges are represented
            //  by the two vertices that make it up so global edges never get
            //  constructed.
            //  Applies rotation and optionally separation for parallel
            //  cyclics.
            template <class T, class CombineOp>
            static void syncEdgeMap
            (
                const polyMesh&,
                EdgeMap<T>& edgeValues,
                const CombineOp& cop,
                const bool applySeparation
            );

mattijs's avatar
mattijs committed
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
        // PackedList versions

            template <int nBits, class CombineOp>
            static void syncFaceList
            (
                const polyMesh& mesh,
                PackedList<nBits>& faceValues,
                const CombineOp& cop
            );

            template <int nBits>
            static void swapFaceList
            (
                const polyMesh& mesh,
                PackedList<nBits>& faceValues
            );

            template <int nBits, class CombineOp>
            static void syncPointList
            (
                const polyMesh& mesh,
                PackedList<nBits>& pointValues,
                const CombineOp& cop,
                const unsigned int nullValue
            );

            template <int nBits, class CombineOp>
            static void syncEdgeList
            (
                const polyMesh& mesh,
                PackedList<nBits>& edgeValues,
                const CombineOp& cop,
                const unsigned int nullValue
            );

259
260
261
262
263
        // Other

            //- Get per point whether is it master (of a coupled set of points)
            static PackedList<1> getMasterPoints(const polyMesh&);

mattijs's avatar
mattijs committed
264
            //- Get per edge whether is it master (of a coupled set of edges)
265
266
            static PackedList<1> getMasterEdges(const polyMesh&);

mattijs's avatar
mattijs committed
267
268
269
            //- Get per face whether is it master (of a coupled set of faces)
            static PackedList<1> getMasterFaces(const polyMesh&);

270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
};


template<>
void syncTools::separateList(const vectorField&, UList<vector>&);

template<>
void syncTools::separateList(const vectorField&, Map<vector>&);

template<>
void syncTools::separateList(const vectorField&, EdgeMap<vector>&);


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#ifdef NoRepository
#   include "syncToolsTemplates.C"
#endif

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //