hostCollatedFileOperation.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) 2017-2018 OpenFOAM Foundation
9  Copyright (C) 2021-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::fileOperations::hostCollatedFileOperation
29 
30 Description
31  Version of collatedFileOperation with multiple read/write ranks.
32 
33  In parallel it will assume ranks are sorted according to hostname
34  and the lowest rank per hostname will be the IO rank. The output directories
35  will get a unique name processors<N>_<low>-<high> where N is the
36  overall number of processors and low and high is the range of ranks
37  contained in the files. Each of these subsets uses its own communicator.
38 
39  Instead of using the hostnames the IO ranks can be assigned using the
40  FOAM_IORANKS environment variable (also when running non-parallel), e.g.
41  when decomposing into 4:
42 
43  \verbatim
44  FOAM_IORANKS='(0 2)' decomposePar -fileHandler hostCollated
45  FOAM_IORANKS='0,2' decomposePar -fileHandler hostCollated
46  FOAM_IORANKS='0 2' decomposePar -fileHandler hostCollated
47  \endverbatim
48 
49  will generate
50 
51  \verbatim
52  processors4_0-1/ : containing data for processors 0 to 1
53  processors4_2-3/ : containing data for processors 2 to 3
54  \endverbatim
55 
56 Environment
57  - \c FOAM_ENV : list of io-ranks as plain space or comma separated
58  list or as an OpenFOAM formatted list. Eg, '(0 4 8)'
59 
60 See also
61  Foam::collatedFileOperation
62 
63 SourceFiles
64  hostCollatedFileOperation.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef Foam_fileOperations_hostCollatedFileOperation_H
69 #define Foam_fileOperations_hostCollatedFileOperation_H
70 
71 #include "collatedFileOperation.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 namespace fileOperations
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class hostCollatedFileOperation Declaration
82 \*---------------------------------------------------------------------------*/
83 
85 :
87 {
88  // Private Data
89 
90  //- Communicator allocated/managed by us
91  mutable label managedComm_;
92 
93 
94  // Private Member Functions
95 
96  //- Any initialisation steps after constructing
97  void init(bool verbose);
98 
99 
100 public:
101 
102  //- Runtime type information
103  TypeName("hostCollated");
104 
105 
106  // Constructors
107 
108  //- Default construct
109  explicit hostCollatedFileOperation(bool verbose = false);
110 
111  //- Construct from communicator with specified io-ranks
113  (
114  const Tuple2<label, labelList>& commAndIORanks,
115  const bool distributedRoots,
116  bool verbose = false
117  );
118 
119 
120  //- Destructor
121  virtual ~hostCollatedFileOperation();
122 
123 
124  // Member Functions
125 
126  //- Transfer ownership of communicator to this fileOperation.
127  //- Use with caution
128  virtual void storeComm() const;
129 };
130 
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 } // End namespace fileOperations
135 } // End namespace Foam
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 #endif
140 
141 // ************************************************************************* //
hostCollatedFileOperation(bool verbose=false)
Default construct.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:54
Version of collatedFileOperation with multiple read/write ranks.
TypeName("hostCollated")
Runtime type information.
Version of masterUncollatedFileOperation that collates regIOobjects into a container in the processor...
Namespace for OpenFOAM.
virtual void storeComm() const
Transfer ownership of communicator to this fileOperation. Use with caution.