zoneDistribute.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2020 DLR
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::zoneDistribute
28 
29 Description
30  Class for parallel communication in a narrow band. It either provides a Map
31  with the neighbouring values of the selected region or returns a Map of the
32  required values in global addressing. Also holds a reference to the stencil
33  Before the data transfer the communation has to be set up:
34  exchangeFields_.setUpCommforZone(interfaceCell_);
35  Is used in the plicRDF
36 
37  Original code supplied by Henning Scheufler, DLR (2019)
38 
39 SourceFiles
40  zoneDistribute.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef zoneDistribute_H
45 #define zoneDistribute_H
46 
47 #include "fvMesh.H"
48 #include "globalIndex.H"
49 #include "volFields.H"
50 
51 #include "zoneCPCStencil.H"
52 #include "IOobject.H"
53 #include "MeshObject.H"
54 
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class zoneDistribute Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class zoneDistribute
66 :
67  public MeshObject<fvMesh, UpdateableMeshObject, zoneDistribute>
68 {
69  // Private Data
70 
71  //- cell-point-cell stencil elements are in global addressing
72  zoneCPCStencil stencil_;
73 
74  //- labels of the points on coupled patches
75  labelList coupledBoundaryPoints_;
76 
77  //- storage of the addressing for processor-to-processor comms
78  List<labelHashSet> send_;
79 
80  //- Return patch of all coupled faces.
81  autoPtr<indirectPrimitivePatch> coupledFacesPatch() const;
82 
83 
84  //- Gives patchNumber and patchFaceNumber for a given
85  //- Geometric volume field
86  template<typename Type>
87  Type getLocalValue
88  (
90  const label localIdx
91  ) const;
92 
93 
94  //- Gives patchNumber and patchFaceNumber for a given
95  //- Geometric volume field
96  template<typename Type>
97  Type faceValue
98  (
100  const label localIdx
101  ) const;
102 
103 
104 public:
105 
106  //- Runtime information
107  TypeName("zoneDistribute");
108 
109 
110  // Constructors
111 
112  //- Construct from fvMesh
113  explicit zoneDistribute(const fvMesh&);
114 
115 
116  // Selectors
117 
118  static zoneDistribute& New(const fvMesh&);
119 
120 
121  // Member Functions
122 
123  //- Update stencil with boolList the size has to match mesh nCells
124  void setUpCommforZone(const boolList& zone, bool updateStencil=true);
125 
126  //- Updates stencil with boolList the size has to match mesh nCells
127  void updateStencil(const boolList& zone);
128 
129  //- Stencil reference
130  const labelListList& getStencil()
131  {
132  return stencil_;
133  }
134 
135  //- Addressing reference
136  const globalIndex& globalNumbering() const
137  {
138  return stencil_.globalNumbering();
139  }
140 
141  //- Gives patchNumber and patchFaceNumber for a given
142  //- Geometric volume field
143  template<typename Type>
144  Type getValue
145  (
147  const Map<Type>& valuesFromOtherProc,
148  const label gblIdx
149  ) const;
150 
151  //- Returns stencil and provides a Map with globalNumbering
152  template<typename Type>
154  (
155  const boolList& zone,
157  );
158 
159  //- Returns stencil and provides a Map with globalNumbering
160  template<typename Type>
162  (
163  const boolList& zone,
165  );
166 
167  virtual void updateMesh(const mapPolyMesh& mpm);
168 
169  virtual bool movePoints()
170  {
171  // do nothing
172  return false;
173  }
174 };
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 } // End namespace Foam
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #ifdef NoRepository
186 #include "zoneDistributeI.H"
187 #endif
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
Foam::zoneDistribute::getValue
Type getValue(const GeometricField< Type, fvPatchField, volMesh > &phi, const Map< Type > &valuesFromOtherProc, const label gblIdx) const
Definition: zoneDistributeI.H:85
volFields.H
Foam::zoneDistribute::getDatafromOtherProc
Map< Type > getDatafromOtherProc(const boolList &zone, const GeometricField< Type, fvPatchField, volMesh > &phi)
Returns stencil and provides a Map with globalNumbering.
Foam::zoneDistribute::TypeName
TypeName("zoneDistribute")
Runtime information.
Foam::zoneDistribute::movePoints
virtual bool movePoints()
Definition: zoneDistribute.H:168
globalIndex.H
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
zoneDistributeI.H
zoneCPCStencil.H
Foam::zoneDistribute::getStencil
const labelListList & getStencil()
Stencil reference.
Definition: zoneDistribute.H:129
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::zoneCellStencils::globalNumbering
const globalIndex & globalNumbering() const
Global numbering for cells and boundary faces.
Definition: zoneCellStencils.H:147
IOobject.H
Foam::zoneDistribute::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Definition: zoneDistribute.C:196
Foam::zoneDistribute::zoneDistribute
zoneDistribute(const fvMesh &)
Construct from fvMesh.
Definition: zoneDistribute.C:92
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
Foam::zoneDistribute::New
static zoneDistribute & New(const fvMesh &)
Definition: zoneDistribute.C:104
Foam::zoneDistribute::setUpCommforZone
void setUpCommforZone(const boolList &zone, bool updateStencil=true)
Update stencil with boolList the size has to match mesh nCells.
Definition: zoneDistribute.C:131
Foam::zoneDistribute::updateStencil
void updateStencil(const boolList &zone)
Updates stencil with boolList the size has to match mesh nCells.
Definition: zoneDistribute.C:124
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::zoneDistribute
Class for parallel communication in a narrow band. It either provides a Map with the neighbouring val...
Definition: zoneDistribute.H:64
Foam::List< label >
Foam::zoneDistribute::getFields
Map< Field< Type > > getFields(const boolList &zone, const GeometricField< Type, fvPatchField, volMesh > &phi)
Returns stencil and provides a Map with globalNumbering.
MeshObject.H
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::MeshObject
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:88
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::zoneDistribute::globalNumbering
const globalIndex & globalNumbering() const
Addressing reference.
Definition: zoneDistribute.H:135
Foam::zoneCPCStencil
computes a cell point cell stencil in a narrow band. resizes in case of topological change
Definition: zoneCPCStencil.H:58