FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::syncTools
00026 
00027 Description
00028     Various tools to aid synchronizing lists across coupled patches.
00029 
00030     Require
00031     - combineOperator (e.g. sumEqOp - not sumOp!) that is defined for the
00032       type and combineReduce(UList<T>, combineOperator) should be defined.
00033     - null value which gets overridden by any valid value.
00034     - transform function
00035 
00036     Can apply coordinate rotation/separation on cyclics but only for faces
00037     or if there is a single rotation/separation tensor.
00038 
00039 SourceFiles
00040     syncTools.C
00041     syncToolsTemplates.C
00042 
00043 \*---------------------------------------------------------------------------*/
00044 
00045 #ifndef syncTools_H
00046 #define syncTools_H
00047 
00048 #include <OpenFOAM/UList.H>
00049 #include <OpenFOAM/Pstream.H>
00050 #include <OpenFOAM/transformList.H>
00051 #include <OpenFOAM/Map.H>
00052 #include <OpenFOAM/EdgeMap.H>
00053 #include <OpenFOAM/PackedBoolList.H>
00054 
00055 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00056 
00057 namespace Foam
00058 {
00059 
00060 class polyBoundaryMesh;
00061 class polyMesh;
00062 class coupledPolyPatch;
00063 
00064 /*---------------------------------------------------------------------------*\
00065                            Class syncTools Declaration
00066 \*---------------------------------------------------------------------------*/
00067 
00068 class syncTools
00069 {
00070     // Private Member Functions
00071 
00072         //- Check whether uses couples.
00073         static bool hasCouples(const polyBoundaryMesh&);
00074 
00075         //- Check for single transformation tensor only.
00076         static void checkTransform(const coupledPolyPatch&, const bool);
00077 
00078         //- Apply separation to list. Either single vector or one vector
00079         //  per element.
00080         template <class T>
00081         static void separateList(const vectorField&, UList<T>&);
00082 
00083         template <class T>
00084         static void separateList(const vectorField&, Map<T>&);
00085 
00086         template <class T>
00087         static void separateList(const vectorField&, EdgeMap<T>&);
00088 
00089         //- Combine value with existing value in map.
00090         template <class T, class CombineOp>
00091         static void combine
00092         (
00093             Map<T>& pointValues,
00094             const CombineOp& cop,
00095             const label index,
00096             const T& val
00097         );
00098 
00099         //- Combine val with existing value at (implicit index) e.
00100         template <class T, class CombineOp>
00101         static void combine
00102         (
00103             EdgeMap<T>& edgeValues,
00104             const CombineOp& cop,
00105             const edge& index,
00106             const T& val
00107         );
00108 
00109 
00110 public:
00111 
00112     // Static data members
00113 
00114         //- Synchronize values on all mesh points.
00115         //  Applies rotation and optionally separation for parallel cyclics
00116         template <class T, class CombineOp>
00117         static void syncPointList
00118         (
00119             const polyMesh&,
00120             UList<T>&,
00121             const CombineOp& cop,
00122             const T& nullValue,
00123             const bool applySeparation
00124         );
00125 
00126         //- Synchronize values on selected mesh points.
00127         //  Applies rotation and optionally separation for parallel cyclics
00128         template <class T, class CombineOp>
00129         static void syncPointList
00130         (
00131             const polyMesh&,
00132             const labelList& meshPoints,
00133             UList<T>&,
00134             const CombineOp& bop,
00135             const T& nullValue,
00136             const bool applySeparation
00137         );
00138 
00139         //- Synchronize values on all mesh edges.
00140         //  Applies rotation and optionally separation for parallel cyclics
00141         template <class T, class CombineOp>
00142         static void syncEdgeList
00143         (
00144             const polyMesh&,
00145             UList<T>&,
00146             const CombineOp& cop,
00147             const T& nullValue,
00148             const bool applySeparation
00149         );
00150 
00151         //- Synchronize values on boundary faces only.
00152         //  Optionally applies rotation tensor for non-parallel cyclics
00153         //  (but not separation!)
00154         template <class T, class CombineOp>
00155         static void syncBoundaryFaceList
00156         (
00157             const polyMesh&,
00158             UList<T>&,
00159             const CombineOp& cop,
00160             const bool applySeparation
00161         );
00162 
00163         //- Synchronize values on all mesh faces.
00164         //  Optionally applies rotation tensor for non-parallel cyclics
00165         //  (but not separation!)
00166         template <class T, class CombineOp>
00167         static void syncFaceList
00168         (
00169             const polyMesh&,
00170             UList<T>&,
00171             const CombineOp& cop,
00172             const bool applySeparation
00173         );
00174 
00175         //- Swap coupled face values.
00176         //  Applies rotation and optionally separation for parallel cyclics
00177         template <class T>
00178         static void swapBoundaryFaceList
00179         (
00180             const polyMesh&,
00181             UList<T>&,
00182             const bool applySeparation
00183         );
00184 
00185         //- Swap coupled face values.
00186         //  Applies rotation and optionally separation for parallel cyclics
00187         template <class T>
00188         static void swapFaceList
00189         (
00190             const polyMesh&,
00191             UList<T>&,
00192             const bool applySeparation
00193         );
00194 
00195         // Sparse versions
00196 
00197             //- Synchronize values on selected points.
00198             //  Applies rotation and optionally separation for parallel
00199             //  cyclics.
00200             template <class T, class CombineOp>
00201             static void syncPointMap
00202             (
00203                 const polyMesh&,
00204                 Map<T>& pointValues,
00205                 const CombineOp& cop,
00206                 const bool applySeparation
00207             );
00208 
00209             //- Synchronize values on selected edges. Edges are represented
00210             //  by the two vertices that make it up so global edges never get
00211             //  constructed.
00212             //  Applies rotation and optionally separation for parallel
00213             //  cyclics.
00214             template <class T, class CombineOp>
00215             static void syncEdgeMap
00216             (
00217                 const polyMesh&,
00218                 EdgeMap<T>& edgeValues,
00219                 const CombineOp& cop,
00220                 const bool applySeparation
00221             );
00222 
00223         // PackedList versions
00224 
00225             template <unsigned nBits, class CombineOp>
00226             static void syncFaceList
00227             (
00228                 const polyMesh& mesh,
00229                 PackedList<nBits>& faceValues,
00230                 const CombineOp& cop
00231             );
00232 
00233             template <unsigned nBits>
00234             static void swapFaceList
00235             (
00236                 const polyMesh& mesh,
00237                 PackedList<nBits>& faceValues
00238             );
00239 
00240             template <unsigned nBits, class CombineOp>
00241             static void syncPointList
00242             (
00243                 const polyMesh& mesh,
00244                 PackedList<nBits>& pointValues,
00245                 const CombineOp& cop,
00246                 const unsigned int nullValue
00247             );
00248 
00249             template <unsigned nBits, class CombineOp>
00250             static void syncEdgeList
00251             (
00252                 const polyMesh& mesh,
00253                 PackedList<nBits>& edgeValues,
00254                 const CombineOp& cop,
00255                 const unsigned int nullValue
00256             );
00257 
00258         // Other
00259 
00260             //- Get per point whether is it master (of a coupled set of points)
00261             static PackedBoolList getMasterPoints(const polyMesh&);
00262 
00263             //- Get per edge whether is it master (of a coupled set of edges)
00264             static PackedBoolList getMasterEdges(const polyMesh&);
00265 
00266             //- Get per face whether is it master (of a coupled set of faces)
00267             static PackedBoolList getMasterFaces(const polyMesh&);
00268 
00269 };
00270 
00271 
00272 template<>
00273 void syncTools::separateList(const vectorField&, UList<vector>&);
00274 
00275 template<>
00276 void syncTools::separateList(const vectorField&, Map<vector>&);
00277 
00278 template<>
00279 void syncTools::separateList(const vectorField&, EdgeMap<vector>&);
00280 
00281 
00282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00283 
00284 } // End namespace Foam
00285 
00286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00287 
00288 #ifdef NoRepository
00289 #   include "syncToolsTemplates.C"
00290 #endif
00291 
00292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00293 
00294 #endif
00295 
00296 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines