parLagrangianDistributor.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) 2015 OpenFOAM Foundation
9  Copyright (C) 2018-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::parLagrangianDistributor
29 
30 Description
31  Lagrangian field redistributor.
32 
33  Runs in parallel. Redistributes from fromMesh to toMesh.
34 
35 SourceFiles
36  parLagrangianDistributor.cxx
37  parLagrangianDistributor.txx
38  parLagrangianDistributorFields.cxx
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef Foam_parLagrangianDistributor_H
43 #define Foam_parLagrangianDistributor_H
44 
45 #include "fvMesh.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 class mapDistributePolyMesh;
54 class mapDistributeBase;
55 class IOobjectList;
56 class passivePositionParticleCloud;
57 
58 /*---------------------------------------------------------------------------*\
59  Class parLagrangianDistributor Declaration
60 \*---------------------------------------------------------------------------*/
61 
63 {
64  // Private Data
65 
66  //- Source mesh reference
67  const fvMesh& srcMesh_;
68 
69  //- Destination mesh reference
70  const fvMesh& tgtMesh_;
71 
72  //- Distribution map reference
73  const mapDistributePolyMesh& distMap_;
74 
75  //- For every src cell the target processor
76  labelList destinationProcID_;
77 
78  //- For every src cell the target cell
79  labelList destinationCell_;
80 
81 
82 public:
83 
84  //- Output verbosity when writing
85  static int verbose_;
86 
87 
88  // Generated Methods
89 
90  //- No copy construct
92 
93  //- No copy assignment
94  void operator=(const parLagrangianDistributor&) = delete;
95 
96 
97  // Constructors
98 
99  //- Construct from components
101  (
102  const fvMesh& srcMesh,
103  const fvMesh& tgtMesh,
104  const label nOldCells,
105  const mapDistributePolyMesh& distMap
106  );
107 
108 
109  // Static Functions
110 
111  //- Find all clouds (on all processors) and for each cloud all
112  //- the objects. Result will be synchronised on all processors
113  static void findClouds
114  (
115  const fvMesh&,
116 
118  wordList& cloudNames,
119 
121  boolList& haveClouds,
122 
124  List<wordList>& objectNames
125  );
126 
127  //- Pick up any fields of a given type
128  template<class Type>
129  static wordList filterObjects
130  (
131  const IOobjectList& objects,
132  const wordRes& selectedFields = wordRes()
133  );
134 
135  //- Read and store all fields of a cloud
136  template<class Container>
137  static label readFields
138  (
140  const bool haveCloud,
141  const IOobjectList& objects,
142  const wordRes& selectedFields = wordRes()
143  );
144 
145  //- Read and store all fields for known cloud field types
146  static label readAllFields
147  (
149  const bool haveCloud,
150  const IOobjectList& objects,
151  const wordRes& selectedFields = wordRes()
152  );
153 
154 
155  // Member Functions
156 
157  //- The source mesh
158  const fvMesh& sourceMesh() const noexcept { return srcMesh_; }
159 
160  //- The destination mesh
161  const fvMesh& targetMesh() const noexcept { return tgtMesh_; }
162 
163  //- Redistribute and write lagrangian positions
164  autoPtr<mapDistributeBase> distributeLagrangianPositions
165  (
166  passivePositionParticleCloud& cloud
167  ) const;
168 
169  //- Read, redistribute and write lagrangian positions
170  autoPtr<mapDistributeBase> distributeLagrangianPositions
171  (
172  const word& cloudName
173  ) const;
174 
175  //- Redistribute all fields for known cloud field types
176  label distributeAllFields
177  (
178  const mapDistributeBase& lagrangianMap,
179  const word& cloudName,
180  const bool haveCloud,
181  const IOobjectList& cloudObjs,
182  const wordRes& selectedFields
183  ) const;
184 
185  //- Redistribute and write all stored lagrangian fields
187  (
188  const mapDistributeBase& lagrangianMap,
190  ) const;
191 
192 
193  //- Read, redistribute and write all/selected lagrangian fields
194  template<class Type>
195  label distributeFields
196  (
197  const mapDistributeBase& map,
198  const word& cloudName,
199  const bool haveCloud,
200  const IOobjectList& objects,
201  const wordRes& selectedFields = wordRes()
202  ) const;
203 
204  //- Read, redistribute and write all/selected lagrangian fieldFields
205  template<class Type>
207  (
208  const mapDistributeBase& map,
209  const word& cloudName,
210  const bool haveCloud,
211  const IOobjectList& objects,
212  const wordRes& selectedFields = wordRes()
213  ) const;
214 
215  //- Redistribute and write stored lagrangian fields.
216  // Note: does no reading so no need to check for existence
217  // of lagrangian files
218  template<class Container>
220  (
221  const mapDistributeBase& map,
223  ) const;
224 };
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace Foam
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 #ifdef NoRepository
234 # include "parLagrangianDistributor.txx"
235 #endif
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #endif
240 
241 // ************************************************************************* //
label distributeFields(const mapDistributeBase &map, const word &cloudName, const bool haveCloud, const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, redistribute and write all/selected lagrangian fields.
static int verbose_
Output verbosity when writing.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
label distributeAllStoredFields(const mapDistributeBase &lagrangianMap, passivePositionParticleCloud &cloud) const
Redistribute and write all stored lagrangian fields.
static label readAllFields(const passivePositionParticleCloud &cloud, const bool haveCloud, const IOobjectList &objects, const wordRes &selectedFields=wordRes())
Read and store all fields for known cloud field types.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
void operator=(const parLagrangianDistributor &)=delete
No copy assignment.
static void findClouds(const fvMesh &, wordList &cloudNames, boolList &haveClouds, List< wordList > &objectNames)
Find all clouds (on all processors) and for each cloud all the objects. Result will be synchronised o...
static label readFields(const passivePositionParticleCloud &cloud, const bool haveCloud, const IOobjectList &objects, const wordRes &selectedFields=wordRes())
Read and store all fields of a cloud.
const word cloudName(propsDict.get< word >("cloud"))
A class for handling words, derived from Foam::string.
Definition: word.H:63
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:53
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
Class containing processor-to-processor mapping information.
const direction noexcept
Definition: scalarImpl.H:265
static wordList filterObjects(const IOobjectList &objects, const wordRes &selectedFields=wordRes())
Pick up any fields of a given type.
parLagrangianDistributor(const parLagrangianDistributor &)=delete
No copy construct.
label distributeAllFields(const mapDistributeBase &lagrangianMap, const word &cloudName, const bool haveCloud, const IOobjectList &cloudObjs, const wordRes &selectedFields) const
Redistribute all fields for known cloud field types.
const fvMesh & targetMesh() const noexcept
The destination mesh.
label distributeFieldFields(const mapDistributeBase &map, const word &cloudName, const bool haveCloud, const IOobjectList &objects, const wordRes &selectedFields=wordRes()) const
Read, redistribute and write all/selected lagrangian fieldFields.
Lagrangian field redistributor.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const fvMesh & sourceMesh() const noexcept
The source mesh.
label distributeStoredFields(const mapDistributeBase &map, passivePositionParticleCloud &cloud) const
Redistribute and write stored lagrangian fields.
Namespace for OpenFOAM.
autoPtr< mapDistributeBase > distributeLagrangianPositions(passivePositionParticleCloud &cloud) const
Redistribute and write lagrangian positions.