OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

syncTools.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::syncTools
00027 
00028 Description
00029     Various tools to aid synchronizing lists across coupled patches.
00030 
00031     Require
00032     - combineOperator (e.g. sumEqOp - not sumOp!) that is defined for the
00033       type and combineReduce(UList<T>, combineOperator) should be defined.
00034     - null value which gets overridden by any valid value.
00035     - transform function
00036 
00037     Can apply coordinate rotation/separation on cyclics but only for faces
00038     or if there is a single rotation/separation tensor.
00039 
00040 SourceFiles
00041     syncTools.C
00042     syncToolsTemplates.C
00043 
00044 \*---------------------------------------------------------------------------*/
00045 
00046 #ifndef syncTools_H
00047 #define syncTools_H
00048 
00049 #include "UList.H"
00050 #include "Pstream.H"
00051 #include "transformList.H"
00052 #include "Map.H"
00053 #include "EdgeMap.H"
00054 #include "PackedBoolList.H"
00055 
00056 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00057 
00058 namespace Foam
00059 {
00060 
00061 class polyBoundaryMesh;
00062 class polyMesh;
00063 class coupledPolyPatch;
00064 
00065 /*---------------------------------------------------------------------------*\
00066                            Class syncTools Declaration
00067 \*---------------------------------------------------------------------------*/
00068 
00069 class syncTools
00070 {
00071     // Private Member Functions
00072 
00073         //- Check whether uses couples.
00074         static bool hasCouples(const polyBoundaryMesh&);
00075 
00076         //- Check for single transformation tensor only.
00077         static void checkTransform(const coupledPolyPatch&, const bool);
00078 
00079         //- Apply separation to list. Either single vector or one vector
00080         //  per element.
00081         template <class T>
00082         static void separateList(const vectorField&, UList<T>&);
00083 
00084         template <class T>
00085         static void separateList(const vectorField&, Map<T>&);
00086 
00087         template <class T>
00088         static void separateList(const vectorField&, EdgeMap<T>&);
00089 
00090         //- Combine value with existing value in map.
00091         template <class T, class CombineOp>
00092         static void combine
00093         (
00094             Map<T>& pointValues,
00095             const CombineOp& cop,
00096             const label index,
00097             const T& val
00098         );
00099 
00100         //- Combine val with existing value at (implicit index) e.
00101         template <class T, class CombineOp>
00102         static void combine
00103         (
00104             EdgeMap<T>& edgeValues,
00105             const CombineOp& cop,
00106             const edge& index,
00107             const T& val
00108         );
00109 
00110 
00111 public:
00112 
00113     // Static data members
00114 
00115         //- Synchronize values on all mesh points.
00116         //  Applies rotation and optionally separation for parallel cyclics
00117         template <class T, class CombineOp>
00118         static void syncPointList
00119         (
00120             const polyMesh&,
00121             UList<T>&,
00122             const CombineOp& cop,
00123             const T& nullValue,
00124             const bool applySeparation
00125         );
00126 
00127         //- Synchronize values on selected mesh points.
00128         //  Applies rotation and optionally separation for parallel cyclics
00129         template <class T, class CombineOp>
00130         static void syncPointList
00131         (
00132             const polyMesh&,
00133             const labelList& meshPoints,
00134             UList<T>&,
00135             const CombineOp& bop,
00136             const T& nullValue,
00137             const bool applySeparation
00138         );
00139 
00140         //- Synchronize values on all mesh edges.
00141         //  Applies rotation and optionally separation for parallel cyclics
00142         template <class T, class CombineOp>
00143         static void syncEdgeList
00144         (
00145             const polyMesh&,
00146             UList<T>&,
00147             const CombineOp& cop,
00148             const T& nullValue,
00149             const bool applySeparation
00150         );
00151 
00152         //- Synchronize values on boundary faces only.
00153         //  Optionally applies rotation tensor for non-parallel cyclics
00154         //  (but not separation!)
00155         template <class T, class CombineOp>
00156         static void syncBoundaryFaceList
00157         (
00158             const polyMesh&,
00159             UList<T>&,
00160             const CombineOp& cop,
00161             const bool applySeparation
00162         );
00163 
00164         //- Synchronize values on all mesh faces.
00165         //  Optionally applies rotation tensor for non-parallel cyclics
00166         //  (but not separation!)
00167         template <class T, class CombineOp>
00168         static void syncFaceList
00169         (
00170             const polyMesh&,
00171             UList<T>&,
00172             const CombineOp& cop,
00173             const bool applySeparation
00174         );
00175 
00176         //- Swap coupled face values.
00177         //  Applies rotation and optionally separation for parallel cyclics
00178         template <class T>
00179         static void swapBoundaryFaceList
00180         (
00181             const polyMesh&,
00182             UList<T>&,
00183             const bool applySeparation
00184         );
00185 
00186         //- Swap coupled face values.
00187         //  Applies rotation and optionally separation for parallel cyclics
00188         template <class T>
00189         static void swapFaceList
00190         (
00191             const polyMesh&,
00192             UList<T>&,
00193             const bool applySeparation
00194         );
00195 
00196         // Sparse versions
00197 
00198             //- Synchronize values on selected points.
00199             //  Applies rotation and optionally separation for parallel
00200             //  cyclics.
00201             template <class T, class CombineOp>
00202             static void syncPointMap
00203             (
00204                 const polyMesh&,
00205                 Map<T>& pointValues,
00206                 const CombineOp& cop,
00207                 const bool applySeparation
00208             );
00209 
00210             //- Synchronize values on selected edges. Edges are represented
00211             //  by the two vertices that make it up so global edges never get
00212             //  constructed.
00213             //  Applies rotation and optionally separation for parallel
00214             //  cyclics.
00215             template <class T, class CombineOp>
00216             static void syncEdgeMap
00217             (
00218                 const polyMesh&,
00219                 EdgeMap<T>& edgeValues,
00220                 const CombineOp& cop,
00221                 const bool applySeparation
00222             );
00223 
00224         // PackedList versions
00225 
00226             template <unsigned nBits, class CombineOp>
00227             static void syncFaceList
00228             (
00229                 const polyMesh& mesh,
00230                 PackedList<nBits>& faceValues,
00231                 const CombineOp& cop
00232             );
00233 
00234             template <unsigned nBits>
00235             static void swapFaceList
00236             (
00237                 const polyMesh& mesh,
00238                 PackedList<nBits>& faceValues
00239             );
00240 
00241             template <unsigned nBits, class CombineOp>
00242             static void syncPointList
00243             (
00244                 const polyMesh& mesh,
00245                 PackedList<nBits>& pointValues,
00246                 const CombineOp& cop,
00247                 const unsigned int nullValue
00248             );
00249 
00250             template <unsigned nBits, class CombineOp>
00251             static void syncEdgeList
00252             (
00253                 const polyMesh& mesh,
00254                 PackedList<nBits>& edgeValues,
00255                 const CombineOp& cop,
00256                 const unsigned int nullValue
00257             );
00258 
00259         // Other
00260 
00261             //- Get per point whether is it master (of a coupled set of points)
00262             static PackedBoolList getMasterPoints(const polyMesh&);
00263 
00264             //- Get per edge whether is it master (of a coupled set of edges)
00265             static PackedBoolList getMasterEdges(const polyMesh&);
00266 
00267             //- Get per face whether is it master (of a coupled set of faces)
00268             static PackedBoolList getMasterFaces(const polyMesh&);
00269 
00270 };
00271 
00272 
00273 template<>
00274 void syncTools::separateList(const vectorField&, UList<vector>&);
00275 
00276 template<>
00277 void syncTools::separateList(const vectorField&, Map<vector>&);
00278 
00279 template<>
00280 void syncTools::separateList(const vectorField&, EdgeMap<vector>&);
00281 
00282 
00283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00284 
00285 } // End namespace Foam
00286 
00287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00288 
00289 #ifdef NoRepository
00290 #   include "syncToolsTemplates.C"
00291 #endif
00292 
00293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00294 
00295 #endif
00296 
00297 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd