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.C
37  parLagrangianDistributorFields.C
38  parLagrangianDistributorTemplates.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef Foam_parLagrangianDistributor_H
43 #define Foam_parLagrangianDistributor_H
44 
45 #include "PtrList.H"
46 #include "fvMesh.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward Declarations
54 class mapDistributePolyMesh;
55 class mapDistributeBase;
56 class IOobjectList;
57 class passivePositionParticleCloud;
58 
59 /*---------------------------------------------------------------------------*\
60  Class parLagrangianDistributor Declaration
61 \*---------------------------------------------------------------------------*/
62 
64 {
65  // Private Data
66 
67  //- Source mesh reference
68  const fvMesh& srcMesh_;
69 
70  //- Destination mesh reference
71  const fvMesh& tgtMesh_;
72 
73  //- Distribution map reference
74  const mapDistributePolyMesh& distMap_;
75 
76  //- For every src cell the target processor
77  labelList destinationProcID_;
78 
79  //- For every src cell the target cell
80  labelList destinationCell_;
81 
82 
83 public:
84 
85  //- Output verbosity when writing
86  static int verbose_;
87 
88 
89  // Generated Methods
90 
91  //- No copy construct
93 
94  //- No copy assignment
95  void operator=(const parLagrangianDistributor&) = delete;
96 
97 
98  // Constructors
99 
100  //- Construct from components
102  (
103  const fvMesh& srcMesh,
104  const fvMesh& tgtMesh,
105  const label nOldCells,
106  const mapDistributePolyMesh& distMap
107  );
108 
109 
110  // Static Functions
111 
112  //- Find all clouds (on all processors) and for each cloud all
113  //- the objects. Result will be synchronised on all processors
114  static void findClouds
115  (
116  const fvMesh&,
117 
119  wordList& cloudNames,
120 
122  boolList& haveClouds,
123 
125  List<wordList>& objectNames
126  );
127 
128  //- Pick up any fields of a given type
129  template<class Type>
130  static wordList filterObjects
131  (
132  const IOobjectList& objects,
133  const wordRes& selectedFields = wordRes()
134  );
135 
136  //- Read and store all fields of a cloud
137  template<class Container>
138  static label readFields
139  (
141  const bool haveCloud,
142  const IOobjectList& objects,
143  const wordRes& selectedFields = wordRes()
144  );
145 
146  //- Read and store all fields for known cloud field types
147  static label readAllFields
148  (
150  const bool haveCloud,
151  const IOobjectList& objects,
152  const wordRes& selectedFields = wordRes()
153  );
154 
155 
156  // Member Functions
157 
158  //- Redistribute and write lagrangian positions
160  (
162  ) const;
163 
164  //- Read, redistribute and write lagrangian positions
166  (
167  const word& cloudName
168  ) const;
169 
170  //- Redistribute all fields for known cloud field types
171  label distributeAllFields
172  (
173  const mapDistributeBase& lagrangianMap,
174  const word& cloudName,
175  const bool haveCloud,
176  const IOobjectList& cloudObjs,
177  const wordRes& selectedFields
178  ) const;
179 
180  //- Redistribute and write all stored lagrangian fields
182  (
183  const mapDistributeBase& lagrangianMap,
185  ) const;
186 
187 
188  //- Read, redistribute and write all/selected lagrangian fields
189  template<class Type>
190  label distributeFields
191  (
192  const mapDistributeBase& map,
193  const word& cloudName,
194  const bool haveCloud,
195  const IOobjectList& objects,
196  const wordRes& selectedFields = wordRes()
197  ) const;
198 
199  //- Read, redistribute and write all/selected lagrangian fieldFields
200  template<class Type>
202  (
203  const mapDistributeBase& map,
204  const word& cloudName,
205  const bool haveCloud,
206  const IOobjectList& objects,
207  const wordRes& selectedFields = wordRes()
208  ) const;
209 
210  //- Redistribute and write stored lagrangian fields.
211  // Note: does no reading so no need to check for existence
212  // of lagrangian files
213  template<class Container>
215  (
216  const mapDistributeBase& map,
218  ) const;
219 };
220 
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 } // End namespace Foam
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 #ifdef NoRepository
230 #endif
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #endif
235 
236 // ************************************************************************* //
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.
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.
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
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.