OpenFOAM logo
Open Source CFD Toolkit

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-2005 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) that is defined for the type and
00033       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 "Pstream.H"
00050 #include "UList.H"
00051 #include "tensorField.H"
00052 
00053 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00054 
00055 namespace Foam
00056 {
00057 
00058 // Define dummy transform for labels.
00059 label transform(const tensor&, const label val);
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         //- Dummy transform for labels
00080         static label transform(const tensor&, const label i)
00081         {
00082             return i;
00083         }
00084 
00085         //- Apply transformation to list. Either single transformation tensor
00086         //  or one tensor per element.
00087         template <class T>
00088         static void transformList(const tensorField&, UList<T>&);
00089 
00090         //- Apply separation to list. Either single vector or one vector
00091         //  per element.
00092         template <class T>
00093         static void separateList(const vectorField&, UList<T>&);
00094 
00095 
00096 public:
00097 
00098     // Static data members
00099 
00100         //- Synchronize values on all mesh points. Returns number of changed
00101         //  values (not accurate for shared points)
00102         //  Applies rotation and optionally separation for parallel cyclics
00103         template <class T, class CombineOp>
00104         static label 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 all mesh edges. Returns number of changed
00114         //  values (not accurate for shared edges)
00115         //  Applies rotation and optionally separation for parallel cyclics
00116         template <class T, class CombineOp>
00117         static label syncEdgeList
00118         (
00119             const polyMesh&,
00120             UList<T>&,
00121             const CombineOp& bop,
00122             const T& nullValue,
00123             const bool applySeparation
00124         );
00125 
00126         //- Synchronize values on all mesh faces. Returns number of changed
00127         //  values.
00128         //  Optionally applies rotation tensor for non-parallel cyclics
00129         //  (but not separation!)
00130         template <class T, class CombineOp>
00131         static label syncFaceList
00132         (
00133             const polyMesh&,
00134             UList<T>&,
00135             const CombineOp& bop,
00136             const bool applySeparation
00137         );
00138 
00139         //- Swap coupled face values.
00140         //  Applies rotation and optionally separation for parallel cyclics
00141         template <class T>
00142         static void swapFaceList
00143         (
00144             const polyMesh&,
00145             UList<T>&,
00146             const bool applySeparation
00147         );
00148 };
00149 
00150 
00151 template <>
00152 inline void syncTools::transformList(const tensorField&, UList<label>&)
00153 {}
00154 
00155 template <>
00156 inline void syncTools::transformList(const tensorField&, UList<scalar>&)
00157 {}
00158 
00159 template <>
00160 void syncTools::separateList(const vectorField&, UList<vector>&);
00161 
00162 
00163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00164 
00165 } // End namespace Foam
00166 
00167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00168 
00169 #ifdef NoRepository
00170 #   include "syncToolsTemplates.C"
00171 #endif
00172 
00173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00174 
00175 #endif
00176 
00177 // ************************************************************************* //
For further information go to www.openfoam.org