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, TopologicalMeshObject, zoneDistribute>
68 {
69  // Private Data
70 
71 
72  //- labels of the points on coupled patches
73  labelList coupledBoundaryPoints_;
74 
75  //- storage of the addressing for processor-to-processor comms
76  List<labelHashSet> send_;
77 
78  //- Return patch of all coupled faces.
79  autoPtr<indirectPrimitivePatch> coupledFacesPatch() const;
80 
81  zoneCPCStencil& stencil_;
82 
83  const globalIndex& gblIdx_;
84 
85 
86  //- Gives patchNumber and patchFaceNumber for a given
87  //- Geometric volume field
88  template<typename Type>
89  Type getLocalValue
90  (
92  const label localIdx
93  ) const;
94 
95 
96  //- Gives patchNumber and patchFaceNumber for a given
97  //- Geometric volume field
98  template<typename Type>
99  Type faceValue
100  (
102  const label localIdx
103  ) const;
104 
105 
106 public:
107 
108  //- Runtime information
109  TypeName("zoneDistribute");
110 
111 
112  // Constructors
113 
114  //- Construct from fvMesh
115  explicit zoneDistribute(const fvMesh&);
116 
117 
118  // Selectors
119 
120  static zoneDistribute& New(const fvMesh&);
121 
122 
123  //- Destructor
124 
125  virtual ~zoneDistribute() = default;
126 
127 
128  // Member Functions
129 
130  //- Update stencil with boolList the size has to match mesh nCells
131  void setUpCommforZone(const boolList& zone, bool updateStencil=true);
132 
133  //- Updates stencil with boolList the size has to match mesh nCells
134  void updateStencil(const boolList& zone);
135 
136  //- Stencil reference
137  const labelListList& getStencil() noexcept
138  {
139  return stencil_;
140  }
141 
142  //- Addressing reference
143  const globalIndex& globalNumbering() const noexcept
144  {
145  return gblIdx_;
146  }
147 
148  //- Gives patchNumber and patchFaceNumber for a given
149  //- Geometric volume field
150  template<typename Type>
151  Type getValue
152  (
154  const Map<Type>& valuesFromOtherProc,
155  const label gblIdx
156  ) const;
157 
158  //- Returns stencil and provides a Map with globalNumbering
159  template<typename Type>
161  (
162  const boolList& zone,
164  );
165 
166  //- Returns stencil and provides a Map with globalNumbering
167  template<typename Type>
169  (
170  const boolList& zone,
172  );
173 
174 
175 };
176 
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 #ifdef NoRepository
187 #include "zoneDistributeI.H"
188 #endif
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #endif
193 
194 // ************************************************************************* //
Foam::zoneDistribute::getValue
Type getValue(const GeometricField< Type, fvPatchField, volMesh > &phi, const Map< Type > &valuesFromOtherProc, const label gblIdx) const
Definition: zoneDistributeI.H:82
volFields.H
Foam::zoneDistribute::~zoneDistribute
virtual ~zoneDistribute()=default
Destructor.
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.
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
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::zoneDistribute::globalNumbering
const globalIndex & globalNumbering() const noexcept
Addressing reference.
Definition: zoneDistribute.H:142
IOobject.H
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:85
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:105
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:127
Foam::zoneDistribute::updateStencil
void updateStencil(const boolList &zone)
Updates stencil with boolList the size has to match mesh nCells.
Definition: zoneDistribute.C:121
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::zoneDistribute::getStencil
const labelListList & getStencil() noexcept
Stencil reference.
Definition: zoneDistribute.H:136
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::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::zoneCPCStencil
computes a cell point cell stencil in a narrow band. resizes in case of topological change
Definition: zoneCPCStencil.H:58