/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ 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 3 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, see . Class Foam::syncTools Description Various tools to aid synchronising lists across coupled patches. WIP. Require - combineOperator (e.g. sumEqOp - not sumOp!) that is defined for the type and combineReduce(UList\, combineOperator) should be defined. - null value which gets overridden by any valid value. - transform function SourceFiles syncTools.C syncToolsTemplates.C \*---------------------------------------------------------------------------*/ #ifndef syncTools_H #define syncTools_H #include "Pstream.H" #include "EdgeMap.H" #include "PackedBoolList.H" #include "polyMesh.H" #include "coupledPolyPatch.H" #include "distributionMap.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { class polyBoundaryMesh; /*---------------------------------------------------------------------------*\ Class syncTools Declaration \*---------------------------------------------------------------------------*/ class syncTools { // Private Member Functions //- Combine value with existing value in map. template static void combine ( Map& pointValues, const CombineOp& cop, const label index, const T& val ); //- Combine val with existing value at (implicit index) e. template static void combine ( EdgeMap& edgeValues, const CombineOp& cop, const edge& index, const T& val ); public: // Basic routines with user-supplied transformation. Preferably // use specialisations below. //- Synchronise values on selected points. template static void syncPointMap ( const polyMesh&, Map& pointValues, const CombineOp& cop, const TransformOp& top ); //- Synchronise values on selected edges. template static void syncEdgeMap ( const polyMesh&, EdgeMap& edgeValues, const CombineOp& cop, const TransformOp& top ); //- Synchronise values on all mesh points. template static void syncPointList ( const polyMesh&, List&, const CombineOp& cop, const T& nullValue, const TransformOp& top ); //- Synchronise values on selected mesh points. template static void syncPointList ( const polyMesh&, const labelList& meshPoints, List&, const CombineOp& cop, const T& nullValue, const TransformOp& top ); //- Synchronise values on all mesh edges. template static void syncEdgeList ( const polyMesh&, List&, const CombineOp& cop, const T& nullValue, const TransformOp& top ); //- Synchronise values on selected mesh edges. template static void syncEdgeList ( const polyMesh&, const labelList& meshEdges, List&, const CombineOp& cop, const T& nullValue, const TransformOp& top ); //- Synchronise values on boundary faces only. template static void syncBoundaryFaceList ( const polyMesh&, UList&, const CombineOp& cop, const TransformOp& top, const bool parRun = Pstream::parRun() ); // Synchronise point-wise data //- Synchronise values on all mesh points. template static void syncPointList ( const polyMesh& mesh, List& l, const CombineOp& cop, const T& nullValue ) { syncPointList ( mesh, l, cop, nullValue, distributionMap::transform() ); } //- Synchronise locations on all mesh points. template static void syncPointPositions ( const polyMesh& mesh, List& l, const CombineOp& cop, const point& nullValue ) { syncPointList ( mesh, l, cop, nullValue, distributionMap::transformPosition() ); } //- Synchronise values on selected mesh points. template static void syncPointList ( const polyMesh& mesh, const labelList& meshPoints, List& l, const CombineOp& cop, const T& nullValue ) { syncPointList ( mesh, meshPoints, l, cop, nullValue, distributionMap::transform() ); } //- Synchronise locations on selected mesh points. template static void syncPointPositions ( const polyMesh& mesh, const labelList& meshPoints, List& l, const CombineOp& cop, const point& nullValue ) { syncPointList ( mesh, meshPoints, l, cop, nullValue, distributionMap::transformPosition() ); } // Synchronise edge-wise data //- Synchronise values on all mesh edges. template static void syncEdgeList ( const polyMesh& mesh, List& l, const CombineOp& cop, const T& nullValue ) { syncEdgeList ( mesh, l, cop, nullValue, distributionMap::transform() ); } //- Synchronise locations on all mesh edges. template static void syncEdgePositions ( const polyMesh& mesh, List& l, const CombineOp& cop, const point& nullValue ) { syncEdgeList ( mesh, l, cop, nullValue, distributionMap::transformPosition() ); } //- Synchronise values on selected mesh edges. template static void syncEdgeList ( const polyMesh& mesh, const labelList& meshEdges, List& l, const CombineOp& cop, const T& nullValue ) { syncEdgeList ( mesh, meshEdges, l, cop, nullValue, distributionMap::transform() ); } //- Synchronise locations on selected mesh edges. template static void syncEdgePositions ( const polyMesh& mesh, const labelList& meshEdges, List& l, const CombineOp& cop, const point& nullValue ) { syncEdgeList ( mesh, meshEdges, l, cop, nullValue, distributionMap::transformPosition() ); } // Synchronise face-wise data //- Synchronise values on boundary faces only. template static void syncBoundaryFaceList ( const polyMesh& mesh, UList& l, const CombineOp& cop ) { syncBoundaryFaceList ( mesh, l, cop, distributionMap::transform() ); } //- Synchronise locations on boundary faces only. template static void syncBoundaryFacePositions ( const polyMesh& mesh, UList& l, const CombineOp& cop ) { syncBoundaryFaceList ( mesh, l, cop, distributionMap::transformPosition() ); } //- Synchronise values on all mesh faces. template static void syncFaceList ( const polyMesh& mesh, UList& l, const CombineOp& cop ) { SubList bndValues ( l, mesh.nFaces()-mesh.nInternalFaces(), mesh.nInternalFaces() ); syncBoundaryFaceList ( mesh, bndValues, cop, distributionMap::transform() ); } //- Synchronise locations on all mesh faces. template static void syncFacePositions ( const polyMesh& mesh, UList& l, const CombineOp& cop ) { SubList bndValues ( l, mesh.nFaces()-mesh.nInternalFaces(), mesh.nInternalFaces() ); syncBoundaryFaceList ( mesh, bndValues, cop, distributionMap::transformPosition() ); } //- Swap coupled boundary face values. template static void swapBoundaryFaceList ( const polyMesh& mesh, UList& l ) { syncBoundaryFaceList ( mesh, l, eqOp(), distributionMap::transform() ); } //- Swap coupled positions. static void swapBoundaryFacePositions ( const polyMesh& mesh, UList& l ) { syncBoundaryFaceList ( mesh, l, eqOp(), distributionMap::transformPosition() ); } //- Swap coupled face values. template static void swapFaceList ( const polyMesh& mesh, UList& l ) { SubList bndValues ( l, mesh.nFaces()-mesh.nInternalFaces(), mesh.nInternalFaces() ); syncBoundaryFaceList ( mesh, bndValues, eqOp(), distributionMap::transform() ); } //- Swap to obtain neighbour cell values for all boundary faces template static void swapBoundaryCellList ( const polyMesh& mesh, const UList& cellData, List& neighbourCellData ); //- Swap to obtain neighbour cell positions for all boundary faces static void swapBoundaryCellPositions ( const polyMesh& mesh, const UList& cellData, List& neighbourCellData ); // Sparse versions //- Synchronise values on selected points. template static void syncPointMap ( const polyMesh& mesh, Map& l, const CombineOp& cop ) { syncPointMap(mesh, l, cop, distributionMap::transform()); } //- Synchronise locations on selected points. template static void syncPointPositions ( const polyMesh& mesh, Map& l, const CombineOp& cop ) { syncPointMap ( mesh, l, cop, distributionMap::transformPosition() ); } //- Synchronise values on selected edges. Edges are represented // by the two vertices that make it up so global edges never get // constructed. template static void syncEdgeMap ( const polyMesh& mesh, EdgeMap& l, const CombineOp& cop ) { syncEdgeMap(mesh, l, cop, distributionMap::transform()); } //- Synchronise locations on selected edges. template static void syncEdgePositions ( const polyMesh& mesh, EdgeMap& l, const CombineOp& cop ) { syncEdgeMap(mesh, l, cop, distributionMap::transformPosition()); } // PackedList versions template static void syncFaceList ( const polyMesh& mesh, PackedList& faceValues, const CombineOp& cop, const bool parRun = Pstream::parRun() ); template static void swapFaceList ( const polyMesh& mesh, PackedList& faceValues ); template static void syncPointList ( const polyMesh& mesh, PackedList& pointValues, const CombineOp& cop, const unsigned int nullValue ); template static void syncEdgeList ( const polyMesh& mesh, PackedList& edgeValues, const CombineOp& cop, const unsigned int nullValue ); // Other //- Get per point whether it is uncoupled or a master of a // coupled set of points static PackedBoolList getMasterPoints(const polyMesh&); //- Get per edge whether it is uncoupled or a master of a // coupled set of edges static PackedBoolList getMasterEdges(const polyMesh&); //- Get per face whether it is uncoupled or a master of a // coupled set of faces static PackedBoolList getMasterFaces(const polyMesh&); //- Get per face whether it is internal or a master of a // coupled set of faces static PackedBoolList getInternalOrMasterFaces(const polyMesh&); //- Get per face whether it is internal or coupled static PackedBoolList getInternalOrCoupledFaces(const polyMesh&); }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository #include "syncToolsTemplates.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //