OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen 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-2007 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     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
00038     This is not tested!!!
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 "tensorField.H"
00052 #include "PackedList.H"
00053 
00054 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00055 
00056 namespace Foam
00057 {
00058 
00059 // Define dummy transform for labels.
00060 label transform(const tensor&, const label val);
00061 
00062 class polyBoundaryMesh;
00063 class polyMesh;
00064 class coupledPolyPatch;
00065 
00066 /*---------------------------------------------------------------------------*\
00067                            Class syncTools Declaration
00068 \*---------------------------------------------------------------------------*/
00069 
00070 class syncTools
00071 {
00072     // Private Member Functions
00073 
00074         //- Check whether uses couples.
00075         static bool hasCouples(const polyBoundaryMesh&);
00076 
00077         //- Check for single transformation tensor only.
00078         static void checkTransform(const coupledPolyPatch&, const bool);
00079 
00080         //- Dummy transform for labels
00081         static label transform(const tensor&, const label i)
00082         {
00083             return i;
00084         }
00085 
00086         //- Apply transformation to list. Either single transformation tensor
00087         //  or one tensor per element.
00088         template <class T>
00089         static void transformList(const tensorField&, UList<T>&);
00090 
00091         //- Apply separation to list. Either single vector or one vector
00092         //  per element.
00093         template <class T>
00094         static void separateList(const vectorField&, UList<T>&);
00095 
00096 
00097 public:
00098 
00099     // Static data members
00100 
00101         //- Synchronize values on all mesh points.
00102         //  Applies rotation and optionally separation for parallel cyclics
00103         template <class T, class CombineOp>
00104         static void syncPointList
00105         (
00106             const polyMesh&,
00107             UList<T>&,
00108             const CombineOp& bop,
00109             const T& nullValue,
00110             const bool applySeparation
00111         );
00112 
00113         //- Synchronize values on selected mesh points.
00114         //  Applies rotation and optionally separation for parallel cyclics
00115         template <class T, class CombineOp>
00116         static void syncPointList
00117         (
00118             const polyMesh&,
00119             const labelList& meshPoints,
00120             UList<T>&,
00121             const CombineOp& bop,
00122             const T& nullValue,
00123             const bool applySeparation
00124         );
00125 
00126         //- Synchronize values on all mesh edges.
00127         //  Applies rotation and optionally separation for parallel cyclics
00128         template <class T, class CombineOp>
00129         static void syncEdgeList
00130         (
00131             const polyMesh&,
00132             UList<T>&,
00133             const CombineOp& bop,
00134             const T& nullValue,
00135             const bool applySeparation
00136         );
00137 
00138         //- Synchronize values on boundary faces only.
00139         //  Optionally applies rotation tensor for non-parallel cyclics
00140         //  (but not separation!)
00141         template <class T, class CombineOp>
00142         static void syncBoundaryFaceList
00143         (
00144             const polyMesh&,
00145             UList<T>&,
00146             const CombineOp& bop,
00147             const bool applySeparation
00148         );
00149 
00150         //- Synchronize values on all mesh faces.
00151         //  Optionally applies rotation tensor for non-parallel cyclics
00152         //  (but not separation!)
00153         template <class T, class CombineOp>
00154         static void syncFaceList
00155         (
00156             const polyMesh&,
00157             UList<T>&,
00158             const CombineOp& bop,
00159             const bool applySeparation
00160         );
00161 
00162         //- Swap coupled face values.
00163         //  Applies rotation and optionally separation for parallel cyclics
00164         template <class T>
00165         static void swapBoundaryFaceList
00166         (
00167             const polyMesh&,
00168             UList<T>&,
00169             const bool applySeparation
00170         );
00171 
00172         //- Swap coupled face values.
00173         //  Applies rotation and optionally separation for parallel cyclics
00174         template <class T>
00175         static void swapFaceList
00176         (
00177             const polyMesh&,
00178             UList<T>&,
00179             const bool applySeparation
00180         );
00181 
00182         //- Get per point whether is it master (of a coupled set of points)
00183         static PackedList<1> getMasterPoints(const polyMesh&);
00184 
00185         //- Get per edge whether is it master (of a coupled set of edge)
00186         static PackedList<1> getMasterEdges(const polyMesh&);
00187 
00188 
00189 };
00190 
00191 
00192 template <>
00193 inline void syncTools::transformList(const tensorField&, UList<label>&)
00194 {}
00195 
00196 template <>
00197 inline void syncTools::transformList(const tensorField&, UList<scalar>&)
00198 {}
00199 
00200 template <>
00201 void syncTools::separateList(const vectorField&, UList<vector>&);
00202 
00203 template <class T>
00204 List<T> transform(const tensor& rotTensor, UList<T>& field);
00205 
00206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00207 
00208 } // End namespace Foam
00209 
00210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00211 
00212 #ifdef NoRepository
00213 #   include "syncToolsTemplates.C"
00214 #endif
00215 
00216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00217 
00218 #endif
00219 
00220 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd